[Super-tux-commit] supertux/src badguy.cpp,1.56,1.57 badguy.h,1.35,1.36 level.cpp,1.55,1.56 level.h,
Brought to you by:
wkendrick
From: Ingo R. <gr...@us...> - 2004-04-28 18:45:37
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15303/src Modified Files: badguy.cpp badguy.h level.cpp level.h leveleditor.cpp title.cpp Log Message: <MatzeB> my patch fixes another leak in the levelsubset code and cleans that up a little bit <MatzeB> it also removes the code for the bsod badguy, since that was a duplication of the snowball code anyway Index: level.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/level.h,v retrieving revision 1.38 retrieving revision 1.39 diff -u -d -r1.38 -r1.39 --- level.h 26 Apr 2004 19:11:54 -0000 1.38 +++ level.h 28 Apr 2004 18:45:24 -0000 1.39 @@ -31,14 +31,15 @@ /** This type holds meta-information about a level-subset. It could be extended to handle manipulation of subsets. */ -class st_subset +class LevelSubset { public: - st_subset(); + LevelSubset(); + ~LevelSubset(); + static void create(const std::string& subset_name); void load(char *subset); void save(); - void free(); std::string name; std::string title; Index: badguy.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy.h,v retrieving revision 1.35 retrieving revision 1.36 diff -u -d -r1.35 -r1.36 --- badguy.h 28 Apr 2004 14:09:26 -0000 1.35 +++ badguy.h 28 Apr 2004 18:45:24 -0000 1.36 @@ -35,7 +35,6 @@ /* Bad guy kinds: */ enum BadGuyKind { - BAD_BSOD, BAD_MRICEBLOCK, BAD_JUMPY, BAD_MRBOMB, @@ -65,7 +64,7 @@ : kind(kind_), x(x_), y(y_), stay_on_platform(stay_on_platform_) {} BadGuyData() - : kind(BAD_BSOD), x(0), y(0), stay_on_platform(false) {} + : kind(BAD_SNOWBALL), x(0), y(0), stay_on_platform(false) {} }; class Player; @@ -142,7 +141,6 @@ bool is_removable() const { return removable; } private: - void action_bsod(float frame_ratio); void action_mriceblock(float frame_ratio); void action_jumpy(float frame_ratio); void action_bomb(float frame_ratio); Index: badguy.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy.cpp,v retrieving revision 1.56 retrieving revision 1.57 diff -u -d -r1.56 -r1.57 --- badguy.cpp 28 Apr 2004 14:09:26 -0000 1.56 +++ badguy.cpp 28 Apr 2004 18:45:24 -0000 1.57 @@ -33,16 +33,10 @@ #include "resources.h" #include "sprite_manager.h" -Sprite* img_bsod_squished_left; -Sprite* img_bsod_squished_right; -Sprite* img_bsod_falling_left; -Sprite* img_bsod_falling_right; Sprite* img_mriceblock_flat_left; Sprite* img_mriceblock_flat_right; Sprite* img_mriceblock_falling_left; Sprite* img_mriceblock_falling_right; -Sprite* img_bsod_left; -Sprite* img_bsod_right; Sprite* img_mriceblock_left; Sprite* img_mriceblock_right; Sprite* img_jumpy_left_up; @@ -78,8 +72,6 @@ return BAD_JUMPY; else if (str == "laptop" || str == "mriceblock") // was laptop in old maps return BAD_MRICEBLOCK; - else if (str == "bsod") - return BAD_BSOD; else if (str == "mrbomb") return BAD_MRBOMB; else if (str == "stalactite") @@ -94,12 +86,12 @@ return BAD_FLYINGSNOWBALL; else if (str == "spiky") return BAD_SPIKY; - else if (str == "snowball") + else if (str == "snowball" || str == "bsod") // was bsod in old maps return BAD_SNOWBALL; else { printf("Couldn't convert badguy: '%s'\n", str.c_str()); - return BAD_BSOD; + return BAD_SNOWBALL; } } @@ -113,9 +105,6 @@ case BAD_MRICEBLOCK: return "mriceblock"; break; - case BAD_BSOD: - return "bsod"; - break; case BAD_MRBOMB: return "mrbomb"; break; @@ -141,7 +130,7 @@ return "snowball"; break; default: - return "bsod"; + return "snowball"; } } @@ -167,10 +156,7 @@ physic.reset(); timer.init(true); - if(kind == BAD_BSOD) { - physic.set_velocity(-BADGUY_WALK_SPEED, 0); - set_sprite(img_bsod_left, img_bsod_right); - } else if(kind == BAD_MRBOMB) { + if(kind == BAD_MRBOMB) { physic.set_velocity(-BADGUY_WALK_SPEED, 0); set_sprite(img_mrbomb_left, img_mrbomb_right); } else if (kind == BAD_MRICEBLOCK) { @@ -215,38 +201,6 @@ } void -BadGuy::action_bsod(float frame_ratio) -{ - static const float BSODJUMP = 2; - - if (dying == DYING_NOT) - check_horizontal_bump(); - - fall(); - - // jump when we're about to fall - if (physic.get_velocity_y() == 0 && - !issolid(base.x+base.width/2, base.y + base.height)) - { - physic.enable_gravity(true); - physic.set_velocity(physic.get_velocity_x(), BSODJUMP); - } - - // Handle dying timer: - if (dying == DYING_SQUISHED && !timer.check()) - { - /* Remove it if time's up: */ - remove_me(); - return; - } - - // move - physic.apply(frame_ratio, base.x, base.y); - if(dying != DYING_FALLING) - collision_swept_object_map(&old_base, &base); -} - -void BadGuy::action_mriceblock(float frame_ratio) { Player& tux = *World::current()->get_tux(); @@ -721,10 +675,6 @@ switch (kind) { - case BAD_BSOD: - action_bsod(frame_ratio); - break; - case BAD_MRICEBLOCK: action_mriceblock(frame_ratio); break; @@ -872,12 +822,6 @@ remove_me(); return; - } else if(kind == BAD_BSOD) { - squish_me(player); - set_sprite(img_bsod_squished_left, img_bsod_squished_right); - physic.set_velocity_x(0); - return; - } else if (kind == BAD_MRICEBLOCK) { if (mode == NORMAL || mode == KICK) { @@ -958,20 +902,14 @@ Player& tux = *World::current()->get_tux(); tux.holding_something = false; } - } else if(kind == BAD_BSOD) { - set_sprite(img_bsod_falling_left, img_bsod_falling_right); } physic.enable_gravity(true); physic.set_velocity_y(0); /* Gain some points: */ -// if (kind == BAD_BSOD) World::current()->add_score(base.x - scroll_x, base.y, score * player_status.score_multiplier); -/* else - World::current()->add_score(base.x - scroll_x, base.y, - 25 * player_status.score_multiplier);*/ /* Play death sound: */ play_sound(sounds[SND_FALL], SOUND_CENTER_SPEAKER); @@ -1109,16 +1047,10 @@ void load_badguy_gfx() { - img_bsod_squished_left = sprite_manager->load("bsod-squished-left"); - img_bsod_squished_right = sprite_manager->load("bsod-squished-right"); - img_bsod_falling_left = sprite_manager->load("bsod-falling-left"); - img_bsod_falling_right = sprite_manager->load("bsod-falling-right"); img_mriceblock_flat_left = sprite_manager->load("mriceblock-flat-left"); img_mriceblock_flat_right = sprite_manager->load("mriceblock-flat-right"); img_mriceblock_falling_left = sprite_manager->load("mriceblock-falling-left"); img_mriceblock_falling_right = sprite_manager->load("mriceblock-falling-right"); - img_bsod_left = sprite_manager->load("bsod-left"); - img_bsod_right = sprite_manager->load("bsod-right"); img_mriceblock_left = sprite_manager->load("mriceblock-left"); img_mriceblock_right = sprite_manager->load("mriceblock-right"); img_jumpy_left_up = sprite_manager->load("jumpy-left-up"); Index: title.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/title.cpp,v retrieving revision 1.66 retrieving revision 1.67 diff -u -d -r1.66 -r1.67 --- title.cpp 28 Apr 2004 14:58:24 -0000 1.66 +++ title.cpp 28 Apr 2004 18:45:26 -0000 1.67 @@ -62,22 +62,33 @@ static unsigned int last_update_time; static unsigned int update_time; -std::vector<st_subset> contrib_subsets; +std::vector<LevelSubset*> contrib_subsets; std::string current_contrib_subset; +void free_contrib_menu() +{ + for(std::vector<LevelSubset*>::iterator i = contrib_subsets.begin(); + i != contrib_subsets.end(); ++i) + delete *i; + + contrib_subsets.clear(); + contrib_menu->clear(); +} + void generate_contrib_menu() { string_list_type level_subsets = dsubdirs("/levels", "info"); - contrib_menu->clear(); + free_contrib_menu(); + contrib_menu->additem(MN_LABEL,"Contrib Levels",0,0); contrib_menu->additem(MN_HL,"",0,0); for (int i = 0; i < level_subsets.num_items; ++i) { - st_subset subset; - subset.load(level_subsets.item[i]); - contrib_menu->additem(MN_GOTO, subset.title.c_str(), i, + LevelSubset* subset = new LevelSubset(); + subset->load(level_subsets.item[i]); + contrib_menu->additem(MN_GOTO, subset->title.c_str(), i, contrib_subset_menu, i+1); contrib_subsets.push_back(subset); } @@ -102,7 +113,7 @@ { current_subset = index; // FIXME: This shouln't be busy looping - st_subset& subset = contrib_subsets[index]; + LevelSubset& subset = * (contrib_subsets[index]); current_contrib_subset = subset.name; @@ -222,7 +233,6 @@ /* --- TITLE SCREEN --- */ void title(void) { - st_subset subset; random_timer.init(true); walking = true; @@ -360,6 +370,7 @@ } /* Free surfaces: */ + free_contrib_menu(); delete bkg_title; delete logo; delete img_choose_subset; Index: leveleditor.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/leveleditor.cpp,v retrieving revision 1.67 retrieving revision 1.68 diff -u -d -r1.67 -r1.68 --- leveleditor.cpp 27 Apr 2004 17:09:35 -0000 1.67 +++ leveleditor.cpp 28 Apr 2004 18:45:24 -0000 1.68 @@ -113,7 +113,7 @@ static int pos_x, cursor_x, cursor_y, fire; static int le_level; static LevelEditorWorld le_world; -static st_subset le_level_subset; +static LevelSubset le_level_subset; static int le_show_grid; static int le_frame; static Surface* le_selection; @@ -303,7 +303,7 @@ switch (i = subset_new_menu->check()) { case 3: - st_subset::create(subset_new_menu->item[2].input); + LevelSubset::create(subset_new_menu->item[2].input); le_level_subset.load(subset_new_menu->item[2].input); leveleditor_menu->item[3].kind = MN_GOTO; le_level = 1; @@ -1158,7 +1158,7 @@ le_world.bad_guys.erase(le_world.bad_guys.begin() + i); if(c == '0') /* if it's a bad guy */ - le_world.add_bad_guy(xx*32, yy*32, BAD_BSOD); + le_world.add_bad_guy(xx*32, yy*32, BAD_SNOWBALL); else if(c == '1') le_world.add_bad_guy(xx*32, yy*32, BAD_MRICEBLOCK); else if(c == '2') @@ -1204,7 +1204,7 @@ le_current_level->change(xx*32, yy*32, tm, c); if(c == '0') // if it's a bad guy - le_world.add_bad_guy(xx*32, yy*32, BAD_BSOD); + le_world.add_bad_guy(xx*32, yy*32, BAD_SNOWBALL); else if(c == '1') le_world.add_bad_guy(xx*32, yy*32, BAD_MRICEBLOCK); else if(c == '2') Index: level.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/level.cpp,v retrieving revision 1.55 retrieving revision 1.56 diff -u -d -r1.55 -r1.56 --- level.cpp 27 Apr 2004 15:15:17 -0000 1.55 +++ level.cpp 28 Apr 2004 18:45:24 -0000 1.56 @@ -36,15 +36,20 @@ using namespace std; -st_subset::st_subset() +LevelSubset::LevelSubset() + : image(0), levels(0) { - levels = 0; } -void st_subset::create(const std::string& subset_name) +LevelSubset::~LevelSubset() +{ + delete image; +} + +void LevelSubset::create(const std::string& subset_name) { Level new_lev; - st_subset new_subset; + LevelSubset new_subset; new_subset.name = subset_name; new_subset.title = "Unknown Title"; new_subset.description = "No description so far."; @@ -53,7 +58,7 @@ new_lev.save(subset_name.c_str(),1); } -void st_subset::parse (lisp_object_t* cursor) +void LevelSubset::parse (lisp_object_t* cursor) { while(!lisp_nil_p(cursor)) { @@ -85,7 +90,7 @@ } } -void st_subset::load(char *subset) +void LevelSubset::load(char *subset) { FILE* fi; char filename[1024]; @@ -156,7 +161,7 @@ levels = --i; } -void st_subset::save() +void LevelSubset::save() { FILE* fi; string filename; @@ -192,15 +197,6 @@ } } -void st_subset::free() -{ - title.clear(); - description.clear(); - name.clear(); - delete image; - levels = 0; -} - Level::Level() : img_bkgd(0) { |