diff --git a/SpriteMaps.cpp b/SpriteMaps.cpp index ac2af161..6b8853bb 100644 --- a/SpriteMaps.cpp +++ b/SpriteMaps.cpp @@ -12,25 +12,32 @@ using namespace df::enums; c_sprite * GetTerrainSpriteMap(int in, t_matglossPair material, vector>& configTable, uint16_t form) { + // in case we need to return nothing + static c_sprite* defaultSprite = new c_sprite; + defaultSprite->reset(); + defaultSprite->set_sheetindex(UNCONFIGURED_INDEX); + defaultSprite->set_fileindex(INVALID_INDEX); + defaultSprite->set_needoutline(1); + int tempform; - if(form == item_type::BAR) { + switch (form) + { + case item_type::BAR: tempform = FORM_BAR; - } - if(form == item_type::BLOCKS) { + break; + case item_type::BLOCKS: tempform = FORM_BLOCK; - } - if(form == item_type::BOULDER) { + break; + case item_type::BOULDER: tempform = FORM_BOULDER; - } - if(form == item_type::WOOD) { + break; + case item_type::WOOD: tempform = FORM_LOG; + break; + default: + return defaultSprite; } - // in case we need to return nothing - static c_sprite * defaultSprite = new c_sprite; - defaultSprite->reset(); - defaultSprite->set_sheetindex(UNCONFIGURED_INDEX); - defaultSprite->set_fileindex(INVALID_INDEX); - defaultSprite->set_needoutline(1); + // first check the input is sane if( in < 0 || in >= (int)configTable.size() ) { return defaultSprite;