Skip to content

Reimplement 33 Synchrony::Commands functions at 100% - #415

Open
kotijekriv wants to merge 46 commits into
sourcehold:mainfrom
kotijekriv:reimpl/Synchrony-Commands-100
Open

kotijekriv wants to merge 46 commits into
sourcehold:mainfrom
kotijekriv:reimpl/Synchrony-Commands-100

Conversation

@kotijekriv

@kotijekriv kotijekriv commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

33 Synchrony::Commands functions at 100%, from gynt's drafts on his reimpl/Synchrony-Commands branch, with three small header commits they need. Pero asked on Discord to continue that branch, and gynt said to go ahead. Nine of the 33 were already 100% in gynt's own files, with stale status lines. They go in as his commits (author Gynt), unchanged except for small fixes that main's headers need in three of them, and each is followed by our style commit, which also sets the status line. The other 24 are finished from his drafts, with him as co-author. Wilps' versions on gynt's fork (reimpl/Wilps-2026-10-18, 8ca7861) already had forms the match needed in several of them, and those commits credit him. The draft scores below are gynt's, from his commit subjects. Each commit body also gives the draft's score on main's headers, and names the field renames main needed to build it.

Function Address Started from After
Commands::CommandSpawnEntity 0x004845B0 gynt's file, already 100% (461be14) 100.0%
Commands::SendPlayerToPlayerRequestOrResponse 0x00486140 gynt's file, already 100% (655eb2f) 100.0%
Commands::ResyncShortLayer 0x004840C0 gynt's file, already 100% (684e4f3) 100.0%
Commands::SendResyncIntLayer 0x0048A7C0 gynt's file, already 100% (c8d9db8) 100.0%
Commands::AnnounceTeamsAndPositions 0x00480BE0 gynt's file, already 100% (52aa702; it measured 97.5% on his branch) 100.0%
Commands::RemoveTowerSiegeEngine 0x00484B10 gynt's file, already 100% (d47a469) 100.0%
Commands::VoteKick_K_D_B_G_J 0x00485140 gynt's file, already 100% (42cfbd8) 100.0%
Commands::SendResyncUnknown 0x0048A510 gynt's file, already 100% (f2f2c13; it measured 92.7% on his branch) 100.0%
Commands::QueueChangeTaxes 0x00465700 gynt's file, already 100% (Wilps' body, ported by gynt in 6fa5eaa) 100.0%
Commands::CommandLoadMapHeader 0x00489C80 gynt's draft 96.2% (604e1bc) 100.0%
Commands::CommandChangeMapSelection 0x00483290 gynt's draft 95.3% (bcac165) 100.0%
Commands::ShareGameSeedAndMultiplayerSettingsAndStartGame 0x00480980 gynt's draft 93.9% (6c834c0) 100.0%
Commands::StartSendingMapFile 0x00485C10 gynt's draft 93.6% (b6a3f50) 100.0%
Commands::KickPlayerUnk 0x00484F30 gynt's draft 91.7% (227a8cd) 100.0%
Commands::ClickPlaceBuilding 0x00481D90 gynt's draft 91.7% (ebb7be7) 100.0%
Commands::AnnouncePlayerInformationSuchAsNameLordTypeAndAvailableAIVS 0x00480710 gynt's draft 91.4% (ca62515) 100.0%
Commands::AskForPlayerSlotAssignment 0x0048F870 gynt's draft 87.0% (5cfd575) 100.0%
Commands::StartReceivingMapFile 0x00485CC0 gynt's draft 81.4% (ed4a057) 100.0%
Commands::DestroyPlayer 0x0048A8A0 gynt's draft 79.7% (cf5944a) 100.0%
Commands::SendResyncCharLayer 0x00483A00 gynt's draft 76.8% (aeaf655) 100.0%
Commands::HostAnnounceRoundTable 0x00485F20 gynt's draft 76.4% (7c73f78) 100.0%
Commands::ShareMapHashForMapName 0x0048B6C0 gynt's draft 75.3% (ca943ba) 100.0%
Commands::SomePlayerNameUpdateCommand 0x00485380 gynt's draft 70.7% (e52878b) 100.0%
Commands::ShareQuitGameVote 0x0048B330 gynt's draft 69.2% (5153b24; 70.8% at c7021d2) 100.0%
Commands::ClickPlaceSiegeTent 0x004827E0 gynt's draft 68.2% (9997d6d) 100.0%
Commands::UpdateSkirmishGameMenuFaceBitmap 0x004863A0 gynt's draft 66.7% (c2eea52) 100.0%
Commands::ShareMapPart 0x0048B8F0 gynt's draft 66.7% (8f6faf1) 100.0%
Commands::SetUnitAssemblyPoint 0x00485830 gynt's draft 64.5% (fe31c33) 100.0%
Commands::SetPlayerNameUnk 0x00489AC0 gynt's draft 61.4% (5597d29) 100.0%
Commands::AutoSaveTriggered 0x00489880 gynt's draft 59.9% (7141365) 100.0%
Commands::ClickTauntOrChat 0x004895E0 gynt's draft 55.4% (a9a04a1) 100.0%
Commands::SubmitMSVMapIndexAndProperties 0x00489E30 gynt's draft 52.3% (82db2ef) 100.0% (see below)
Commands::CommandSwitchTeams 0x0048ACB0 gynt's draft 40.9% (73efa0f; 36.3% at 1030ebb) 100.0%, under /GL (see below)

SubmitMSVMapIndexAndProperties reads 99.5% raw and 100.0% normalised. Its frame is 0x17a0 bytes, so it calls the stack probe, and the one difference is that call's target name: call <OFFSET1> in the original, call _chkstk in ours. That is 100% by the call-target rule, as the review of #298 counted the same call (b5499a6), so its status line says 100.0%.

Measured.

  • Setup: the bundled MSVC1400-SP1 against the Steam Stronghold Crusader.exe (3bb0a8c1…5387ac5a), both resolver sets enabled locally (not committed), and sourcehold's reccmp with --resolve-wrapped-calls --ignore-security-cookie.
  • The 33 files built together on main 3458fea, with the two callees of CommandSwitchTeams and main's three /GL Synchrony files: 32 read 100.0% raw and normalised, and SubmitMSVMapIndexAndProperties 99.5% raw and 100.0% normalised. countPlayersInSameTeam, addChatMessageToDisplayList and receiveAllTransmittedCommands (on the /GL list already, and a caller of addChatMessageToDisplayList) read 100.0%.
  • Full build (all source files of main 3458fea with this branch at ca026fa, against a full build of main alone, every function resolver that has a .cpp switched on, each with its own compiler-flags-gl.txt): the 33 read as above. The main-alone build is of f489b72; 3458fea only adds files under tools/.
    • Of the 2,439 functions measured on main, 2,438 read exactly the same with this branch, and none read lower.
    • One read higher: UI::Rendering::DisplayMapDescriptionAndAllocatePlayersToSlots, from 94.8% to 100.0%. Main's status file already lists it at 100%. It uses neither new enum value and calls none of the 33. Its only difference on main is an eax/ecx swap in one add. Its file includes GameCommandType.hpp, so this looks like the symbol-count effect gynt found on Reimplement 88 Map::TileMapState functions at 100% #366, here in the good direction.
    • MapEditorLandscaping's GeneralButtons action handler doesn't compile on main since the last sync, so it was left out of both builds; Reimplement 88 Map::TileMapState functions at 100% #366 changes that file.
  • Checks: openshc-pr-fix finds nothing to change, and openshc-pr-check gives 0 ERROR and 41 CHECKs: the three header changes, and the ones explained below.
  • Not run in game.

What got them to 100%

Four forms come back again and again:

  • A lookup inside the call that uses it. The original calls the lookup in the middle of pushing the outer call's arguments, often after a constant such as 1000 or 250. So the map or player name's lookup is written inside the call that converts, copies or serializes it. This was the main step in CommandLoadMapHeader, CommandChangeMapSelection and ShareGameSeedAndMultiplayerSettingsAndStartGame, and one of the steps in eight more.
  • strcpy, strcat and wcslen in place of hand-written copy loops and searches for a string's end, because the original has them inline. ".map" and ".msv" are then the string macros. StartReceivingMapFile is the first file to include both string headers: ".map" is copied inline, while "wb" is pushed by its address (s_wb_005a5510).
  • One call in each branch, where the original pushes the other arguments first and picks one last: placeBuilding in ClickPlaceBuilding, addPlayerToCurrentPlayerArray in AskForPlayerSlotAssignment, processPlacementResourceLossForBuildingType in ClickPlaceSiegeTent, and three addChatMessageToDisplayList calls in ClickTauntOrChat. With the argument chosen before a single call, the compiler picks it first.
  • Faces on the ushort face pointer (bitmapsFaces_0x94 + (slot + 19) * 66 * 64, as drawBitmapFace indexes it) in place of byte sums through (int), in AskForPlayerSlotAssignment, UpdateSkirmishGameMenuFaceBitmap and SetPlayerNameUnk.

