Fix unit commands#1
Open
leviathan400 wants to merge 8 commits into
Open
Conversation
The direct GetMapObject()->CmdMove() thunk leaves the unit's move/waypoint state uninitialized; the next ProcessUnits pass calls through a garbage pointer (EXCEPTION_ACCESS_VIOLATION, eip in the heap). Route the order through ProcessCommandPacket (CommandType::Move), the same path DoStandGround/DoAttack already use.
Same class of bug as DoMove: the direct GetMapObject()->CmdDock() thunk never docks the unit and leaves command state corrupted. Route the order through ProcessCommandPacket (CommandType::Dock, which uses MoveCommand with the structure's dock tile as the waypoint).
numUnits (a uint8 count) was set to the unit id and the id was written to unitID[1], leaving unitID[0] = 0, so the engine matched the route to no unit and Cargo Trucks never moved. Set numUnits = 1; unitID[0] = id_, matching every other Do* command builder.
The direct GetMapObject()->CmdDumpCargo() thunk corrupts command state and the engine faults a tick later (EXCEPTION_ACCESS_VIOLATION). Route through DoSimpleCommand(CommandType::DumpCargo), the same path the sibling DoLoadCargo/DoUnloadCargo already use - DumpCargo is already handled in DoSimpleCommand's switch.
The direct GetMapObject()->CmdTransferCargo() thunk corrupts command state and the engine faults a tick later. Route through ProcessCommandPacket (CommandType::TransferCargo, which uses TransferCargoCommand: unitID, bay, unknown=0).
Add 0.8.3 change log entry for the five Do* command-packet fixes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes a class of Unit::Do* orders that called a raw GetMapObject()->Cmd*() thunk directly instead of going through ProcessCommandPacket. The direct calls crash the engine (or no-op the order) a tick later; routing them through the command-packet path, the same one every other working Do* order uses - fixes it and stays multiplayer-deterministic. All verified in-game on and confirmed with a before/after in a TethysAPI smoke-test mission.
Unit::DoMove()to issue aCommandType::Movecommand packet instead of the rawCmdMove().Unit::DoDock()to issue aCommandType::Dockcommand packet instead of the rawCmdDock().Unit::DoMiningRoute()command packet header (numUnits = 1, unit id inunitID[0]).Unit::DoDumpCargo()to issue aCommandType::DumpCargocommand packet instead of the rawCmdDumpCargo().Unit::DoTransferCargo()to issue aCommandType::TransferCargocommand packet instead of the rawCmdTransferCargo().