Author: ai0867
Date: Mon Nov 17 02:08:36 2008
New Revision: 30780
URL: http://svn.gna.org/viewcvs/wesnoth?rev=30780&view=rev
Log:
* [kill] fire_event=yes now also fires 'last breath'.
Modified:
trunk/changelog
trunk/src/game_events.cpp
Modified: trunk/changelog
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/changelog?rev=30780&r1=30779&r2=30780&view=diff
==============================================================================
--- trunk/changelog (original)
+++ trunk/changelog Mon Nov 17 02:08:36 2008
@@ -82,6 +82,7 @@
* Restore x1, y1, x2, and y2 after events fired from events.
* WML variable expansion can be used inside story [part] tags
(feature request #10398).
+ * When fire_event=yes, [kill] now also fires the 'last breath' event.
* Miscellaneous and bug fixes:
* fixed addon update version logic (patch #1110)
* Fixed a flaw which caused sound sources to be forgotten after saving
Modified: trunk/src/game_events.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_events.cpp?rev=30780&r1=30779&r2=30780&view=diff
==============================================================================
--- trunk/src/game_events.cpp (original)
+++ trunk/src/game_events.cpp Mon Nov 17 02:08:36 2008
@@ -2020,51 +2020,56 @@
for(loc.y = 0; loc.y < game_map->h(); ++loc.y) {
unit_map::iterator un = units->find(loc);
if(un != units->end() &&
game_events::unit_matches_filter(un,cfg)) {
+ bool fire_event = false;
+ game_events::entity_location
death_loc(un);
+
if(utils::string_bool(cfg["fire_event"])) {
+ // Prevent infinite recursion
of 'die' events
+ fire_event = true;
+ recursion_preventer_ptr
recursion_prevent;
+
+ if (event_info.loc1 ==
death_loc && (event_info.name == "die" || event_info.name == "last breath") &&
!handler.first_time_only())
+ {
+
recursion_prevent.reset(new recursion_preventer(death_loc));
+
+
if(recursion_prevent->too_many_recursions())
+ {
+ fire_event =
false;
+
+ ERR_NG <<
"tried to fire 'die' or 'last breath' event on primary_unit inside its own
'die' or 'last breath' event with 'first_time_only' set to false!\n";
+ }
+ }
+ }
+ if (fire_event) {
+ game_events::fire("last
breath", death_loc, death_loc);
+ }
if(utils::string_bool(cfg["animate"])) {
(screen)->scroll_to_tile(loc);
unit_display::unit_die(loc,
un->second);
}
-
if(utils::string_bool(cfg["fire_event"])) {
- game_events::entity_location
death_loc(un);
- // Prevent infinite recursion
of 'die' events
- bool fire_event = true;
- recursion_preventer_ptr
recursion_prevent;
-
- if (event_info.loc1 ==
death_loc && event_info.name == "die" && !handler.first_time_only())
- {
-
recursion_prevent.reset(new recursion_preventer(death_loc));
-
-
if(recursion_prevent->too_many_recursions())
- {
- fire_event =
false;
-
- ERR_NG <<
"tried to fire 'die' event on primary_unit inside its own 'die' event with
'first_time_only' set to false!\n";
- }
+ if (fire_event)
+ {
+ game_events::fire("die",
death_loc, death_loc);
+
+ char buf[50];
+
snprintf(buf,sizeof(buf),"%d",event_info.loc1.x+1);
+
state_of_game->set_variable("x1", buf);
+
+
snprintf(buf,sizeof(buf),"%d",event_info.loc1.y+1);
+
state_of_game->set_variable("y1", buf);
+
+
snprintf(buf,sizeof(buf),"%d",event_info.loc2.x+1);
+
state_of_game->set_variable("x2", buf);
+
+
snprintf(buf,sizeof(buf),"%d",event_info.loc2.y+1);
+
state_of_game->set_variable("y2", buf);
+
+ un = units->find(death_loc);
+ if(un != units->end() &&
death_loc.matches_unit(un->second)) {
+ units->erase(un);
+ unit_mutations++;
}
- if (fire_event)
- {
-
game_events::fire("die", death_loc, death_loc);
-
- char buf[50];
-
snprintf(buf,sizeof(buf),"%d",event_info.loc1.x+1);
-
state_of_game->set_variable("x1", buf);
-
-
snprintf(buf,sizeof(buf),"%d",event_info.loc1.y+1);
-
state_of_game->set_variable("y1", buf);
-
-
snprintf(buf,sizeof(buf),"%d",event_info.loc2.x+1);
-
state_of_game->set_variable("x2", buf);
-
-
snprintf(buf,sizeof(buf),"%d",event_info.loc2.y+1);
-
state_of_game->set_variable("y2", buf);
-
- un =
units->find(death_loc);
- if(un != units->end()
&& death_loc.matches_unit(un->second)) {
-
units->erase(un);
-
unit_mutations++;
- }
- }
- } else {
+ }
+ if (!
utils::string_bool(cfg["fire_event"])) {
units->erase(un);
unit_mutations++;
}
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits