Skip to content

reimplement: PathFindingState methods that are 100% - #266

Open
gynt wants to merge 4 commits into
mainfrom
reimpl/PathFindingState-100
Open

gynt wants to merge 4 commits into
mainfrom
reimpl/PathFindingState-100

Conversation

@gynt

@gynt gynt commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

100% matching but currently not always styled properly yet.

@TheRedDaemon
TheRedDaemon self-requested a review October 15, 2026 20:27
Comment thread src/OpenSHC/Map/Navigation/PathFindingState/clearActiveClimbDataOfType6And7.cpp Outdated
Comment thread src/OpenSHC/Map/Navigation/PathFindingState/clearPathFindingTileMaps.cpp Outdated
Comment thread src/OpenSHC/Map/Navigation/PathFindingState/computeAttackVectorsBasedOnXAndY.cpp Outdated
Comment thread AGENTS.md
handwritten assembly the frame pointer says nothing about the optimisation level: reimplement the handwritten part as
inline asm and leave the rest at `/O2`. Checking the prologue settles it - values kept in registers across the entry
tests mean `/O2`. Taking the `/Od` reading instead took `findLinkageBasedPathOrWalkRadius` from 5.1% to 2.8%, where
the same body without the pragma reaches 49.2%. When it really is `/Od`, add `#pragma optimize(, off)`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you had a case that needed \Od?

@gynt gynt Oct 17, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/Od is tried every now and then but it usually ends up as an inbetween stage for progress, but never used in the final product. JUst like the pragma's.... I just don't see it being used in a logical way ever. Actually I think we should remove any mention of /Od or pragma's in these docs. Or say as little as possible about it. What do you think?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with you.
Custom ASM aside, the code seems very much compiled with /O2. so I guess questioning this should come very late.

return;
}
this->searchQueue.readIndex = this->searchQueue.readIndex + 1;
if (0x13a10 <= (int)this->searchQueue.readIndex) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Magic number again?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see you changed it to the decimal number. My question would be: Is the number related to the PathLinkageLayer explicitly, or is this a map/tile size number?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is the map tile size number. Where should we handle this number? Should we make an enum and I make the code refer to it?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be a good idea. Assuming we do not forget it and create multiple... although, even then.
Once we are done and start consolidating them.
Maybe, in an ideal world, we might up only having to change small things to adjust this later.

Bring the twelve PathFindingState .cpp files that already match the original
binary to the style used on main, and verify every one of them still matches:

- drop the decompiler's comment blocks (decompilerscript, WARNING: Enum) and
  the duplicate include of the file's own .func.hpp
- clearActiveClimbDataOfType6And7: the two lockstep pointers over climbData
  become a counted for loop over named fields, the trailing return goes
- clearPathFindingTileMaps: sizeof(layer) instead of 0x27420/0x13a10, and the
  layer passed straight through instead of (void*)((int)(...))
- computeAttackVectorsBasedOnXAndY: iVar1/_index named, += 1 instead of
  x = x + 1, 80400 instead of 0x13a10, de-yoda'd bound test
- reflow the clearActiveClimbDataOfType6And7 doc comment

reccmp before and after: all twelve at 100.0%, normalized 100.0%.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
namespace Map {
namespace Navigation {

/*

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove these comment lines

int* piVar2;
int iVar1 = 1;
piVar2 = &this->climbData[1].type;
do {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make a for-loop?

@gynt
gynt requested a review from TheRedDaemon October 17, 2026 22:00

This branch has not been deployed

No deployments
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