mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-21 05:11:15 +00:00
Fixed spelling mistake in do_replay
Fixed end_level_exception preventing attack::attack from giving xp
This commit is contained in:
parent
828e97374c
commit
64a8543756
@ -752,9 +752,18 @@ void attack::fire_event(const std::string& n)
|
|||||||
std::pair<std::string,t_string> to_insert("weapon", d_weap);
|
std::pair<std::string,t_string> to_insert("weapon", d_weap);
|
||||||
tempcfg->values.insert(to_insert);
|
tempcfg->values.insert(to_insert);
|
||||||
}
|
}
|
||||||
game_events::fire(n,
|
try {
|
||||||
game_events::entity_location(a_),
|
game_events::fire(n,
|
||||||
game_events::entity_location(d_), dat);
|
game_events::entity_location(a_),
|
||||||
|
game_events::entity_location(d_), dat);
|
||||||
|
}
|
||||||
|
catch(end_level_exception &e)
|
||||||
|
{
|
||||||
|
if(delayed_exception == 0)
|
||||||
|
{
|
||||||
|
delayed_exception = new end_level_exception(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
a_ = units_.find(attacker_);
|
a_ = units_.find(attacker_);
|
||||||
d_ = units_.find(defender_);
|
d_ = units_.find(defender_);
|
||||||
return;
|
return;
|
||||||
@ -766,7 +775,16 @@ void attack::fire_event(const std::string& n)
|
|||||||
dat.add_child("second");
|
dat.add_child("second");
|
||||||
(*(dat.child("first")))["weapon"]=a_stats_->weapon->id();
|
(*(dat.child("first")))["weapon"]=a_stats_->weapon->id();
|
||||||
(*(dat.child("second")))["weapon"]=d_stats_->weapon != NULL ? d_stats_->weapon->id() : "none";
|
(*(dat.child("second")))["weapon"]=d_stats_->weapon != NULL ? d_stats_->weapon->id() : "none";
|
||||||
game_events::fire(n,attacker_,defender_,dat);
|
try {
|
||||||
|
game_events::fire(n,attacker_,defender_,dat);
|
||||||
|
}
|
||||||
|
catch(end_level_exception &e)
|
||||||
|
{
|
||||||
|
if(delayed_exception == 0)
|
||||||
|
{
|
||||||
|
delayed_exception = new end_level_exception(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
// The event could have killed either the attacker or
|
// The event could have killed either the attacker or
|
||||||
// defender, so we have to make sure they still exist
|
// defender, so we have to make sure they still exist
|
||||||
a_ = units_.find(attacker_);
|
a_ = units_.find(attacker_);
|
||||||
@ -807,6 +825,7 @@ void attack::refresh_bc()
|
|||||||
|
|
||||||
attack::~attack()
|
attack::~attack()
|
||||||
{
|
{
|
||||||
|
delete delayed_exception;
|
||||||
delete bc_;
|
delete bc_;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -849,7 +868,8 @@ attack::attack(game_display& gui, const gamemap& map,
|
|||||||
attackerxp_(0),
|
attackerxp_(0),
|
||||||
defenderxp_(0),
|
defenderxp_(0),
|
||||||
update_display_(update_display),
|
update_display_(update_display),
|
||||||
OOS_error_(false)
|
OOS_error_(false),
|
||||||
|
delayed_exception(0)
|
||||||
{
|
{
|
||||||
// Stop the user from issuing any commands while the units are fighting
|
// Stop the user from issuing any commands while the units are fighting
|
||||||
const events::command_disabler disable_commands;
|
const events::command_disabler disable_commands;
|
||||||
@ -1050,7 +1070,16 @@ attack::attack(game_display& gui, const gamemap& map,
|
|||||||
std::string undead_variation = d_->second.undead_variation();
|
std::string undead_variation = d_->second.undead_variation();
|
||||||
const int defender_side = d_->second.side();
|
const int defender_side = d_->second.side();
|
||||||
fire_event("attack_end");
|
fire_event("attack_end");
|
||||||
game_events::fire("last breath", death_loc, attacker_loc);
|
try {
|
||||||
|
game_events::fire("last breath", death_loc, attacker_loc);
|
||||||
|
}
|
||||||
|
catch(end_level_exception &e)
|
||||||
|
{
|
||||||
|
if(delayed_exception == 0)
|
||||||
|
{
|
||||||
|
delayed_exception = new end_level_exception(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
d_ = units_.find(death_loc);
|
d_ = units_.find(death_loc);
|
||||||
a_ = units_.find(attacker_loc);
|
a_ = units_.find(attacker_loc);
|
||||||
@ -1075,7 +1104,16 @@ attack::attack(game_display& gui, const gamemap& map,
|
|||||||
unit_display::unit_die(d_->first, d_->second,a_stats_->weapon,d_stats_->weapon, &(a_->second));
|
unit_display::unit_die(d_->first, d_->second,a_stats_->weapon,d_stats_->weapon, &(a_->second));
|
||||||
}
|
}
|
||||||
|
|
||||||
game_events::fire("die",death_loc,attacker_loc);
|
try {
|
||||||
|
game_events::fire("die",death_loc,attacker_loc);
|
||||||
|
}
|
||||||
|
catch(end_level_exception &e)
|
||||||
|
{
|
||||||
|
if(delayed_exception == 0)
|
||||||
|
{
|
||||||
|
delayed_exception = new end_level_exception(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
d_ = units_.find(death_loc);
|
d_ = units_.find(death_loc);
|
||||||
a_ = units_.find(attacker_loc);
|
a_ = units_.find(attacker_loc);
|
||||||
@ -1147,7 +1185,17 @@ attack::attack(game_display& gui, const gamemap& map,
|
|||||||
d_->second.set_state("stoned","yes");
|
d_->second.set_state("stoned","yes");
|
||||||
n_defends_ = 0;
|
n_defends_ = 0;
|
||||||
n_attacks_ = 0;
|
n_attacks_ = 0;
|
||||||
game_events::fire(stone_string,d_->first,a_->first);
|
try {
|
||||||
|
game_events::fire(stone_string,d_->first,a_->first);
|
||||||
|
}
|
||||||
|
catch(end_level_exception &e)
|
||||||
|
{
|
||||||
|
if(delayed_exception == 0)
|
||||||
|
{
|
||||||
|
delayed_exception = new end_level_exception(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1301,7 +1349,16 @@ attack::attack(game_display& gui, const gamemap& map,
|
|||||||
game_events::entity_location defender_loc(d_);
|
game_events::entity_location defender_loc(d_);
|
||||||
const int attacker_side = a_->second.side();
|
const int attacker_side = a_->second.side();
|
||||||
fire_event("attack_end");
|
fire_event("attack_end");
|
||||||
game_events::fire("die",death_loc,defender_loc);
|
try {
|
||||||
|
game_events::fire("die",death_loc,defender_loc);
|
||||||
|
}
|
||||||
|
catch(end_level_exception &e)
|
||||||
|
{
|
||||||
|
if(delayed_exception == 0)
|
||||||
|
{
|
||||||
|
delayed_exception = new end_level_exception(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
refresh_bc();
|
refresh_bc();
|
||||||
|
|
||||||
@ -1410,8 +1467,14 @@ attack::attack(game_display& gui, const gamemap& map,
|
|||||||
replay::throw_error(errbuf_.str());
|
replay::throw_error(errbuf_.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (delayed_exception != 0)
|
||||||
|
{
|
||||||
|
throw end_level_exception(*delayed_exception);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int village_owner(const gamemap::location& loc, const std::vector<team>& teams)
|
int village_owner(const gamemap::location& loc, const std::vector<team>& teams)
|
||||||
{
|
{
|
||||||
for(size_t i = 0; i != teams.size(); ++i) {
|
for(size_t i = 0; i != teams.size(); ++i) {
|
||||||
|
@ -41,6 +41,8 @@ class game_data;
|
|||||||
|
|
||||||
bool can_recruit_on(const gamemap& map, const gamemap::location& leader, const gamemap::location loc);
|
bool can_recruit_on(const gamemap& map, const gamemap::location& leader, const gamemap::location loc);
|
||||||
|
|
||||||
|
struct end_level_exception;
|
||||||
|
|
||||||
//! Function which recruits a unit into the game.
|
//! Function which recruits a unit into the game.
|
||||||
// A copy of u will be created and inserted as the new recruited unit.
|
// A copy of u will be created and inserted as the new recruited unit.
|
||||||
// If need_castle is true, then the new unit must be on the same castle
|
// If need_castle is true, then the new unit must be on the same castle
|
||||||
@ -191,7 +193,6 @@ class attack {
|
|||||||
battle_context* bc_;
|
battle_context* bc_;
|
||||||
const battle_context::unit_stats* a_stats_;
|
const battle_context::unit_stats* a_stats_;
|
||||||
const battle_context::unit_stats* d_stats_;
|
const battle_context::unit_stats* d_stats_;
|
||||||
|
|
||||||
int orig_attacks_,orig_defends_;
|
int orig_attacks_,orig_defends_;
|
||||||
int n_attacks_,n_defends_;
|
int n_attacks_,n_defends_;
|
||||||
int attacker_cth_,defender_cth_;
|
int attacker_cth_,defender_cth_;
|
||||||
@ -200,6 +201,8 @@ class attack {
|
|||||||
|
|
||||||
bool update_display_;
|
bool update_display_;
|
||||||
bool OOS_error_;
|
bool OOS_error_;
|
||||||
|
end_level_exception* delayed_exception;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Given the location of a village, will return the 0-based index
|
//! Given the location of a village, will return the 0-based index
|
||||||
|
20
src/ai.cpp
20
src/ai.cpp
@ -1115,9 +1115,25 @@ void ai_interface::attack_enemy(const location u,
|
|||||||
}
|
}
|
||||||
|
|
||||||
recorder.add_attack(u,target,weapon,def_weapon);
|
recorder.add_attack(u,target,weapon,def_weapon);
|
||||||
|
try {
|
||||||
|
attack(info_.disp, info_.map, info_.teams, u, target, weapon, def_weapon,
|
||||||
|
info_.units, info_.state, info_.gameinfo);
|
||||||
|
}
|
||||||
|
catch (end_level_exception&)
|
||||||
|
{
|
||||||
|
dialogs::advance_unit(info_.gameinfo,info_.map,info_.units,u,info_.disp,true);
|
||||||
|
|
||||||
attack(info_.disp, info_.map, info_.teams, u, target, weapon, def_weapon,
|
const unit_map::const_iterator defender = info_.units.find(target);
|
||||||
info_.units, info_.state, info_.gameinfo);
|
if(defender != info_.units.end()) {
|
||||||
|
const size_t defender_team = size_t(defender->second.side()) - 1;
|
||||||
|
if(defender_team < info_.teams.size()) {
|
||||||
|
dialogs::advance_unit(info_.gameinfo, info_.map, info_.units,
|
||||||
|
target, info_.disp, !info_.teams[defender_team].is_human());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw;
|
||||||
|
}
|
||||||
dialogs::advance_unit(info_.gameinfo,info_.map,info_.units,u,info_.disp,true);
|
dialogs::advance_unit(info_.gameinfo,info_.map,info_.units,u,info_.disp,true);
|
||||||
|
|
||||||
const unit_map::const_iterator defender = info_.units.find(target);
|
const unit_map::const_iterator defender = info_.units.find(target);
|
||||||
|
@ -742,7 +742,7 @@ bool do_replay_handle(game_display& disp, const gamemap& map, const game_data& g
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DBG_REPLAY << "Repaly data in end\n";
|
DBG_REPLAY << "Repaly data at end\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1115,6 +1115,8 @@ bool do_replay_handle(game_display& disp, const gamemap& map, const game_data& g
|
|||||||
replay::throw_error("illegal defender weapon type in attack\n");
|
replay::throw_error("illegal defender weapon type in attack\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! FIXME: TODO make this handle end_level_exception
|
||||||
|
|
||||||
attack(disp, map, teams, src, dst, weapon_num, def_weapon_num, units, state, gameinfo, !get_replay_source().is_skipping());
|
attack(disp, map, teams, src, dst, weapon_num, def_weapon_num, units, state, gameinfo, !get_replay_source().is_skipping());
|
||||||
|
|
||||||
u = units.find(src);
|
u = units.find(src);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user