And per function:

  • StartSendingMapFile: the host's note of the answer is an if/else that stores 2 or 1. The draft's (hasMap != 0) + 1 adds in 16 bits now that main has the field as a short; the original adds in 32 bits.
  • KickPlayerUnk: one RemovePositionOfPlayer call after an if / else if, where the draft called it in each branch. The original pops the menu call's argument before the shared call.
  • ShareGameSeedAndMultiplayerSettingsAndStartGame: the map index is relative + scroll offset, because the original loads the relative selection first. quick_diff can't see the order; with scroll + relative, reccmp reads 98.0% (90.9% normalised).
  • HostAnnounceRoundTable: rewritten from the binary. The original keeps two bytes. One starts at 0 and becomes 1 when the round table is the active dialog, and that is what the host sends. The other receives the host's flag and is copied over the first before the tests.
  • ShareQuitGameVote: the eight votes are tested by a loop that clears a flag (the original has it unrolled), and the vote is stored through the local that holds the sender.
  • SetPlayerNameUnk and AutoSaveTriggered: the host's arm comes first, with its own deserialize call, because the original pushes the call's last three arguments before it tests isHost. In AutoSaveTriggered a client then returns early, where the original has a second epilogue.
  • SubmitMSVMapIndexAndProperties: the answer to the host (command 51) is written twice: once where the save doesn't exist, and once where its time or its units' hash differs. The compiler merges the two into the original's one copy, but the second copy makes it keep 0 in ebx for the whole function, as the original does.
  • ShareMapPart: the ending part returns. The file's end is tested first, with the tenth part in the else-if. The flag is cleared again in the ending part, and the length test is >= 0.
  • ClickTauntOrChat: the sender's range test comes first, and int receivers[9] = { 0 } is an array of its own, indexed by this machine's slot, with the taunt in an int before it.
  • SetUnitAssemblyPoint: no local for the unit category (parameter 0 in every index), and one int receives all three parameters.
  • ClickPlaceSiegeTent: the resource check's mapper starts as M_MAPPER_NULL, becomes the mangonel's or the ballista's, and the check runs when it isn't null. The compiler turns this into the original's jumps, so the draft's goto goes. The tiles are / 8.
  • DestroyPlayer: the first block returns. The first two stores read the slot from parameter 0 and the rest use the local, which gives the original's lea eax, [edx*4].
  • CommandSwitchTeams: three new lines in cmake/compiler-flags-gl.txt, for the file and its two callees that are finished on main, countPlayersInSameTeam and addChatMessageToDisplayList. The original keeps the flag and the constant 0 in one register (ebx) and tests the flag with test ebx, ebx. Under /GL the compiler does the same. Without it, the same source gets a zero register of its own and reads quick_diff 0.6609. The clears, counts and marks over the teams and slots are plain for loops that the compiler unrolls, where the draft wrote the copies out by hand. The search for the first empty team stays a loop, as in the original. The three kinds of request are separate ifs with early returns, in the original's order 0, 2, 1.

Behaviour fixed compared with the drafts

  • CommandChangeMapSelection, ShareGameSeedAndMultiplayerSettingsAndStartGame and SubmitMSVMapIndexAndProperties: the drafts read DAT_ArrayOfMapIndices[... - 1]. That was right on gynt's branch, where the array starts at 0x884 with 500 entries. On main it starts at 0x880 with 501, so the - 1 read the entry before the one the original reads. quick_diff can't see this; reccmp and the listing can.
  • HostAnnounceRoundTable: the byte the draft sent was never set. The original sends whether the round table is open.
  • ShareMapHashForMapName: a client whose copy of the map hashes differently only gets the quit dialog. The draft went on to queue the command that asks for the map file.
  • ShareMapPart: after the ending part (parameter 0 is -1), the draft went on to read the file and send a second part in the same command.
  • AutoSaveTriggered: the draft also stored the announcement time and cleared announcementReceivedBool on a client. The original does that on the host only.
  • ClickTauntOrChat: the draft had no range test for the sender (1 to 8). Its sound file name came from commandFunctions, which was that field's name on its branch. On main it is insultWavFiles.

Header changes (each in a commit of its own)

  • GCT_UNKNOWN_53 (52526f7), for SetPlayerNameUnk. 53 is queued in one place: 0x00489C50 push 0x35, then 0x00489C61 call 0x00489100 (queueCommand). A scan of the 215 calls to queueCommand finds no other immediate 53. queueCommand dispatches the type through the table at 0x00B38E10 (0x004891E7 mov edx, [ecx*4 + 0x00B38E10], call edx), and the receive paths at 0x0048017F, 0x0048034A and 0x0048041E index the same table. Entry 53, at 0x00B38EE4, is 0x00483850, Commands::SharePlayerName.
  • GCT_UNKNOWN_51 (7c54a03), for SubmitMSVMapIndexAndProperties. 51 is queued only at 0x0048A0B1 push 0x33, then 0x0048A0C3 call 0x00489100, in SubmitMSVMapIndexAndProperties itself. Entry 51 of the same table, at 0x00B38EDC, is 0x004834B0, Commands::ShareMSVMapIndex. Both names follow the enum's other unnamed values (GCT_UNKNOWN_33, _37, _40). Wilps' header on gynt's fork names the two values GCT_SHARE_MSV_MAP_INDEX and GCT_SHARE_PLAYER_NAME.
  • ProtocolDefinedData::insultWavFiles is char* [21] (d991122), not char** [21], for ClickTauntOrChat. The data at 0x00B38DBC is 21 plain char pointers: element 0 is NULL, and elements 1 to 20 point at "insult1.wav" (0x005A6E14) to "insult20.wav" (0x005A6D04). ClickTauntOrChat passes an element as the file name: 0x004897C1 mov ecx, [eax*4 + 0x00B38DBC], push ecx, then 0x004897D0 call 0x00478360 (resolveResourceFileName, whose parameter is a char const*). Nothing else on main uses the field.

Each sits just before the commit that uses it, and that code needs no cast. The declaration check will fail and label this PR until main has these lines. Then we merge main in, and the check passes.

Left out

Kept as they are, measured with quick_diff

Function Kept The cleaner form
CommandSpawnEntity readBuffer also receives the brazier's gold cost, as in the original a goldCost of its own (frame 12 bytes, the original's 8): 1.0000 -> 0.9592
CommandLoadMapHeader mapChecksum and wideMapName serve both halves one per half (frame 0x17b0 with _chkstk): 0.9519 -> 0.8134, with -s
CommandChangeMapSelection selectionIndex serves both halves; the map index is set in an if/else one per half (frame 0xfb4): 0.9302 -> 0.8372 with -s; int mapIndex = 0; and one if: 0.9884 -> 0.9357
KickPlayerUnk the AI slot tested before it is cleared a plain store: 0.9636 -> 0.8704
RemoveTowerSiegeEngine unitType as a UnitTypeShort an int (movsx and a 32-bit compare): 1.0000 -> 0.9630
ClickPlaceBuilding one placeBuilding call in each branch the player in a local, or a conditional in the arguments: 1.0000 -> 0.9250
AskForPlayerSlotAssignment the delay test as > -1 >= 0: 1.0000 -> 0.9852
HostAnnounceRoundTable the received flag copied over the first byte the tests reading the received byte: 1.0000 -> 0.9730
ShareQuitGameVote the vote stored through the sender's local the field read again: 1.0000 -> 0.9315
ClickTauntOrChat taunt reused for the insult's number, as the original reuses its stack slot a fresh local: 0.9449 -> 0.8385
SubmitMSVMapIndexAndProperties the answer to the host written in both places written once (a goto, an early return, a flag or one condition): 0.9920 -> 0.8248
SetUnitAssemblyPoint no local for the unit category a local (the store of x moves behind the building lookup): 1.0000 -> 0.9725
ClickPlaceSiegeTent the mapper starts as null and is set per engine an if/else under one condition: 0.9826; a ternary: 0.9623; two calls: 0.9769
DestroyPlayer the slot from parameter 0 in the first two stores, the local elsewhere the local everywhere: 0.8880; the parameter everywhere: 0.8854 (kept: 0.9880)

CommandSwitchTeams, measured with reccmp under /GL (100.0% as it is): canSwitch declared just above its test, or as one const expression there, reads 66.3%. teamCount declared just above its counting loop reads 97.1% for either of the two copies alone and 83.3% for both.

The kept forms that a reader might tidy away each have a one-line comment.

