mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-03 23:53:28 +00:00
fixed bug #16117: added a way to supress E_NOT_REACHED_DESTINATION...
...to lua api via an optional boolean parameter - ai.move_full(from,to_x,to_y,true) - this allows to steal units in custom moveto events without the AI complaining that something is wrong
This commit is contained in:
parent
b5db06e075
commit
41cc607f65
@ -1,4 +1,7 @@
|
||||
Version 1.9.8+svn:
|
||||
* AI:
|
||||
* Fixed bug #16117: added a way to supress E_NOT_REACHED_DESTINATION to lua
|
||||
api via an optional boolean parameter - ai.move_full(from,to_x,to_y,true)
|
||||
* Campaigns:
|
||||
* Fixed remaining deprecation warnings about empty side=
|
||||
* Language and i18n:
|
||||
|
@ -336,7 +336,7 @@ void attack_result::do_init_for_execution()
|
||||
|
||||
// move_result
|
||||
move_result::move_result(side_number side, const map_location& from,
|
||||
const map_location& to, bool remove_movement)
|
||||
const map_location& to, bool remove_movement, bool unreach_is_ok)
|
||||
: action_result(side)
|
||||
, from_(from)
|
||||
, move_spectator_(*resources::units)
|
||||
@ -344,6 +344,7 @@ move_result::move_result(side_number side, const map_location& from,
|
||||
, remove_movement_(remove_movement)
|
||||
, route_()
|
||||
, unit_location_(from)
|
||||
, unreach_is_ok_(unreach_is_ok)
|
||||
{
|
||||
}
|
||||
|
||||
@ -434,7 +435,7 @@ void move_result::do_check_after()
|
||||
}
|
||||
///@todo 1.9 add 'new units spotted' failure mode
|
||||
|
||||
if (unit_location_!=to_) {
|
||||
if (!unreach_is_ok_ && unit_location_!=to_) {
|
||||
set_error(E_NOT_REACHED_DESTINATION);
|
||||
return;
|
||||
}
|
||||
@ -1037,9 +1038,10 @@ move_result_ptr actions::execute_move_action( side_number side,
|
||||
bool execute,
|
||||
const map_location& from,
|
||||
const map_location& to,
|
||||
bool remove_movement)
|
||||
bool remove_movement,
|
||||
bool unreach_is_ok)
|
||||
{
|
||||
move_result_ptr action(new move_result(side,from,to,remove_movement));
|
||||
move_result_ptr action(new move_result(side,from,to,remove_movement,unreach_is_ok));
|
||||
execute ? action->execute() : action->check_before();
|
||||
return action;
|
||||
|
||||
|
@ -155,7 +155,8 @@ public:
|
||||
move_result( side_number side,
|
||||
const map_location& from,
|
||||
const map_location& to,
|
||||
bool remove_movement );
|
||||
bool remove_movement,
|
||||
bool unreach_is_ok);
|
||||
static const int E_EMPTY_MOVE = 2001;
|
||||
static const int E_NO_UNIT = 2002;
|
||||
static const int E_NOT_OWN_UNIT = 2003;
|
||||
@ -180,6 +181,7 @@ private:
|
||||
bool remove_movement_;
|
||||
boost::shared_ptr<pathfind::plain_route> route_;
|
||||
map_location unit_location_;
|
||||
bool unreach_is_ok_;
|
||||
};
|
||||
|
||||
|
||||
@ -317,7 +319,8 @@ static move_result_ptr execute_move_action( side_number side,
|
||||
bool execute,
|
||||
const map_location& from,
|
||||
const map_location& to,
|
||||
bool remove_movement );
|
||||
bool remove_movement,
|
||||
bool unreach_is_ok = false);
|
||||
|
||||
|
||||
|
||||
|
@ -177,7 +177,11 @@ static int ai_execute_move(lua_State *L, bool remove_movement)
|
||||
map_location from, to;
|
||||
if (!to_map_location(L, index, from)) goto error_call_destructors;
|
||||
if (!to_map_location(L, index, to)) goto error_call_destructors;
|
||||
ai::move_result_ptr move_result = ai::actions::execute_move_action(side,true,from,to,remove_movement);
|
||||
bool unreach_is_ok = false;
|
||||
if (lua_isboolean(L, index)) {
|
||||
unreach_is_ok = lua_toboolean(L, index);
|
||||
}
|
||||
ai::move_result_ptr move_result = ai::actions::execute_move_action(side,true,from,to,remove_movement, unreach_is_ok);
|
||||
return transform_ai_action(L,move_result);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user