Skip to content

Commit

Permalink
Add Spring.ClearUnitGoal(unitID)
Browse files Browse the repository at this point in the history
will help custom commands to clean after themselves
also fix #5153
  • Loading branch information
ashdnazg committed Mar 8, 2016
1 parent f4376b1 commit 2cadd70
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
13 changes: 13 additions & 0 deletions rts/Lua/LuaSyncedCtrl.cpp
Expand Up @@ -196,6 +196,7 @@ bool LuaSyncedCtrl::PushEntries(lua_State* L)
REGISTER_LUA_CFUNC(SetUnitFuel);
REGISTER_LUA_CFUNC(SetUnitMoveGoal);
REGISTER_LUA_CFUNC(SetUnitLandGoal);
REGISTER_LUA_CFUNC(ClearUnitGoal);
REGISTER_LUA_CFUNC(SetUnitNeutral);
REGISTER_LUA_CFUNC(SetUnitTarget);
REGISTER_LUA_CFUNC(SetUnitMidAndAimPos);
Expand Down Expand Up @@ -2391,6 +2392,18 @@ int LuaSyncedCtrl::SetUnitLandGoal(lua_State* L)
}


int LuaSyncedCtrl::ClearUnitGoal(lua_State* L)
{
CUnit* unit = ParseUnit(L, __FUNCTION__, 1);

if (unit == nullptr)
return 0;

unit->moveType->StopMoving();
return 0;
}


int LuaSyncedCtrl::SetUnitPhysics(lua_State* L)
{
return (SetSolidObjectPhysicalState(L, ParseUnit(L, __FUNCTION__, 1)));
Expand Down
1 change: 1 addition & 0 deletions rts/Lua/LuaSyncedCtrl.h
Expand Up @@ -85,6 +85,7 @@ class LuaSyncedCtrl
static int SetUnitFuel(lua_State* L);
static int SetUnitMoveGoal(lua_State* L);
static int SetUnitLandGoal(lua_State* L);
static int ClearUnitGoal(lua_State* L);
static int SetUnitNeutral(lua_State* L);
static int SetUnitTarget(lua_State* L);
static int SetUnitMidAndAimPos(lua_State* L);
Expand Down
3 changes: 2 additions & 1 deletion rts/Sim/MoveTypes/StrafeAirMoveType.cpp
Expand Up @@ -1314,10 +1314,11 @@ void CStrafeAirMoveType::StopMoving(bool callScript, bool hardStop)
SetGoal(owner->pos);
SetWantedMaxSpeed(0.0f);

if (aircraftState != AAirMoveType::AIRCRAFT_FLYING)
if (aircraftState != AAirMoveType::AIRCRAFT_FLYING && aircraftState != AAirMoveType::AIRCRAFT_LANDING)
return;

if (owner->unitDef->DontLand() || !autoLand) {
SetState(AIRCRAFT_FLYING);
return;
}
SetState(AIRCRAFT_LANDING);
Expand Down

0 comments on commit 2cadd70

Please sign in to comment.