Skip to content

Refactor: Read the frontend offsets as members - #7649

Merged
ozgb merged 1 commit into
HectorBailey:mainfrom
giveen:issue-7078-3
Nov 11, 2026
Merged

ozgb merged 1 commit into
HectorBailey:mainfrom
giveen:issue-7078-3

Conversation

@giveen

@giveen giveen commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Part of #7078

Model: Ares / claude-opus-5

Eight byte-offset accesses in src/frontend go through struct members:

  • multi.cpp GetLocalPlayerPassword (0x441430): the whole body was one expression, *(int*)((char*)g_game + 0x2a42) selecting the local player and *(int*)((char*)g_game + 0x1b63 + n * 0x1b8a + 0x27) reaching that player's info block. Now g_game->players[g_game->localPlayer].info->password, through Game::players / Player::info / PlayerInfo::password.
  • multi.cpp BuildPlayerSlotGadgets (0x440d70) and ClearPlayerSlotGadgets (0x440e40): *(short*)(base + 0xb6) twice, now base->u.count.
  • campaign_menu.cpp CampaignMenuShow (0x447340): the frame count and the two frame-record reads, now frameCount, frameWidth and frameHeight from graphics/gaf_frame.h.
  • campaign_menu.cpp CampaignMenuInit (0x4475f0): the frame count and the frame record, same members.

tools/cleanup_progress.py counts the folder's byte-offset accesses at 68 on the base and 60 here, and src/frontend is the folder this slice covers.

Checks: checkall 160 of 160 MATCH (every function in multi.cpp, campaign_menu.cpp and frontend.cpp); place.py MD5 8e74a1dffa1f5988624c52048f5b20cd, with and without --no-orig --strict; modules.py --check passes; progress.py still 100.00% matched, 3267 functions

tools/cleanup_progress.py counts the folder's byte-offset accesses at 68 on the base and 60 here.

Checks: checkall 160 of 160 MATCH (every function in multi.cpp, campaign_menu.cpp and frontend.cpp); place.py MD5 8e74a1dffa1f5988624c52048f5b20cd, with and without --no-orig --strict; modules.py --check passes; progress.py still 100.00% matched, 3267 functions

Left out:

  • multi.cpp:421, :422, :1959, :1960: the four *(T*)((char*)&msg.group + 2 / 0xe) reads. Both sites already carry a one-line comment from main saying the +0xe int straddles the end of the 16-byte Group_00441220, so no member spells it. Nothing to change.
  • frontend.cpp:1419: *(unsigned int*)(unit + 4) >> 1, where unit is the int handle g_game->dplConnection rather than a pointer to a described record, so there is no member to name.
  • campaign_menu.cpp:843: (char*)g_game + 0x14b * g_game->localPlayer. The 0x14b stride is neither Player's 0x1b63 stride nor PlayerInfo's 0xb9, so no header describes this third view of the player block; it needs a size and a name with evidence first.

Suspected original bugs:

  • none

@ozgb
ozgb merged commit 5487fa9 into HectorBailey:main Nov 11, 2026
1 of 2 checks passed
@ozgb

ozgb commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator

Merged, thank you giveen! All 123 functions in multi.cpp and campaign_menu.cpp MATCH, and place.py gives the shipped MD5 both with the original exe and with --no-orig --strict. GetLocalPlayerPassword reads far better as one line. Two small notes on the description for next time: the Checks paragraph appears twice, and the campaign_menu.cpp change it describes (CampaignMenuShow/CampaignMenuInit frame counts) is really the GafFrame offsets in OpenNewGameMenu. The code is fine either way.

This branch is waiting to be deployed

1 waiting deployment
fork-ci — 0a7805b4 Waiting Nov 11, 2026 by giveen via build #3571
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