summaryrefslogtreecommitdiff
path: root/CreatureConfiguration.cpp
diff options
context:
space:
mode:
authorJapa2010-05-16 15:31:28 +0000
committerJapa2010-05-16 15:31:28 +0000
commit5c235e57af3ad3234608ee4ebf06de43324caf79 (patch)
treeb851b20b6d9053ec4ad18ba11ccca222c99159a3 /CreatureConfiguration.cpp
parent72a82d2e50e9232c79edb7905dd2a214a95d66b6 (diff)
downloadstonesense-5c235e57af3ad3234608ee4ebf06de43324caf79.tar.gz
stonesense-5c235e57af3ad3234608ee4ebf06de43324caf79.tar.bz2
stonesense-5c235e57af3ad3234608ee4ebf06de43324caf79.tar.xz
did some errorchecking, stonesense will now not crash when running old DF.
Diffstat (limited to 'CreatureConfiguration.cpp')
-rw-r--r--CreatureConfiguration.cpp35
1 files changed, 20 insertions, 15 deletions
diff --git a/CreatureConfiguration.cpp b/CreatureConfiguration.cpp
index 74c4fad..bab1044 100644
--- a/CreatureConfiguration.cpp
+++ b/CreatureConfiguration.cpp
@@ -73,27 +73,32 @@ int translateProfession(const char* currentProf)
void pushCreatureConfig( vector<vector<CreatureConfiguration>*>& knownCreatures, unsigned int gameID, CreatureConfiguration& cre)
{
- vector<CreatureConfiguration>* creatureList;
- if (knownCreatures.size() <= gameID)
+ if(!config.skipCreatureTypes)
{
- //resize using hint from creature name list
- unsigned int newsize = gameID +1;
- if (newsize <= contentLoader.Mats->race.size())
+ vector<CreatureConfiguration>* creatureList;
+ if (knownCreatures.size() <= gameID)
{
- newsize = contentLoader.Mats->race.size() + 1;
+ //resize using hint from creature name list
+ unsigned int newsize = gameID +1;
+ if (newsize <= contentLoader.Mats->race.size())
+ {
+ newsize = contentLoader.Mats->race.size() + 1;
+ }
+ knownCreatures.resize(newsize);
}
- knownCreatures.resize(newsize);
- }
- creatureList = knownCreatures[gameID];
- if (creatureList == NULL)
- {
- creatureList = new vector<CreatureConfiguration>();
- knownCreatures[gameID]=creatureList;
+ creatureList = knownCreatures[gameID];
+ if (creatureList == NULL)
+ {
+ creatureList = new vector<CreatureConfiguration>();
+ knownCreatures[gameID]=creatureList;
+ }
+ creatureList->push_back(cre);
}
- creatureList->push_back(cre);
}
bool addSingleCreatureConfig( TiXmlElement* elemCreature, vector<vector<CreatureConfiguration>*>& knownCreatures, int basefile ){
+ if(config.skipCreatureTypes)
+ return false;
int gameID = lookupIndexedType(elemCreature->Attribute("gameID"),contentLoader.Mats->race);
if (gameID == INVALID_INDEX)
return false;
@@ -194,7 +199,7 @@ bool addSingleCreatureConfig( TiXmlElement* elemCreature, vector<vector<Creature
strcpy(sprite.bodyPart, bodyVarPartStr);
}
- //subsprites
+ //subsprites
sprite.subSprites.clear();
TiXmlElement* elemVarSubSprite = elemVariant->FirstChildElement("subsprite");
while(elemVarSubSprite)