[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Wesnoth-cvs-commits] wesnoth/src game_events.cpp
From: |
David White |
Subject: |
[Wesnoth-cvs-commits] wesnoth/src game_events.cpp |
Date: |
Mon, 29 Nov 2004 20:03:01 -0500 |
CVSROOT: /cvsroot/wesnoth
Module name: wesnoth
Branch:
Changes by: David White <address@hidden> 04/11/30 00:54:46
Modified files:
src : game_events.cpp
Log message:
added 'allow_undo' command which allows a scenario designer to specify
that players may undo moves that trigger events
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/game_events.cpp.diff?tr1=1.113&tr2=1.114&r1=text&r2=text
Patches:
Index: wesnoth/src/game_events.cpp
diff -u wesnoth/src/game_events.cpp:1.113 wesnoth/src/game_events.cpp:1.114
--- wesnoth/src/game_events.cpp:1.113 Thu Nov 18 22:00:12 2004
+++ wesnoth/src/game_events.cpp Tue Nov 30 00:54:46 2004
@@ -1,4 +1,4 @@
-/* $Id: game_events.cpp,v 1.113 2004/11/18 22:00:12 ydirson Exp $ */
+/* $Id: game_events.cpp,v 1.114 2004/11/30 00:54:46 Sirp Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -187,10 +187,10 @@
return cfg_->get_children("filter_second");
}
- void handle_event(const queued_event& event_info, const config*
cfg=NULL);
+ bool handle_event(const queued_event& event_info, const config*
cfg=NULL);
private:
- bool handle_event_command(const queued_event& event_info, const
std::string& cmd, const config& cfg);
+ bool handle_event_command(const queued_event& event_info, const
std::string& cmd, const config& cfg, bool& mutated);
std::string name_;
bool first_time_only_;
@@ -207,7 +207,7 @@
//this function handles all the different types of actions that can be
triggered
//by an event.
-bool event_handler::handle_event_command(const queued_event& event_info, const
std::string& cmd, const config& cfg)
+bool event_handler::handle_event_command(const queued_event& event_info, const
std::string& cmd, const config& cfg, bool& mutated)
{
log_scope2(engine, "handle_event_command");
LOG_NG << "handling command: '" << cmd << "'\n";
@@ -217,7 +217,11 @@
if(cmd == "command") {
handle_event(event_info,&cfg);
}
-
+
+ //allow undo sets the flag saying whether the event has mutated the
game to false
+ else if(cmd == "allow_undo") {
+ mutated = false;
+ }
//change shroud settings for portions of the map
else if(cmd == "remove_shroud" || cmd == "place_shroud") {
const bool remove = cmd == "remove_shroud";
@@ -1242,10 +1246,12 @@
return rval;
}
-void event_handler::handle_event(const queued_event& event_info, const config*
cfg)
+bool event_handler::handle_event(const queued_event& event_info, const config*
cfg)
{
if(cfg == NULL)
- cfg = cfg_;
+ cfg = cfg_;
+
+ bool mutated = true;
bool skip_messages = false;
for(config::all_children_iterator i = cfg->ordered_begin();
@@ -1260,13 +1266,15 @@
}
}
- if (!handle_event_command(event_info,*item.first,*item.second))
{
+ if
(!handle_event_command(event_info,*item.first,*item.second,mutated)) {
skip_messages = true;
}
else {
skip_messages = false;
}
- }
+ }
+
+ return mutated;
}
bool filter_loc_impl(const gamemap::location& loc, const std::string& xloc,
@@ -1362,13 +1370,13 @@
}
//the event hasn't been filtered out, so execute the handler
- handler.handle_event(ev);
+ const bool res = handler.handle_event(ev);
if(handler.first_time_only()) {
handler.disable();
}
- return true;
+ return res;
}
void get_variable_internal(const std::string& key, config& cfg,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Wesnoth-cvs-commits] wesnoth/src game_events.cpp,
David White <=