diff options
| author | Alexander Gavrilov | 2012-03-17 13:09:22 +0400 |
|---|---|---|
| committer | Petr Mrázek | 2012-03-18 12:47:01 +0100 |
| commit | 719dbc048a55ba1def2ce21e9cd29e33dbe833ce (patch) | |
| tree | 7ba4f05e3e2beb41600d50f9a2fa20910da96887 | |
| parent | fa17ba5de0a003c135150516cd9c80205ac3f9f1 (diff) | |
| download | stonesense-719dbc048a55ba1def2ce21e9cd29e33dbe833ce.tar.gz stonesense-719dbc048a55ba1def2ce21e9cd29e33dbe833ce.tar.bz2 stonesense-719dbc048a55ba1def2ce21e9cd29e33dbe833ce.tar.xz | |
Fix ENUM_KEY_STR breakage.
| -rw-r--r-- | BlockCondition.cpp | 12 | ||||
| -rw-r--r-- | ContentLoader.cpp | 10 | ||||
| -rw-r--r-- | GUI.cpp | 6 | ||||
| -rw-r--r-- | SpriteObjects.cpp | 7 |
4 files changed, 16 insertions, 19 deletions
diff --git a/BlockCondition.cpp b/BlockCondition.cpp index 022b32b..4d45845 100644 --- a/BlockCondition.cpp +++ b/BlockCondition.cpp @@ -32,14 +32,10 @@ int getDirectionFromString(const char* strDir) int getBuildingFromString(const char* strType)
{
- FOR_ENUM_ITEMS(building_type,i)
- {
- if (strcmp(strType,ENUM_KEY_STR(building_type,i)) == 0)
- {
- return i;
- }
- }
- return INVALID_INDEX;
+ df::building_type item;
+ if (find_enum_item(&item, strType))
+ return (int)item;
+ return INVALID_INDEX;
}
NeighbourWallCondition::NeighbourWallCondition(const char* strDir)
diff --git a/ContentLoader.cpp b/ContentLoader.cpp index 48ed0a0..8a2f344 100644 --- a/ContentLoader.cpp +++ b/ContentLoader.cpp @@ -493,15 +493,15 @@ const char *lookupBuildingSubtype(int main_type, int i) switch (main_type)
{
case building_type::Furnace:
- return ENUM_KEY_STR(furnace_type,(furnace_type::furnace_type)i);
+ return enum_item_key_str((df::furnace_type)i);
case building_type::Construction:
- return ENUM_KEY_STR(construction_type,(construction_type::construction_type)i);
+ return enum_item_key_str((df::construction_type)i);
case building_type::SiegeEngine:
- return ENUM_KEY_STR(siegeengine_type,(siegeengine_type::siegeengine_type)i);
+ return enum_item_key_str((df::siegeengine_type)i);
case building_type::Shop:
- return ENUM_KEY_STR(shop_type,(shop_type::shop_type)i);
+ return enum_item_key_str((df::shop_type)i);
case building_type::Workshop:
- return ENUM_KEY_STR(workshop_type,(workshop_type::workshop_type)i);
+ return enum_item_key_str((df::workshop_type)i);
default:
return "NA";
}
@@ -477,7 +477,7 @@ void drawDebugCursorAndInfo(WorldSegment * segment) draw_textf_border(font, al_map_rgb(255,255,255), 2, (i++*al_get_font_line_height(font)), 0,
"%s - %s%s%s%s%s",
mat.getToken().c_str(),
- ENUM_KEY_STR(item_type, Actual_building->contained_items[index]->item->getType()),
+ ENUM_KEY_STR(item_type, Actual_building->contained_items[index]->item->getType()).c_str(),
(Actual_building->contained_items[index]->item->getSubtype()>=0)?"/":"",
(Actual_building->contained_items[index]->item->getSubtype()>=0)?get_item_subtype(Actual_building->contained_items[index]->item->getType(),Actual_building->contained_items[index]->item->getSubtype()):"",
Actual_building->contained_items[index]->item->getStackSize()>1?stacknum:"",
@@ -503,7 +503,7 @@ void drawDebugCursorAndInfo(WorldSegment * segment) if(b->inv->item[item_type_idex].empty())
continue;
draw_textf_border(font, al_map_rgb(255,255,255), 2, (i++*al_get_font_line_height(font)), 0,
- "%s:", ENUM_KEY_STR(item_type, (item_type::item_type)item_type_idex));
+ "%s:", ENUM_KEY_STR(item_type, (df::item_type)item_type_idex).c_str());
for(int ind = 0; ind < b->inv->item[item_type_idex].size(); ind++)
{
if(b->inv->item[item_type_idex][ind].empty())
@@ -630,7 +630,7 @@ void drawDebugCursorAndInfo(WorldSegment * segment) const char* subTypeName = lookupBuildingSubtype(b->building.info.type, b->building.info.subtype);
draw_textf_border(font, al_map_rgb(255,255,255), 2, (i++*al_get_font_line_height(font)), 0,
"Building: game_type = %s(%i) game_subtype = %s(%i) Material: %s%s%s (%d,%d)",
- ENUM_KEY_STR(building_type, (building_type::building_type)b->building.info.type),
+ ENUM_KEY_STR(building_type, (df::building_type)b->building.info.type).c_str(),
b->building.info.type,
subTypeName,
b->building.info.subtype,
diff --git a/SpriteObjects.cpp b/SpriteObjects.cpp index 9c1bed0..963fb63 100644 --- a/SpriteObjects.cpp +++ b/SpriteObjects.cpp @@ -494,10 +494,11 @@ void c_sprite::set_by_xml(TiXmlElement *elemSprite) {
itemtype = INVALID_INDEX;
}
- else for(int index=ENUM_FIRST_ITEM(item_type); index <= ENUM_LAST_ITEM(item_type); index++)
+ else
{
- if(strcmp(equiptypestr, ENUM_KEY_STR(item_type, (item_type::item_type)index)) == 0)
- itemtype = index;
+ df::item_type index;
+ if (find_enum_item(&index, equiptypestr))
+ itemtype = (int)index;
}
const char* equipsindexstr = elemSprite->Attribute("equipment_name");
|
