diff options
| author | Kris Parker | 2009-12-19 05:46:36 +0000 |
|---|---|---|
| committer | Kris Parker | 2009-12-19 05:46:36 +0000 |
| commit | 954733a0793e3094e1753577f037dcd596b4cdee (patch) | |
| tree | da8e5eddb9716d03767e9f7eda1943537ef70c52 /VegetationConfiguration.cpp | |
| parent | 7d0a5e9ec0f75766184f0630b493a70f159223d7 (diff) | |
| download | stonesense-954733a0793e3094e1753577f037dcd596b4cdee.tar.gz stonesense-954733a0793e3094e1753577f037dcd596b4cdee.tar.bz2 stonesense-954733a0793e3094e1753577f037dcd596b4cdee.tar.xz | |
Added ability to set default sprites for vegetation types
Diffstat (limited to 'VegetationConfiguration.cpp')
| -rw-r--r-- | VegetationConfiguration.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/VegetationConfiguration.cpp b/VegetationConfiguration.cpp index 9b64b74..98ff911 100644 --- a/VegetationConfiguration.cpp +++ b/VegetationConfiguration.cpp @@ -43,13 +43,21 @@ bool addSingleVegetationConfig( TiXmlElement* elemRoot, vector<VegetationConfig TiXmlElement* elemTree;
for (elemTree = elemRoot->FirstChildElement("plant");
elemTree; elemTree = elemTree->NextSiblingElement("plant") ){
- int gameID = lookupIndexedType(elemTree->Attribute("gameID"),plantNames);
- if (gameID == INVALID_INDEX)
- continue;
+ const char* idstr = elemTree->Attribute("gameID");
+ int gameID = INVALID_INDEX;
+ if (idstr && idstr[0])
+ {
+ lookupIndexedType(idstr,plantNames);
+ if (gameID == INVALID_INDEX)
+ {
+ contentError("No matching plant type",elemTree);
+ continue;
+ }
+ }
const char* deadstr = elemTree->Attribute("dead");
- bool dead = (deadstr && deadstr[0]);
+ bool dead = (deadstr && deadstr[0]);
const char* saplingstr = elemTree->Attribute("sapling");
- bool sapling = (saplingstr && saplingstr[0]);
+ bool sapling = (saplingstr && saplingstr[0]);
sheetIndexStr = elemTree->Attribute("sheetIndex");
/* No animated trees.
But we may repurpose it later to make a xyz variance?
@@ -73,7 +81,7 @@ t_SpriteWithOffset getVegetationSprite(vector<VegetationConfiguration>& vegetati for (int i=0;i<vcmax;i++)
{
VegetationConfiguration* current = &(vegetationConfigs[i]);
- if (current->gameID != index) continue;
+ if (current->gameID != INVALID_INDEX && current->gameID != index) continue;
if (current->live != live) continue;
if (current->grown != grown) continue;
return current->sprite;
|