Buffer sizes from the original's frame: CommandLoadMapHeader's WCHAR wideMapName[1010] and char mapName[2008] (0xfc8 = 4 + 4 + 2020 + 2008 + 4 for the cookie). WCHAR wideMapName[1002] in ShareGameSeedAndMultiplayerSettingsAndStartGame (0x7d8 = 2004 + 4) and CommandChangeMapSelection (0x7dc = 4 + 2004 + 4). SubmitMSVMapIndexAndProperties' char[2008] and WCHAR[2006] (0x17a0 = 12 + 12 + 2008 + 4012 + 4). UpdateSkirmishGameMenuFaceBitmap declares slot, rowIndex and rowBytes[128] in the frame's order.

The checker's CHECKs

  • Locals declared without a value: each is filled through its address by the deserialize call (or getBuildingCost) right below it. mapChecksum, selectionIndex, mapHash and byteCount serve both halves of their function, as one stack slot does in the original.
  • Numeric case labels: the six message kinds of SendPlayerToPlayerRequestOrResponse, the layer numbers of ResyncShortLayer (1 to 9) and SendResyncCharLayer (10 to 28), and RemoveTowerSiegeEngine's 1 (an entity) and 2 (a unit). The headers have no enums for them, and main's senders of the message kinds write numbers too.
  • != TRUE and '\0': isSkirmishTrail in CommandChangeMapSelection and the chat line's flag in SomePlayerNameUpdateCommand, which the original compares with 1 (a comment line says so, as main's MenuItemActionHandler_InGameMenu_MainButtons does). The '\0's are string terminators stored into char arrays, in CommandChangeMapSelection and DestroyPlayer.
  • Casts on globals: ClickPlaceBuilding's (MappersEnum)(ushort)DAT_GameCommandParam2 is the original's 16-bit load (movzx). ClickPlaceSiegeTent's (int)DAT_GameCommandParam1 / 8 is its signed division (cdq), on a parameter the header has as undefined4.

Things the original does that look odd, kept

  • CommandLoadMapHeader sets DAT_CommandSize to 1008 (mov [0x194af98], 0x3f0), but serializes 2008 bytes. For a time-0 command, main's queueCommand hands DAT_CommandSize bytes to transmitCommand, so the checksum (offset 2000) and the index (offset 2004) may never reach the client. We haven't read transmitCommand, so this is as far as the evidence goes.
  • AnnounceTeamsAndPositions reads the AI type and the AI variation into the receiver's own slot (currentPlayerSlotID, at 0x00480CFD and 0x00480D1A), not the sender's. It looks like a bug of the original.
  • SetPlayerNameUnk and AutoSaveTriggered convert the name into shortMapName with a size of 1000, but the field has 120 bytes.
  • CommandSwitchTeams counts the players per team number in teamCounts, but its two count tests index that array with a player's slot: the sender's at 0x0048AE68 and parameter 0's at 0x0048B0F5. That is only right while a player's team number equals its slot number. The draft has it too.

What some placeholders hold

  • unknownMapName_01: on a client, the map's name without ".map" (ShareMapHashForMapName).
  • SEC_TileMap1104 and SEC_PathfindingCostTileMap1105[9]: resynced as layers 18 and 20 to 28 by SendResyncCharLayer.
  • playerNames2 and DAT_CurrentPlayerFullIDArray2: second copies of the players' names and IDs. Faces 28 to 35 are a second copy of the players' faces 20 to 27 (SetPlayerNameUnk).
  • mapSendingByteBufferAddress: the bytes sent or received per slot (Wilps: mapBytesTransferredPerSlot).
  • ClickTauntOrChat's taunt: 10000 is a message without a sender, a negative taunt is insult -1 - taunt for the player in parameter 0, a positive one is an insult from the sender, and 0 is typed text.

Proposed, not changed here

  • SetPlayerNameUnk's name looks wrong. It is command 40 (table entry 40 is 0x00489AC0), and MenuItemActionHandler_SaveLoadMap_Buttons copies the chosen map's name into shortMapName before it queues 40. So the command shares the map's name, which setSessionDescription then uses.
  • syncedStateBase is an int at 0x194 of MapAndTimeState, but SendResyncUnknown's parts run from there to exactly the end of the struct (0x194 + 18 * 14566 + 16 = 262608 = sizeof(MapAndTimeState)). A sub-struct would explain its (char*)&syncedStateBase + part * 14566. After those parts it resyncs the AIV state's map info (816 bytes), so a better name for SendResyncUnknown could say both.
  • MemCopyFromParameter's third parameter is named playerID, but both callers pass a part or chunk number, and it only feeds the "ID:%d" of the function's mismatch message. Its destination could be void*, so SendResyncIntLayer's (char*) cast would go.
  • DAT_GameCommandParam1 and protocolInvokerPlayerID as int, not undefined4 (parameter 0 is an int already). A retype touches every user on main, so it is left for the header sync.
  • BOOLEnum candidates, only ever 0 or 1 and tested by truth: lobbyStateReceived, announcementReceivedByPlayer, saveRelated and shouldSendAnnouncementUnk.
  • Enums: the six player-to-player message kinds, named after their handlers (ally request attack/defence, ally requesting goods, ally goods request, deny, accept, deny 2); the nine resync layers (1 random, 2 walk, 3 organism, 4 building, 5 unit, 6 entity, 7 certain path, 8 path connection, 9 macro); DTET_NONE = 0 in DefensiveTowerEngineType; the refund codes -1 to -4 of giveBackResourceForDestroyedBuilding (-3 a tower mangonel, -4 a tower ballista); quitGameVoteRelated (0, 2) and DAT_MapFileReceivingState.
  • The assembly point arrays: SetUnitAssemblyPoint indexes barracksAssemblyPoints[7], mercenaryAssemblyPoints[7] and specialBuildingAssemblyPoints[5] with categories up to 9, as the original does. The arrays may be longer, or one array of points: the original works out all three from one base.

Other PRs

🤖 Generated with Claude Code

gynt and others added 30 commits November 17, 2026 04:30
CommandSpawnEntity, gynt's version as it stands on reimpl/Synchrony-Commands (upstream ca943ba and his fork's
6fa5eaa), where the status line still reads 73.5% (Style pass, asm differs): the file was last changed in his
461be14 ("reimplement: SHC_3BB0A8C1_0x004845B0 100.0% Reimplemented", 2026-10-03), which left the status line of
3b215e1 in place. Taken unchanged; it compiles on main's headers as it is. With both resolver sets on it reads
reccmp 100.0 (normalized 100.0). What main's style rules need on top follows in our own commit, which also sets the
status line.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
On top of gynt's version in the commit before; the code is the same, reccmp 100.0 (normalized 100.0) and quick_diff
147/147 at 1.0000 before and after.

- The first include is ../Commands.func.hpp, once; the using lines and the imported block comments are gone.
- The execute half is an early return, and entityID is declared where it gets its value.
- local_8 is `readBuffer`: the buffer each parameter is read into. It also receives the brazier's gold cost, as in
  gynt's version and in the original: a `goldCost` of its own makes the frame 12 bytes where the original has 8
  (quick_diff 0.9592). local_4 is `stoneCost`.
- The doubled `(int)((int)(...))` casts on the six parameters are gone, and the narrowing casts are `(char)` and
  `(short)` alone.

The status line goes to 100.0% (Reimplemented) with this commit.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
SendPlayerToPlayerRequestOrResponse, gynt's version as it stands on reimpl/Synchrony-Commands (upstream ca943ba
and his fork's 6fa5eaa), where the status line still reads 70.8% (Style pass, asm differs): the file was last
changed in his 655eb2f ("reimplement: SHC_3BB0A8C1_0x00486140 100.0% Reimplemented", 2026-10-03), which left the
status line of ffed63e in place. Taken unchanged; it compiles on main's headers as it is. With both resolver sets
on it reads reccmp 100.0 (normalized 100.0). What main's style rules need on top follows in our own commit, which
also sets the status line.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…tyle guide

On top of gynt's version in the commit before; the code is the same, reccmp 100.0 (normalized 100.0) and quick_diff
136/136 at 1.0000 before and after.

- The first include is ../Commands.func.hpp, once; the using lines and the imported block comments are gone.
- The execute half is an early return, and the switch cases end in break.
- `short local_4[2]` is `short messageKind`, read straight into DAT_GameCommandParam0 with no cast.
- The doubled `(int)((int)(...))` casts on the parameters are gone, and the command size is decimal.

The six message kinds stay numbers: the headers have no enum for them, and main's two senders (Allies and
AlliesOrder) write numbers too.

