- added more techtree validation (show upgrade types that cannot be produced)
This commit is contained in:
parent
e996dd2b79
commit
9d94e56886
|
@ -585,6 +585,8 @@ int glestMain(int argc, char** argv){
|
||||||
}
|
}
|
||||||
if(hasCommandArgument(argc, argv,"--validate-techtrees") == true) {
|
if(hasCommandArgument(argc, argv,"--validate-techtrees") == true) {
|
||||||
|
|
||||||
|
printf("====== Started Validation ======\n");
|
||||||
|
|
||||||
Config &config = Config::getInstance();
|
Config &config = Config::getInstance();
|
||||||
vector<string> results;
|
vector<string> results;
|
||||||
findDirs(config.getPathListForType(ptTechs), results);
|
findDirs(config.getPathListForType(ptTechs), results);
|
||||||
|
@ -654,6 +656,8 @@ int glestMain(int argc, char** argv){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf("\n====== Finished Validation ======\n");
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -433,6 +433,48 @@ std::vector<std::string> FactionType::validateFactionTypeResourceTypes(vector<Re
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> FactionType::validateFactionTypeUpgradeTypes() {
|
||||||
|
std::vector<std::string> results;
|
||||||
|
|
||||||
|
// For each upgrade type make sure there is at least 1 unit that can produce
|
||||||
|
// the upgrade
|
||||||
|
for(int i = 0; i < upgradeTypes.size(); ++i) {
|
||||||
|
const UpgradeType &upgradeType = upgradeTypes[i];
|
||||||
|
|
||||||
|
// First find a unit with a command type to upgrade to this Upgrade type
|
||||||
|
bool foundUnit = false;
|
||||||
|
for(int j=0; j<unitTypes.size() && foundUnit == false; ++j){
|
||||||
|
UnitType &unitType = unitTypes[j];
|
||||||
|
for(int k = 0; k < unitType.getCommandTypeCount() && foundUnit == false; ++k) {
|
||||||
|
const CommandType *cmdType = unitType.getCommandType(k);
|
||||||
|
if(cmdType != NULL) {
|
||||||
|
// Ensure for each build type command that the build units
|
||||||
|
// exist in this faction
|
||||||
|
if(cmdType->getClass() == ccUpgrade) {
|
||||||
|
const UpgradeCommandType *upgrade = dynamic_cast<const UpgradeCommandType *>(cmdType);
|
||||||
|
if(upgrade != NULL) {
|
||||||
|
const UpgradeType *upgradeType2 = upgrade->getProducedUpgrade();
|
||||||
|
|
||||||
|
if(upgradeType2 != NULL && upgradeType.getName() == upgradeType2->getName()) {
|
||||||
|
foundUnit = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(foundUnit == false) {
|
||||||
|
char szBuf[4096]="";
|
||||||
|
sprintf(szBuf,"The Upgrade Type [%s] in Faction [%s] has no Unit able to produce this upgrade in this faction!",upgradeType.getName().c_str(),this->getName().c_str());
|
||||||
|
results.push_back(szBuf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
// ==================== get ====================
|
// ==================== get ====================
|
||||||
|
|
||||||
const UnitType *FactionType::getUnitType(const string &name) const{
|
const UnitType *FactionType::getUnitType(const string &name) const{
|
||||||
|
|
|
@ -66,6 +66,7 @@ public:
|
||||||
std::string toString() const;
|
std::string toString() const;
|
||||||
std::vector<std::string> validateFactionType();
|
std::vector<std::string> validateFactionType();
|
||||||
std::vector<std::string> validateFactionTypeResourceTypes(vector<ResourceType> &resourceTypes);
|
std::vector<std::string> validateFactionTypeResourceTypes(vector<ResourceType> &resourceTypes);
|
||||||
|
std::vector<std::string> validateFactionTypeUpgradeTypes();
|
||||||
};
|
};
|
||||||
|
|
||||||
}}//end namespace
|
}}//end namespace
|
||||||
|
|
|
@ -164,6 +164,9 @@ std::vector<std::string> TechTree::validateFactionTypes() {
|
||||||
for (int i = 0; i < factionTypes.size(); ++i) {
|
for (int i = 0; i < factionTypes.size(); ++i) {
|
||||||
std::vector<std::string> factionResults = factionTypes[i].validateFactionType();
|
std::vector<std::string> factionResults = factionTypes[i].validateFactionType();
|
||||||
results.insert(results.end(), factionResults.begin(), factionResults.end());
|
results.insert(results.end(), factionResults.begin(), factionResults.end());
|
||||||
|
|
||||||
|
factionResults = factionTypes[i].validateFactionTypeUpgradeTypes();
|
||||||
|
results.insert(results.end(), factionResults.begin(), factionResults.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user