Resetting to previous powerups and coin count when aborting level to prevent powerup...
authorTobias Markus <tobbi@mozilla-uk.org>
Mon, 27 Jan 2014 14:53:36 +0000 (15:53 +0100)
committerTobias Markus <tobbi@mozilla-uk.org>
Mon, 27 Jan 2014 15:07:40 +0000 (16:07 +0100)
src/supertux/game_session.cpp
src/supertux/game_session.hpp

index c338d16..b33d2cc 100644 (file)
@@ -34,6 +34,7 @@
 #include "supertux/gameconfig.hpp"
 #include "supertux/levelintro.hpp"
 #include "supertux/globals.hpp"
+#include "supertux/player_status.hpp"
 #include "supertux/screen_manager.hpp"
 #include "supertux/menu/menu_storage.hpp"
 #include "supertux/menu/game_menu.hpp"
@@ -85,6 +86,11 @@ GameSession::GameSession(const std::string& levelfile_, PlayerStatus* player_sta
 int
 GameSession::restart_level()
 {
+    PlayerStatus* currentStatus = get_player_status();
+    coins_at_start = currentStatus->coins;
+    bonus_at_start = currentStatus->bonus;
+    max_fire_bullets_at_start = currentStatus->max_fire_bullets;
+    max_ice_bullets_at_start = currentStatus->max_ice_bullets;
 
   if (edit_mode) {
     force_ghost_mode();
@@ -398,8 +404,11 @@ GameSession::process_menu()
         case MNID_ABORTLEVEL:
           MenuManager::set_current(0);
           g_screen_manager->exit_screen();
-          // TODO: revert coins and powerups to previous
-          // values so as to discourage powerup "farming"
+          currentsector->player->set_bonus(bonus_at_start);
+          PlayerStatus *currentStatus = get_player_status();
+          currentStatus->coins = coins_at_start;
+          currentStatus->max_fire_bullets = max_fire_bullets_at_start;
+          currentStatus->max_ice_bullets = max_ice_bullets_at_start;
       }
     }
   }
index 17370bc..33cdd2d 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "object/endsequence.hpp"
 #include "supertux/screen.hpp"
+#include "supertux/player_status.hpp"
 #include "util/currenton.hpp"
 #include "video/surface.hpp"
 
@@ -146,6 +147,11 @@ private:
 
   bool edit_mode; /**< true if GameSession runs in level editor mode */
   bool levelintro_shown; /**< true if the LevelIntro screen was already shown */
+    
+  int coins_at_start; /** How many coins does the player have at the start */
+  BonusType bonus_at_start; /** What bonuses does the player have at the start */
+  int max_fire_bullets_at_start; /** How many fire bullets does the player have */
+  int max_ice_bullets_at_start; /** How many ice bullets does the player have */
 
 private:
   GameSession(const GameSession&);