[Super-tux-commit] supertux/src button.cpp,1.16,1.17 configfile.cpp,1.3,1.4 defines.h,1.23,1.24 high
Brought to you by:
wkendrick
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2323/src Modified Files: button.cpp configfile.cpp defines.h high_scores.cpp level.cpp lispreader.cpp menu.cpp menu.h setup.cpp special.cpp special.h sprite_manager.cpp text.cpp texture.cpp texture.h tile.cpp tile.h title.cpp worldmap.cpp worldmap.h Log Message: - memleak fix and menu fix from MatzeB - little bullet tweaking from myself - added story Index: tile.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/tile.h,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- tile.h 20 Apr 2004 11:09:34 -0000 1.12 +++ tile.h 25 Apr 2004 21:55:39 -0000 1.13 @@ -31,8 +31,12 @@ /** Tile Class */ -struct Tile +class Tile { +public: + Tile(); + ~Tile(); + int id; std::vector<Surface*> images; Index: menu.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/menu.cpp,v retrieving revision 1.56 retrieving revision 1.57 diff -u -d -r1.56 -r1.57 --- menu.cpp 24 Apr 2004 18:03:35 -0000 1.56 +++ menu.cpp 25 Apr 2004 21:55:39 -0000 1.57 @@ -223,8 +223,6 @@ pos_x = screen->w/2; pos_y = screen->h/2; - has_backitem = false; - last_id = 0; arrange_left = 0; active_item = 0; effect.init(false); @@ -239,15 +237,6 @@ void Menu::additem(MenuItemKind kind_, const std::string& text_, int toggle_, Menu* menu_, int id, int* int_p) { - if(kind_ == MN_BACK) - has_backitem = true; - - if(id == -1 && item.size() == (unsigned)last_id) - { - id = last_id; - last_id++; - } - additem(MenuItem::create(kind_, text_.c_str(), toggle_, menu_, id, int_p)); } @@ -255,9 +244,6 @@ void Menu::additem(MenuItem* pmenu_item) { - if(pmenu_item->kind == MN_BACK) - has_backitem = true; - item.push_back(*pmenu_item); delete pmenu_item; } Index: defines.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/defines.h,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- defines.h 22 Apr 2004 20:41:39 -0000 1.23 +++ defines.h 25 Apr 2004 21:55:39 -0000 1.24 @@ -69,9 +69,8 @@ #define START_LIVES 4 -#define MAX_BULLETS 1 +#define MAX_BULLETS 2 -#define GRAVITY 1.0 #define YM_FOR_JUMP 6.0 #define WALK_ACCELERATION_X 0.03 #define RUN_ACCELERATION_X 0.04 Index: sprite_manager.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/sprite_manager.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- sprite_manager.cpp 20 Apr 2004 11:09:34 -0000 1.2 +++ sprite_manager.cpp 25 Apr 2004 21:55:39 -0000 1.3 @@ -29,7 +29,8 @@ void SpriteManager::load_resfile(const std::string& filename) { - lisp_object_t* cur = lisp_read_from_file(filename); + lisp_object_t* root_obj = lisp_read_from_file(filename); + lisp_object_t* cur = root_obj; if (strcmp(lisp_symbol(lisp_car(cur)), "supertux-resources") != 0) return; @@ -62,6 +63,8 @@ cur = lisp_cdr(cur); } + + lisp_free(root_obj); } Sprite* Index: special.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/special.cpp,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- special.cpp 22 Apr 2004 20:14:49 -0000 1.26 +++ special.cpp 25 Apr 2004 21:55:39 -0000 1.27 @@ -18,6 +18,7 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <assert.h> +#include <iostream> #include "SDL.h" #include "defines.h" #include "special.h" @@ -30,8 +31,7 @@ #include "sprite_manager.h" #include "resources.h" -Surface* img_bullet; - +Sprite* img_bullet; Sprite* img_star; Sprite* img_growup; Sprite* img_iceflower; @@ -39,6 +39,9 @@ #define GROWUP_SPEED 1.0f +#define BULLET_STARTING_YM 0 +#define BULLET_XM 6 + void Bullet::init(float x, float y, float xm, Direction dir) { @@ -79,6 +82,10 @@ void Bullet::action(double frame_ratio) { + frame_ratio *= 0.5f; + + float old_y = base.y; + base.x = base.x + base.xm * frame_ratio; base.y = base.y + base.ym * frame_ratio; @@ -86,11 +93,15 @@ if (issolid(base.x, base.y + 4) || issolid(base.x, base.y)) { - base.ym = -base.ym; - base.y = (int)(base.y / 32) * 32; + base.y = old_y; + base.ym = -base.ym; + if (base.ym > 13) + base.ym = 13; + else if (base.ym < -13) + base.ym = -13; } - base.ym = base.ym + GRAVITY; + base.ym = base.ym + 0.5 * frame_ratio; if (base.x < scroll_x || base.x > scroll_x + screen->w || @@ -110,8 +121,7 @@ if (base.x >= scroll_x - base.width && base.x <= scroll_x + screen->w) { - img_bullet->draw( base.x - scroll_x, base.y, 255, - NO_UPDATE); + img_bullet->draw(base.x - scroll_x, base.y); } } @@ -342,8 +352,7 @@ img_star = sprite_manager->load("star"); img_1up = sprite_manager->load("1up"); - img_bullet = new Surface(datadir + "/images/shared/bullet.png", - USE_ALPHA); + img_bullet = sprite_manager->load("bullet"); } void free_special_gfx() Index: worldmap.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.cpp,v retrieving revision 1.48 retrieving revision 1.49 diff -u -d -r1.48 -r1.49 --- worldmap.cpp 25 Apr 2004 12:29:23 -0000 1.48 +++ worldmap.cpp 25 Apr 2004 21:55:39 -0000 1.49 @@ -83,8 +83,6 @@ return NONE; } -TileManager* TileManager::instance_ = 0; - TileManager::TileManager() { std::string stwt_filename = datadir + "images/worldmap/antarctica.stwt"; @@ -143,6 +141,14 @@ { assert(0); } + + lisp_free(root_obj); +} + +TileManager::~TileManager() +{ + for(std::vector<Tile*>::iterator i = tiles.begin(); i != tiles.end(); ++i) + delete *i; } Tile* @@ -152,6 +158,8 @@ return tiles[i]; } +//--------------------------------------------------------------------------- + Tux::Tux(WorldMap* worldmap_) : worldmap(worldmap_) { @@ -164,6 +172,11 @@ input_direction = NONE; } +Tux::~Tux() +{ + delete sprite; +} + void Tux::draw(const Point& offset) { @@ -268,8 +281,21 @@ } } +//--------------------------------------------------------------------------- +Tile::Tile() +{ +} + +Tile::~Tile() +{ + delete sprite; +} + +//--------------------------------------------------------------------------- + WorldMap::WorldMap() { + tile_manager = new TileManager(); tux = new Tux(this); width = 20; @@ -291,6 +317,11 @@ WorldMap::~WorldMap() { delete tux; + delete tile_manager; + + delete level_sprite; + delete leveldot_green; + delete leveldot_red; } void @@ -362,38 +393,42 @@ cur = lisp_cdr(cur); } } + + lisp_free(root_obj); } void WorldMap::get_level_title(Levels::pointer level) { -/** get level's title */ -level->title = "<no title>"; + /** get level's title */ + level->title = "<no title>"; -FILE * fi; -lisp_object_t* root_obj = 0; -fi = fopen((datadir + "levels/" + level->name).c_str(), "r"); -if (fi == NULL) + FILE * fi; + lisp_object_t* root_obj = 0; + fi = fopen((datadir + "levels/" + level->name).c_str(), "r"); + if (fi == NULL) { - perror((datadir + "levels/" + level->name).c_str()); - return; + perror((datadir + "levels/" + level->name).c_str()); + return; } -lisp_stream_t stream; -lisp_stream_init_file (&stream, fi); -root_obj = lisp_read (&stream); + lisp_stream_t stream; + lisp_stream_init_file (&stream, fi); + root_obj = lisp_read (&stream); -if (root_obj->type == LISP_TYPE_EOF || root_obj->type == LISP_TYPE_PARSE_ERROR) + if (root_obj->type == LISP_TYPE_EOF || root_obj->type == LISP_TYPE_PARSE_ERROR) { - printf("World: Parse Error in file %s", level->name.c_str()); + printf("World: Parse Error in file %s", level->name.c_str()); } -if (strcmp(lisp_symbol(lisp_car(root_obj)), "supertux-level") == 0) + if (strcmp(lisp_symbol(lisp_car(root_obj)), "supertux-level") == 0) { - LispReader reader(lisp_cdr(root_obj)); - reader.read_string("name", &level->title); + LispReader reader(lisp_cdr(root_obj)); + reader.read_string("name", &level->title); } -fclose(fi); + lisp_free(root_obj); + + fclose(fi); } void @@ -635,7 +670,7 @@ && p.y >= 0 && p.y < height); - return TileManager::instance()->get(tilemap[width * p.y + p.x]); + return tile_manager->get(tilemap[width * p.y + p.x]); } WorldMap::Level* @@ -797,66 +832,69 @@ std::cout << "loadgame: " << filename << std::endl; savegame_file = filename; - if (access(filename.c_str(), F_OK) == 0) - { - lisp_object_t* cur = lisp_read_from_file(filename); + if (access(filename.c_str(), F_OK) != 0) + return; + + lisp_object_t* savegame = lisp_read_from_file(filename); + lisp_object_t* cur = savegame; - if (strcmp(lisp_symbol(lisp_car(cur)), "supertux-savegame") != 0) - return; + if (strcmp(lisp_symbol(lisp_car(cur)), "supertux-savegame") != 0) + return; - cur = lisp_cdr(cur); - LispReader reader(cur); - - reader.read_int("lives", &player_status.lives); - reader.read_int("score", &player_status.score); - reader.read_int("distros", &player_status.distros); + cur = lisp_cdr(cur); + LispReader reader(cur); - if (player_status.lives < 0) - player_status.lives = START_LIVES; + reader.read_int("lives", &player_status.lives); + reader.read_int("score", &player_status.score); + reader.read_int("distros", &player_status.distros); - lisp_object_t* tux_cur = 0; - if (reader.read_lisp("tux", &tux_cur)) - { - Point p; - std::string back_str = "none"; + if (player_status.lives < 0) + player_status.lives = START_LIVES; - LispReader tux_reader(tux_cur); - tux_reader.read_int("x", &p.x); - tux_reader.read_int("y", &p.y); - tux_reader.read_string("back", &back_str); - - tux->back_direction = string_to_direction(back_str); - tux->set_tile_pos(p); - } + lisp_object_t* tux_cur = 0; + if (reader.read_lisp("tux", &tux_cur)) + { + Point p; + std::string back_str = "none"; - lisp_object_t* level_cur = 0; - if (reader.read_lisp("levels", &level_cur)) + LispReader tux_reader(tux_cur); + tux_reader.read_int("x", &p.x); + tux_reader.read_int("y", &p.y); + tux_reader.read_string("back", &back_str); + + tux->back_direction = string_to_direction(back_str); + tux->set_tile_pos(p); + } + + lisp_object_t* level_cur = 0; + if (reader.read_lisp("levels", &level_cur)) + { + while(level_cur) { - while(level_cur) - { - lisp_object_t* sym = lisp_car(lisp_car(level_cur)); - lisp_object_t* data = lisp_cdr(lisp_car(level_cur)); + lisp_object_t* sym = lisp_car(lisp_car(level_cur)); + lisp_object_t* data = lisp_cdr(lisp_car(level_cur)); - if (strcmp(lisp_symbol(sym), "level") == 0) - { - std::string name; - bool solved = false; + if (strcmp(lisp_symbol(sym), "level") == 0) + { + std::string name; + bool solved = false; - LispReader level_reader(data); - level_reader.read_string("name", &name); - level_reader.read_bool("solved", &solved); + LispReader level_reader(data); + level_reader.read_string("name", &name); + level_reader.read_bool("solved", &solved); - for(Levels::iterator i = levels.begin(); i != levels.end(); ++i) - { - if (name == i->name) - i->solved = solved; - } + for(Levels::iterator i = levels.begin(); i != levels.end(); ++i) + { + if (name == i->name) + i->solved = solved; } - - level_cur = lisp_cdr(level_cur); } + + level_cur = lisp_cdr(level_cur); } } + + lisp_free(savegame); } } // namespace WorldMapNS Index: level.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/level.cpp,v retrieving revision 1.50 retrieving revision 1.51 diff -u -d -r1.50 -r1.51 --- level.cpp 25 Apr 2004 13:51:19 -0000 1.50 +++ level.cpp 25 Apr 2004 21:55:39 -0000 1.51 @@ -127,6 +127,7 @@ } + lisp_free(root_obj); fclose(fi); snprintf(str, 1024, "%s.png", filename); @@ -203,6 +204,7 @@ Level::Level() : img_bkgd(0) { + init_defaults(); } Level::Level(const std::string& subset, int level) @@ -501,6 +503,7 @@ else endpos = 32*(width-15); + lisp_free(root_obj); fclose(fi); return 0; } Index: special.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/special.h,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- special.h 20 Apr 2004 19:55:10 -0000 1.16 +++ special.h 25 Apr 2004 21:55:39 -0000 1.17 @@ -17,9 +17,6 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -#define BULLET_STARTING_YM 1 -#define BULLET_XM 5 - #ifndef SUPERTUX_SPECIAL_H #define SUPERTUX_SPECIAL_H Index: button.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/button.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- button.cpp 20 Apr 2004 11:09:33 -0000 1.16 +++ button.cpp 25 Apr 2004 21:55:23 -0000 1.17 @@ -57,7 +57,8 @@ dest.y = 0; dest.w = icon->w; dest.h = icon->h; - SDL_SoftStretch(icon->impl->sdl_surface, NULL, icon->impl->sdl_surface, &dest); + SDL_SoftStretch(icon->impl->get_sdl_surface(), NULL, + icon->impl->get_sdl_surface(), &dest); } else icon = new Surface(filename,USE_ALPHA); Index: text.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/text.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- text.cpp 20 Apr 2004 11:09:34 -0000 1.10 +++ text.cpp 25 Apr 2004 21:55:39 -0000 1.11 @@ -55,7 +55,7 @@ chars = new Surface(file, USE_ALPHA); // Load shadow font. - conv = SDL_DisplayFormatAlpha(chars->impl->sdl_surface); + conv = SDL_DisplayFormatAlpha(chars->impl->get_sdl_surface()); pixels = conv->w * conv->h; SDL_LockSurface(conv); for(i = 0; i < pixels; ++i) Index: lispreader.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/lispreader.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- lispreader.cpp 25 Apr 2004 14:16:10 -0000 1.14 +++ lispreader.cpp 25 Apr 2004 21:55:39 -0000 1.15 @@ -49,10 +49,10 @@ static char token_string[MAX_TOKEN_LENGTH + 1] = ""; static int token_length = 0; -static lisp_object_t end_marker = { LISP_TYPE_EOF , {0,0} }; -static lisp_object_t error_object = { LISP_TYPE_PARSE_ERROR , {0,0} }; -static lisp_object_t close_paren_marker = { LISP_TYPE_PARSE_ERROR , {0,0} }; -static lisp_object_t dot_marker = { LISP_TYPE_PARSE_ERROR , {0,0} }; +static lisp_object_t end_marker = { LISP_TYPE_EOF, {{0, 0}} }; +static lisp_object_t error_object = { LISP_TYPE_PARSE_ERROR , {{0,0}} }; +static lisp_object_t close_paren_marker = { LISP_TYPE_PARSE_ERROR , {{0,0}} }; +static lisp_object_t dot_marker = { LISP_TYPE_PARSE_ERROR , {{0,0}} }; static void _token_clear (void) Index: setup.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/setup.cpp,v retrieving revision 1.57 retrieving revision 1.58 diff -u -d -r1.57 -r1.58 --- setup.cpp 25 Apr 2004 16:46:55 -0000 1.57 +++ setup.cpp 25 Apr 2004 21:55:39 -0000 1.58 @@ -55,6 +55,8 @@ #include "player.h" +void display_text_file(char *filename); + #ifdef WIN32 #define mkdir(dir, mode) mkdir(dir) // on win32 we typically don't want LFS paths @@ -437,21 +439,21 @@ load_game_menu->additem(MN_LABEL,"Start Game",0,0); load_game_menu->additem(MN_HL,"",0,0); - load_game_menu->additem(MN_DEACTIVE,"Slot 1",0,0); - load_game_menu->additem(MN_DEACTIVE,"Slot 2",0,0); - load_game_menu->additem(MN_DEACTIVE,"Slot 3",0,0); - load_game_menu->additem(MN_DEACTIVE,"Slot 4",0,0); - load_game_menu->additem(MN_DEACTIVE,"Slot 5",0,0); + load_game_menu->additem(MN_DEACTIVE,"Slot 1",0,0, 1); + load_game_menu->additem(MN_DEACTIVE,"Slot 2",0,0, 2); + load_game_menu->additem(MN_DEACTIVE,"Slot 3",0,0, 3); + load_game_menu->additem(MN_DEACTIVE,"Slot 4",0,0, 4); + load_game_menu->additem(MN_DEACTIVE,"Slot 5",0,0, 5); load_game_menu->additem(MN_HL,"",0,0); load_game_menu->additem(MN_BACK,"Back",0,0); save_game_menu->additem(MN_LABEL,"Save Game",0,0); save_game_menu->additem(MN_HL,"",0,0); - save_game_menu->additem(MN_DEACTIVE,"Slot 1",0,0); - save_game_menu->additem(MN_DEACTIVE,"Slot 2",0,0); - save_game_menu->additem(MN_DEACTIVE,"Slot 3",0,0); - save_game_menu->additem(MN_DEACTIVE,"Slot 4",0,0); - save_game_menu->additem(MN_DEACTIVE,"Slot 5",0,0); + save_game_menu->additem(MN_DEACTIVE,"Slot 1",0,0, 1); + save_game_menu->additem(MN_DEACTIVE,"Slot 2",0,0, 2); + save_game_menu->additem(MN_DEACTIVE,"Slot 3",0,0, 3); + save_game_menu->additem(MN_DEACTIVE,"Slot 4",0,0, 4); + save_game_menu->additem(MN_DEACTIVE,"Slot 5",0,0, 5); save_game_menu->additem(MN_HL,"",0,0); save_game_menu->additem(MN_BACK,"Back",0,0); @@ -489,14 +491,14 @@ { int slot = load_game_menu->check(); - if(slot != -1 && load_game_menu->get_item(slot).kind == MN_ACTION) + if(slot != -1 && load_game_menu->get_item_by_id(slot).kind == MN_ACTION) { char slotfile[1024]; - snprintf(slotfile, 1024, "%s/slot%d.stsg", st_save_dir, slot-1); + snprintf(slotfile, 1024, "%s/slot%d.stsg", st_save_dir, slot); if (access(slotfile, F_OK) != 0) { - draw_intro(); + display_text_file("intro.txt"); } WorldMapNS::WorldMap worldmap; Index: worldmap.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.h,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- worldmap.h 24 Apr 2004 14:49:04 -0000 1.22 +++ worldmap.h 25 Apr 2004 21:55:39 -0000 1.23 @@ -46,8 +46,12 @@ int y; }; -struct Tile +class Tile { +public: + Tile(); + ~Tile(); + Surface* sprite; // Directions in which Tux is allowed to walk from this tile @@ -65,13 +69,11 @@ private: typedef std::vector<Tile*> Tiles; Tiles tiles; - static TileManager* instance_ ; - TileManager(); public: - static TileManager* instance() { return instance_ ? instance_ : instance_ = new TileManager(); } + TileManager(); + ~TileManager(); - void load(); Tile* get(int i); }; @@ -102,6 +104,7 @@ void stop(); public: Tux(WorldMap* worldmap_); + ~Tux(); void draw(const Point& offset); void update(float delta); @@ -133,6 +136,8 @@ int width; int height; + TileManager* tile_manager; + public: struct Level { Index: configfile.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/configfile.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- configfile.cpp 21 Apr 2004 17:45:17 -0000 1.3 +++ configfile.cpp 25 Apr 2004 21:55:39 -0000 1.4 @@ -104,6 +104,8 @@ reader.read_int ("keyboard-left", &keymap.left); reader.read_int ("keyboard-right", &keymap.right); reader.read_int ("keyboard-fire", &keymap.fire); + + lisp_free(root_obj); } void saveconfig (void) Index: texture.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/texture.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- texture.cpp 20 Apr 2004 11:09:34 -0000 1.14 +++ texture.cpp 25 Apr 2004 21:55:39 -0000 1.15 @@ -29,7 +29,7 @@ Surface::Surfaces Surface::surfaces; SurfaceData::SurfaceData(SDL_Surface* temp, int use_alpha_) - : type(SURFACE), use_alpha(use_alpha_) + : type(SURFACE), surface(0), use_alpha(use_alpha_) { // Copy the given surface and make sure that it is not stored in // video memory @@ -40,24 +40,26 @@ temp->format->Gmask, temp->format->Bmask, temp->format->Amask); + if(!surface) + st_abort("No memory left.", ""); SDL_SetAlpha(temp,0,0); SDL_BlitSurface(temp, NULL, surface, NULL); } SurfaceData::SurfaceData(const std::string& file_, int use_alpha_) - : type(LOAD), file(file_), use_alpha(use_alpha_) + : type(LOAD), surface(0), file(file_), use_alpha(use_alpha_) { } SurfaceData::SurfaceData(const std::string& file_, int x_, int y_, int w_, int h_, int use_alpha_) - : type(LOAD_PART), file(file_), use_alpha(use_alpha_), + : type(LOAD_PART), surface(0), file(file_), use_alpha(use_alpha_), x(x_), y(y_), w(w_), h(h_) { } SurfaceData::~SurfaceData() { - + SDL_FreeSurface(surface); } SurfaceImpl* @@ -321,6 +323,22 @@ return sdl_surface; } +//--------------------------------------------------------------------------- + +SurfaceImpl::SurfaceImpl() +{ +} + +SurfaceImpl::~SurfaceImpl() +{ + SDL_FreeSurface(sdl_surface); +} + +SDL_Surface* SurfaceImpl::get_sdl_surface() const +{ + return sdl_surface; +} + #ifndef NOOPENGL SurfaceOpenGL::SurfaceOpenGL(SDL_Surface* surf, int use_alpha) { @@ -351,7 +369,6 @@ SurfaceOpenGL::~SurfaceOpenGL() { - SDL_FreeSurface(sdl_surface); glDeleteTextures(1, &gl_texture); } @@ -367,7 +384,7 @@ h = power_of_two(surf->h), #if SDL_BYTEORDER == SDL_BIG_ENDIAN - conv = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, surf->format->BitsPerPixel, + conv = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, surf->format->BitsPerPixel, 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff); #else conv = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, surf->format->BitsPerPixel, @@ -432,10 +449,8 @@ glDisable(GL_TEXTURE_2D); glDisable(GL_BLEND); - /* Avoid compiler warnings */ - if(update) - {} - + (void) update; // avoid compiler warning + return 0; } @@ -463,9 +478,7 @@ glDisable(GL_TEXTURE_2D); - /* Avoid compiler warnings */ - if(update) - {} + (void) update; // avoid compiler warning return 0; } @@ -599,7 +612,6 @@ SurfaceSDL::~SurfaceSDL() { - SDL_FreeSurface(sdl_surface); } /* EOF */ Index: title.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/title.cpp,v retrieving revision 1.60 retrieving revision 1.61 diff -u -d -r1.60 -r1.61 --- title.cpp 25 Apr 2004 15:21:06 -0000 1.60 +++ title.cpp 25 Apr 2004 21:55:39 -0000 1.61 @@ -79,7 +79,8 @@ { st_subset subset; subset.load(level_subsets.item[i]); - contrib_menu->additem(MN_GOTO, subset.title.c_str(), i, contrib_subset_menu); + contrib_menu->additem(MN_GOTO, subset.title.c_str(), i, + contrib_subset_menu, i+1); contrib_subsets.push_back(subset); } @@ -96,7 +97,7 @@ int index = contrib_menu->check(); if (index != -1) { - index -= 2; // FIXME: Hack + index -= 1; if (index >= 0 && index <= int(contrib_subsets.size())) { if (current_subset != index) @@ -117,7 +118,7 @@ { Level level; level.load(subset.name, i); - contrib_subset_menu->additem(MN_ACTION, level.name, 0, 0); + contrib_subset_menu->additem(MN_ACTION, level.name, 0, 0, i); } contrib_subset_menu->additem(MN_HL,"",0,0); contrib_subset_menu->additem(MN_BACK, "Back", 0, 0); @@ -135,9 +136,8 @@ int index = contrib_subset_menu->check(); if (index != -1) { - if (contrib_subset_menu->get_item(index).kind == MN_ACTION) + if (contrib_subset_menu->get_item_by_id(index).kind == MN_ACTION) { - index -= 1; // FIXME: Hack std::cout << "Sarting level: " << index << std::endl; GameSession session(current_contrib_subset, index, ST_GL_PLAY); session.run(); @@ -453,7 +453,9 @@ draw_background(); - white_big_text->drawf("- Credits -", 0, screen->h-scroll, A_HMIDDLE, A_TOP, 2); + if (strcmp(file, "CREDITS") == 0) + white_big_text->drawf("- SuperTux " VERSION " -", + 0, screen->h-scroll, A_HMIDDLE, A_TOP, 2); y = 0; for(int i = 0; i < length; i++) Index: high_scores.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/high_scores.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- high_scores.cpp 20 Apr 2004 11:09:33 -0000 1.16 +++ high_scores.cpp 25 Apr 2004 21:55:39 -0000 1.17 @@ -74,9 +74,7 @@ } fclose(fi); - -printf("name=%s\n", hs_name.c_str()); -printf("score=%i\n\n", hs_score); + lisp_free(root_obj); } void save_hs(int score) Index: tile.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/tile.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- tile.cpp 20 Apr 2004 11:09:34 -0000 1.13 +++ tile.cpp 25 Apr 2004 21:55:39 -0000 1.14 @@ -25,6 +25,24 @@ TileManager* TileManager::instance_ = 0; std::vector<TileGroup>* TileManager::tilegroups_ = 0; +Tile::Tile() +{ +} + +Tile::~Tile() +{ + for(std::vector<Surface*>::iterator i = images.begin(); i != images.end(); + ++i) { + delete *i; + } + for(std::vector<Surface*>::iterator i = editor_images.begin(); + i != editor_images.end(); ++i) { + delete *i; + } +} + +//--------------------------------------------------------------------------- + TileManager::TileManager() { std::string filename = datadir + "images/tilesets/supertux.stgt"; @@ -33,6 +51,12 @@ void TileManager::load_tileset(std::string filename) { + // free old tiles + for(std::vector<Tile*>::iterator i = tiles.begin(); i != tiles.end(); ++i) { + delete *i; + } + tiles.clear(); + lisp_object_t* root_obj = lisp_read_from_file(filename); if (!root_obj) @@ -142,6 +166,8 @@ { assert(0); } + + lisp_free(root_obj); } void Index: texture.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/texture.h,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- texture.h 20 Apr 2004 11:09:34 -0000 1.17 +++ texture.h 25 Apr 2004 21:55:39 -0000 1.18 @@ -90,23 +90,28 @@ this class */ class SurfaceImpl { -public: +protected: SDL_Surface* sdl_surface; + +public: int w; int h; public: + SurfaceImpl(); + virtual ~SurfaceImpl(); + /** Return 0 on success, -2 if surface needs to be reloaded */ virtual int draw(float x, float y, Uint8 alpha, bool update) = 0; virtual int draw_bg(Uint8 alpha, bool update) = 0; virtual int draw_part(float sx, float sy, float x, float y, float w, float h, Uint8 alpha, bool update) = 0; + + SDL_Surface* get_sdl_surface() const; // @evil@ try to avoid this function }; class SurfaceSDL : public SurfaceImpl { public: - -public: SurfaceSDL(SDL_Surface* surf, int use_alpha); SurfaceSDL(const std::string& file, int use_alpha); SurfaceSDL(const std::string& file, int x, int y, int w, int h, int use_alpha); Index: menu.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/menu.h,v retrieving revision 1.49 retrieving revision 1.50 diff -u -d -r1.49 -r1.50 --- menu.h 24 Apr 2004 17:48:49 -0000 1.49 +++ menu.h 25 Apr 2004 21:55:39 -0000 1.50 @@ -138,8 +138,6 @@ // position of the menu (ie. center of the menu, not top/left) int pos_x; int pos_y; - bool has_backitem; - int last_id; /** input event for the menu (up, down, left, right, etc.) */ MenuAction menuaction; |