Skip to content

Commit

Permalink
Merge pull request #104 from plule/large_screenshot_crash
Browse files Browse the repository at this point in the history
Fix a crash with pre-existing campsite
  • Loading branch information
myk002 authored Apr 9, 2024
2 parents 5dab6a8 + 9dd25c9 commit bf64c9a
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions SpriteMaps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,32 @@ using namespace df::enums;

c_sprite * GetTerrainSpriteMap(int in, t_matglossPair material, vector<std::unique_ptr<TerrainConfiguration>>& 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;
Expand Down

0 comments on commit bf64c9a

Please sign in to comment.