Skip to content

refactor(player): Use slot indices for player conversions - #3033

Open
CryoTheRenegade wants to merge 5 commits into
TheSuperHackers:mainfrom
CryoTheRenegade:refactor/player-index-to-slot-index
Open

refactor(player): Use slot indices for player conversions#3033
CryoTheRenegade wants to merge 5 commits into
TheSuperHackers:mainfrom
CryoTheRenegade:refactor/player-index-to-slot-index

Conversation

@CryoTheRenegade

@CryoTheRenegade CryoTheRenegade commented Jul 31, 2026

Copy link
Copy Markdown

Replaces the remaining player-index-to-slot-index reconstruction with PlayerList::getSlotIndex.
Update GameLogic::onLogicCrc, RecorderClass::handleCRCMessage, and VictoryConditions::update.

Related: #2897
Merge before #3034

@greptile-apps

greptile-apps Bot commented Jul 31, 2026

Copy link
Copy Markdown

Greptile Summary

Replaces ad hoc player-name reconstruction with the centralized player-index-to-slot-index mapping.

  • Uses slot indices for multiplayer CRC connectivity checks.
  • Uses slot indices when matching replay CRCs to the local player.
  • Uses slot indices when recording defeated AI players’ final frame in both game targets.

Confidence Score: 5/5

The PR appears safe to merge with no concrete correctness or security failures identified.

The changed paths consistently convert game-layer player indices through PlayerList’s slot mapping before consuming APIs and metadata expressed in the network-slot domain, while retaining invalid-slot and null guards.

Important Files Changed

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

@CryoTheRenegade CryoTheRenegade changed the title refactor(player): Use slot indices for player conversions (#2897) refactor(player): Use slot indices for player conversions Jul 31, 2026
@Skyaero42

Copy link
Copy Markdown

Is 2987 related, or does it actually resolve it? If it doesnt resolve it, what (part) of it does it solve?

@CryoTheRenegade

Copy link
Copy Markdown
Author

If you mean #2897, #3033 resolves part 1: the player-index-to-slot-index conversions in onLogicCrc, handleCRCMessage, and VictoryConditions::update. It does not cover part 2, the reverse slot-index-to-player lookups; #3034 handles those. #2987 itself is unrelated.

@CryoTheRenegade
CryoTheRenegade force-pushed the refactor/player-index-to-slot-index branch from 7623f98 to b2024a6 Compare August 4, 2026 17:36
@Skyaero42
Skyaero42 requested a review from Caball009 August 4, 2026 18:22

@xezon xezon left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code can be simplified more.

Comment thread Core/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp Outdated
Comment thread Generals/Code/GameEngine/Source/Common/Recorder.cpp Outdated
Comment thread Generals/Code/GameEngine/Source/GameLogic/ScriptEngine/VictoryConditions.cpp Outdated
@xezon xezon added Minor Severity: Minor < Major < Critical < Blocker Refactor Edits the code with insignificant behavior changes, is never user facing labels Aug 5, 2026
Comment thread Generals/Code/GameEngine/Source/Common/Recorder.cpp Outdated
Comment thread Generals/Code/GameEngine/Source/GameLogic/ScriptEngine/VictoryConditions.cpp Outdated
Comment thread Generals/Code/GameEngine/Source/Common/Recorder.cpp Outdated
Comment thread Generals/Code/GameEngine/Source/GameLogic/ScriptEngine/VictoryConditions.cpp Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Minor Severity: Minor < Major < Critical < Blocker Refactor Edits the code with insignificant behavior changes, is never user facing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants