refactor(player): Use slot indices for player conversions - #3033
refactor(player): Use slot indices for player conversions#3033CryoTheRenegade wants to merge 1 commit into
Conversation
|
| Filename | Overview |
|---|---|
| Core/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp | Converts the CRC message sender’s player index to the network slot domain before checking connectivity. |
| Generals/Code/GameEngine/Source/Common/Recorder.cpp | Compares the converted sender slot with the replay header’s local slot instead of reconstructing player identity from a name key. |
| Generals/Code/GameEngine/Source/GameLogic/ScriptEngine/VictoryConditions.cpp | Resolves defeated AI players through PlayerList’s established slot mapping before updating slot metadata. |
| GeneralsMD/Code/GameEngine/Source/Common/Recorder.cpp | Mirrors the domain-correct replay CRC player-to-slot conversion for Zero Hour. |
| GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/VictoryConditions.cpp | Mirrors the defeated-AI slot lookup update for Zero Hour. |
Reviews (1): Last reviewed commit: "refactor(player): Use slot indices for p..." | Re-trigger Greptile
|
Is 2987 related, or does it actually resolve it? If it doesnt resolve it, what (part) of it does it solve? |
7623f98 to
b2024a6
Compare
| } | ||
| } | ||
| const Int slotIndex = msgPlayer->getPlayerType() == PLAYER_HUMAN | ||
| ? ThePlayerList->getSlotIndex(msgPlayer->getPlayerIndex()) |
There was a problem hiding this comment.
Can simplify by first returning false when player is not human.
| if (!p || (p->getPlayerNameKey() == NAMEKEY(playerName))) | ||
| samePlayer = TRUE; | ||
| const Int slotIndex = ThePlayerList->getSlotIndex(playerIndex); | ||
| const Bool samePlayer = !p || slotIndex == localPlayerIndex; |
There was a problem hiding this comment.
Cheaper condition:
if (!p || localPlayerIndex < 0 || ThePlayerList->getSlotIndex(playerIndex) == localPlayerIndex)
| for (Int idx = 0; idx < MAX_SLOTS; ++idx) | ||
| const Int slotIndex = ThePlayerList->getSlotIndex(p->getPlayerIndex()); | ||
| GameSlot *slot = TheGameInfo && slotIndex >= 0 ? TheGameInfo->getSlot(slotIndex) : nullptr; | ||
| if (slot && slot->isAI()) |
Replaces the remaining player-index-to-slot-index reconstruction with
PlayerList::getSlotIndex.Update
GameLogic::onLogicCrc,RecorderClass::handleCRCMessage, andVictoryConditions::update.Related: #2897
Merge before #3034