Skip to content

Commit

Permalink
Rewrite Map: Upper tiles - Bugfixes
Browse files Browse the repository at this point in the history
- Fixed wrong IDs
- Fixed wrong Layer assertion
- Added a conditional branch to protect IDs from overflowing.
  • Loading branch information
jetrotal committed Jan 6, 2025
1 parent 7b288c5 commit b983e20
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/spriteset_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ void Spriteset_Map::ReplaceDownAt(int x, int y, int tile_index, bool disable_aut
}

void Spriteset_Map::ReplaceUpAt(int x, int y, int tile_index) {
tile_index += BLOCK_F_INDEX;
if (tile_index >= NUM_UPPER_TILES + BLOCK_F_INDEX) tile_index = 0;

auto tile_id = IndexToChipId(tile_index);
tilemap->SetMapTileDataUpAt(x, y, tile_id);
}
Expand Down
2 changes: 1 addition & 1 deletion src/tilemap.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ inline void Tilemap::SetMapDataUp(std::vector<short> up) {
}

inline void Tilemap::SetMapTileDataUpAt(int x, int y, int tile_id) {
layer_down.SetMapTileDataAt(x, y, tile_id, true);
layer_up.SetMapTileDataAt(x, y, tile_id, true);
}

inline const std::vector<unsigned char>& Tilemap::GetPassableDown() const {
Expand Down

0 comments on commit b983e20

Please sign in to comment.