Skip to content

Reimplement native multiplayer command selection and ordering - #221

Open
Krarilotus wants to merge 2 commits into
sourcehold:mainfrom
Krarilotus:reimplement/command-selection
Open

Krarilotus wants to merge 2 commits into
sourcehold:mainfrom
Krarilotus:reimplement/command-selection

Conversation

@Krarilotus

@Krarilotus Krarilotus commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

TL;DR: Reconstruct how the game chooses and orders queued multiplayer commands.

OpenSHC needs a C++ implementation of this existing native function as part of its reconstruction goal.

Changes: Implement GameSynchronyState::getCommandIDFromCommandSelectionStuff at 0x480440 with existing resolvers. Preserve the 100-command limit, player ordering, ring-end behavior and native failure cases.

Review / testing: MSVC 2005 SP1 DLL build and 941 comparison cases per variant were reported passing. Linked reccmp similarity is 64.89%; the status file records that partial match. Further matching work remains. This is reconstruction, not a change to multiplayer rules.

// Scan only the remaining physical ring entries. Wrapping and further
// batches belong to the caller; sorting here must not cross that boundary.
for (int slot = this->MBR_GameCommandID; slot < 200; ++slot) {
Commands::GameCommand& command = this->DAT_GameCommandArray[slot];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Try directly using the array access at the usage positions.
Creating temporaries creates other assembly and experience shows that pointer/reference temporaries were either rarely or not at all used in such contexts.

++pass;
swapped = 0;
for (int index = 1; index < static_cast<int>(this->MBR_someIndex); ++index) {
int* previous = this->MBR_SelectedGameCommands[index - 1];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same here, try without the local pointers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants