Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

D2GAME_TARGETS_Last_6FC40380 (aka TARGETS_RemoveTarget) Missing Else Branch #178

Open
Necrolis opened this issue Nov 27, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@Necrolis
Copy link
Member

if (pTargetNode == pGame->pTargetNodes[nNodeIndex])

The if statement for in the path for target nodes >= 8 has an else branch that is missing from the code but present in the assembly; taken from 1.10 D2Game (verified in 1.13c):

6FC403FF     CMP EDX,EDI ; if (pTargetNode == pGame->pTargetNodes[nNodeIndex])
6FC40401     JNZ SHORT D2Game.6FC4041D
6FC40403     MOV EDI,DWORD PTR DS:[EDX+8]
6FC40406     MOV DWORD PTR DS:[ECX+EAX*4+10F8],EDI
6FC4040D     MOV EAX,DWORD PTR DS:[EDX+8]
6FC40410     TEST EAX,EAX
6FC40412     JE SHORT D2Game.6FC40433
6FC40414     MOV DWORD PTR DS:[EAX+C],0
6FC4041B     JMP SHORT D2Game.6FC40433
6FC4041D     MOV EAX,DWORD PTR DS:[EDX+C] ; else
6FC40420     MOV EDI,DWORD PTR DS:[EDX+8]
6FC40423     MOV DWORD PTR DS:[EAX+8],EDI
6FC40426     MOV EAX,DWORD PTR DS:[EDX+8]
6FC40429     TEST EAX,EAX
6FC4042B     JE SHORT D2Game.6FC40433
6FC4042D     MOV EDI,DWORD PTR DS:[EDX+C]
6FC40430     MOV DWORD PTR DS:[EAX+C],EDI

The alternate case for target nodes < 8 is however correct.

@Necrolis Necrolis added the bug Something isn't working label Nov 27, 2024
@Lectem
Copy link
Member

Lectem commented Dec 9, 2024

I think that would be the code at the end of the whole block

    pTargetNode->unk0x0C->pNext = pTargetNode->pNext;
    if (pTargetNode->pNext)
    {
        pTargetNode->pNext->unk0x0C = pTargetNode->unk0x0C;
    }

    D2_FREE_POOL(pGame->pMemoryPool, pTargetNode);
    pUnit->dwNodeIndex = 11;

It's in common with the end of the loop in the <8 branch (see jump at 6FC403CF).

The code looks correct to me ? (albeit not that easy to follow)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants