From: Ingo Ruhnke Date: Sun, 21 Mar 2004 19:22:55 +0000 (+0000) Subject: - replaced char* with string X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=e8ce5f3978548da90d41229cd7da36ef6eaebf99;p=supertux.git - replaced char* with string - replace assert() with st_aboart() SVN-Revision: 301 --- diff --git a/src/setup.cpp b/src/setup.cpp index 4d41e1583..6cc2e4ae5 100644 --- a/src/setup.cpp +++ b/src/setup.cpp @@ -790,9 +790,9 @@ void st_shutdown(void) /* --- ABORT! --- */ -void st_abort(const char * reason,const char * details) +void st_abort(const std::string& reason, const std::string& details) { - fprintf(stderr, "\nError: %s\n%s\n\n", reason, details); + fprintf(stderr, "\nError: %s\n%s\n\n", reason.c_str(), details.c_str()); st_shutdown(); exit(1); } diff --git a/src/setup.h b/src/setup.h index cc2b68da3..35a8b6b55 100644 --- a/src/setup.h +++ b/src/setup.h @@ -32,7 +32,7 @@ void st_audio_setup(void); void st_joystick_setup(void); void st_shutdown(void); void st_menu(void); -void st_abort( const char * reason, const char * details); +void st_abort(const std::string& reason, const std::string& details); void process_options_menu(void); void process_save_load_game_menu(int save); void update_load_save_game_menu(menu_type* pmenu, int load); diff --git a/src/sound.cpp b/src/sound.cpp index 9863eaf67..412f3c0f0 100644 --- a/src/sound.cpp +++ b/src/sound.cpp @@ -97,7 +97,7 @@ Mix_Chunk * load_sound(const std::string& file) /* printf message and abort if there is an initialized audio device */ if ((snd == NULL) && (audio_device == YES)) - st_abort("Can't load", file.c_str()); + st_abort("Can't load", file); return(snd); } @@ -113,7 +113,7 @@ Mix_Music * load_song(const std::string& file) /* printf message and abort if there is an initialized audio device */ if ((sng == NULL) && (audio_device == YES)) - st_abort("Can't load", file.c_str()); + st_abort("Can't load", file); return (sng); } diff --git a/src/texture.cpp b/src/texture.cpp index 4108d1024..e318207bf 100644 --- a/src/texture.cpp +++ b/src/texture.cpp @@ -225,7 +225,7 @@ void texture_load_sdl(texture_type* ptexture, const std::string& file, int use_a temp = IMG_Load(file.c_str()); if (temp == NULL) - st_abort("Can't load", file.c_str()); + st_abort("Can't load", file); if(use_alpha == IGNORE_ALPHA && !use_gl) ptexture->sdl_surface = SDL_DisplayFormat(temp); @@ -233,7 +233,7 @@ void texture_load_sdl(texture_type* ptexture, const std::string& file, int use_a ptexture->sdl_surface = SDL_DisplayFormatAlpha(temp); if (ptexture->sdl_surface == NULL) - st_abort("Can't covert to display format", file.c_str()); + st_abort("Can't covert to display format", file); if (use_alpha == IGNORE_ALPHA && !use_gl) SDL_SetAlpha(ptexture->sdl_surface, 0, 0); @@ -255,7 +255,7 @@ void texture_load_part_sdl(texture_type* ptexture, const std::string& file, int temp = IMG_Load(file.c_str()); if (temp == NULL) - st_abort("Can't load", file.c_str()); + st_abort("Can't load", file); /* Set source rectangle for conv: */ @@ -286,7 +286,7 @@ void texture_load_part_sdl(texture_type* ptexture, const std::string& file, int ptexture->sdl_surface = SDL_DisplayFormatAlpha(conv); if (ptexture->sdl_surface == NULL) - st_abort("Can't covert to display format", file.c_str()); + st_abort("Can't covert to display format", file); if (use_alpha == IGNORE_ALPHA && !use_gl) SDL_SetAlpha(ptexture->sdl_surface, 0, 0); diff --git a/src/worldmap.cpp b/src/worldmap.cpp index d7201fbbd..c6f9d2d1f 100644 --- a/src/worldmap.cpp +++ b/src/worldmap.cpp @@ -25,6 +25,7 @@ #include "screen.h" #include "lispreader.h" #include "gameloop.h" +#include "setup.h" #include "worldmap.h" namespace WorldMapNS { @@ -33,9 +34,11 @@ TileManager* TileManager::instance_ = 0; TileManager::TileManager() { - lisp_object_t* root_obj = lisp_read_from_file(datadir + "images/worldmap/antarctica.scm"); - - assert(root_obj); + std::string filename = datadir + "images/worldmap/antarctica.scm"; + lisp_object_t* root_obj = lisp_read_from_file(filename); + + if (!root_obj) + st_abort("Couldn't load file", filename); if (strcmp(lisp_symbol(lisp_car(root_obj)), "supertux-worldmap-tiles") == 0) { @@ -217,8 +220,11 @@ WorldMap::~WorldMap() void WorldMap::load_map() { - lisp_object_t* root_obj = lisp_read_from_file(datadir + "levels/default/worldmap.stwm"); - assert(root_obj); + std::string filename = datadir + "levels/default/worldmap.stwm"; + + lisp_object_t* root_obj = lisp_read_from_file(filename); + if (!root_obj) + st_abort("Couldn't load file", filename); if (strcmp(lisp_symbol(lisp_car(root_obj)), "supertux-worldmap") == 0) { diff --git a/src/worldmap.h b/src/worldmap.h index 4767c2e4d..388b1a34b 100644 --- a/src/worldmap.h +++ b/src/worldmap.h @@ -155,7 +155,10 @@ public: Point get_next_tile(Point pos, Direction direction); Tile* at(Point pos); - bool path_ok(Direction direction, Point old_pos, Point* new_pos); + + /** Check if it is possible to walk from \a pos into \a direction, + if possible, write the new position to \a new_pos */ + bool path_ok(Direction direction, Point pos, Point* new_pos); }; } // namespace WorldMapNS