Author: anonymissimus
Date: Mon Oct 24 00:57:52 2011
New Revision: 51603

URL: http://svn.gna.org/viewcvs/wesnoth?rev=51603&view=rev
Log:
limit number of executions of [endlevel] to 1 times per scenario (fix for bug 
#18828)

A scenario can only be ended once. Also prevents sort-of recursion
if it appears in a victory or defeat event.

Modified:
    trunk/src/game_end_exceptions.hpp
    trunk/src/game_events.cpp
    trunk/src/playsingle_controller.cpp

Modified: trunk/src/game_end_exceptions.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_end_exceptions.hpp?rev=51603&r1=51602&r2=51603&view=diff
==============================================================================
--- trunk/src/game_end_exceptions.hpp (original)
+++ trunk/src/game_end_exceptions.hpp Mon Oct 24 00:57:52 2011
@@ -96,6 +96,7 @@
                , carryover_add(false)
                , custom_endlevel_music()
                , reveal_map(true)
+               , disabled(false)
        {}
 
        bool carryover_report;             /**< Should a summary of the 
scenario outcome be displayed? */
@@ -107,6 +108,7 @@
        bool carryover_add;                /**< Add or replace next scenario's 
minimum starting gold. */
        std::string custom_endlevel_music; /**< Custom short music played at 
the end. */
        bool reveal_map;                   /**< Should we reveal map when game 
is ended? (Multiplayer only) */
+       bool disabled;                     /**< Limits execution of tag 
[endlevel] to a single time > */
 
        void write(config& cfg) const {
                cfg["prescenario_save"] = prescenario_save;

Modified: trunk/src/game_events.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_events.cpp?rev=51603&r1=51602&r2=51603&view=diff
==============================================================================
--- trunk/src/game_events.cpp (original)
+++ trunk/src/game_events.cpp Mon Oct 24 00:57:52 2011
@@ -2298,6 +2298,13 @@
 
 WML_HANDLER_FUNCTION(endlevel, /*event_info*/, cfg)
 {
+       end_level_data &data = resources::controller->get_end_level_data();
+       if(data.disabled) {
+               WRN_NG << "repeated [endlevel] execution, ignoring\n";
+               return;
+       }
+       data.disabled = true;
+
        game_state *state_of_game = resources::state_of_game;
        unit_map *units = resources::units;
 
@@ -2330,7 +2337,6 @@
                        
end_of_campaign_text_delay.to_int(state_of_game->classification().end_text_duration);
        }
 
-       end_level_data &data = resources::controller->get_end_level_data();
 
        std::string result = cfg["result"];
        VALIDATE_WITH_DEV_MESSAGE(

Modified: trunk/src/playsingle_controller.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/playsingle_controller.cpp?rev=51603&r1=51602&r2=51603&view=diff
==============================================================================
--- trunk/src/playsingle_controller.cpp (original)
+++ trunk/src/playsingle_controller.cpp Mon Oct 24 00:57:52 2011
@@ -378,6 +378,7 @@
                        //determine the bonus gold handling for this scenario
                        end_level.read(level_.child_or_empty("endlevel"));
                        end_level.carryover_report = false;
+                       end_level.disabled = true;
                        throw end_level_exception(SKIP_TO_LINGER);
                }
 


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to