Skip to content

Commit f030f7a

Browse files
committed
monobj: cache mlAttackCheck group cursor in wloop
The volatile groupCursor was re-read between the groupCount[] index and the increment; reading it once into a local wcursor (keeping the volatile store and the post-store >=8 re-read) matches the target's single-load pattern. mlAttackCheck 96.493->96.702, unit 97.927->97.940. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 9800057 commit f030f7a

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

src/monobj.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1790,12 +1790,15 @@ int CGMonObj::mlAttackCheck(int partyIndex)
17901790
if (selectorType == 1) {
17911791
#define groupCursor (*reinterpret_cast<volatile int*>(&monObj->m_unk6CC))
17921792
wloop:
1793-
if (groupCount[groupCursor] == 0) {
1794-
groupCursor = groupCursor + 1;
1795-
if (groupCursor >= 8) {
1796-
groupCursor = 0;
1793+
{
1794+
int wcursor = groupCursor;
1795+
if (groupCount[wcursor] == 0) {
1796+
groupCursor = wcursor + 1;
1797+
if (groupCursor >= 8) {
1798+
groupCursor = 0;
1799+
}
1800+
goto wloop;
17971801
}
1798-
goto wloop;
17991802
}
18001803

18011804
int pick = Rand__5CMathFUl(&Math);

0 commit comments

Comments
 (0)