Remove memory leaks from map destruction

This commit is contained in:
Linus Probert 2019-03-15 16:00:20 +01:00
parent 38dc3deb2c
commit 68533f05b3
1 changed files with 6 additions and 2 deletions

View File

@ -99,8 +99,6 @@ map_tile_destroy(MapTile *tile)
static void
switch_tile(Map *map, Position *tile_pos, MapTile *tile, MapTile **oldTile)
{
const Position *cr = &map->currentRoom;
// Set the decoration sprites position to match tile pos
tile->sprite->pos = POS(tile_pos->x * TILE_DIMENSION + (map->currentRoom.x * GAME_VIEW_WIDTH),
tile_pos->y * TILE_DIMENSION + (map->currentRoom.y * GAME_VIEW_HEIGHT));
@ -425,6 +423,12 @@ void map_room_destroy(Room *room)
if (room->tiles[i][j]) {
map_tile_destroy(room->tiles[i][j]);
}
if (room->doors[i][j]) {
map_tile_destroy(room->doors[i][j]);
}
if (room->walls[i][j]) {
map_tile_destroy(room->walls[i][j]);
}
if (room->decorations[i][j]) {
map_tile_destroy(room->decorations[i][j]);
}