Repository navigation
One more Map::Units function at 100%: UpdateHorseArcher_DoShooting - #475
Open
kotijekriv wants to merge 1 commit into
Open
kotijekriv wants to merge 1 commit into
kotijekriv wants to merge 1 commit into
Conversation
Units::UpdateHorseArcher_DoShooting, from Gynt's draft on sourcehold's reimpl/map-units-updatefunctions (his draft PR 204; his commits on the file: 9fde7f2 at 70.33%, then 974c32f's clang-format), with this tree's field names (43a17df). It reads a true 100.0 / 100.0 in main's visibility (see the end). The statements are his except the building index local, the goto with its label and the second `= 6` store (the facing direction is now an int local); what the text needed is how they are arranged. 1. Shooting variation 5's failure path (the target is gone and no new one is found) ends in `goto resetShooting;` into the function's last lines, which reset the state and the variation: the original shares them there (0x00575C21, jmp at 0x00575A6E; variation 6's failure keeps its own copy, which goes on to the frame test). Written out, the copy counts as more uses of the constant 4 (the reload state), and the compiler then keeps 4 in a register through the function where the original compares with an immediate 4. 2. `horseArcherShootingVariation = 6;` is written on both paths of variation 5 (behind the copied target position and for no target). The code has one store (0x00575A4B, `mov word ptr [esi + ...], di`); with the two written uses the constant 6 gets its register (`mov edi, 6` at 0x00575935), as in the original. 3. Variation 4: the facing direction (savedFacingDirection) and the target building's index (targetBuildingID) are int locals in front of the targeting-type test (both loaded before the branch, `movsx` at 0x00575865 and 0x0057586C); the index is used for the building's x and y. 4. Variation 6: the acquireShootTarget test the original's way round, the failure (reset) first, so that it is the fall-through (0x00575B87). 5. The three height sums terrainOrClimbHeight first (the target position copy and both arrowShootingRelated heights): the original loads it in front of buildingHeight (0x00575A35, 0x00575AAF, 0x00575AD0). 6. The calls that return BOOLEnum, the BOOLEnum field animationCycleNumberHasJustIncremented and `dying` tested by truthiness; the gfx offsets in decimal and `(EntityType)24` (EntityType has no entry for 24); the usings and the include nobody names dropped. `target > -1` stays (the original compares with -1; `>= 0` differs). Measured with real builds of the units stack's head 6e3de74062 (every header this file includes is the same there as on main 0e4a83b), the whole build list plus this file and its /GL line, BUILD_OK: with the /GL lines of its two callees (setFacingDirectionTowardCoords / -TowardUnit, on the stack's list only through PR 378) taken off, as main has them, UpdateHorseArcher_DoShooting reads 100.0 raw / 100.0 normalised, no diff entry, 345 functions, none of the others reading differently. With the two callees on the list (a build of that stack with this function, UpdateFireEater and UpdateLady, 350 functions), the text before the goto's comment was reworded read the same. 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 1 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 branch has not been deployed
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.
One more function at 100%, with no header changes.
Units::UpdateHorseArcher_DoShooting(the horse archer'sshooting step, called from
UpdateHorseArcher, which is in #449) is from gynt's units branchreimpl/map-units-updatefunctions(his draft #204), and the commit credits him as co-author.Units::UpdateHorseArcher_DoShooting/GLWhat got it to 100%. Five arrangements, each measured:
goto resetShooting;into thefunction's last lines: the original shares them there (0x00575C21, jumped to at 0x00575A6E). Written out, the
copy counts as more uses of the constant 4, and the compiler then keeps 4 in a register through the function
where the original compares with an immediate 4. Variation 6's failure keeps its own copy, as in the original.
horseArcherShootingVariation = 6;is written on both paths of variation 5: the code has one store(0x00575A4B), but with the two written uses the 6 gets its register (
mov edi, 6at 0x00575935), as in theoriginal.
targeting-type test (the original loads both before it branches, 0x00575865 / 0x0057586C).
acquireShootTargettest has the failure arm first, so that it is the fall-through.terrainOrClimbHeightfirst (0x00575A35, 0x00575AAF, 0x00575AD0). Our quickcompile could not see this (it folds the field offsets); the real build showed it.
(EntityType)24stays a cast:EntityTypehas no entry for 24 (anET_UNKNOWN_24would be a header change of itsown).
target > -1stays as the draft wrote it: the original compares with -1, and>= 0compiles differently.Measured.
Stronghold Crusader.exe(3bb0a8c1…5387ac5a), both resolversets enabled locally (not committed), and sourcehold's reccmp with
--resolve-wrapped-calls --ignore-security-cookie./GLlist (main's plus this file), and with 0x004314E0 (theMapEditorLandscaping_GeneralButtonshandler) left out and its resolver off, as in main's baseline: 0 failed of 2,426 compile steps, 99.58 over 2,442 functions.UpdateHorseArcher_DoShootingreads 100.0 raw and normalised there too, with no diff entry, and its two callees,setFacingDirectionTowardCoordsandsetFacingDirectionTowardUnit(main's, not on main's/GLlist), read 100.0 as before. No other main function reads differently: against main's own build (made at f489b72, 2,439 functions) the only other changes are main's since then (One more UI::MenuModals function at 100%: ProgressBarBox #467'sMenuModalRenderFunction_ProgressBarBoxand its constructor, UI: the single-player game launch at 100% #466'sLaunchSinglePlayerGameUnk), and every other function reads exactly what it read before (unrounded 99.5790 raw and 99.5529 normalised, 2,326 functions at 100.0 raw; main 0e4a83b alone: 99.5788 and 99.5528 over 2,441, 2,325 at 100.0).UpdateHorseArcher, which calls this function, is in Three more Map::Units functions at 100%: UpdateSwordsman, UpdateArabianSwordsman and UpdateHorseArcher #449 and so not in this build; on main no reimplemented function calls it.includes is the same there as on main 0e4a83b). Its two callees,
setFacingDirectionTowardCoordsandsetFacingDirectionTowardUnit, are on that stack's/GLlist only through Reimplement 47 UnitsState functions at 100% and restyle 28 more #378, so the build for this PR takestheir two lines off locally, as main has them:
UpdateHorseArcher_DoShooting100.0% raw and normalised, no diffentries, 345 functions, none of the other 344 reading differently from the build without it. With the two
callees on the list it reads the same.
Checks:
openshc-pr-checkgives 0 ERROR and 12 CHECK:field_0x58,field_0x40eandfield_0x3f8(no better name in this tree); its CHECK thatfield_0x58is a BOOLEnum field matches a field of that name inSoundEffectsHelperData1.hpp: the unit'sfield_0x58is ashort;(char)casts on the threeANIM_Frames_HorseArcher_Shooting_*tables, whose elements arebyte: the castmakes the frame signed for the
> 0tests, as in the other unit files;(EntityType)24(see above);goto(two CHECKs, and main's style-lint bot will post it once): its target has two predecessors, the end ofthe function and variation 5's failure path, and the comment says what writing it out does.
Other PRs
UpdateHorseArcher_DoShooting.cppand one more statushunk, at 0x00575820 (100.0% here against his 70.3%). Once this lands, his branch can take main's version.
UpdateSiegeTent), Reimplement 33 Synchrony::Commands functions at 100% #415, Five more functions at 100%: InGameMenu MainButtons, Roundtable handler, BuySell, UpdateGhost and UpdateHopsFarmer #416, Three more Map::Units functions at 100%: UpdateOx, ConsiderHavingABreakNowUnk and UpdateMinerIronFetcher #421, Two more Map::Units functions at 100%: UpdateHunterDog and UpdateFireWatch #433, One more Map::Units function at 100%: UpdateCageDog #438, One more Map::Units function at 100%: UpdateKnight #444, One more Map::Units function at 100%: UpdateMangonel #445, Three more Map::Units functions at 100%: UpdateSwordsman, UpdateArabianSwordsman and UpdateHorseArcher #449, One more Map::Units function at 100%: UpdateAssassin, with Unit::field_0x41a as a short #450, One more Map::Units function at 100%: UpdateBallista #451, One more Map::Units function at 100%: UpdateFireBallista #452, One more Map::Units function at 100%: UpdateTrebuchet #453, One more Map::Units function at 100%: UpdateCatapult #469 and One more Map::Units function at 100%: UpdateBatteringRam #471also add lines at the end of
cmake/compiler-flags-gl.txt, so whichever goes in second gets a small conflictthere: keep the lines of both (reimpl/BuildingsState #234, Reimpl/units state #238, Reimpl/viewport render state #241, reimplement OpenSHC::Text::TextManager and OpenSHC::Text::UserTextHandler #265, Reimplement 3 UI::MenuItems functions from gynt's drafts (not yet 100%) #328 and Reimpl/TileMapState 100% batch 2 #396 conflict there too, but they already
conflict with main). Reimplement 47 UnitsState functions at 100% and restyle 28 more #378, Map::Units::UpdateLion at 100% #425, Reimplement 20 BuildingsState functions at 100% #377, Reimplement 88 Map::TileMapState functions at 100% #366 and Reimplement the remaining Map::Buildings Update* functions #297 merge cleanly. Checked with
git merge-treeagainst everyopen PR's head.
UpdateHorseArchercalls this function; neither PR needs the other. With this function's body visible to it(our quick compile of Three more Map::Units functions at 100%: UpdateSwordsman, UpdateArabianSwordsman and UpdateHorseArcher #449's file),
UpdateHorseArchercompiles to the same code.🤖 Generated with Claude Code