Skip to content

Commit c6820b0

Browse files
committed
Fix 1.7 streaming sectors crash when moving around a total replacement map (like VC) that presents itself as if in CShadows::CastShadowSectorList but it wasn't that straightforward..
1. 0x6C65746E - "ntel" (corrupted pointer: executing string data) 2. 0x70A6DC` CShadows::CastShadowSectorList` 3. 0x70AD74` CShadows::RenderStoredShadows` 4. 0x7FDC29` __rwD3D9RenderStateTextureFilter` 5. 0x7FE7CB` __rwD3D9RWSetRenderState`
1 parent 4d2b8e2 commit c6820b0

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

Client/multiplayer_sa/CMultiplayerSA_HookDestructors.cpp

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -515,14 +515,17 @@ static void __declspec(naked) HOOK_CEntityAddMid1()
515515

516516
__asm
517517
{
518-
mov eax, [esp+4]
519-
mov edx, ecx
518+
// At hook entry: ECX = list pointer (thiscall this), [esp] = entity pointer (pushed arg)
519+
mov eax, [esp] // Entity pointer from stack arg
520+
mov edx, ecx // List pointer from ECX
520521

521522
pushad
522523
pushfd
523524

524-
push edx
525-
push eax
525+
// cdecl: push args right-to-left, so arg2 first, arg1 second
526+
// Handler: OnCEntityAddMid1(list, entity)
527+
push eax // arg2: entity
528+
push edx // arg1: list
526529
call OnCEntityAddMid1
527530
add esp, 4*2
528531

@@ -579,14 +582,17 @@ static void __declspec(naked) HOOK_CEntityAddMid2()
579582

580583
__asm
581584
{
582-
mov eax, [esp+4]
583-
mov edx, ecx
585+
// At hook entry: ECX = list pointer (thiscall this), [esp] = entity pointer (pushed arg)
586+
mov eax, [esp] // Entity pointer from stack arg
587+
mov edx, ecx // List pointer from ECX
584588

585589
pushad
586590
pushfd
587591

588-
push edx
589-
push eax
592+
// cdecl: push args right-to-left, so arg2 first, arg1 second
593+
// Handler: OnCEntityAddMid2(list, entity)
594+
push eax // arg2: entity
595+
push edx // arg1: list
590596
call OnCEntityAddMid2
591597
add esp, 4*2
592598

@@ -643,14 +649,17 @@ static void __declspec(naked) HOOK_CEntityAddMid3()
643649

644650
__asm
645651
{
646-
mov eax, [esp+4]
647-
mov edx, ecx
652+
// At hook entry: ECX = list pointer (thiscall this), [esp] = entity pointer (pushed arg)
653+
mov eax, [esp] // Entity pointer from stack arg
654+
mov edx, ecx // List pointer from ECX
648655

649656
pushad
650657
pushfd
651658

652-
push edx
653-
push eax
659+
// cdecl: push args right-to-left, so arg2 first, arg1 second
660+
// Handler: OnCEntityAddMid3(list, entity)
661+
push eax // arg2: entity
662+
push edx // arg1: list
654663
call OnCEntityAddMid3
655664
add esp, 4*2
656665

0 commit comments

Comments
 (0)