Skip to content

Reimpl/ViewportRenderState methods that are 100% - #392

Merged
TheRedDaemon merged 17 commits into
mainfrom
reimpl/ViewportRenderState-100
Nov 16, 2026
Merged

TheRedDaemon merged 17 commits into
mainfrom
reimpl/ViewportRenderState-100

Conversation

@gynt

@gynt gynt commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

No description provided.

gynt and others added 4 commits November 10, 2026 00:47
…int; lookup table layout

- ViewportRenderState: availableFloaterIndex, windowX/Y, screenPixelWidth/Height,
  the four animation intervals, unitBatchedRenderCounterUntil6 and unitRender1-5
  are int (the original compares them signed).
- screenPointToTileNumber starts at 0x4E5E0 with 321610 entries, absorbing the
  eight field_0x4e5e0..fc slots before it; translationMatrix has 401 triplets,
  absorbing translationResult1/translationTracker1/translationResult2. Both
  arrays are written that way by setTileSystemMemoryLookupArrays.
  ViewportBasedTileNumber and convertMinimapClickToTileXY index the moved array
  with the shifted base (+8 entries), and still measure 100%.
- TileMapState.cursorOverlayAnimationFrame, DAT_CurrentlyRenderedSpriteID and
  DAT_RenderedUnitOwner are int.

From reimpl/ViewportRenderState, limited to the changes its 100% functions need.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmYbLQCBa8ek5RWjimR
From reimpl/ViewportRenderState: every function that measures 100% there, and
again 100% in a trial build of this branch (on main d5d965d, data and
function resolvers enabled, all 23 ViewportRenderState sources plus
ViewportBasedTileNumber and convertMinimapClickToTileXY at 100%).

- 15 new sources in src/OpenSHC/Rendering/ViewportRenderState/, with their
  status lines set to 100.0% Reimplemented
- the 8 sources main already has at 100% are identical there and unchanged

Left out: resetupViewport, which reaches 100% only under /GL together with
setupViewport (here 43.8%, with setupViewport proxied to the original), and
the 8 functions still below 100% on reimpl/ViewportRenderState (setupViewport,
computeMouseTileFromScreenPosition, renderAssassinClimbingOverlay,
renderGmOverlayBuilding, renderMap, renderUnits,
setTileSystemMemoryLookupArrays, updateBuildingPreviewPosition), with the
header changes only they use.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmYbLQCBa8ek5RWjimR
100% in the reimpl/ViewportRenderState build, where it is compiled with /GL
together with setupViewport; not re-measured on this branch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmYbLQCBa8ek5RWjimR
origin/main now carries the ViewportRenderState, TileMapState and global type
changes from this branch's types commit, identical, so they merge cleanly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmYbLQCBa8ek5RWjimR
@github-actions

Copy link
Copy Markdown

Style guide reading (advisory, posted once)

5 possible deviation(s) from REIMPLEMENTATION_STYLE_GUIDE.md across 4 of the 18 reimplemented .cpp file(s) in this PR.

The match comes first. Where the ugly form is what matched, it stays -- that is the guide's own overriding rule, and rule 21 asks for a one-line comment saying what was measured so the next reader does not retry it. This report is posted once, when the PR opens, and is not repeated on later pushes.

rule what it asks hits
18 Use the name, not the number 1
23 Prefer if-else over ternary 2
24 Declare variables upon first use 2
Where

Rule 18 — Use the name, not the number

  • src/OpenSHC/Rendering/ViewportRenderState/assignRandomTiles.cpp:18 — hex constant 0x3C0; use a name, or decimal

Rule 23 — Prefer if-else over ternary

  • src/OpenSHC/Rendering/ViewportRenderState/renderBuildingAnimation.cpp:37 — ternary; the guide prefers extending the if-else chain
  • src/OpenSHC/Rendering/ViewportRenderState/renderGmOverlayBuilding2.cpp:556 — ternary; the guide prefers extending the if-else chain

Rule 24 — Declare variables upon first use

  • src/OpenSHC/Rendering/ViewportRenderState/focusOnTile.cpp:24 — declare tileY where it is first assigned
  • src/OpenSHC/Rendering/ViewportRenderState/renderGmOverlayBuilding2.cpp:55 — declare healthPercent where it is first assigned

gynt and others added 3 commits November 11, 2026 00:31
…able layout

Constants the ViewportRenderState functions use: the 32 x 8 pixel tile
column and row steps, the screen point tables' start, size and row lengths,
the map surface height and the unit render batch and white cap frame counts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmYbLQCBa8ek5RWjimR
…ssignment

LogicLayer and Logic2Layer tests use the Logic1 and Logic2 flags, map sizes
use MapConstants, the debug overlay text is Colors::COL_FFFFFF, and the
remaining pixel and table constants come from the new ViewportConstants.
Array bounds are countof(); the floater id check keeps `countof - 1 <`
because `>= countof` compiles to cmp 250 / jae where the original has
cmp 249 / ja. Self-assignments are ++, += and -=.

All 24 ViewportRenderState functions on this branch measure as before (23 at
100%, resetupViewport unchanged at 43.8% without /GL).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmYbLQCBa8ek5RWjimR
@github-actions github-actions Bot added the declaration/type change This requires changes to the generated/exported types or definitions. label Nov 10, 2026
gynt and others added 5 commits November 11, 2026 10:46
TileMapState::mapOrientation takes 0, 2, 4 and 6.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmYbLQCBa8ek5RWjimR
…ST, SOUTH and WEST

