summaryrefslogtreecommitdiff
path: root/BlockCondition.cpp
diff options
context:
space:
mode:
authorKris Parker2009-12-25 11:55:27 +0000
committerKris Parker2009-12-25 11:55:27 +0000
commitea2820e40d8ee93d42af8706c63bcc60b9ad3927 (patch)
tree0d55000c17d8102dfa70b279fc254651a041d802 /BlockCondition.cpp
parenta604cf12cd604df8e75a1e674856e6bf61dc433b (diff)
downloadstonesense-ea2820e40d8ee93d42af8706c63bcc60b9ad3927.tar.gz
stonesense-ea2820e40d8ee93d42af8706c63bcc60b9ad3927.tar.bz2
stonesense-ea2820e40d8ee93d42af8706c63bcc60b9ad3927.tar.xz
Materials are selected by name in building configurations
Diffstat (limited to 'BlockCondition.cpp')
-rw-r--r--BlockCondition.cpp51
1 files changed, 19 insertions, 32 deletions
diff --git a/BlockCondition.cpp b/BlockCondition.cpp
index 0b789f0..d4bf2f3 100644
--- a/BlockCondition.cpp
+++ b/BlockCondition.cpp
@@ -85,46 +85,33 @@ bool PositionIndexCondition::Matches(Block* b)
-MaterialTypeCondition::MaterialTypeCondition(const char* strValue)
+MaterialTypeCondition::MaterialTypeCondition(const char* strValue, const char* strSubtype)
: BlockCondition()
{
// is there a better way to handle this?
// seems non-extensible
- value = -1;
- if( strcmp(strValue, "Wood") == 0)
- value = Mat_Wood;
- else if( strcmp(strValue, "Stone") == 0)
- value = Mat_Stone;
- else if( strcmp(strValue, "Metal") == 0)
- value = Mat_Metal;
- else if( strcmp(strValue, "Leather") == 0)
- value = Mat_Leather;
- else if( strcmp(strValue, "Silk") == 0)
- value = Mat_SilkCloth;
- else if( strcmp(strValue, "PlantCloth") == 0)
- value = Mat_PlantCloth;
- else if( strcmp(strValue, "GreenGlass") == 0)
- value = Mat_GreenGlass;
- else if( strcmp(strValue, "ClearGlass") == 0)
- value = Mat_ClearGlass;
- else if( strcmp(strValue, "CrystalGlass") == 0)
- value = Mat_CrystalGlass;
+ subtype = INVALID_INDEX;
+ value = lookupMaterialType(strValue);
+ if (value == INVALID_INDEX)
+ return;
+ if (strSubtype == NULL || strSubtype[0] == 0)
+ return;
+ subtype = lookupMaterialIndex(value, strSubtype);
+ if (subtype == INVALID_INDEX)
+ {
+ WriteErr("Material subtype not found in MaterialTypeCondition: %s\n", strSubtype);
+ //make material never match;
+ value = INVALID_INDEX;
+ }
}
bool MaterialTypeCondition::Matches(Block* b)
{
- return b->building.info.material.type == this->value;
-}
-
-MaterialIndexCondition::MaterialIndexCondition(const char* strValue)
- : BlockCondition()
-{
- this->value = atoi( strValue );
-}
-
-bool MaterialIndexCondition::Matches(Block* b)
-{
- return b->building.info.material.index == this->value;
+ if (b->building.info.material.type != this->value)
+ return false;
+ if (this->subtype == INVALID_INDEX)
+ return true;
+ return b->building.info.material.index == this->subtype;
}