mail[Wesnoth-commits] r28335 - /trunk/src/playsingle_controller.cpp


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by shadowm2006 on August 05, 2008 - 23:59:
Author: shadowmaster
Date: Tue Aug  5 23:59:10 2008
New Revision: 28335

URL: http://svn.gna.org/viewcvs/wesnoth?rev=28335&view=rev
Log:
* Made victory music not play on 'continue' endlevel result.
* Victory music will no longer play on replay/observation, either.
* Victory music will play after the commands of the 'victory' WML event 
handler are finished.
* Added some const qualifiers around.
* Output an error message if [endlevel] is used in the 'defeat' WML event 
handler.

Modified:
    trunk/src/playsingle_controller.cpp

Modified: trunk/src/playsingle_controller.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/playsingle_controller.cpp?rev=28335&r1=28334&r2=28335&view=diff
==============================================================================
--- trunk/src/playsingle_controller.cpp (original)
+++ trunk/src/playsingle_controller.cpp Tue Aug  5 23:59:10 2008
@@ -314,7 +314,7 @@
                        }
                }
        
-               bool obs = team_manager_.is_observer();
+               const bool obs = team_manager_.is_observer();
                if (game_config::exit_at_end) {
                        exit(0);
                }
@@ -346,6 +346,7 @@
                        try {
                                game_events::fire("defeat");
                        } catch(end_level_exception&) {
+                               ERR_NG << "[endlevel] used in 'defeat' event 
handler\n";
                        }
 
                        if (!obs) {
@@ -360,19 +361,27 @@
                } else if (end_level.result == VICTORY
                || end_level.result == LEVEL_CONTINUE
                || end_level.result == LEVEL_CONTINUE_NO_SAVE) {
-                       if(end_level.result == LEVEL_CONTINUE_NO_SAVE) {
-                               gamestate_.completion = "running";
-                       } else {
-                               gamestate_.completion = "victory";
-                               const std::string& victory_music = 
select_victory_music();
-                               if(victory_music.empty() != true)
-                                       sound::play_music_once(victory_music);
-                       }
+                       gamestate_.completion = (end_level.result == 
LEVEL_CONTINUE_NO_SAVE ?
+                                                "running" : "victory");
                        
recorder.set_save_info_completion(gamestate_.completion);
                        try {
                                game_events::fire("victory");
                        } catch(end_level_exception&) {
-                               ERR_NG << "[endlevel] used in victory even 
handler\n";
+                               ERR_NG << "[endlevel] used in 'victory' event 
handler\n";
+                       }
+                       //
+                       // Play victory music once all victory events
+                       // are finished, if we aren't observers.
+                       //
+                       // Some scenario authors may use 'continue'
+                       // result for something that is not story-wise
+                       // a victory, so let them use [music] tags
+                       // instead should they want special music.
+                       //
+                       if(end_level.result == VICTORY && !obs) {
+                               const std::string& victory_music = 
select_victory_music();
+                               if(victory_music.empty() != true)
+                                       sound::play_music_once(victory_music);
                        }
                        if (first_human_team_ != -1)
                                log.victory(status_.turn(), 
teams_[first_human_team_].gold());




Related Messages


Powered by MHonArc, Updated Wed Aug 06 00:01:27 2008