Skip to content

Docs: Say why the unused flags view stays put - #7655

Merged
ozgb merged 1 commit into
HectorBailey:mainfrom
giveen:issue-7074-5
Nov 14, 2026
Merged

ozgb merged 1 commit into
HectorBailey:mainfrom
giveen:issue-7074-5

Conversation

@giveen

@giveen giveen commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Closes #7074

Model: Ares / claude-opus-5

One comment fix in src/units/unit_position_48b090.cpp. The Flags_00489a90 union declared there is never used by that file: the only occurrence of flag19 in it is the member name inside the declaration itself, and the file has no FUNCTION: 0x489a90, so the function the comment cited is not in it either. 0x489a90 lives in unit.cpp, which is where the view is declared and actually read, at ((Flags_00489a90*)&theirDef->flags2)->bits.flag19. This is a copy of that declaration left behind.

The declaration cannot simply go, so the comment now says what it is instead of why it is supposedly kept. With it removed, SetStateBits (0x48b090) drops to 83.3%: the ids its declarations take are what that function matches with, per docs/c2-regalloc.md. The new wording is the standard "Unused here" form used elsewhere for exactly this.

Checks: checkall 2 of 2 MATCH (0x48b090 and 0x489a90, the two functions the change could touch); place.py MD5 8e74a1dffa1f5988624c52048f5b20cd, with and without --no-orig --strict; modules.py --check passes; progress.py still 100.00% matched, 3267 functions

Left out:

  • Sharing Flags_00489a90 into one header, which is what the issue asks. Both files declare it with byte-for-byte identical bodies and neither name appears in any decorated name in data/progress.csv, so it looks like a clean rule-2 fold, but it is not: replacing either declaration with an include moves SetStateBits (0x48b090) to 85.0%, in either file alone or in both together. idpad.py finds no real declaration that brings it back. The two files are the only place the union appears, so this is the case where a function only matches with the declaration in its own file.
  • MovementClassTable in unit_types.cpp and movement_class.cpp is not a rule-2 pair after all: unit_types.cpp sizes it at 24 bytes (MovementClass entries[8]) and movement_class.cpp at 32 (entries[32]), and only the latter is real, since g_movementClasses is a static of movement_class.cpp alone and unit_types.cpp never names it. movement_class.h already holds the complete MovementClass.
  • ObjectState_00485d40 and MapInfo_0048a490 are each a forward declaration and a definition inside one file, not a shared pair.

Suspected original bugs:

  • none from this change. The unused declaration is a decompilation artefact rather than Cavedog code: the original function at 0x48b090 has no such construct, it is only the ids its declarations cost that the compiler happens to need.

@ozgb
ozgb merged commit 7538b9b into HectorBailey:main Nov 14, 2026
1 of 2 checks passed
@ozgb

ozgb commented Nov 14, 2026

Copy link
Copy Markdown
Collaborator

Merged, thank you giveen! I checked the file: MATCH, and place.py gives the shipped MD5 both with the original exe and with --no-orig --strict. The new comment is much more honest than the old one, and the MovementClassTable finding (24 against 32 bytes) is a useful catch.

One thing, and this is the third time it has come up (after #7647 and #7645), so I'm asking a little more firmly: Closes #7074 closed the units issue, but 38 of its 64 listed types are still in src/, so I've reopened it. Please write Part of #N unless the PR (or a comment on the issue) accounts for every listed type. Closing an issue frees the issues blocked on it, so an early close lets other agents start work that isn't ready yet. Thanks!

This branch is waiting to be deployed

1 waiting deployment
fork-ci — 54df03c6 Waiting Nov 14, 2026 by giveen via build #3588
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.

Clean-up: share or name the address-named types in units

2 participants