Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a crash with pre-existing campsite #104

Merged
merged 1 commit into from
Apr 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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