The status line goes to 100.0% (Reimplemented) with this commit.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
CommandLoadMapHeader, from gynt's draft on reimpl/Synchrony-Commands (604e1bc, 96.2% there; the file was last
changed in 4242ae2, "Synchrony/Commands: drop the hand-written /GS cookie"). reccmp 100.0 (normalized 100.0).
quick_diff 104/104 at 0.9904 (the draft: 0.9808 on main's headers); the rest is the /GS cookie load, which reccmp is
told to ignore.

What the match needed: the map name lookup is written inside the call that converts it,
multiByteToWideCharWithSize(wideMapName, mapNames_getLoadedMapNameForIndex(...), 1000). The original pushes the 1000
before it calls the lookup; with the name in a local first, as in the draft, the 1000 is pushed after the call. The
checksum's lookup is nested the same way. Wilps' version on gynt's fork (reimpl/Wilps-2026-10-18, 8ca7861,
2026-10-27) already nests the first lookup like this.

The buffers' sizes are the original's frame: 0xfc8 = 4 (checksum) + 4 (index) + 2020 (WCHAR[1010]) + 2008
(char[2008]) + 4 (cookie). mapChecksum and wideMapName serve both halves: with one local per half the frame grows to
0x17b0 and gets a _chkstk call (quick_diff -s 0.8134 with 105 instructions, against 0.9519 with 104). mapIndex and
mapName are declared where they are first filled.

DAT_CommandSize keeps the original's 1008 (the three parameters take 2008 bytes); its comment says the value is the
original's.

