Skip to content

Commit

Permalink
Replace remaining class checks
Browse files Browse the repository at this point in the history
A few class checks did not check for inheritence
  • Loading branch information
szapp committed Aug 29, 2021
1 parent 0fedf3a commit 842b38a
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 20 deletions.
62 changes: 46 additions & 16 deletions src/exec/misc.asm
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@ setVobToTransient:
resetStackoffset 0x68
pusha

mov ecx, [esi]
cmp ecx, oCNpc__vftable
jnz .back
mov eax, [esi]
mov ecx, esi
call DWORD [eax]
push eax
push oCNpc__classDef
call zCObject__CheckInheritance
add esp, 0x8
test eax, eax
jz .back

mov eax, [esi+g1g2(0x7B0,0x770)] ; oCNpc.instanz
test eax, eax
Expand Down Expand Up @@ -478,9 +484,19 @@ fix_Hlp_GetNpc:
mov eax, [esi+zCPar_Symbol_offset_offset]
test eax, eax
jz g1g2(0x65880E,0x6EEE6E)
mov eax, [eax]
cmp eax, oCNpc__vftable
jnz g1g2(0x65880E,0x6EEE6E)

push ecx
mov ecx, eax
mov eax, [ecx]
call DWORD [eax]
push eax
push oCNpc__classDef
call zCObject__CheckInheritance
add esp, 0x8
test eax, eax
pop ecx
jz g1g2(0x65880E,0x6EEE6E)
verifyStackoffset 0x10

; Jump back
push edi
Expand All @@ -493,11 +509,18 @@ fix_Hlp_IsValidNpc:
resetStackoffset 0x18
test eax, eax
jz .back
mov eax, [eax]
cmp eax, oCNpc__vftable
jz .back
xor eax, eax
jmp .backClean

push ecx
mov ecx, eax
mov eax, [ecx]
call DWORD [eax]
push eax
push oCNpc__classDef
call zCObject__CheckInheritance
add esp, 0x8
test eax, eax
pop ecx
jz .backClean
verifyStackoffset 0x18

.back:
Expand All @@ -512,11 +535,18 @@ fix_Hlp_IsValidItem:
resetStackoffset 0x18
test eax, eax
jz .back
mov eax, [eax]
cmp eax, oCItem__vftable
jz .back
xor eax, eax
jmp .backClean

push ecx
mov ecx, eax
mov eax, [ecx]
call DWORD [eax]
push eax
push oCItem__classDef
call zCObject__CheckInheritance
add esp, 0x8
test eax, eax
pop ecx
jz .backClean
verifyStackoffset 0x18

.back:
Expand Down
3 changes: 1 addition & 2 deletions src/inc/engine_g1.inc
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@
%define oCGame__GetInfoManager 0x638AE0 ; void
%define oCMissionManager_misMan 0x8DAB2C ; oCMissionManager*
%define oCNpc__classDef 0x8DB408 ; zCClassDef
%define oCNpc__vftable 0x7DDF34 ; const
%define oCItem__vftable 0x7DD0CC ; const
%define oCItem__classDef 0x8DAA80 ; zCClassDef
%define zCObject__CheckInheritance 0x470130 ; zCClassDef const *, zCClassDef const *
%define oCWorld__InsertInLists 0x6D7670 ; zCVob *
%define oCWorld__RemoveFromLists 0x6D7750 ; zCVob *
Expand Down
3 changes: 1 addition & 2 deletions src/inc/engine_g2.inc
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@
%define oCGame__GetInfoManager 0x6C2C90 ; void
%define oCMissionManager_misMan 0xAB1384 ; oCMissionManager*
%define oCNpc__classDef 0xAB1E20 ; zCClassDef
%define oCNpc__vftable 0x83D724 ; const
%define oCItem__vftable 0x83C804 ; const
%define oCItem__classDef 0xAB1168 ; zCClassDef
%define zCObject__CheckInheritance 0x476E30 ; zCClassDef const *, zCClassDef const *
%define oCWorld__InsertInLists 0x7808B0 ; zCVob *
%define oCWorld__RemoveFromLists 0x780990 ; zCVob *
Expand Down

0 comments on commit 842b38a

Please sign in to comment.