max level advancements now raise the advance and post_advance WML events

This commit is contained in:
Patrick Parker 2007-02-03 02:52:27 +00:00
parent d7ff1e8c8e
commit b82dbbcd2b
2 changed files with 17 additions and 7 deletions

View file

@ -206,6 +206,7 @@ Version 1.3-svn:
* the encountered terrains are now written in a new format.
this means the user has to rediscover all available terrains.
* fixed a bug which returned wrong values if a random number was negative
* max level advancements now raise the advance and post_advance events
* sound
* new or revised sounds: morning star, holy magic.
* add advanced sound tab to pref allowing you to play with sample_rate and

View file

@ -18,6 +18,7 @@
#include "filesystem.hpp"
#include "game_config.hpp"
#include "game_errors.hpp"
#include "game_events.hpp"
#include "gettext.hpp"
#include "help.hpp"
#include "language.hpp"
@ -44,6 +45,7 @@
#include <time.h>
#include <vector>
#define LOG_NG LOG_STREAM(info, engine)
#define LOG_DP LOG_STREAM(info, display)
#define ERR_G LOG_STREAM(err, general)
@ -152,19 +154,26 @@ bool animate_unit_advancement(const game_data& info,unit_map& units, gamemap::lo
}
if(choice < options.size()) {
const std::string& chosen_unit = choice < options.size() ? options[choice] : u->second.id();
const std::string& chosen_unit = options[choice];
::advance_unit(info,units,loc,chosen_unit);
} else {
unit amla_unit(u->second);
LOG_NG << "firing advance event (AMLA)\n";
game_events::fire("advance",loc);
amla_unit.get_experience(-amla_unit.max_experience()); //subtract xp required
amla_unit.add_modification("advance",*mod_options[choice - options.size()]);
units.replace(new std::pair<gamemap::location,unit>(loc,amla_unit));
LOG_NG << "firing post_advance event (AMLA)\n";
game_events::fire("post_advance",loc);
}
u = units.find(loc);
if(u != units.end() && choice >= options.size()) {
u->second.get_experience(-u->second.max_experience()); //subtract xp required
u->second.add_modification("advance",*mod_options[choice - options.size()]);
}
gui.invalidate_unit();
if(!gui.update_locked()) {
if(u != units.end() && !gui.update_locked()) {
u->second.set_leveling_in(gui,u->first);
while(!u->second.get_animation()->animation_would_finish()) {
gui.invalidate(loc);