- added more validation to the techtree validator (make sure that a unit that can build another unit, the unit to be built must have a be_built_skill
This commit is contained in:
parent
a64fa69d02
commit
58b23f8b91
|
@ -728,6 +728,7 @@ int glestMain(int argc, char** argv){
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
|
printf("\n---------------- Loading factions inside world ----------------");
|
||||||
World world;
|
World world;
|
||||||
|
|
||||||
vector<string> techPaths = config.getPathListForType(ptTechs);
|
vector<string> techPaths = config.getPathListForType(ptTechs);
|
||||||
|
@ -752,18 +753,20 @@ int glestMain(int argc, char** argv){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("\nChecking techPath [%s] techName [%s] factionsList.size() = %d\n",techPath.c_str(), techName.c_str(),factionsList.size());
|
printf("\nChecking techPath [%s] techName [%s] total faction count = %d\n",techPath.c_str(), techName.c_str(),factionsList.size());
|
||||||
for(int j = 0; j < factionsList.size(); ++j) {
|
for(int j = 0; j < factionsList.size(); ++j) {
|
||||||
if( filteredFactionList.size() == 0 ||
|
if( filteredFactionList.size() == 0 ||
|
||||||
std::find(filteredFactionList.begin(),filteredFactionList.end(),factionsList[j]) != filteredFactionList.end()) {
|
std::find(filteredFactionList.begin(),filteredFactionList.end(),factionsList[j]) != filteredFactionList.end()) {
|
||||||
printf("Found faction [%s]\n",factionsList[j].c_str());
|
printf("Using faction [%s]\n",factionsList[j].c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool techtree_errors = false;
|
||||||
world.loadTech(config.getPathListForType(ptTechs,""), techName, factions, &checksum);
|
world.loadTech(config.getPathListForType(ptTechs,""), techName, factions, &checksum);
|
||||||
// Validate the faction setup to ensure we don't have any bad associations
|
// Validate the faction setup to ensure we don't have any bad associations
|
||||||
std::vector<std::string> resultErrors = world.validateFactionTypes();
|
std::vector<std::string> resultErrors = world.validateFactionTypes();
|
||||||
if(resultErrors.size() > 0) {
|
if(resultErrors.size() > 0) {
|
||||||
|
techtree_errors = true;
|
||||||
// Display the validation errors
|
// Display the validation errors
|
||||||
string errorText = "\nErrors were detected:\n=====================\n";
|
string errorText = "\nErrors were detected:\n=====================\n";
|
||||||
for(int i = 0; i < resultErrors.size(); ++i) {
|
for(int i = 0; i < resultErrors.size(); ++i) {
|
||||||
|
@ -786,6 +789,7 @@ int glestMain(int argc, char** argv){
|
||||||
|
|
||||||
resultErrors = world.validateResourceTypes();
|
resultErrors = world.validateResourceTypes();
|
||||||
if(resultErrors.size() > 0) {
|
if(resultErrors.size() > 0) {
|
||||||
|
techtree_errors = true;
|
||||||
// Display the validation errors
|
// Display the validation errors
|
||||||
string errorText = "\nErrors were detected:\n=====================\n";
|
string errorText = "\nErrors were detected:\n=====================\n";
|
||||||
for(int i = 0; i < resultErrors.size(); ++i) {
|
for(int i = 0; i < resultErrors.size(); ++i) {
|
||||||
|
@ -798,6 +802,13 @@ int glestMain(int argc, char** argv){
|
||||||
//throw runtime_error(errorText);
|
//throw runtime_error(errorText);
|
||||||
printf("%s",errorText.c_str());
|
printf("%s",errorText.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(techtree_errors == false) {
|
||||||
|
printf("\nValidation found NO ERRORS for techPath [%s] techName [%s] factions checked (count = %d):\n",techPath.c_str(), techName.c_str(),factions.size());
|
||||||
|
for ( set<string>::iterator it = factions.begin(); it != factions.end(); ++it ) {
|
||||||
|
printf("Faction [%s]\n",(*it).c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -193,8 +193,17 @@ std::vector<std::string> FactionType::validateFactionType() {
|
||||||
for(int l=0; l<unitTypes.size() && foundUnit == false; ++l){
|
for(int l=0; l<unitTypes.size() && foundUnit == false; ++l){
|
||||||
UnitType &unitType2 = unitTypes[l];
|
UnitType &unitType2 = unitTypes[l];
|
||||||
if(unitType2.getName() == buildUnit->getName()) {
|
if(unitType2.getName() == buildUnit->getName()) {
|
||||||
foundUnit = true;
|
foundUnit = true;
|
||||||
break;
|
|
||||||
|
// Now also validate the the unit to be built
|
||||||
|
// has a be_built_skill
|
||||||
|
if(buildUnit->hasSkillClass(scBeBuilt) == false) {
|
||||||
|
char szBuf[4096]="";
|
||||||
|
sprintf(szBuf,"The Unit [%s] in Faction [%s] has the command [%s]\nwhich can build the Unit [%s] but the Unit to be built\ndoes not have the skill class [be_built_skill] in this faction!",unitType.getName().c_str(),this->getName().c_str(),cmdType->getName().c_str(),buildUnit->getName().c_str());
|
||||||
|
results.push_back(szBuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user