focusOnTile and setViewportBasedOnMapSize compile as before (quick_diff
identical to the committed sources).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmYbLQCBa8ek5RWjimR
…literals.hpp

renderDebugDataMousePointing still measures 100%.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmYbLQCBa8ek5RWjimR
/GS (on by default in MSVC 2005) emits the cookie for char text[200] itself;
the unused local read of MSVC_SecurityCookie was optimised away.
renderDebugDataMousePointing still measures 100%.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmYbLQCBa8ek5RWjimR
origin/main now carries both headers from this branch. MapConstants is
identical; ViewportConstants (add/add) takes main's generated version, which
has the same names and values without the hand-written comments.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmYbLQCBa8ek5RWjimR
@github-actions github-actions Bot removed the declaration/type change This requires changes to the generated/exported types or definitions. label Nov 11, 2026
@gynt
gynt requested a review from TheRedDaemon November 11, 2026 10:12
gynt and others added 2 commits November 14, 2026 01:47
…ic numbers

- Map::LogicHelpers::MiscDisplay: MiscDisplayLayer bits 0x40-0x200 are the
  sea edge graphics updateGfxLayer sets (cliff, shore, shore edge);
  MD_SEA_EDGES is their 0x3C0 mask.
- Map::Buildings::BuildingTargetMarker(Short): Building+0xC2, set to 1 by
  drawFlagsAndUnitDestinations for a building an own unit targets and to 2
  by the unit selection handler for an own engine when engineers are
  selected; renderGmOverlayBuilding2 draws the marker and clears it.
- ViewportConstants: VC_TILE_PIXEL_HEIGHT (16) and
  VC_MAP_SURFACE_MARGIN_X (150, the map surface's left margin in
  currentCameraOffsetX).
- ViewportRenderState: the updateWaterAnimationFrames clocks named after
  the counters they drive (animationFrame16/32/36/512, slowAnimation*);
  slowAnimationTicked is BOOLEnum.
- ViewportState::mouseTile -> mouseFlatTile: the height-ignoring tile
  updateBuildingPreviewPosition writes, against the elevation-aware
  mouseAtomRefFloorTile.
- Floater::id -> nextFloaterID: the per-tile floater chain link.
- TileMapState::disableElevationRendering is BOOLEnum.
- scheduleUnitForBatchedRendering takes ints; param_7 -> batchesEarlier.
- renderBuildingAnimation(buildingID, screenX, screenY, tile,
  BOOLEnum clipToBuilding).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
MD_SEA_EDGES for the white cap tile test, BTM_* for the building target
marker, FALSE/TRUE for the BOOLEnum flags, the renamed animation clocks,
mouseFlatTile and nextFloaterID, MC_MAP_SIZE_400 + 1 and tile-size and
map-surface-margin constants in setViewportBasedOnMapSize. Dropped the
redundant (char) casts on char layers and the (ushort) store cast, and
renderGmOverlayBuilding2 declares buildingType at first use. All 25
functions stay at 100%.

Co-Authored-By: Claude Opus 5.5 (1M context) <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 14, 2026
@gynt

gynt commented Nov 15, 2026

Copy link
Copy Markdown
Contributor Author

Re the style-lint reading above:

  • Rule 18, assignRandomTiles.cpp 0x3C0: now Map::LogicHelpers::MD_SEA_EDGES (new MiscDisplay enum).
  • Rule 23, renderBuildingAnimation.cpp / renderGmOverlayBuilding2.cpp: both are a clamp-to-zero inside a call argument (screenY - N < 0 ? 0 : screenY - N), not the last arm of an if-else chain, so there is no chain to extend. Kept.
  • Rule 24, focusOnTile.cpp tileY: it is read after the loop, so it has to be declared outside the for. renderGmOverlayBuilding2.cpp healthPercent: it is assigned in both arms of an if/else, so there is no single first assignment to declare it at. Kept.

All 25 functions that were at 100% are still at 100%.

gynt and others added 2 commits November 15, 2026 22:28
…:Enums

Main's Ghidra sync moved the enum into Map/Buildings/Enums.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmb1ZyWXFVVKYYu4FWo
@github-actions github-actions Bot removed the declaration/type change This requires changes to the generated/exported types or definitions. label Nov 15, 2026
Tested as booleans (style guide rule 5), every store checked in the
original binary where the field is not already BOOLEnum:
- disableElevationRendering, clipToBuilding: BOOLEnum.
- Building::useOffsetGraphics, displayOwnerFlag: only ever stored 0/1.
- ViewportState::isZoomedOutUnk: a toggle, short form already on main.
- DAT_BinaryTileMap400x400: filled by setTileSystemMemoryLookupArrays
  with SETG, cleared to 0 here.
- Bitmask tests in assignRandomTiles and tweakValidTilesToExcludeMapBorders.

Counters, image frames, IDs, renderAnimation (also stored 2) and
drawBridgeState1 (2, 3) keep their comparisons.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmXCmb1ZyWXFVVKYYu4FWo
@gynt
gynt requested a review from TheRedDaemon November 16, 2026 05:56
@TheRedDaemon
TheRedDaemon added this pull request to the merge queue Nov 16, 2026
Merged via the queue into main with commit e086ba7 Nov 16, 2026
4 checks passed
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