From 3e754167548414481668ec3e3ee034f2356650cc Mon Sep 17 00:00:00 2001 From: Ryan Flegel Date: Tue, 1 Jun 2004 21:09:37 +0000 Subject: [PATCH] - fixed some crashes where there was an invalid tile number - some tiles need to be fixed (ie, there is no tile 6 but level5 and others contain it) SVN-Revision: 1380 --- src/badguy.cpp | 3 ++- src/collision.cpp | 2 +- src/sector.cpp | 23 +++++++++++++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/badguy.cpp b/src/badguy.cpp index d2e1a9164..6d1015dfd 100644 --- a/src/badguy.cpp +++ b/src/badguy.cpp @@ -644,7 +644,8 @@ BadGuy::action_fish(double elapsed_time) // go in wait mode when back in water if(dying == DYING_NOT - && gettile(base.x, base.y+ base.height)->attributes & Tile::WATER + && gettile(base.x, base.y + base.height) + && gettile(base.x, base.y + base.height)->attributes & Tile::WATER && physic.get_velocity_y() <= 0 && mode == NORMAL) { mode = FISH_WAIT; diff --git a/src/collision.cpp b/src/collision.cpp index e36327f5b..ad1cc80db 100644 --- a/src/collision.cpp +++ b/src/collision.cpp @@ -55,7 +55,7 @@ bool collision_object_map(const base_type& base) for(int x = starttilex; x*32 < max_x; ++x) { for(int y = starttiley; y*32 < max_y; ++y) { Tile* tile = tilemap.get_tile(x, y); - if(tile->attributes & Tile::SOLID) + if(tile && tile->attributes & Tile::SOLID) return true; } } diff --git a/src/sector.cpp b/src/sector.cpp index 434582b0c..3d75b7723 100644 --- a/src/sector.cpp +++ b/src/sector.cpp @@ -618,6 +618,13 @@ bool Sector::trybreakbrick(const Vector& pos, bool small) { Tile* tile = solids->get_tile_at(pos); + if (!tile) + { + char errmsg[64]; + sprintf(errmsg, "Invalid tile at %i,%i", (int)((pos.x+1)/32*32), (int)((pos.y+1)/32*32)); + throw SuperTuxException(errmsg, __FILE__, __LINE__); + } + if (tile->attributes & Tile::BRICK) { if (tile->data > 0) @@ -674,6 +681,14 @@ void Sector::tryemptybox(const Vector& pos, Direction col_side) { Tile* tile = solids->get_tile_at(pos); + if (!tile) + { + char errmsg[64]; + sprintf(errmsg, "Invalid tile at %i,%i", (int)((pos.x+1)/32*32), (int)((pos.y+1)/32*32)); + throw SuperTuxException(errmsg, __FILE__, __LINE__); + } + + if (!(tile->attributes & Tile::FULLBOX)) return; @@ -730,6 +745,14 @@ void Sector::trygrabdistro(const Vector& pos, int bounciness) { Tile* tile = solids->get_tile_at(pos); + if (!tile) + { + char errmsg[64]; + sprintf(errmsg, "Invalid tile at %i,%i", (int)((pos.x+1)/32*32), (int)((pos.y+1)/32*32)); + throw SuperTuxException(errmsg, __FILE__, __LINE__); + } + + if (!(tile->attributes & Tile::COIN)) return; -- 2.11.0