Repository navigation
Reimplement 14 UI functions from gynt's drafts, and drawHeaderTextBanner's text group as eTextSections (100%) - #384
Merged
Conversation
BuildMenu::MenuView_BuildMenu_DoInitial, from gynt's draft (0b3b5bf, 27.26%, and abf493f, 27.3%, in his closed sourcehold#253; on his fork's reimpl/UI-MenuViews-development 2a65f06, 41.59%, 722a4a2, 44.58%, 22964ce, 74.03%, 1f5a1aa, 98.90%, the dropped guard restored, and fa2be92, 99.84%, the two hidden-tab guards as early returns; his style passes up to e9bc49c on his fork's reimpl/UI-MenuItems-development) and our 3717c67, 99.9%, in the draft sourcehold#356. The function is his: the menu's position by resolution, then per build menu tab its menu picture, its edge pictures and the redraw. 3717c67 added the 640x480 y store (the draft never set DAT_MenuHandlerState:: instance.y there; the original stores it for both branches at 0x00431BA3) and the style pass (decimal offsets, s_ pointers for the 98 edge pictures with their names above them, comments on what the blocks draw). New here: y is assigned in each branch instead of once before the resolution test, which puts the original's xor esi, esi before its add eax, -600 (one y before the test: quick_diff 0.9992 -> 0.9984; the rest is the listing's ret 0); the BOOLEnum pendingMenuRedraw is tested by truthiness and cleared with FALSE (neutral). reccmp 100.0%. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fifteen of its eighteen callers passed the text group as a number: 199 is TEXT_SCENARIO, 0x4a TEXT_GAME_OPTIONS, 5 TEXT_MAINOPTIONS and 0x4f TEXT_XPLAY_WAITING_ROOM (eTextSections.hpp). Each now names it, as NewEvent, NewEventAction and EditScenario already did, and includes eTextSections.hpp. The enum converts to the int parameter, so the code is the same: all fifteen stay at reccmp 100.0. On the lines this touches, the text number is decimal and each file's first include is its own "../X.func.hpp" (style guide 18 and 14). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
As sourcehold#376's description proposed. The function hands it straight to getTextStringInGroupAtOffset, whose first parameter is an eTextSections (the definition cast it), and every caller passes an eTextSections value: TEXT_SCENARIO, TEXT_GAME_OPTIONS, TEXT_MAINOPTIONS or TEXT_XPLAY_WAITING_ROOM. PencilRenderCore.hpp includes eTextSections.hpp and declares the parameter with it; the resolver in PencilRenderCore.func.hpp takes the same signature. PencilRenderCore.func.hpp includes eTextSections.hpp and has its using, as TextManager.func.hpp does. The definition follows in the next commit, so this commit alone doesn't build (C2511: the class declares eTextSections while the definition still takes int); the two stay apart because a header change goes in a commit of its own. Measured with the next commit: drawHeaderTextBanner and its 18 callers stay at reccmp 100.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The definition's textGroupIndex becomes eTextSections, and the cast before getTextStringInGroupAtOffset goes. reccmp 100.0 before and after; its 18 callers stay at 100.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
BottomLeftTextDisplayState::hasPassedCountdownOrDuration, from gynt's draft (d92c05c, 72.22%, in his closed sourcehold#256; truth tests in dd14331 on his fork's archive/UI-MenuViews-development-second-pass, locals at first use in 10280b1 on his fork's reimpl/UI-Core-development), restructured from the binary: one if/else chain in place of the goto (a duration of -1 expires the text, as in his draft), and the previous time is tested after the global is overwritten instead of through a bool copy, which added a setne. reccmp 100.0%. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
GreatestLord::ComputeSkMasterScore, from gynt's draft (73e93f1, 33.33%, in his closed sourcehold#256; 36.8% in 10280b1 on his fork's reimpl/UI-Core-development). His finalResults.yearEnd, yearStart, monthStart and monthEnd are finalResults.tail.tail1's fields on main now, which is what kept the draft from compiling; the killed-lords bonus is added with +=, and the draft's (char) on finalKilledLords, already a char, goes. The arithmetic is his. reccmp 100.0%. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
HoveredState::Constructor_HoveredState, gynt's draft (bcc9597, 20.00%, in his closed sourcehold#256; 40.0% in 10280b1 on his fork's reimpl/UI-Core-development) unchanged apart from a duplicate include. The original keeps this in edx across the call to clearHoveredState, which needs link-time code generation to know that clearHoveredState leaves edx alone, so both files go into cmake/compiler-flags-gl.txt (without it: push esi / mov esi, ecx). clearHoveredState stays at reccmp 100.0%. reccmp 100.0%. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
HoveredState::createHoverStateElement, from gynt's draft (fee5db4, 50.00%, and 5976ab1, 75.0%, the full-array return, in his closed sourcehold#256; locals at first use in cf563c2 and the flag comparison in f507976 on his fork's archive/UI-MenuViews-development-second-pass; restyled in 10280b1 on reimpl/UI-Core-development), rewritten from the binary: an early return for GM_SOLITARY, and the search for a free element is one for-loop with the element's fields filled in and returned from inside it, so a full list falls off the end as in the original (the draft's while loop had an empty bound check). The expiry time adds mapTimeInTicks first, which loads it into ecx as the original does (commandDelay first: reccmp 93.8%). reccmp 100.0%. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuHandlerState::startBuildMenuTransition, from gynt's draft (453d527, 82.35%, and 1b5e0a3, 82.4%, in his closed sourcehold#256; 88.2% in 10280b1 on his fork's reimpl/UI-Core-development). The direction flip is an if/else: his (uint)(direction < 0) * 2 + -1 put the result in edx where the original reuses ecx (quick_diff 0.7647 -> 0.8824, the rest being the listing's import call and tail jump). The sound is (SoundEffectID)103, which SoundEffectID doesn't name yet (a later header commit adds SEID_UNKNOWN_0x67 for it); the draft wrote it as SEID_BURNING_MAN_SCREAM2 | SEID_WOOD_SAW. reccmp 100.0%. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuHandlerState::setupMenuForRendering, from gynt's draft (0dfa41d, 40.68%, and cc5c6ea, 45.9%, the not-found return, in his closed sourcehold#256; 44.1% in 10280b1 on his fork's reimpl/UI-Core-development), rewritten from the binary as one loop over the menu pairs with the setup inside it. loadMenuElements is called on this->currentMenu, which is what the original reads ([edi + 4]), not on DAT_MenuHandlerState's. reccmp 100.0%. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuModalComposition::setSliderParameters, from gynt's draft (9f04be9, 78.05%, in his closed sourcehold#256; 93.7% with the arms swapped in e9bc49c on his fork's reimpl/UI-MenuItems-development), now in the form of its sibling setSliderParameters2 (0x004AA540, at 100% on main): the offset is stored first and overwritten, as the original does, and the parameters match the header (NoArgCallback*). It differs from the sibling only in which destination it sets. Its bound is range > 200, as in the binary and in setSliderParameters2; e9bc49c tested >= 200. reccmp 100.0%. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuTextInputState::Constructor_MenuTextInputState, from gynt's draft (d64401f, 95.00%, in his closed sourcehold#256; field names in 0caea1f on his fork's archive/UI-MenuViews-development-second-pass, restyled in 10280b1 on reimpl/UI-Core-development). Main has since merged his modalDialog_2 to modalDialog_6 into previousModalDialogs[5], so those five stores are a for-loop over the array; the rest is his. reccmp 100.0%. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MinimapViewState::convertLoadedMinimapColors, from gynt's draft (6cbe8e7, 52.48%, in his closed sourcehold#256; 63.6% in 10280b1 on his fork's reimpl/UI-Core-development), rewritten with loops. The palette copy is a memcpy, which MSVC inlines as the original's rep movsd; the RGB565 conversion reads each colour once, which keeps MSVC from unrolling that loop as the original doesn't; and the loop over the 200 x 200 tiles is a plain for-loop that MSVC unrolls by five, as in the original (the draft wrote the five stores out). The 0xffe0 mask is written ~0x1f: the same code, and main's style_lint accepts it. The draft's #pragma optimize("y", off) isn't needed. reccmp 100.0% (with --ignore-security-cookie). Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MinimapViewState::generateMinimapImage, from gynt's draft (c00d3e9 and 76f32df, 70.33%, a2075f1, 70.3%, in his closed sourcehold#256; 74.7% in 10280b1 on his fork's reimpl/UI-Core-development), rewritten from the binary as the counterpart of convertLoadedMinimapColors (0x004B6320, earlier in this branch): it packs the minimap into a palette of up to 256 colours and one index per tile. The colour mask is a ushort set in an if/else (an int mask stays in a register where the original reloads it from the stack: quick_diff 0.6404 -> 0.8315), the palette search leaves with a goto (measured against a break and an index test in its comment), the colour is compared first, and the RGB555 conversion shifts an int and masks with 0x7fe0 (measured in its comment). The two colour masks (0xf79e and 0xfbde) are written as the bits they clear. reccmp 100.0% (with --ignore-security-cookie). Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MinimapViewState::renderMinimapMain, from gynt's draft (2e5a61f and 270c7e2, 45.5%, af82e41, 65.40%, in his closed sourcehold#256; field names in 2113d0b and 314b50c on his fork's archive/UI-MenuViews-development-second-pass; 10280b1 on reimpl/UI-Core-development). The code is mostly his. Changed from the draft, to match the binary: the large-map test is mapSize > 200 (the draft's < 200 swapped the two draws at exactly 200), with the two drawMinimap calls written out per branch; the y offset adds viewportY / 8 first (the other order: quick_diff 0.9911 -> 0.9464); the counter wraps with % 4; the click test is one condition; the cursor picture is GM_MINI_CURSORS (the draft's (eGM)153); and field_0xc and someMiniMapCounterTill4 are main's names now. reccmp 100.0%. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rendering::RenderCurrentButtonOnScreenMenu, from gynt's draft (6e94dc7, 47.27%, and ea80e97, 47.3%, in his closed sourcehold#255). The picture number is an argument of drawTgxGmOnFlaggedSurface rather than a local (the original pushes y and x before it calls getPictureNumberInGm), and the file goes into cmake/compiler-flags-gl.txt next to getPictureNumberInGm and RenderCurrentNotActiveButtonWithPossibleAlphaTexOnCurrentSurfaceUnk: the original keeps buttonGmData in ecx across that call, which needs link-time code generation. reccmp 100.0%. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rendering::RenderCurrentButtonToScreenMenuWithBlendingUnk, from gynt's draft (5fc0022, 40.00%, and 34ea366, 40.0%, in his closed sourcehold#255), in the form of RenderCurrentButtonOnScreenMenu (0x00464300, previous commit): a blend strength of 32 returns early, the picture number is an argument of renderGMWithBlending, and the file goes into cmake/compiler-flags-gl.txt so that buttonGmData stays in ecx across getPictureNumberInGm. reccmp 100.0%. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuView_BuildMenu_DoInitial (0x00431B60) returns early when activeMenuTab.buildMenuTab is 62, a tab the enum has no name for. Main's hideOrUnhideUI (0x00471AA0) switches the build menu from BMTT_SOLDIERS to 62 when it hides the menu and from 62 back to BMTT_SOLDIERS when it shows it again, so 62 is the hidden soldiers tab. Named the way the enum already names 49 (BMTT_UNKNOWN_49) until Ghidra has a name for it. Used in a later commit; code generation is the same. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuHandlerState::startBuildMenuTransition (0x004F4C80) plays sound effect 103 (push 0x67 before setUpSFXToPlayUnk), which the enum leaves out between SEID_BURNING_MAN_SCREAM2 (100) and SEID_CATAPULT_SHOOT (106); gynt's draft wrote it SEID_BURNING_MAN_SCREAM2 | SEID_WOOD_SAW. Named in the enum's SEID_UNKNOWN_0x.. form. Used in a later commit; code generation is the same. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d includes - MenuView_BuildMenu_DoInitial compares with BMTT_UNKNOWN_62 (header commit) in one early return with the hidden menu, the comments keep only their reasons, and a fixme says that from 1280x1024 on editor and siege games reset the gfx list before the second load, so slot 1 is drawn without being loaded (the original's bug; it matches). - startBuildMenuTransition plays SEID_UNKNOWN_0x67 (header commit) in place of (SoundEffectID)103. - The fifteen drawHeaderTextBanner callers have their banner text above the call, from cr.tex, as main's three named callers do. - setupMenuForRendering says why currentMenu is read again for the last two calls; renderMinimapMain writes needsRedraw = FALSE, compares DAT_SelectionIconType with 0 and the map size with MC_MAP_SIZE_200; convertLoadedMinimapColors says why one copy is inlined and the other calls _memcpy, and loses its history line; generateMinimapImage writes its mask as 31 << 10 | 31 << 5 like its colorMask lines, its comment on one line; hasPassedCountdownOrDuration uses --unknownCountdown01 and countdown -= now - previousTime. - Unused includes and usings go (MappersEnum, MenuModalType, MenuViewType, SoundEffectID's using). Kept, measured: setupMenuForRendering's pointer over the pairs (indexed: quick_diff 1.0000 -> 0.3636), with a line in the code. Everything else is quick_diff-identical, and all functions the branch touches are reccmp 100.0 in a full build. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…twice Only the soldiers tab resets totalLoadedGfx a second time, in editor and siege games, before loading slot 1; the other tabs reset it once per resolution and load both slots. The two copies of the fixme on those tabs go, and the true one fits on one line. Comments only. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Style guide reading (advisory, posted once) 1 possible deviation(s) from REIMPLEMENTATION_STYLE_GUIDE.md across 1 of the 30 reimplemented 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.
WhereRule 20 — Keep nesting low; no
|
This was referenced Nov 9, 2026
Main's Ghidra sync 6c1e0bd brought this branch's header changes; main's versions are kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gynt
approved these changes
Nov 10, 2026
gynt
pushed a commit
to gynt/OpenSHC
that referenced
this pull request
Nov 10, 2026
sourcehold#387) Ghidra sync 6c1e0bd declares drawHeaderTextBanner's textGroupIndex as eTextSections (the header line from sourcehold#384). Main's definition still takes an int, and 15 of its callers pass a bare number, so these 16 files don't compile on d5d965d (C2511 for the definition, C2664 for each caller). These are sourcehold#384's versions of the 16 files, unchanged (from 1262303, db68fc5 and 85b9d29): the definition takes eTextSections, each caller names its text group with the banner's text above the call, and the own header is included first. sourcehold#384 then merges cleanly on top of this. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fourteen more UI functions at 100%, all from gynt's drafts, which were below 100% (his closed #253/#256, restyled later on his fork). Each commit names the drafts it builds on and their scores, and credits him as co-author. This PR also gives
drawHeaderTextBanner's text group its real type,eTextSections. Part of the rest of UI gynt OK'd on 2026-11-09.BuildMenu::MenuView_BuildMenu_DoInitialBottomLeftTextDisplayState::hasPassedCountdownOrDurationGreatestLord::ComputeSkMasterScoreHoveredState::Constructor_HoveredStateHoveredState::createHoverStateElementMenuHandlerState::startBuildMenuTransitionMenuHandlerState::setupMenuForRenderingMenuModalComposition::setSliderParametersMenuTextInputState::Constructor_MenuTextInputStateMinimapViewState::convertLoadedMinimapColorsMinimapViewState::generateMinimapImageMinimapViewState::renderMinimapMainRendering::RenderCurrentButtonOnScreenMenuRendering::RenderCurrentButtonToScreenMenuWithBlendingUnkHow it was measured. All runs are on today's main: the bundled MSVC1400-SP1 against the Steam
Stronghold Crusader.exe(3bb0a8c1…5387ac5a), resolvers enabled locally (not committed), and sourcehold's reccmp with--resolve-wrapped-calls --ignore-security-cookie.drawHeaderTextBannerand its callers. convertLoadedMinimapColors and generateMinimapImage are 100% with--ignore-security-cookie; only the /GS cookie differs (Reimplement Map::Version UpgradeMapLogicToVersion_102 (not yet 100%) #298).cmake/compiler-flags-gl.txtlists them: the two button renderers and their callees, and main'sclearHoveredState.cpp, which stays at 100%.openshc-pr-checkgives no errors, andstatus_regression.pyfinds nothing worse.drawHeaderTextBanner's text group. It is passed straight togetTextStringInGroupAtOffset, which takes aneTextSections. 15 of its 18 callers on main passed bare numbers (199, 0x4a, 5, 0x4f). They now name the group:TEXT_SCENARIO,TEXT_GAME_OPTIONS,TEXT_MAINOPTIONSorTEXT_XPLAY_WAITING_ROOM. Each call has its banner's text above it, read fromcr.tex, the way main's three named callers already do. All 18 callers stay at 100.0%.Draft #356 and this PR. #356 carries the old 99.9% draft of BuildMenu_DoInitial. A commit on it drops that draft, so the two PRs merge cleanly in either order.
Header changes (each in a commit of its own)
Main's Ghidra sync (6c1e0bd) brought these header lines, and main (d5d965d) is merged in, with our code following main's spellings (
TAIT_UNKNOWNfor text index 4,INT_00b9840c), so the declaration check passes now.PencilRenderCore::drawHeaderTextBanner'stextGroupIndexis aneTextSections, in PencilRenderCore.hpp and .func.hpp (bf6cc6e).BuildMenuTabTypegetsBMTT_UNKNOWN_62(6905948).BMTT_SOLDIERSto 62 when it hides it, and back when it shows it again. So 62 is the hidden soldiers tab.SoundEffectIDgetsSEID_UNKNOWN_0x67(23c7f46). startBuildMenuTransition (0x004F4C80) pushes 0x67 before setUpSFXToPlayUnk. gynt's draft wrote itSEID_BURNING_MAN_SCREAM2 | SEID_WOOD_SAW.Kept as they are, measured with quick_diff
int y;set in each branchgotoout of the searchbreakplus an index test: 0.8636 → 0.85390x7fe0written as31 << 10 | 31 << 5~0x1f: 0.8636 → 0.7458viewportY / 8firstThe style-lint bot will post on generateMinimapImage's
goto. The comment above it gives the number in main's one-line form.Also left as the original has it:
fixmein BuildMenu_DoInitial is the original's bug. On the soldiers tab, in editor and siege games, the list is reset before the second load, so slot 1 is drawn stale.ushort colorMaskin generateMinimapImage is set in an if/else rather than a ternary (rule 23), as the int mask measured lower.(DWORD)cast in hasPassedCountdownOrDuration only silences C4018.Proposed, not changed here
undefined*parameter →int* destination(MenuModalComposition.hpp; the field it is stored in is alreadyint*). That would drop our(int*)and main's four(undefined*)casts in MenuItemActionHandler_EditScenario_BaseMenuButtons.MinimapViewState::needsRedraw→BOOLEnum: every store is 0, 1 or TRUE.loadedMiniMapas a union of the pixels and the packed form (palette[256]followed bycolorIndices[40000]). That would drop the casts in convertLoadedMinimapColors and generateMinimapImage.savedListOffset/Selection/SortOrder1-3look like an array of three structs.BMTT_UNKNOWN_62andMC_MAP_SIZE_200could replace the bare 62s in hideOrUnhideUI, switchToMenuView and playVideoOverMap, and the> 200in setMapPropertyDependingOnMapSize and setTileColorsDependingOnMapSize.Names
currentlyDisplayedTextIsDisplayedUnkholds a message type (it is compared with 6, 7, 12 and 13), so its!= 0stays.textMessageDurationUnkis in milliseconds: 0 shows the text for one frame, and -1 expires it.field_0xcis main's name; it is zeroed every frame here, and its meaning is unknown.Other PRs
eTextSectionsline. The two merge cleanly in either order.🤖 Generated with Claude Code