diff --git a/cont/base/springcontent/LuaGadgets/callins.lua b/cont/base/springcontent/LuaGadgets/callins.lua index d5b212d6eac..312b0945c7a 100644 --- a/cont/base/springcontent/LuaGadgets/callins.lua +++ b/cont/base/springcontent/LuaGadgets/callins.lua @@ -102,6 +102,8 @@ CALLIN_LIST = { "AllowUnitTransfer", "AllowUnitBuildStep", "AllowUnitTransport", + "AllowUnitTransportLoad", + "AllowUnitTransportUnload", "AllowUnitCloak", "AllowUnitDecloak", "AllowFeatureBuildStep", diff --git a/cont/base/springcontent/LuaGadgets/gadgets.lua b/cont/base/springcontent/LuaGadgets/gadgets.lua index de6e77620bd..dbbc203e1dc 100644 --- a/cont/base/springcontent/LuaGadgets/gadgets.lua +++ b/cont/base/springcontent/LuaGadgets/gadgets.lua @@ -1138,14 +1138,47 @@ function gadgetHandler:AllowUnitTransport( transporteeID, transporteeUnitDefID, transporteeTeam ) for _,g in r_ipairs(self.AllowUnitTransportList) do - if (not g:AllowUnitTransport(transporterID, transporterUnitDefID, transporterTeam, - transporteeID, transporteeUnitDefID, transporteeTeam)) then + if (not g:AllowUnitTransport( + transporterID, transporterUnitDefID, transporterTeam, + transporteeID, transporteeUnitDefID, transporteeTeam + )) then return false end end return true end +function gadgetHandler:AllowUnitTransportLoad( + transporterID, transporterUnitDefID, transporterTeam, + transporteeID, transporteeUnitDefID, transporteeTeam +) + for _,g in r_ipairs(self.AllowUnitTransportLoadList) do + if (not g:AllowUnitTransportLoad( + transporterID, transporterUnitDefID, transporterTeam, + transporteeID, transporteeUnitDefID, transporteeTeam + )) then + return false + end + end + return true +end + +function gadgetHandler:AllowUnitTransportUnload( + transporterID, transporterUnitDefID, transporterTeam, + transporteeID, transporteeUnitDefID, transporteeTeam +) + for _,g in r_ipairs(self.AllowUnitTransportUnloadList) do + if (not g:AllowUnitTransportUnload( + transporterID, transporterUnitDefID, transporterTeam, + transporteeID, transporteeUnitDefID, transporteeTeam + )) then + return false + end + end + return true +end + + function gadgetHandler:AllowUnitCloak(unitID, enemyID) for _,g in r_ipairs(self.AllowUnitCloakList) do if (not g:AllowUnitCloak(unitID, enemyID)) then diff --git a/rts/Lua/LuaHandleSynced.cpp b/rts/Lua/LuaHandleSynced.cpp index f11ddfbe219..fb6efee7f05 100644 --- a/rts/Lua/LuaHandleSynced.cpp +++ b/rts/Lua/LuaHandleSynced.cpp @@ -207,9 +207,9 @@ bool CUnsyncedLuaHandle::DrawUnit(const CUnit* unit) if (!success) return false; - const bool retval = luaL_optboolean(L, -1, false); + const bool draw = luaL_optboolean(L, -1, false); lua_pop(L, 1); - return retval; + return draw; } @@ -234,9 +234,9 @@ bool CUnsyncedLuaHandle::DrawFeature(const CFeature* feature) if (!success) return false; - const bool retval = luaL_optboolean(L, -1, false); + const bool draw = luaL_optboolean(L, -1, false); lua_pop(L, 1); - return retval; + return draw; } @@ -263,9 +263,9 @@ bool CUnsyncedLuaHandle::DrawShield(const CUnit* unit, const CWeapon* weapon) if (!success) return false; - const bool retval = luaL_optboolean(L, -1, false); + const bool draw = luaL_optboolean(L, -1, false); lua_pop(L, 1); - return retval; + return draw; } @@ -292,9 +292,9 @@ bool CUnsyncedLuaHandle::DrawProjectile(const CProjectile* projectile) if (!success) return false; - const bool retval = luaL_optboolean(L, -1, false); + const bool draw = luaL_optboolean(L, -1, false); lua_pop(L, 1); - return retval; + return draw; } @@ -475,9 +475,9 @@ bool CSyncedLuaHandle::CommandFallback(const CUnit* unit, const Command& cmd) if (!RunCallIn(L, cmdStr, 7, 1)) return true; - const bool retval = luaL_optboolean(L, -1, true); + const bool remove = luaL_optboolean(L, -1, true); lua_pop(L, 1); - return retval; // return 'true' to remove the command + return remove; // return 'true' to remove the command } @@ -499,9 +499,9 @@ bool CSyncedLuaHandle::AllowCommand(const CUnit* unit, const Command& cmd, bool return true; // get the results - const bool retval = luaL_optboolean(L, -1, true); + const bool allow = luaL_optboolean(L, -1, true); lua_pop(L, 1); - return retval; + return allow; } @@ -531,9 +531,9 @@ bool CSyncedLuaHandle::AllowUnitCreation(const UnitDef* unitDef, return true; // get the results - const bool retval = luaL_optboolean(L, -1, true); + const bool allow = luaL_optboolean(L, -1, true); lua_pop(L, 1); - return retval; + return allow; } @@ -558,9 +558,9 @@ bool CSyncedLuaHandle::AllowUnitTransfer(const CUnit* unit, int newTeam, bool ca return true; // get the results - const bool retval = luaL_optboolean(L, -1, true); + const bool allow = luaL_optboolean(L, -1, true); lua_pop(L, 1); - return retval; + return allow; } @@ -585,21 +585,21 @@ bool CSyncedLuaHandle::AllowUnitBuildStep(const CUnit* builder, return true; // get the results - const bool retval = luaL_optboolean(L, -1, true); + const bool allow = luaL_optboolean(L, -1, true); lua_pop(L, 1); - return retval; + return allow; } bool CSyncedLuaHandle::AllowUnitTransport(const CUnit* transporter, const CUnit* transportee) { LUA_CALL_IN_CHECK(L, true); - luaL_checkstack(L, 8, __func__); + luaL_checkstack(L, 2 + 6, __func__); static const LuaHashString cmdStr(__func__); if (!cmdStr.GetGlobalFunc(L)) - return true; // the call is not defined + return true; lua_pushnumber(L, transporter->id); lua_pushnumber(L, transporter->unitDef->id); @@ -608,14 +608,62 @@ bool CSyncedLuaHandle::AllowUnitTransport(const CUnit* transporter, const CUnit* lua_pushnumber(L, transportee->unitDef->id); lua_pushnumber(L, transportee->team); - // call the function if (!RunCallIn(L, cmdStr, 6, 1)) return true; - // get the results - const bool retval = luaL_optboolean(L, -1, true); + const bool allow = luaL_optboolean(L, -1, true); + lua_pop(L, 1); + return allow; +} + +bool CSyncedLuaHandle::AllowUnitTransportLoad(const CUnit* transporter, const CUnit* transportee, bool allowed) +{ + LUA_CALL_IN_CHECK(L, true); + luaL_checkstack(L, 2 + 6, __func__); + + static const LuaHashString cmdStr(__func__); + + if (!cmdStr.GetGlobalFunc(L)) + return allowed; + + lua_pushnumber(L, transporter->id); + lua_pushnumber(L, transporter->unitDef->id); + lua_pushnumber(L, transporter->team); + lua_pushnumber(L, transportee->id); + lua_pushnumber(L, transportee->unitDef->id); + lua_pushnumber(L, transportee->team); + + if (!RunCallIn(L, cmdStr, 6, 1)) + return true; + + const bool allow = luaL_optboolean(L, -1, allowed); + lua_pop(L, 1); + return allow; +} + +bool CSyncedLuaHandle::AllowUnitTransportUnload(const CUnit* transporter, const CUnit* transportee, bool allowed) +{ + LUA_CALL_IN_CHECK(L, true); + luaL_checkstack(L, 2 + 6, __func__); + + static const LuaHashString cmdStr(__func__); + + if (!cmdStr.GetGlobalFunc(L)) + return allowed; + + lua_pushnumber(L, transporter->id); + lua_pushnumber(L, transporter->unitDef->id); + lua_pushnumber(L, transporter->team); + lua_pushnumber(L, transportee->id); + lua_pushnumber(L, transportee->unitDef->id); + lua_pushnumber(L, transportee->team); + + if (!RunCallIn(L, cmdStr, 6, 1)) + return true; + + const bool allow = luaL_optboolean(L, -1, allowed); lua_pop(L, 1); - return retval; + return allow; } @@ -641,9 +689,9 @@ bool CSyncedLuaHandle::AllowUnitCloak(const CUnit* unit, const CUnit* enemy) if (!RunCallIn(L, cmdStr, 2, 1)) return true; - const bool retval = luaL_optboolean(L, -1, true); + const bool allow = luaL_optboolean(L, -1, true); lua_pop(L, 1); - return retval; + return allow; } bool CSyncedLuaHandle::AllowUnitDecloak(const CUnit* unit, const CSolidObject* object, const CWeapon* weapon) @@ -675,9 +723,9 @@ bool CSyncedLuaHandle::AllowUnitDecloak(const CUnit* unit, const CSolidObject* o assert(lua_isboolean(L, -1)); - const bool retval = lua_toboolean(L, -1); + const bool allow = lua_toboolean(L, -1); lua_pop(L, 1); - return retval; + return allow; } @@ -701,9 +749,9 @@ bool CSyncedLuaHandle::AllowFeatureCreation(const FeatureDef* featureDef, int te return true; // get the results - const bool retval = luaL_optboolean(L, -1, true); + const bool allow = luaL_optboolean(L, -1, true); lua_pop(L, 1); - return retval; + return allow; } @@ -727,9 +775,9 @@ bool CSyncedLuaHandle::AllowFeatureBuildStep(const CUnit* builder, const CFeatur return true; // get the results - const bool retval = luaL_optboolean(L, -1, true); + const bool allow = luaL_optboolean(L, -1, true); lua_pop(L, 1); - return retval; + return allow; } @@ -751,9 +799,9 @@ bool CSyncedLuaHandle::AllowResourceLevel(int teamID, const string& type, float return true; // get the results - const bool retval = luaL_optboolean(L, -1, true); + const bool allow = luaL_optboolean(L, -1, true); lua_pop(L, 1); - return retval; + return allow; } @@ -776,9 +824,9 @@ bool CSyncedLuaHandle::AllowResourceTransfer(int oldTeam, int newTeam, const cha return true; // get the results - const bool retval = luaL_optboolean(L, -1, true); + const bool allow = luaL_optboolean(L, -1, true); lua_pop(L, 1); - return retval; + return allow; } @@ -801,9 +849,9 @@ bool CSyncedLuaHandle::AllowDirectUnitControl(int playerID, const CUnit* unit) return true; // get the results - const bool retval = luaL_optboolean(L, -1, true); + const bool allow = luaL_optboolean(L, -1, true); lua_pop(L, 1); - return retval; + return allow; } @@ -825,9 +873,9 @@ bool CSyncedLuaHandle::AllowBuilderHoldFire(const CUnit* unit, int action) return true; // get the results - const bool retval = luaL_optboolean(L, -1, true); + const bool allow = luaL_optboolean(L, -1, true); lua_pop(L, 1); - return retval; + return allow; } @@ -856,9 +904,9 @@ bool CSyncedLuaHandle::AllowStartPosition(int playerID, int teamID, unsigned cha return true; // get the results - const bool retval = luaL_optboolean(L, -1, true); + const bool allow = luaL_optboolean(L, -1, true); lua_pop(L, 1); - return retval; + return allow; } @@ -882,9 +930,9 @@ bool CSyncedLuaHandle::MoveCtrlNotify(const CUnit* unit, int data) return false; // get the results - const bool retval = luaL_optboolean(L, -1, false); + const bool disable = luaL_optboolean(L, -1, false); lua_pop(L, 1); - return retval; + return disable; } @@ -914,9 +962,9 @@ bool CSyncedLuaHandle::TerraformComplete(const CUnit* unit, const CUnit* build) return false; // get the results - const bool retval = luaL_optboolean(L, -1, false); + const bool stop = luaL_optboolean(L, -1, false); lua_pop(L, 1); - return retval; + return stop; } diff --git a/rts/Lua/LuaHandleSynced.h b/rts/Lua/LuaHandleSynced.h index ffd184c2319..308f4b428ce 100644 --- a/rts/Lua/LuaHandleSynced.h +++ b/rts/Lua/LuaHandleSynced.h @@ -59,6 +59,8 @@ class CSyncedLuaHandle : public CLuaHandle bool AllowUnitTransfer(const CUnit* unit, int newTeam, bool capture) override; bool AllowUnitBuildStep(const CUnit* builder, const CUnit* unit, float part) override; bool AllowUnitTransport(const CUnit* transporter, const CUnit* transportee) override; + bool AllowUnitTransportLoad(const CUnit* transporter, const CUnit* transportee, bool allowed) override; + bool AllowUnitTransportUnload(const CUnit* transporter, const CUnit* transportee, bool allowed) override; bool AllowUnitCloak(const CUnit* unit, const CUnit* enemy) override; bool AllowUnitDecloak(const CUnit* unit, const CSolidObject* object, const CWeapon* weapon) override; bool AllowFeatureCreation(const FeatureDef* featureDef, int allyTeamID, const float3& pos) override; diff --git a/rts/Sim/Units/CommandAI/MobileCAI.cpp b/rts/Sim/Units/CommandAI/MobileCAI.cpp index 8ffca29e068..21536e6e7fe 100644 --- a/rts/Sim/Units/CommandAI/MobileCAI.cpp +++ b/rts/Sim/Units/CommandAI/MobileCAI.cpp @@ -21,6 +21,7 @@ #include "Sim/Weapons/Weapon.h" #include "Sim/Weapons/WeaponDef.h" #include "System/Log/ILog.h" +#include "System/EventHandler.h" #include "System/myMath.h" #include "System/StringUtil.h" #include @@ -1336,12 +1337,18 @@ void CMobileCAI::ExecuteLoadUnits(Command& c) } if (inCommand) { - if (!owner->script->IsBusy()) { + if (!owner->script->IsBusy()) StopMoveAndFinishCommand(); - } + + return; + } + + if (!owner->CanTransport(unit) || !UpdateTargetLostTimer(int(c.params[0]))) { + StopMoveAndFinishCommand(); return; } - if (owner->CanTransport(unit) && UpdateTargetLostTimer(int(c.params[0]))) { + + { SetTransportee(unit); const float sqDist = unit->pos.SqDistance2D(owner->pos); @@ -1379,33 +1386,40 @@ void CMobileCAI::ExecuteLoadUnits(Command& c) const bool b2 = (std::abs(owner->heading - unit->heading) < AIRTRANSPORT_DOCKING_ANGLE); const bool b3 = (owner->updir.dot(UpVector) > 0.995f); - if (b1 && b2 && b3) { - am->SetAllowLanding(false); - am->SetWantedAltitude(0.0f); + if (!eventHandler.AllowUnitTransportLoad(owner, unit, b1 && b2 && b3)) + return; - owner->script->BeginTransport(unit); - SetTransportee(nullptr); - owner->AttachUnit(unit, owner->script->QueryTransport(unit)); + am->SetAllowLanding(false); + am->SetWantedAltitude(0.0f); - StopMoveAndFinishCommand(); - return; - } + owner->script->BeginTransport(unit); + SetTransportee(nullptr); + owner->AttachUnit(unit, owner->script->QueryTransport(unit)); + + StopMoveAndFinishCommand(); } else { + if (!eventHandler.AllowUnitTransportLoad(owner, unit, true)) + return; + inCommand = true; StopMove(); owner->script->TransportPickup(unit); } - } else if (owner->moveType->progressState == AMoveType::Failed && sqDist < (200 * 200)) { - // if we're pretty close already but CGroundMoveType fails because it considers - // the goal clogged (with the future passenger...), just try to move to the - // point halfway between the transport and the passenger. - SetGoal((unit->pos + owner->pos) * 0.5f, owner->pos); + + return; } - } else { - StopMoveAndFinishCommand(); + + if (owner->moveType->progressState != AMoveType::Failed || sqDist >= Square(200.0f)) + return; + + // if we're pretty close already but CGroundMoveType fails because it considers + // the goal clogged (with the future passenger...), just try to move to the + // point halfway between the transport and the passenger. + SetGoal((unit->pos + owner->pos) * 0.5f, owner->pos); } } break; + case 4: { // area-load, avoid infinite loops if (lastCommandFrame == gs->frameNum) @@ -1518,7 +1532,7 @@ bool CMobileCAI::AllowedCommand(const Command& c, bool fromSynced) if (c.GetParamsCount() == 5) { if (fromSynced) { // point transported buildings (...) in their wanted direction after unloading - for (auto& tu: transportees) { + for (const CUnit::TransportedUnit& tu: transportees) { tu.unit->buildFacing = std::abs(int(c.GetParam(4))) % NUM_FACINGS; } } @@ -1526,7 +1540,7 @@ bool CMobileCAI::AllowedCommand(const Command& c, bool fromSynced) if (c.GetParamsCount() >= 4) { // find unload positions for transportees (WHY can this run in unsynced context?) - for (const auto& tu: transportees) { + for (const CUnit::TransportedUnit& tu: transportees) { const CUnit* u = tu.unit; const float radius = (c.GetID() == CMD_UNLOAD_UNITS)? c.GetParam(3): 0.0f; @@ -1863,7 +1877,7 @@ void CMobileCAI::UnloadLand(Command& c) const int unitID = c.params[3]; // unload a specific transportee - for (auto& tu: transportees) { + for (const CUnit::TransportedUnit& tu: transportees) { CUnit* carried = tu.unit; if (unitID == carried->id) { @@ -1877,55 +1891,64 @@ void CMobileCAI::UnloadLand(Command& c) } } - if (wantedPos.SqDistance2D(owner->pos) < Square(owner->unitDef->loadingRadius * 0.9f)) { - wantedPos.y = owner->GetTransporteeWantedHeight(wantedPos, transportee); + if (wantedPos.SqDistance2D(owner->pos) >= Square(owner->unitDef->loadingRadius * 0.9f)) + return; - if ((am = dynamic_cast(owner->moveType)) != nullptr) { - // handle air transports differently - SetGoal(wantedPos, owner->pos); + wantedPos.y = owner->GetTransporteeWantedHeight(wantedPos, transportee); - am->SetWantedAltitude(wantedPos.y - CGround::GetHeightAboveWater(wantedPos.x, wantedPos.z)); - am->ForceHeading(owner->GetTransporteeWantedHeading(transportee)); + if ((am = dynamic_cast(owner->moveType)) == nullptr) { + if (!eventHandler.AllowUnitTransportUnload(owner, transportee, true)) + return; - am->maxDrift = 1.0f; + inCommand = true; - // FIXME: kill the hardcoded constants, use the command's radius - // NOTE: 2D distance-check would mean units get dropped from air - const bool b1 = (owner->pos.SqDistance(wantedPos) < Square(AIRTRANSPORT_DOCKING_RADIUS)); - const bool b2 = (std::abs(owner->heading - am->GetForcedHeading()) < AIRTRANSPORT_DOCKING_ANGLE); - const bool b3 = (owner->updir.dot(UpVector) > 0.99f); + StopMove(); + owner->script->TransportDrop(transportee, wantedPos); + return; + } - if (b1 && b2 && b3) { - wantedPos.y -= transportee->radius; + { + // handle air transports differently + SetGoal(wantedPos, owner->pos); - if (!SpotIsClearIgnoreSelf(wantedPos, transportee)) { - // chosen spot is no longer clear to land, choose a new one - // if a new spot cannot be found, don't unload at all - float3 newWantedPos; + am->SetWantedAltitude(wantedPos.y - CGround::GetHeightAboveWater(wantedPos.x, wantedPos.z)); + am->ForceHeading(owner->GetTransporteeWantedHeading(transportee)); - if (FindEmptySpot(transportee, wantedPos, std::max(16.0f * SQUARE_SIZE, transportee->radius * 4.0f), transportee->radius, newWantedPos)) { - c.SetPos(0, newWantedPos); - SetGoal(newWantedPos + UpVector * transportee->model->height, owner->pos); - return; - } - } else { - owner->DetachUnit(transportee); + am->maxDrift = 1.0f; - if (transportees.empty()) { - am->SetAllowLanding(true); - owner->script->EndTransport(); - } - } + // FIXME: kill the hardcoded constants, use the command's radius + // NOTE: 2D distance-check would mean units get dropped from air + const bool b1 = (owner->pos.SqDistance(wantedPos) < Square(AIRTRANSPORT_DOCKING_RADIUS)); + const bool b2 = (std::abs(owner->heading - am->GetForcedHeading()) < AIRTRANSPORT_DOCKING_ANGLE); + const bool b3 = (owner->updir.dot(UpVector) > 0.99f); - // move the transport away slightly - SetGoal(owner->pos + owner->frontdir * 20.0f, owner->pos); - FinishCommand(); + if (!eventHandler.AllowUnitTransportUnload(owner, transportee, b1 && b2 && b3)) + return; + + wantedPos.y -= transportee->radius; + + if (!SpotIsClearIgnoreSelf(wantedPos, transportee)) { + // chosen spot is no longer clear to land, choose a new one + // if a new spot cannot be found, don't unload at all + float3 newWantedPos; + + if (FindEmptySpot(transportee, wantedPos, std::max(16.0f * SQUARE_SIZE, transportee->radius * 4.0f), transportee->radius, newWantedPos)) { + c.SetPos(0, newWantedPos); + SetGoal(newWantedPos + UpVector * transportee->model->height, owner->pos); + return; } } else { - inCommand = true; - StopMove(); - owner->script->TransportDrop(transportee, wantedPos); + owner->DetachUnit(transportee); + + if (transportees.empty()) { + am->SetAllowLanding(true); + owner->script->EndTransport(); + } } + + // move the transport away slightly + SetGoal(owner->pos + owner->frontdir * 20.0f, owner->pos); + FinishCommand(); } } @@ -1981,7 +2004,7 @@ void CMobileCAI::UnloadLandFlood(Command& c) } else { const int unitID = c.params[3]; - for (auto& tu: transportees) { + for (const CUnit::TransportedUnit& tu: transportees) { CUnit* carried = tu.unit; if (unitID == carried->id) { diff --git a/rts/System/EventClient.h b/rts/System/EventClient.h index a4cec1cb1aa..aa3e7a3c3ab 100644 --- a/rts/System/EventClient.h +++ b/rts/System/EventClient.h @@ -201,6 +201,8 @@ class CEventClient virtual bool AllowUnitTransfer(const CUnit* unit, int newTeam, bool capture) { return true; } virtual bool AllowUnitBuildStep(const CUnit* builder, const CUnit* unit, float part) { return true; } virtual bool AllowUnitTransport(const CUnit* transporter, const CUnit* transportee) { return true; } + virtual bool AllowUnitTransportLoad(const CUnit* transporter, const CUnit* transportee, bool allowed) { return true; } + virtual bool AllowUnitTransportUnload(const CUnit* transporter, const CUnit* transportee, bool allowed) { return true; } virtual bool AllowUnitCloak(const CUnit* unit, const CUnit* enemy) { return true; } virtual bool AllowUnitDecloak(const CUnit* unit, const CSolidObject* object, const CWeapon* weapon) { return true; } virtual bool AllowFeatureCreation(const FeatureDef* featureDef, int allyTeamID, const float3& pos) { return true; } diff --git a/rts/System/EventHandler.cpp b/rts/System/EventHandler.cpp index a99ccf43ebc..f1f7a85e93f 100644 --- a/rts/System/EventHandler.cpp +++ b/rts/System/EventHandler.cpp @@ -272,6 +272,16 @@ bool CEventHandler::AllowUnitTransport(const CUnit* transporter, const CUnit* tr return ControlIterateDefTrue(listAllowUnitTransport, &CEventClient::AllowUnitTransport, transporter, transportee); } +bool CEventHandler::AllowUnitTransportLoad(const CUnit* transporter, const CUnit* transportee, bool allowed) +{ + return ControlIterateDefTrue(listAllowUnitTransportLoad, &CEventClient::AllowUnitTransportLoad, transporter, transportee, allowed); +} + +bool CEventHandler::AllowUnitTransportUnload(const CUnit* transporter, const CUnit* transportee, bool allowed) +{ + return ControlIterateDefTrue(listAllowUnitTransportUnload, &CEventClient::AllowUnitTransportUnload, transporter, transportee, allowed); +} + bool CEventHandler::AllowUnitCloak(const CUnit* unit, const CUnit* enemy) { return ControlIterateDefTrue(listAllowUnitCloak, &CEventClient::AllowUnitCloak, unit, enemy); diff --git a/rts/System/EventHandler.h b/rts/System/EventHandler.h index b7bea6c04d6..95fcc0874f5 100644 --- a/rts/System/EventHandler.h +++ b/rts/System/EventHandler.h @@ -140,6 +140,8 @@ class CEventHandler bool AllowUnitTransfer(const CUnit* unit, int newTeam, bool capture); bool AllowUnitBuildStep(const CUnit* builder, const CUnit* unit, float part); bool AllowUnitTransport(const CUnit* transporter, const CUnit* transportee); + bool AllowUnitTransportLoad(const CUnit* transporter, const CUnit* transportee, bool allowed); + bool AllowUnitTransportUnload(const CUnit* transporter, const CUnit* transportee, bool allowed); bool AllowUnitCloak(const CUnit* unit, const CUnit* enemy); bool AllowUnitDecloak(const CUnit* unit, const CSolidObject* object, const CWeapon* weapon); bool AllowFeatureCreation(const FeatureDef* featureDef, int allyTeamID, const float3& pos); diff --git a/rts/System/Events.def b/rts/System/Events.def index 250adb19657..937ed02c657 100644 --- a/rts/System/Events.def +++ b/rts/System/Events.def @@ -159,23 +159,25 @@ SETUP_EVENT(SyncedActionFallback, MANAGED_BIT | CONTROL_BIT) - SETUP_EVENT(CommandFallback, MANAGED_BIT | CONTROL_BIT) - SETUP_EVENT(AllowCommand, MANAGED_BIT | CONTROL_BIT) - SETUP_EVENT(AllowUnitCreation, MANAGED_BIT | CONTROL_BIT) - SETUP_EVENT(AllowUnitTransfer, MANAGED_BIT | CONTROL_BIT) - SETUP_EVENT(AllowUnitBuildStep, MANAGED_BIT | CONTROL_BIT) - SETUP_EVENT(AllowUnitTransport, MANAGED_BIT | CONTROL_BIT) - SETUP_EVENT(AllowUnitCloak, MANAGED_BIT | CONTROL_BIT) - SETUP_EVENT(AllowUnitDecloak, MANAGED_BIT | CONTROL_BIT) - SETUP_EVENT(AllowFeatureCreation, MANAGED_BIT | CONTROL_BIT) - SETUP_EVENT(AllowFeatureBuildStep, MANAGED_BIT | CONTROL_BIT) - SETUP_EVENT(AllowResourceLevel, MANAGED_BIT | CONTROL_BIT) - SETUP_EVENT(AllowResourceTransfer, MANAGED_BIT | CONTROL_BIT) - SETUP_EVENT(AllowDirectUnitControl, MANAGED_BIT | CONTROL_BIT) - SETUP_EVENT(AllowBuilderHoldFire, MANAGED_BIT | CONTROL_BIT) - SETUP_EVENT(AllowStartPosition, MANAGED_BIT | CONTROL_BIT) - SETUP_EVENT(TerraformComplete, MANAGED_BIT | CONTROL_BIT) - SETUP_EVENT(MoveCtrlNotify, MANAGED_BIT | CONTROL_BIT) + SETUP_EVENT(CommandFallback, MANAGED_BIT | CONTROL_BIT) + SETUP_EVENT(AllowCommand, MANAGED_BIT | CONTROL_BIT) + SETUP_EVENT(AllowUnitCreation, MANAGED_BIT | CONTROL_BIT) + SETUP_EVENT(AllowUnitTransfer, MANAGED_BIT | CONTROL_BIT) + SETUP_EVENT(AllowUnitBuildStep, MANAGED_BIT | CONTROL_BIT) + SETUP_EVENT(AllowUnitTransport, MANAGED_BIT | CONTROL_BIT) + SETUP_EVENT(AllowUnitTransportLoad, MANAGED_BIT | CONTROL_BIT) + SETUP_EVENT(AllowUnitTransportUnload, MANAGED_BIT | CONTROL_BIT) + SETUP_EVENT(AllowUnitCloak, MANAGED_BIT | CONTROL_BIT) + SETUP_EVENT(AllowUnitDecloak, MANAGED_BIT | CONTROL_BIT) + SETUP_EVENT(AllowFeatureCreation, MANAGED_BIT | CONTROL_BIT) + SETUP_EVENT(AllowFeatureBuildStep, MANAGED_BIT | CONTROL_BIT) + SETUP_EVENT(AllowResourceLevel, MANAGED_BIT | CONTROL_BIT) + SETUP_EVENT(AllowResourceTransfer, MANAGED_BIT | CONTROL_BIT) + SETUP_EVENT(AllowDirectUnitControl, MANAGED_BIT | CONTROL_BIT) + SETUP_EVENT(AllowBuilderHoldFire, MANAGED_BIT | CONTROL_BIT) + SETUP_EVENT(AllowStartPosition, MANAGED_BIT | CONTROL_BIT) + SETUP_EVENT(TerraformComplete, MANAGED_BIT | CONTROL_BIT) + SETUP_EVENT(MoveCtrlNotify, MANAGED_BIT | CONTROL_BIT) SETUP_EVENT(AllowWeaponTargetCheck, MANAGED_BIT | CONTROL_BIT) SETUP_EVENT(AllowWeaponTarget, MANAGED_BIT | CONTROL_BIT)