refactor(player): Add slot-to-player lookup - #3034
Conversation
|
| Filename | Overview |
|---|---|
| Generals/Code/GameEngine/Source/Common/RTS/PlayerList.cpp | Adds a bounds-checked reverse slot lookup over the existing player-to-slot mapping. |
| GeneralsMD/Code/GameEngine/Source/Common/RTS/PlayerList.cpp | Mirrors the reverse lookup implementation for the independently built Zero Hour target. |
| Core/GameEngine/Source/GameNetwork/NetCommandMsg.cpp | Converts the command sender’s network slot into the corresponding internal player index. |
| Core/GameEngine/Source/GameNetwork/ConnectionManager.cpp | Resolves chat senders using the slot-index semantics of the command header. |
| Core/GameEngine/Source/GameNetwork/Network.cpp | Resolves destroy-player command targets from the slot value carried by the command-specific field. |
| Core/GameEngine/Source/GameNetwork/GameSpy/StagingRoomGameInfo.cpp | Generates results in lobby-slot order using the canonical reverse lookup. |
| Generals/Code/GameEngine/Source/GameNetwork/GameSpyGameInfo.cpp | Associates Generals result records with players through stable multiplayer slot mappings. |
| GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpyGameInfo.cpp | Applies the same slot-ordered result association to Zero Hour. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
Slot["Lobby / network slot index"] --> Lookup["PlayerList::getPlayerFromSlotIndex"]
Lookup --> Mapping["playerIndex → slotIndex mapping"]
Mapping --> Player["Player instance"]
Player --> Network["Network command ownership"]
Player --> Results["GameSpy results"]
Player --> UI["Chat, diplomacy, scores, observers"]
Reviews (1): Last reviewed commit: "refactor(player): Add slot-to-player loo..." | Re-trigger Greptile
|
It does not reference the correct issue. Can you explain in 2 lines what problem this PR is trying to resolve? |
Fixed
Player indices and multiplayer slot indices can differ, so reconstructing their relationship through "player%d" names can select the wrong player or slot. This change uses the stored PlayerList mapping for reliable conversions. |
Add
PlayerList::getPlayerFromSlotIndexfor reverse slot-to-player lookup.Replace synthetic
"player%d"associationsPreserve multiplayer slot ordering in result generation and UI paths.
Update the additional
GameSpyGameInfo::generateGameResultsPacketimplementationCloses #2897
Merge After #3033