From f0fd775650bf913d383a08aca1f0a36a3dca1160 Mon Sep 17 00:00:00 2001 From: loveridge Date: Sun, 10 Sep 2023 09:48:03 -0700 Subject: [PATCH] Manual unit share no longer gives Stop command (#996) --- doc/changelog.txt | 1 + doc/site/changelogs/running-changelog.markdown | 1 + doc/site/migrating-from-spring.markdown | 11 +++++++++++ rts/Lua/LuaUnsyncedCtrl.cpp | 2 -- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/doc/changelog.txt b/doc/changelog.txt index 19f481b13f..1543eac93c 100644 --- a/doc/changelog.txt +++ b/doc/changelog.txt @@ -105,6 +105,7 @@ Misc: in conjunction with `Spring.GetPlayerInfo` poisoning. - Add new `/remove` cheat-only command, it removes selected units similar to `/destroy` except no death script is run (so no explosion nor wreckage). + - Units no longer clear command queue when shared. This can be implemented gameside with UnitGiven callin. Sim: - Improved performance of long-range path finding requests (TKPFS) diff --git a/doc/site/changelogs/running-changelog.markdown b/doc/site/changelogs/running-changelog.markdown index b069b456ed..d8580654f9 100644 --- a/doc/site/changelogs/running-changelog.markdown +++ b/doc/site/changelogs/running-changelog.markdown @@ -31,6 +31,7 @@ The extras are considered to start in the (0, 0) corner and it is now up to the * the `movement.allowGroundUnitGravity` mod rule now defaults to `false`. All known games have an explicit value set, so this should only affect new games. * `/ally` no longer announces this to unrelated players via a console message. The affected players still see one. Use the `TeamChanged` call-in to make a replacement if you want it to be public. +* manually shared units no longer receive the Stop command. Use the `UnitGiven` callin to get back the previous behaviour. ### Deprecation No changes yet, but these will happen in the future and possibly break things. diff --git a/doc/site/migrating-from-spring.markdown b/doc/site/migrating-from-spring.markdown index d645027455..7efb997ac2 100644 --- a/doc/site/migrating-from-spring.markdown +++ b/doc/site/migrating-from-spring.markdown @@ -89,6 +89,17 @@ Instead use the second return value, e.g.: + local counts, unitDefsCount = Spring.GetSelectedUnitsCounts() ``` +## Stop command on manual share +Manually shared units no longer receive the Stop command. +Replicate the previous behaviour via the `UnitGiven` callin: +```lua +function wupget:UnitGiven(unitID, unitDefID, newTeam) + if newTeam == Spring.GetMyTeamID() then -- if doing in unsynced + Spring.GiveOrderToUnit(unitID, CMD.STOP, 0, 0) + end +end +``` + ## Defs - Hovercraft and ships brought out of water no longer forced to be upright. diff --git a/rts/Lua/LuaUnsyncedCtrl.cpp b/rts/Lua/LuaUnsyncedCtrl.cpp index aa32aaad03..e84b8fe2f0 100644 --- a/rts/Lua/LuaUnsyncedCtrl.cpp +++ b/rts/Lua/LuaUnsyncedCtrl.cpp @@ -3520,8 +3520,6 @@ int LuaUnsyncedCtrl::ShareResources(lua_State* L) const char* type = lua_tostring(L, 2); if (type[0] == 'u') { - // update the selection, and clear the unit command queues - selectedUnitsHandler.GiveCommand(Command(CMD_STOP), false); clientNet->Send(CBaseNetProtocol::Get().SendShare(gu->myPlayerNum, teamID, 1, 0.0f, 0.0f)); selectedUnitsHandler.ClearSelected(); return 0;