From a6ccf539e63ca8a765e774887849737862789217 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Wed, 6 Apr 2011 18:03:22 +0000 Subject: [PATCH] - added more techtree validations to indicate things that may make a problem for the AI and invalid xml configurations (like harvest skill but no move skill) --- source/glest_game/types/faction_type.cpp | 19 +++++++++++++++++++ source/glest_game/types/tech_tree.cpp | 8 ++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/source/glest_game/types/faction_type.cpp b/source/glest_game/types/faction_type.cpp index 4ae6e6a9..32f8fd9d 100644 --- a/source/glest_game/types/faction_type.cpp +++ b/source/glest_game/types/faction_type.cpp @@ -387,6 +387,25 @@ std::vector FactionType::validateFactionType() { } } // end + + // Check if the unit has both be_built and harvest skills, this may cause issues + // with the AI + if(unitType.hasSkillClass(scBeBuilt) == true && unitType.hasSkillClass(scHarvest) == true) { + char szBuf[4096]=""; + sprintf(szBuf,"The Unit [%s] in Faction [%s] has both a bebuilt and harvest skill which will cause AI problems for CPU players!",unitType.getName().c_str(),this->getName().c_str()); + results.push_back(szBuf); + } + // end + + // Check if the unit has harvest skills but not move, meaning they cannot + // harvest the resource + if(unitType.hasSkillClass(scHarvest) == true && unitType.hasSkillClass(scMove) == false) { + char szBuf[4096]=""; + sprintf(szBuf,"The Unit [%s] in Faction [%s] has a harvest skill but no move skill so it cannot harvest!",unitType.getName().c_str(),this->getName().c_str()); + results.push_back(szBuf); + } + // end + } return results; diff --git a/source/glest_game/types/tech_tree.cpp b/source/glest_game/types/tech_tree.cpp index 5f082668..0f1bb9b3 100644 --- a/source/glest_game/types/tech_tree.cpp +++ b/source/glest_game/types/tech_tree.cpp @@ -204,10 +204,14 @@ std::vector TechTree::validateFactionTypes() { std::vector results; for (int i = 0; i < factionTypes.size(); ++i) { std::vector factionResults = factionTypes[i].validateFactionType(); - results.insert(results.end(), factionResults.begin(), factionResults.end()); + if(factionResults.size() > 0) { + results.insert(results.end(), factionResults.begin(), factionResults.end()); + } factionResults = factionTypes[i].validateFactionTypeUpgradeTypes(); - results.insert(results.end(), factionResults.begin(), factionResults.end()); + if(factionResults.size() > 0) { + results.insert(results.end(), factionResults.begin(), factionResults.end()); + } } return results;