From: Ryan Flegel Date: Tue, 1 Jun 2004 21:09:37 +0000 (+0000) Subject: - fixed some crashes where there was an invalid tile number X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=3e754167548414481668ec3e3ee034f2356650cc;p=supertux.git - 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 --- 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;