-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not archive non-persistent logical NPC
Fix #22
- Loading branch information
Showing
9 changed files
with
250 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
; void __thiscall oCSpawnManager::Archive(class zCArchiver &) | ||
; Re-implement oCSpawnManager::Archive to exclude non-persistent NPC | ||
global oCSpawnManager__Archive_fix | ||
oCSpawnManager__Archive_fix: | ||
resetStackoffset | ||
%assign var_total 0x8 ; int | ||
%assign var_element -0x8 ; oTSpawnNode* | ||
%assign var_startpos -0x4 ; int | ||
%assign arg_1 +0x4 ; zCArchiver & | ||
%assign arg_total 0x4 | ||
|
||
sub esp, var_total | ||
pusha | ||
|
||
mov esi, [esp+stackoffset+arg_1] ; arc | ||
mov eax, [esi] | ||
mov ebx, ecx | ||
mov ecx, esi | ||
call DWORD [eax+0x100] ; arc->InSaveGame(void) | ||
test eax, eax | ||
jz .loc_end | ||
|
||
mov eax, [esi] ; Store cursor pos for changed writing order | ||
mov ecx, esi | ||
call DWORD [eax+0x12C] ; arc->StoreGetPos(void) | ||
mov [esp+stackoffset+var_startpos], eax | ||
mov eax, [esi] | ||
xor edx, edx ; Write zero for now | ||
push edx | ||
mov edx, char_noOfEntries | ||
mov ecx, esi | ||
call DWORD [eax+0x10] ; arc->WriteInt(char const *,int) | ||
addStack 4 | ||
|
||
mov eax, [ebx+zCArray.numInArray] | ||
xor edi, edi | ||
xor ebp, ebp | ||
test eax, eax | ||
jle .loc_loopend | ||
|
||
.loc_loop: | ||
mov ecx, [ebx] | ||
mov edx, [ecx+edi*0x4] | ||
mov [esp+stackoffset+var_element], edx ; oTSpawnNode* | ||
|
||
mov ecx, [edx] ; oTSpawnNode.npc | ||
%if GOTHIC_BASE_VERSION == 1 | ||
test BYTE [ecx+0xF5], 0x1 ; zCVob.dontwritetoarchive | ||
%elif GOTHIC_BASE_VERSION == 2 | ||
test BYTE [ecx+0x114], 0x10 ; zCVob.dontwritetoarchive | ||
%endif | ||
jnz .loc_next | ||
|
||
mov eax, [esi] | ||
push ecx | ||
mov edx, char_npc | ||
mov ecx, esi | ||
call DWORD [eax+0x40] ; arc->WriteObject(char const *,zCObject *) | ||
addStack 4 | ||
|
||
mov edx, [esp+stackoffset+var_element] | ||
mov eax, [esi] | ||
add edx, 0x4 ; oTSpawnNode.spawnPos[3] | ||
push edx | ||
mov edx, char_spawnPos | ||
mov ecx, esi | ||
call DWORD [eax+0x28] ; arc->WriteVec3(char const *,zVEC3 const &) | ||
addStack 4 | ||
|
||
mov edx, [esp+stackoffset+var_element] | ||
mov eax, [esi] | ||
push DWORD [edx+0x10] ; oTSpawnNode.timer | ||
mov edx, char_timer | ||
mov ecx, esi | ||
call DWORD [eax+0x1C] ; arc->WriteFloat(char const *,float) | ||
addStack 4 | ||
|
||
mov eax, [ebx+zCArray.numInArray] | ||
inc ebp | ||
|
||
.loc_next: | ||
inc edi | ||
cmp edi, eax | ||
jl .loc_loop | ||
|
||
.loc_loopend: | ||
mov eax, [esi] | ||
mov ecx, esi | ||
call DWORD [eax+0x12C] ; arc->StoreGetPos(void) | ||
mov edx, [esp+stackoffset+var_startpos] | ||
push eax | ||
mov eax, [esi] | ||
mov ecx, esi | ||
call DWORD [eax+0x130] ; arc-StoreSeek(ulong) | ||
|
||
mov eax, [esi] | ||
push ebp | ||
mov edx, char_noOfEntries | ||
mov ecx, esi | ||
call DWORD [eax+0x10] ; arc->WriteInt(char const *,int) | ||
addStack 4 | ||
|
||
pop edx | ||
test ebp, ebp | ||
jz .loc_writelast | ||
|
||
mov eax, [esi] | ||
mov ecx, esi | ||
call DWORD [eax+0x130] ; arc->StoreSeek(ulong) | ||
|
||
.loc_writelast: | ||
mov ecx, [ebx+0x0C] ; oCSpawnManager.spawningEnabled | ||
mov eax, [esi] | ||
push ecx | ||
mov edx, char_spawningEnabled | ||
mov ecx, esi | ||
call DWORD [eax+0x20] ; arc->WriteBool(char const *,int) | ||
addStack 4 | ||
%if GOTHIC_BASE_VERSION == 2 | ||
mov ecx, [ebx+0x20] ; oCSpawnManager.spawnFlags | ||
mov eax, [esi] | ||
push ecx | ||
mov edx, char_spawnFlags | ||
mov ecx, esi | ||
call DWORD [eax+0x10] ; arc->WriteInt(char const *,int) | ||
addStack 4 | ||
%endif | ||
|
||
.loc_end: | ||
popa | ||
add esp, var_total | ||
ret arg_total | ||
verifyStackoffset |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
; Hook oCWorld::Archive to ignore counting of logical NPC that are non-persistent | ||
|
||
%include "inc/macros.inc" | ||
|
||
%if GOTHIC_BASE_VERSION == 1 | ||
%include "inc/symbols_g1.inc" | ||
%elif GOTHIC_BASE_VERSION == 2 | ||
%include "inc/symbols_g2.inc" | ||
%endif | ||
|
||
%ifidn __OUTPUT_FORMAT__, bin | ||
org g1g2(0x6D652A,0x77F66A) | ||
%endif | ||
|
||
bits 32 | ||
|
||
|
||
section .text align=1 ; Prevent auto-alignment | ||
|
||
jmp checkNpcTransient1 | ||
nop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
; Hook oCWorld::Archive to ignore writing of logical NPC that are non-persistent | ||
|
||
%include "inc/macros.inc" | ||
|
||
%if GOTHIC_BASE_VERSION == 1 | ||
%include "inc/symbols_g1.inc" | ||
%elif GOTHIC_BASE_VERSION == 2 | ||
%include "inc/symbols_g2.inc" | ||
%endif | ||
|
||
%ifidn __OUTPUT_FORMAT__, bin | ||
org g1g2(0x6D65A3,0x77F6E1) | ||
%endif | ||
|
||
bits 32 | ||
|
||
|
||
section .text align=1 ; Prevent auto-alignment | ||
|
||
jmp checkNpcTransient2 | ||
nop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
; Hook oCSpawnManager::Archive | ||
|
||
%include "inc/macros.inc" | ||
|
||
%if GOTHIC_BASE_VERSION == 1 | ||
%include "inc/symbols_g1.inc" | ||
%elif GOTHIC_BASE_VERSION == 2 | ||
%include "inc/symbols_g2.inc" | ||
%endif | ||
|
||
%ifidn __OUTPUT_FORMAT__, bin | ||
org g1g2(0x6D0F40,0x7797F0) | ||
%endif | ||
|
||
bits 32 | ||
|
||
|
||
section .text align=1 ; Prevent auto-alignment | ||
|
||
jmp oCSpawnManager__Archive_fix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters