From: Ricardo Cruz Date: Thu, 7 Oct 2004 17:10:28 +0000 (+0000) Subject: Two leveleditor related bug fixes: X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=4254c5c1c918e3a3c8fcdba82470d9400602e308;p=supertux.git Two leveleditor related bug fixes: - don't show empty tiles on tiles board; - don't show weird tiles when viewing stuff outside the level margins. SVN-Revision: 1987 --- diff --git a/src/tile_manager.cpp b/src/tile_manager.cpp index 49336e27b..0c87f4e3f 100644 --- a/src/tile_manager.cpp +++ b/src/tile_manager.cpp @@ -152,16 +152,8 @@ Tile* TileManager::get(unsigned int id) { Tiles::iterator i = tiles.find(id); - if(i == tiles.end()) - { - std::cerr << "Warning: Asked for a non-existing tile id. Ignoring.\n"; - // Never return 0, but return the first tile instead so that - // user code doesn't have to check for NULL pointers all over - // the place - i = tiles.begin(); - return i->second; - } + return 0; return i->second; } diff --git a/src/tilemap.cpp b/src/tilemap.cpp index a50bee38a..2bf445d9c 100644 --- a/src/tilemap.cpp +++ b/src/tilemap.cpp @@ -155,6 +155,8 @@ TileMap::draw(DrawingContext& context) int tx, ty; for(pos.x = start_x, tx = tsx; pos.x < end_x; pos.x += 32, ++tx) { for(pos.y = start_y, ty = tsy; pos.y < end_y; pos.y += 32, ++ty) { + if(tx < 0 || tx > width || ty < 0 || ty > height) + continue; // outside tilemap if (!tiles[ty*width + tx].hidden) tilemanager->draw_tile(context, tiles[ty*width + tx].id, pos, layer); } @@ -186,6 +188,8 @@ TileMap::draw(DrawingContext& context) int tx, ty; for(pos.x = start_x, tx = tsx; pos.x < end_x; pos.x += 32, ++tx) { for(pos.y = start_y, ty = tsy; pos.y < end_y; pos.y += 32, ++ty) { + if(tx < 0 || tx > width || ty < 0 || ty > height) + continue; // outside tilemap if (!tiles[ty*width + tx].hidden) tilemanager->draw_tile(context, tiles[ty*width + tx].id, pos, layer); }