From 802650bbc185181e63ee1abae31a521e744079c5 Mon Sep 17 00:00:00 2001 From: Tobias Markus Date: Mon, 27 Jan 2014 15:53:36 +0100 Subject: [PATCH] Resetting to previous powerups and coin count when aborting level to prevent powerup farming --- src/supertux/game_session.cpp | 13 +++++++++++-- src/supertux/game_session.hpp | 6 ++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/supertux/game_session.cpp b/src/supertux/game_session.cpp index c338d1680..b33d2cc38 100644 --- a/src/supertux/game_session.cpp +++ b/src/supertux/game_session.cpp @@ -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; } } } diff --git a/src/supertux/game_session.hpp b/src/supertux/game_session.hpp index 17370bc16..33cdd2d5e 100644 --- a/src/supertux/game_session.hpp +++ b/src/supertux/game_session.hpp @@ -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&); -- 2.11.0