Style: the first include is ../Commands.func.hpp, the using lines and block comments are gone, the execute half is an
early return, and the locals have names (mapChecksum, mapIndex, wideMapName, mapName).

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
StartSendingMapFile, from gynt's draft on reimpl/Synchrony-Commands (cf8d0fd and c48c8e6 at 80.5%, b6a3f50 at
93.6%, his newest commit on the file; the branch's status line reads 80.5%). reccmp 100.0 (normalized 100.0),
quick_diff 46/46 at 1.0000 (the draft: 0.9783 on main's headers).

On main the draft needed one rename to compile: field282_0x109d98 is mapTransferStatePerPlayer. The name is gynt's,
from his 51126b7 ("names: four GameSynchronyState lobby and map-transfer fields", 2026-10-05); main has it since
the Ghidra sync b734082 (sourcehold#260).

What the match needed: the host's note of the answer is an if/else that stores 2 or 1. The draft's
`(local_1 != 0) + 1` is added in 16 bits now that the field is a short (add dx, 1); the original adds in 32 bits
(add edx, 1) and stores dx, which is what the if/else compiles to.

Style: the first include is ../Commands.func.hpp, the using lines and block comments are gone, the execute half is an
early return, local_1 is `hasMap`, hasMap and isHost are tested by truth and the loop bound is countof().

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
KickPlayerUnk, from gynt's draft on reimpl/Synchrony-Commands (5760220 at 86.2%, 227a8cd at 91.7%, his newest
commit on the file). reccmp 100.0 (normalized 100.0). quick_diff 55/55 at 0.9636 (the draft: 54 instructions at
0.8991 on main's headers); the rest is the timeGetTime import call, which reccmp resolves, and quick_diff reading
the sound flags as an address.

What the match needed:
- One RemovePositionOfPlayer call after an if / else if, where the draft had the call in each branch with a return
  between them. The original pops the menu call's argument before the shared call (add esp, 4 ... pop ecx), and
  keeps the player in eax on both paths; two calls in the source give one add esp, 8 and the player in ecx.
- getFileNameOfCurrentActiveResource is called inside playSoundOnStream3Unk's argument list, so the flags are pushed
  before the call, as in the original. Wilps' version on gynt's fork (reimpl/Wilps-2026-10-18, 8ca7861,
  2026-10-27) already nests it like this.

The AI slot is tested before it is cleared: a plain store measures quick_diff 0.8704 with 53 instructions.

Style: the first include is ../Commands.func.hpp, the using lines and block comments are gone, the execute half is an
early return, "insult1.wav" is s_insult1_wav_005a6e14, the sound flags are the three FLAG_SOUND_* names | 1 (as in
main's playVideoOverMap) and 0x16 is 22.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
ResyncShortLayer, gynt's version as it stands on upstream's reimpl/Synchrony-Commands (ca943ba), where the status
line still reads 52.8% (Style pass, asm differs): the file was last changed in his 684e4f3 ("reimplement:
SHC_3BB0A8C1_0x004840C0 100.0% Reimplemented", 2026-10-03), which left the status line of 8f145c3 in place. His
fork's branch (6fa5eaa) has the file of 5d76887, one commit older. Taken unchanged; it compiles on main's
headers as it is. With both resolver sets on it reads reccmp 100.0 (normalized 100.0). What main's style rules need
on top follows in our own commit, which also sets the status line.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
On top of gynt's version in the commit before; the code is the same, reccmp 100.0 (normalized 100.0) and quick_diff
186/186 at 1.0000 before and after.

- The first include is ../Commands.func.hpp, once; the using lines and the imported block comments are gone.
- The execute half is an early return (wrong action plan, or the host), and the switch cases end in break.
- Each layer's chunk is `&layer[chunk * 1256]` in place of `layer + chunk * 0x4e8`, and the sizes are decimal
  (2512 for both `0x9d0` and `(size_t)((int)(2512))`).

The nine layer numbers stay numbers: the headers have no enum for them.

The status line goes to 100.0% (Reimplemented) with this commit.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
SendResyncIntLayer, gynt's version as it stands on upstream's reimpl/Synchrony-Commands (ca943ba), where the
status line still reads 87.5% (Style pass, asm differs): the file was last changed in his c8d9db8 ("reimplement:
SHC_3BB0A8C1_0x0048A7C0 100.0% Reimplemented", 2026-10-03), which left the status line of 9675ea5 in place. His
fork's branch (6fa5eaa) has the older file. Taken unchanged; it compiles on main's headers as it is. With both
resolver sets on it reads reccmp 100.0 (normalized 100.0). What main's style rules need on top follows in our own
commit, which also sets the status line.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
On top of gynt's version in the commit before; the code is the same, reccmp 100.0 (normalized 100.0) and quick_diff
55/55 at 1.0000 before and after.

- The first include is ../Commands.func.hpp, once; the using lines and the imported block comments are gone.
- The execute half is an early return (wrong action plan, or the host).
- The chunk is `&LogicLayer[chunk * 628]` in place of `LogicLayer + chunk * 0x274`, the size is 2512 and
  layerOffset is `int const chunkStart`.

The status line goes to 100.0% (Reimplemented) with this commit.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
AnnounceTeamsAndPositions, gynt's version as it stands on upstream's reimpl/Synchrony-Commands (ca943ba), where
the status line still reads 80.7% (Style pass, asm differs): the file was last changed in his 52aa702
("reimplement: SHC_3BB0A8C1_0x00480BE0 97.5% Reimplemented", 2026-10-03), which made the nine team bytes a memcpy
and left the status line of eb34b1d in place. The file also carries his 9bf755f ("reimplement:
SHC_3BB0A8C1_0x0048A2E0 86.6% Reimplemented", whose body is about this function: it restored the single 9-byte
buffer). His fork's branch (6fa5eaa) has the older file. Taken unchanged; it compiles on main's headers as it is.
With both resolver sets on it now reads reccmp 100.0 (normalized 100.0), where his commit measured 97.5. What main's
style rules need on top follows in our own commit, which also sets the status line.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
On top of gynt's version in the commit before; the code is the same, reccmp 100.0 (normalized 100.0) and quick_diff
121/121 at 0.9917 before and after (the rest is the /GS cookie load, which reccmp is told to ignore).

- The first include is ../Commands.func.hpp, once; the using lines and the imported block comments are gone.
- The execute half is an early return, and the sender test is `< 1 || > 8` in place of `- 1U <= 7`.
- The slot values are `&array[slot]` in place of `array + slot`, and every size in the file is sizeof() of what is
  read or written.
- `_isHost` is `BOOLEnum senderIsHost`, tested by truth; `byte local_10[9]` is `char receivedGroups[9]`, the type of
  DAT_PlayerGroupArray. Both are declared where they are filled.

The status line goes to 100.0% (Reimplemented) with this commit.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
ShareGameSeedAndMultiplayerSettingsAndStartGame, from gynt's draft on reimpl/Synchrony-Commands (6c834c0, 93.9%
there; the file was last changed in 4242ae2, "Synchrony/Commands: drop the hand-written /GS cookie"). On main's
headers the draft reads reccmp 96.9 (normalized 88.5), and now 100.0 (normalized 100.0). quick_diff 98/98 at 0.9898
(the draft: 0.9592); the rest is the /GS cookie load, which reccmp is told to ignore.

What the match needed:
- The map name lookup is written inside the call that converts it, so the 1000 is pushed before the lookup is
  called, as in the original.
- The map index is `relative + scroll offset`: the original loads the relative selection first. quick_diff can't
  see this (both are globals to it); the compiler's listing and reccmp can.
  With scroll + relative reccmp reads 98.0 (normalized 90.9); a comment line keeps the order from being "fixed".

Fix against the draft on main's headers: the draft read DAT_ArrayOfMapIndices[scroll + relative - 1]. Its branch
has the array at 0x884 with 500 entries; main has it at 0x880 with 501, so on main the `- 1` reads the entry before
the one the original reads (the original's address is the array's start plus the sum).

Wilps' version on gynt's fork (reimpl/Wilps-2026-10-18, 8ca7861, 2026-10-27) already nests the lookup and indexes
the list without the `- 1` (his header has it at 0x880); his sum is scroll + relative.

Style: the first include is ../Commands.func.hpp, the using lines and block comments are gone, the execute half is an
early return, and local_7d8 is wideMapName.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
CommandChangeMapSelection, from gynt's draft on reimpl/Synchrony-Commands (3e3269d at 93.0%, bcac165 at 95.3%,
his newest commit on the file). On main's headers the draft reads reccmp 93.0 (normalized 85.4), and now 100.0
(normalized 100.0). quick_diff 86/86 at 0.9884 (the draft: 0.9535); the rest is the /GS cookie load, which reccmp
is told to ignore.

What the match needed: the map name lookup is written inside the call that converts it, so the 1000 is pushed
before the map index and the lookup's call, as in the original. The map index keeps its if/else and its local: with
`int mapIndex = 0;` and one if, quick_diff reads 0.9357 with 85 instructions.

Fix against the draft on main's headers: the draft read DAT_ArrayOfMapIndices[selectionIndex - 1]. Its branch has
the array at 0x884 with 500 entries; main has it at 0x880 with 501, so on main the `- 1` reads the entry before the
one the original reads. Wilps' version on gynt's fork (reimpl/Wilps-2026-10-18, 8ca7861, 2026-10-27) indexes the
list without the `- 1` too (his header has it at 0x880); it keeps the lookup in a local.

Style: the first include is ../Commands.func.hpp, the using lines and block comments are gone, the execute half is an
early return, _mapName is wideMapName and the command size is decimal. isSkirmishTrail is compared with TRUE, as the
original compares it with 1 (main does the same in MenuItemActionHandler_InGameMenu_MainButtons).

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
RemoveTowerSiegeEngine, gynt's version as it stands on upstream's reimpl/Synchrony-Commands (ca943ba), where the
status line still reads 75.0% (Style pass, asm differs): the file was last changed in his d47a469 ("reimplement:
SHC_3BB0A8C1_0x00484B10 100.0% Reimplemented", 2026-10-03), which left the status line in place. His fork's branch
(6fa5eaa) has the older file. One change so that it builds on main: Building::containsSiegeMangonel1OrBallista2 is
defensiveTowerEngineType there (two lines); nothing else changed. With both resolver sets on it reads reccmp 100.0
(normalized 100.0). What main's style rules need on top follows in our own commit, which also sets the status line.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
On top of gynt's version in the commit before; the code is the same, reccmp 100.0 (normalized 100.0) and quick_diff
81/81 at 1.0000 before and after.

- The first include is ../Commands.func.hpp, once; the using lines and the imported block comments are gone.
- The switch cases end in break, and the doubled `(int)((int)(...))` casts are gone.
- Names: `short local_4[2]` is `short readBuffer`, `_entity` is `id` (a unit's or an entity's, by the kind),
  `iVar2` is `buildingID` and `UVar1` is `unitType`, each declared where it gets its value. unitType stays a
  UnitTypeShort: as an int it is loaded with movsx and compared in 32 bits, where the original compares cx
  (quick_diff 0.9630).
- A comment line names the two refund codes, -3 for a tower mangonel and -4 for a tower ballista.

The engine field is cleared with 0: DefensiveTowerEngineType has names for the mangonel (1) and the ballista (2) only.

The status line goes to 100.0% (Reimplemented) with this commit.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
VoteKick_K_D_B_G_J, gynt's version as it stands on upstream's reimpl/Synchrony-Commands (ca943ba), where the
status line still reads 52.8% (Style pass, asm differs): the file was last changed in his 42cfbd8 ("reimplement:
SHC_3BB0A8C1_0x00485140 100.0% Reimplemented", 2026-10-03), which left the status line in place. His fork's branch
(6fa5eaa) has the older file. One change so that it builds on main: GameSynchronyState::DPLAYX_4A is an
IDirectPlay4* there, so the test against `(IDirectPlay4A**)0x0` is a test against NULL (one line); nothing else
changed. With both resolver sets on it reads reccmp 100.0 (normalized 100.0). What main's style rules need on top
follows in our own commit, which also sets the status line.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
On top of gynt's version in the commit before; the code is the same, reccmp 100.0 (normalized 100.0) and quick_diff
50/50 at 0.9800 before and after (the rest is the call through the DirectPlay interface, which quick_diff reads as a
direct call on our side).

- The first include is ../Commands.func.hpp, once; the using lines and the imported block comments are gone.
- The execute half is an early return.
- CancelMessage is called on DPLAYX_4A as it is typed on main, with no cast, as disconnectDPlay does.
- 0x16 is 22.

The status line goes to 100.0% (Reimplemented) with this commit.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
SendResyncUnknown, gynt's version as it stands on upstream's reimpl/Synchrony-Commands (ca943ba), where the status
line still reads 75.9% (Style pass, asm differs): the file was last changed in his f2f2c13 ("reimplement:
SHC_3BB0A8C1_0x0048A510 92.7% Reimplemented", 2026-10-03), which left the status line in place. His fork's branch
(6fa5eaa) has the older file. One change so that it builds on main: MapAndTimeState::field192_0x194 is
syncedStateBase there (three lines); nothing else changed. With both resolver sets on it now reads reccmp 100.0
(normalized 100.0), where his commit measured 92.7. What main's style rules need on top follows in our own commit,
which also sets the status line.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
On top of gynt's version in the commit before; the code is the same, reccmp 100.0 (normalized 100.0) and quick_diff
123/123 at 0.9919 before and after (the rest is the /GS cookie load, which reccmp is told to ignore).

- The first include is ../Commands.func.hpp, once; the using lines and the imported block comments are gone.
- The execute half is an early return (wrong action plan, or the host), and the three kinds of part are one
  if / else if chain in each half.
- Each part's address is `(char*)&mapAndTime.syncedStateBase + part * 14566`, in place of the sum through `(int)`.
  Part 18 is written the same way in both halves; the sending half had `startingTroops[7] + 0x10` for the same
  address, and the compiler folds the sum to it there, since the part is known to be 18.
- The sizes are decimal, and the AIV map info's is sizeof().
- "Glob %d" is s_Glob__d_005a74a0, local_3ec is partName, and the offsets in the text are
  `part * 14566 + offsetof(MapAndTimeState, syncedStateBase)` in place of `0x194` and `0x401c0`.
- Part 19 passes the part number in place of the literal 0x13 (the same code: the compiler knows it is 19 there).

The status line goes to 100.0% (Reimplemented) with this commit.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
QueueChangeTaxes, as it stands on gynt's fork's reimpl/Synchrony-Commands at 6fa5eaa ("Adopt the Wilps
implementations that measure better here (sourcehold#20)", 2026-11-02). The body is Wilps's, from gynt's fork's
reimpl/Wilps-2026-10-18 (8ca7861): gynt ported it over his own draft of 60ff6eb, which upstream's branch still
has, and measured it at quick_diff 0.9231 on that branch's headers; the status line there reads 0.0% (Pending, not
matched by reccmp). Taken unchanged; it compiles on main's headers as it is. With both resolver sets on it reads
reccmp 100.0 (normalized 100.0). What main's style rules need on top follows in our own commit, which also sets the
status line.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
On top of Wilps's body in the commit before; the code is the same, reccmp 100.0 (normalized 100.0) and quick_diff
39/39 at 0.9487 before and after (the rest is the timeGetTime import call and the tail jump into
SetTutorialHintActiveWithTimestamp, both of which reccmp resolves).

- The first include is ../Commands.func.hpp, once; the using lines and the block comment above the function are
  gone.
- An unchanged slider is an early return, and the slider is read from its field where it is used.
- The refused tutorial change is tested by truth (`!Tutorial_IsActionAllowed(...)`), and 0xd is 13.

Two things in Wilps's body carry the match, and both stay: the return after the tutorial hint (the original jumps
into the hint function and ends there), and the player data indexed through currentPlayerSlotID each time, with no
slot local (with one, the slider is read once after timeGetTime where the original reads it twice).

The status line goes to 100.0% (Reimplemented) with this commit.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
ClickPlaceBuilding, from gynt's draft on upstream's reimpl/Synchrony-Commands (ebb7be7, 91.7% there, his newest
commit on the file; the status line reads 89.6%). On main's headers the draft reads reccmp 91.7 (normalized 65.5),
and now 100.0 (normalized 100.0). quick_diff 120/120 at 1.0000 (the draft: 0.9250).

On main the draft needed one rename to compile: field299_0x109e7c is editorPlacementPlayerID.

What the match needed: one placeBuilding call in each branch of the map editor test, the editor's chosen player in
one and the command's sender in the other. The original pushes the five other arguments first and picks the player
last. With the player in a local chosen before a single call (the draft), or as a conditional inside the call's
arguments, the compiler picks the player first and pushes afterwards (quick_diff 0.9250 for both).

Style: the first include is ../Commands.func.hpp, the using lines and block comments are gone, the execute half is an
early return, the resource check is tested by truth in place of `(iVar1 = ..., iVar1 == 0)`, and the doubled
brackets around the arguments are gone.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
AnnouncePlayerInformationSuchAsNameLordTypeAndAvailableAIVS, from gynt's draft on upstream's
reimpl/Synchrony-Commands (2d091b7 and ca62515 at 91.4%; the file was last changed in 4242ae2,
"Synchrony/Commands: drop the hand-written /GS cookie"). On main's headers the draft reads reccmp 93.3 (normalized
80.4), and now 100.0 (normalized 100.0). quick_diff 162/162 at 0.9938 (the draft: 0.9321); the rest is the /GS
cookie load, which reccmp is told to ignore.

What the match needed:
- The three copy loops over pointers are strcpy calls: the sender's name into the final results, this machine's own
  name into its slot, and that name into the final results. The first loop then gets the original's form, one
  pointer and the distance between the two strings.
- The own name's lookup is written inside the call that converts it, so the 250 is pushed before the lookup is
  called. Wilps's version on gynt's fork (reimpl/Wilps-2026-10-18, 8ca7861, 2026-10-27) already nests it; his
  copies are loops.

Style: the strcpy pragma, the first include is ../Commands.func.hpp, the using lines and block comments are gone,
the execute half and the empty sender slot are early returns, the locals have names (senderSlot, lordIcon, lordType,
wideName) and are declared where they are filled, the scalar and AIV list sizes are sizeof(), the text array index
is TAIT_ZERO, and the host test is by truth after the two lord stores.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
AskForPlayerSlotAssignment, from gynt's draft on upstream's reimpl/Synchrony-Commands (c8da6f2 at 52.6%, 864e522
at 53.9%, 5cfd575 at 87.0%, his newest commit on the file; the status line reads 53.9%). On main's headers the
draft reads reccmp 87.0 (normalized 71.5), and now 100.0 (normalized 100.0). quick_diff 135/135 at 1.0000 (the
draft: 134 instructions at 0.8848).

On main the draft needed one rename to compile: TextureRenderCore's field69_0x98 is bitmapFaceSizes.

What the match needed:
- One addPlayerToCurrentPlayerArray call in each branch of the single player test, with 1 in one and the received
  player ID in the other. The original pushes the argument in each branch and shares the call; with the argument in
  a local chosen before one call the compiler picks it first.
- The face copies are written on the ushort pointer, `bitmapsFaces_0x94 + (slot + 19) * 66 * 64`, as drawBitmapFace
  indexes it, in place of byte sums through `(int)`. The original loads the lord icon first and forms `icon - 2`
  with lea; the sums through int load in another order.
- The delay test is `> -1` (cmp -1 / jle), not `>= 0`.

gynt's 6cbbfc2 on his fork's reimpl/UI-MenuItems-development (2026-11-02, "flip 3 comparisons in Synchrony")
writes the delay test as `-delay > 1`. That is another test (delay < -1), so it is not taken.

Style: the first include is ../Commands.func.hpp, the using lines and block comments are gone, the execute half,
the solitary game and the client are early returns, the eight stores of -1 are a loop over the ID array (slot 1
gets its 1 after it; the same code), `_commandOriginPlayer` is senderSlot, and the face size is a FACE_SIZE
constant (66 * 64 * 2, as setBMPFacesToMagenta has it) in place of 0x2100, with FACE_HEIGHT and FACE_WIDTH for the
66 and 64 of the pixel offsets.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
HostAnnounceRoundTable, rewritten from the binary. Wilps's version on gynt's fork (reimpl/Wilps-2026-10-18,
8ca7861, 2026-10-27) is the same function. gynt's draft on upstream's reimpl/Synchrony-Commands (eacec5f, then
7c73f78 at 76.4%, "Return recovered, merged slot differs"; the status line reads 0.0%) reads reccmp 76.4
(normalized 76.4) on main's headers, and this 100.0 (normalized 100.0). quick_diff 75/75 at 1.0000 (the draft: 72
instructions at 0.8299). The file is named after the function now (HostAnnounceRoundTable.cpp; the draft's was
HostAnnounceRoundtable.cpp).

The original keeps two bytes on the stack:
- roundTableOpen starts at 0 and becomes 1 when this machine's active dialog is the round table; the sending half
  serializes it and returns.
- The receiving half reads the host's flag into a second byte and copies it over the first, which the tests then
  read (reading the second byte loses the match: quick_diff 0.9730 with 73 instructions). For the host or in the
  lobby menu: with no dialog open and the flag set, the round table opens; with no dialog open and the flag clear,
  nothing more happens; and a clear flag closes an open round table.

Fix against the draft (7c73f78): the byte it sent, `local_2`, was never set. The draft read an incoming ecx, which
the function doesn't have, into the byte the receiving half deserializes into, so that read had no effect. It
already returned on a clear flag with no dialog open; only the earlier eacec5f opened the round table regardless.

Style: the first include is ../Commands.func.hpp, sizes are sizeof(), the tests are early returns.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
StartReceivingMapFile, from gynt's draft on upstream's reimpl/Synchrony-Commands (70b9f63 at 76.1%, ed4a057 at
81.4%, his newest commit on that branch's file; the status line reads 76.1%). His other branches carry an older
form, 46b7c94 at 70.37%. On main's headers the draft reads reccmp 84.1
(normalized 79.8), and now 100.0 (normalized 100.0). quick_diff 111/111 at 0.9910 (the draft: 0.8288); the rest is
the /GS cookie load, which reccmp is told to ignore.

What the match needed:
- The map name lookup is written inside the first serialize call, so the size and the two flags are pushed before
  the lookup is called.
- The name's copy and the two searches for its end are strcpy and strcat, with ".map" as the macro S__MAP_005A2294,
  because the original copies it inline (as main's MenuItemActionHandler_SendReceiveMap_Main does).

Wilps's version on gynt's fork (reimpl/Wilps-2026-10-18, 8ca7861, 2026-10-27) already has all three: the nested
lookup, strcpy and strcat.

Style: the strcpy pragma, the first include is ../Commands.func.hpp, the using lines and block comments are gone,
the execute half and the host are early returns, "wb" is s_wb_005a5510, and the file name is a `char* const` where
the original keeps it (it is fetched before "wb" is pushed).

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
ShareQuitGameVote, from gynt's draft on upstream's reimpl/Synchrony-Commands (c7021d2 at 70.8%, 5153b24 at
69.2%, "Dropped return recovered, asm form differs", his newest commit on the file; the status line reads 70.8%).
On main's headers the draft reads reccmp 69.2 (normalized 58.6), and now 100.0 (normalized 100.0). quick_diff
109/109 at 1.0000 (the draft: 100 instructions at 0.7656).

On main the draft needed one rename to compile: field122_0xc70 is quitGameVoteArray.

What the match needed:
- The test of the eight votes is a loop that clears a flag for every slot that hasn't voted yes, then one test of
  the flag. The original has it unrolled (`mov eax, 1`, then `xor eax, eax` after each failed test); the draft's
  chain of eight `&&` jumps out at the first no.
- The vote is stored at `quitGameVoteArray[voter]`, with the local that holds the sender: the original indexes with
  the register it keeps the sender in (0.9315 with the field read again).
- The two message copies are strcpy calls.

Wilps's version on gynt's fork (reimpl/Wilps-2026-10-18, 8ca7861, 2026-10-27) already has all three: the loop over
the slots, the vote stored through the local, and the two strcpy calls.

Style: the strcpy pragma, the first include is ../Commands.func.hpp, the using lines and block comments are gone,
the execute half is an early return, subjectPlayerID is `voter`, the text numbers are decimal with the text above
them ("No", "Yes"), and the loop bound is countof().

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
ShareMapHashForMapName, from gynt's draft on upstream's reimpl/Synchrony-Commands (97bf40d at 73.4%, ca943ba at
75.3%, his newest commit on that branch's file; the status line reads 70.5%). His other branches carry an older
form, 3d9f30d at 68.44%. On main's headers the draft reads reccmp 78.1
(normalized 77.8), and now 100.0 (normalized 100.0). quick_diff 141/143 at 0.9789 (the draft: 138 at 0.8470); the
rest is the /GS cookie load and two alignment jumps the listing doesn't show.

On main the draft needed one rename to compile: field282_0x109d98 is mapTransferStatePerPlayer.

What the match needed:
- The map name lookup is written inside the first serialize call, so the size and the two flags are pushed before
  the lookup is called.
- The name's copy and the two searches for its end are strcpy and strcat, with ".map" as the macro S__MAP_005A2294
  (the original copies it inline). The copy into unknownMapName_01 is a strcpy too.
- The loop over the slots is a for loop with countof().

Fix against the draft: a client whose own copy of the map hashes differently only gets the quit dialog. The
original returns there; the draft went on to queue the command that asks for the map file.

Wilps's version on gynt's fork (reimpl/Wilps-2026-10-18, 8ca7861, 2026-10-27) already has the nested lookup, strcpy
and strcat. It queues the command in an else after the dialog, so it already behaves as the original does.

Style: the strcpy pragma, the first include is ../Commands.func.hpp, the using lines and block comments are gone,
the execute half and the host are early returns, _mapHash is `int mapHash` (the hash function returns int), and
0x3ec is 1004.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
kotijekriv and others added 7 commits November 17, 2026 07:56
ShareMapPart, from gynt's draft on upstream's reimpl/Synchrony-Commands (3bc194b at 26.91%, 5404142 at 33.2%,
fc3a51f and 8f6faf1 at 66.7%, "Gotos removed, match unchanged", his newest commit on the file; the status line
reads 33.2%). On main's headers the draft reads reccmp 68.2 (normalized 65.4), and now 100.0 (normalized 100.0).
quick_diff 202/202 at 0.9950 (the draft: 0.7268); the rest is the /GS cookie load. gynt's newest commit on the file
on any branch, 6cbbfc2 (2026-11-02, his fork's reimpl/UI-MenuItems-development), writes the length test as
`-(int)_buffer2 > 1`; this doesn't build on it: the original tests `>= 0`.
3bc194b is only on his fork (development); upstream's branch has the file from 5404142 on.

What the match needed:
- The part that ends the transfer (parameter 0 is -1) returns after its three serialize calls, as the original
  does (pop ebx, the cookie check and ret at 0x0048B9AD).
- The sender's test is the file's end first (`>= mapSendingFileSize`, which closes the file) with the tenth part
  in the else-if, and one condition for the request state: the flag, the receiver's ID and the receiver not being
  this machine.
- The flag is a bool that starts false before the plan is tested and is cleared again in the ending part (the
  original stores it twice; without the second store the function has 201 instructions).
- `+=` for the two byte counters, and `>= 0` for the length test (cmp eax, ebx; jl).

Behaviour fixed against the draft: the ending part. The draft had no return there, so after sending the empty
part of length -1 it went on to read the file and send a second part in the same command.

Wilps's version on gynt's fork (reimpl/Wilps-2026-10-18, 8ca7861, 2026-10-27) already has that return and the
file's end test with the else-if.

Style: the first include is ../Commands.func.hpp, the using lines and block comments (with the draft's TODO) are
gone, the execute half is an early return, the locals have names (answerExpected, receivedAnswerExpected,
byteCount, part) and the two flags are declared where they are first set, the sizes are sizeof(), NULL for the
file pointers, the command type is GCT_UNKNOWN_107 in place of an or of two other names, and the numbers are
decimal.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
AutoSaveTriggered, from gynt's draft on upstream's reimpl/Synchrony-Commands (ba3fec8 and ef8dff7 at 41.50%,
22f995f at 52.1%, 7141365 at 59.9%, his newest commit on the file; the status line reads 52.1%). On main's
headers the draft reads reccmp 61.9 (normalized 61.9), and now 100.0 (normalized 100.0). quick_diff 161/162 at
0.9474 with -s (the draft: 0.6262); the rest is the /GS cookie load, an alignment jmp and the timeGetTime import.
ba3fec8 and ef8dff7 are only on his fork (development); upstream's branch has the file from 22f995f on.

What the match needed:
- The host's arm comes first, and each arm has its own deserialize call: the original pushes the call's last three
  arguments before it tests isHost and the buffer's address after it.
- A client returns after shouldSendAnnouncementUnk is set (the original has a second epilogue there); only the
  host stores the announcement time and clears announcementReceivedBool.
- wcslen() for the wide string's length, and a for loop over the slots 1 to 8.

Behaviour fixed against the draft: the end of the execute half. The draft went on to store the announcement time
and clear announcementReceivedBool on a client too; the original does that on the host only.

Wilps's version on gynt's fork (reimpl/Wilps-2026-10-18, 8ca7861, 2026-10-27) already has the host's arm first,
wcslen, and the client and host ends as an if and else.

Style: the first include is ../Commands.func.hpp, the using lines and block comments are gone, the execute half is
an early return, local_59, _base64State and local_4c are isSaving (the name of ShowProgressBarSaveLoadDialog's
parameter), base64State and wideName, declared where they are filled, the loop's bound is countof(), the scalar
sizes are sizeof() (parameter 2 keeps its 1: one byte of it is sent), the wide string's size is wcslen() *
sizeof(WCHAR), and the numbers are decimal.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The header has `char** insultWavFiles[21]` at offset 0x240 (0x00B38DBC). The original's data there is 21 plain
char pointers: element 0 is NULL, and elements 1 to 20 point at "insult1.wav" (0x005A6E14) to "insult20.wav"
(0x005A6D04).

ClickTauntOrChat passes an element as the file name: 0x004897C1 `mov ecx, [eax*4 + 0x00B38DBC]`, `push ecx`,
`push 0x12`, then 0x004897D0 `call 0x00478360` (resolveResourceFileName, whose second parameter is a
`char const*`).

Nothing else on main uses the field. ClickTauntOrChat, the next commit, passes it with no cast.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
ClickTauntOrChat, from gynt's draft on upstream's reimpl/Synchrony-Commands (4438273 at 24.40%, 69d7f6a and
f9399c5 at 30.3%, a9a04a1 at 55.4%, "Dispatch form fixed, remainder unanalysed", his newest commit on the
file; the status line reads 30.3%). On main's headers the draft reads reccmp 56.5 (normalized 56.5), and now 100.0
(normalized 100.0). quick_diff 172/173 at 0.9449 with -s (the draft: 0.6551); the rest is the /GS cookie load, an
alignment jmp and the sound flags' constant, which quick_diff reads as an address.
4438273 is only on his fork (development); upstream's branch has the file from 69d7f6a on.

What the match needed:
- The execute half starts with the sender's range test (add eax, -1; cmp eax, 7; ja): only the players 1 to 8.
- The receivers are an array of their own, `int receivers[9] = { 0 }`, indexed by this machine's slot; the taunt
  is an int of its own in front of it. The draft had one array of ten with the taunt as its first element and
  cleared the other nine one by one.
- addChatMessageToDisplayList is called in three places: with 0 for taunt 10000, with parameter 0 for a negative
  taunt, with the sender otherwise. The original pushes the two zeros of the first call by themselves.
- The lookups are written inside the calls that use them: the typed text inside the conversion, the insult's text
  inside a strcpy, the sound's file name inside playSoundOnStream3Unk.

Behaviour fixed against the draft:
- The draft had no range test for the sender.
- The sound's file name comes from insultWavFiles, which is what main's header has at 0x00B38DBC. The draft read
  commandFunctions, which was at that address on its branch.

Wilps's version on gynt's fork (reimpl/Wilps-2026-10-18, 8ca7861, 2026-10-27) already has the range test, the
receivers array with its initializer, the three calls, the strcpy calls and the typed text's lookup inside the
conversion.

Style: the strcpy pragma, the first include is ../Commands.func.hpp, the using lines and block comments are gone,
the execute half, a message for other players and the first two kinds of taunt are early returns, the locals have
names (taunt, receivers, wideMessage[MAX_PATH]), the sizes of the scalars and of the receivers are sizeof(), the
sound flags are the enum's names as in KickPlayerUnk, the sound's file name is passed with no cast (the commit
before this one makes insultWavFiles a char* array), and the numbers are decimal.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
SetUnitAssemblyPoint, from gynt's draft on upstream's reimpl/Synchrony-Commands (c2f8efa at 50.22%, 09840aa at
60.8%, abd24c2 at 62.2%, fe31c33 at 64.5%, "EXTEND fixed, allocator differs", his newest commit on the file;
the status line reads 62.2%). The draft doesn't compile on main: tunnelersGuildAssemblyPointX/Y and
cathedralAssemblyPointX/Y are specialBuildingAssemblyPoints[2] and [3] there. With those two renames it reads
quick_diff 0.6283 with 234 instructions, and this reads 218/218 at 1.0000; reccmp 100.0 (normalized 100.0).
c2f8efa is only on his fork (development); upstream's branch has the file from 09840aa on.

What the match needed:
- The unit category has no local: parameter 0 is written in every index. With a local the compiler moves the
  store of x behind the building lookup in the first three blocks (quick_diff 0.9725); the original stores x, then
  y, then looks the building up.
- One int receives the three parameters, read back as its first byte and its first two bytes; the sender, x and y
  are locals, y from the received value and x from parameter 1.
- The five kinds of assembly point are early returns in place of an else-if chain.
- Kept from the draft: the int local for the building type where two types are tested, and the switch for the
  barracks' and the mercenary post's five types.

Fields on main: the third block's points are specialBuildingAssemblyPoints[category - 20], the same bytes the
draft reached as mercenaryAssemblyPoints[category + 1]. The behaviour is the draft's.

Style: the first include is ../Commands.func.hpp, the using lines and block comments are gone, the execute half
and the tests of the point, the building and its owner are early returns, the locals have names (received,
playerID, x, y, buildingID, buildingType) and are declared where they are filled, the switches end in a break, the
map's limits are MC_MAP_XY_LIMIT_INCLUSIVE and MC_MAP_XY_LIMIT, and the numbers are decimal.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
ClickPlaceSiegeTent, from gynt's draft on upstream's reimpl/Synchrony-Commands (915e32a at 52.03%, c8cf62d at
61.0%, e4dcca6 at 65.7%, 380fe5e at 65.3%, 9997d6d at 68.2%, "EXTEND fixed, allocator differs", his newest
commit on the file; the status line reads 61.0%). The draft doesn't compile on main:
containsSiegeMangonel1OrBallista2 is defensiveTowerEngineType there and field261_0x2fa is tileScanCountdown. With
those two renames it reads quick_diff 0.7176 with 168 instructions, and this reads 172/172 at 1.0000; reccmp 100.0
(normalized 100.0).
915e32a is only on his fork (development); upstream's branch has the file from c8cf62d on.

What the match needed:
- The mapper for the resource check starts as M_MAPPER_NULL, becomes the mangonel's or the ballista's, and the
  check runs when it isn't null. The compiler turns that into the original's jumps (cmp 0x29, mov eax, 0xd2, jmp;
  cmp 0x3d, mov eax, 0xd3), so the draft's goto isn't needed. One condition with an if and else for the mapper
  puts the mangonel's arm out of line (0.9826); a ternary and two calls read 0.9623 and 0.9769.
- processPlacementResourceLossForBuildingType is called in two places, once per engine: the original loads the
  sender and pushes the arguments in each arm.
- The tile coordinates are `/ 8` (cdq, and 7, add, sar 3), and the tower's building type is an int local.
- The parameters are read from the globals each time, with no locals.

The behaviour is the draft's.

Wilps's version on gynt's fork (reimpl/Wilps-2026-10-18, 8ca7861, 2026-10-27) already has the divisions and the
two processPlacementResourceLossForBuildingType calls.

Style: the first include is ../Commands.func.hpp, the using lines and block comments are gone, both gotos are
gone, the building lookups are named locals in place of a comma expression and a repeated index, the locals are
declared where they are filled (mapper, buildingID, unitID, buildingType), and the numbers are decimal.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
DestroyPlayer, from gynt's draft. His commits on the file, in date order: 7291ee4 at 62.71% on his fork's
development branch, 1431eb3 at 77.0% and cf5944a at 79.7% on upstream's reimpl/Synchrony-Commands (cf5944a is
the newest there, and what this builds on), then 0084595 at 69.49% on his fork again (2026-10-03 22:45), his
newest commit on the file. The status line reads 77.0%. The draft doesn't compile on main: field261_0x109298 is
connectionNoticeShown there, and DPLAYX_4A is an IDirectPlay4*, so its cast to IDirectPlay4A** goes. With those
two changes it reads quick_diff 0.8273 with 123 instructions, and this reads 125/126 at 0.9880; reccmp 100.0
(normalized 100.0). The rest in quick_diff is the call through the DirectPlay interface and an alignment jmp.

What the match needed:
- The first block returns: the original has its own epilogue after the leaving player's name is cleared, and the
  second block then still has the slot and the text's number in registers.
- The leaving player's slot is a local for the lord's lookup and for the last three stores, but the first two
  stores (currentPlayerFullIDArray and DAT_PlayerSlotArraySomeValue) read it from parameter 0. That split gives
  the original's `lea eax, [edx*4]` and its one reload of the parameter; with the local in all of them the
  function reads 0.8880, with the parameter in all of them 0.8854.
- strcpy for the two messages, with the text's lookup inside the call.

The behaviour is the draft's: its two blocks exclude each other, so the return changes nothing.

Wilps's version on gynt's fork (reimpl/Wilps-2026-10-18, 8ca7861, 2026-10-27) already has the two strcpy calls.
It puts the second block in an else-if; here the first block returns and the second is a plain if. The blocks
exclude each other, so both forms behave the same.

Style: the strcpy pragma, the first include is ../Commands.func.hpp, the using lines and block comments are gone,
the execute half is an early return, the locals have names (readBuffer, playerID, lordID) and are declared where
they are filled, DPLAYX_4A->DestroyPlayer is called with no cast, NULL for the interface pointer,
connectionNoticeShown is tested by truth, and the numbers are decimal.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@github-actions github-actions Bot added the declaration/type change This requires changes to the generated/exported types or definitions. label Nov 17, 2026
kotijekriv and others added 2 commits November 18, 2026 11:39
Main has six commits since e086ba7 (sourcehold#401, sourcehold#409, sourcehold#410 and three tool commits). sourcehold#409 appended a line to
cmake/compiler-flags-gl.txt at the place where the next commit of this branch adds its three, so main goes in
first.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
CommandSwitchTeams, from gynt's draft. His reimplement commits on the file, in date order: 4b3b813 at 20.73% on
his fork's development branch, then 1030ebb at 36.3% and 73efa0f at 40.9% ("Flag widened, register allocation
differs") on upstream's reimpl/Synchrony-Commands, his newest on upstream's branch; the status line reads 36.3%. He
has five more commits on the file: 81e1041 (block comments removed), dd14331 (truth tests), cb45952 ("remove
claimed"), 8ca7861 (Wilps's content, below) and d74f096 of 2026-11-02 (style rules, on his fork's
reimpl/UI-MenuItems-development), his newest commit on the file. On main's headers the draft reads reccmp 40.9
(normalized 40.9), and this 100.0 (normalized 100.0), built under /GL with its two callees.

What the match needed:
- Link-time code generation. The file and the two callees that are finished on main, countPlayersInSameTeam and
  addChatMessageToDisplayList, are in cmake/compiler-flags-gl.txt. The original keeps the flag and the constant 0
  in one register (ebx, set after the sending half) and tests the flag with `test ebx, ebx`. Without /GL the same
  source gets a zero register of its own at the top of the function and the flag in a second one (quick_diff
  0.6609, 349 instructions against 344). Both callees still read 100.0 under /GL, and so does
  receiveAllTransmittedCommands (0x00490690), which is on /GL already and calls addChatMessageToDisplayList.
- The original has 347 instructions: the 344 that quick_diff counts and three alignment fillers in front of loop
  heads: `mov edi, edi` at 0x0048AE9E before request 0's inline strcpy copy, `mov edi, edi` at 0x0048AF7E before
  the search loop, and `nop` at 0x0048AFAF before request 2's inline strcpy copy. The clears, counts and marks
  over the teams 1 to 8 and the slots 1 to 8 are plain for loops that the compiler unrolls; the draft wrote those
  copies out by hand. The search loop for the first empty team (0x0048AF80) stays a loop in the original, as in
  the draft.
- One int receives both parameters, read back as its first two bytes and its first byte.
- The three kinds of request are separate ifs with early returns, in the original's order 0, 2, 1.
- The flag is a BOOLEnum that is FALSE before the plan is tested for GCS_EXECUTE. Measured under /GL: declared
  just above its test, or as one const expression there, the function reads 66.3. teamCount is zeroed before the
  clears in requests 0 and 1; declared just above its counting loop, either copy alone reads 97.1 and both
  together 83.3. `received` and `teamCounts` are declared at their first use, which measures the same as at the
  top.
- strcpy for the three messages, with the text's lookup inside the call.

The behaviour is the draft's.

Wilps's version on gynt's fork (reimpl/Wilps-2026-10-18, 8ca7861, a commit of gynt's of 2026-10-27) has the search
loop and an int flag, as gynt's 73efa0f does; it keeps the other loops written out.

Style: the strcpy pragma, the first include is ../Commands.func.hpp, the using lines and block comments are gone,
the locals have names (received, teamCounts, teamCount, canSwitch), the loop bounds are countof(), the numbers are
decimal, and each text lookup has its text above it.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@kotijekriv kotijekriv changed the title Reimplement 32 Synchrony::Commands functions at 100% Reimplement 33 Synchrony::Commands functions at 100% Nov 18, 2026

This branch has not been deployed

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

Labels

declaration/type change This requires changes to the generated/exported types or definitions.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants