Fixed the screen not returning to the player when moving a controlled critter to another elevation of the map.

Refactored some code in Bugs.cpp.
This commit is contained in:
NovaRain
2019-03-04 12:55:34 +08:00
parent c20e709659
commit 08b9d98d3b
6 changed files with 107 additions and 104 deletions
+3 -4
View File
@@ -175,7 +175,6 @@ DebugEditorKey=0
;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
[Misc] [Misc]
;Time limit in years. Must be between -3 and 13 ;Time limit in years. Must be between -3 and 13
;Set to 0 if you want to die the instant you leave arroyo ;Set to 0 if you want to die the instant you leave arroyo
;Set to -1 to remove the time limit, and automatically reset the date back to 2241 each time you would have reached it ;Set to -1 to remove the time limit, and automatically reset the date back to 2241 each time you would have reached it
@@ -480,13 +479,13 @@ NPCStage6Fix=0
;2 - Restoring the -1 AP bonus for HtH attacks (i.e. Fallout 1 behaviour) ;2 - Restoring the -1 AP bonus for HtH attacks (i.e. Fallout 1 behaviour)
FastShotFix=1 FastShotFix=1
;Set to 1 to boost the maximum number of script names from 1450 to 10000
BoostScriptDialogLimit=0
;Allows you to edit the skill tables ;Allows you to edit the skill tables
;Point the next line at an ini file containing the replacement skill data ;Point the next line at an ini file containing the replacement skill data
;SkillsFile=Skills.ini ;SkillsFile=Skills.ini
;Set to 1 to boost the maximum number of script names from 1450 to 10000
BoostScriptDialogLimit=0
;To change the relationship between SPECIAL stats and derived stats, uncomment the next line ;To change the relationship between SPECIAL stats and derived stats, uncomment the next line
;See the Stats.ini in the modders pack for an example file ;See the Stats.ini in the modders pack for an example file
;DerivedStats=Stats.ini ;DerivedStats=Stats.ini
+2 -2
View File
@@ -91,11 +91,11 @@ void BooksInit() {
bool includeVanilla = (GetPrivateProfileIntA("main", "overrideVanilla", 0, iniBooks) == 0); bool includeVanilla = (GetPrivateProfileIntA("main", "overrideVanilla", 0, iniBooks) == 0);
if (includeVanilla) BooksCount = 5; if (includeVanilla) BooksCount = 5;
int count = max(0, GetPrivateProfileIntA("main", "count", 0, iniBooks)); int count = GetPrivateProfileIntA("main", "count", 0, iniBooks);
if (count > BooksMax) count = BooksMax;
int n = 0; int n = 0;
if (count > 0) { if (count > 0) {
if (count > BooksMax) count = BooksMax;
books = new sBook[BooksCount + count]; books = new sBook[BooksCount + count];
if (includeVanilla) LoadVanillaBooks(); if (includeVanilla) LoadVanillaBooks();
+72 -71
View File
@@ -195,97 +195,95 @@ skip:
} }
} }
static void __declspec(naked) item_d_check_addict_hack() { static void __declspec(naked) item_d_check_addict_hack() { // replace engine function
__asm { __asm {
mov edx, 2 // type = addiction push 0x47A6A1; // return addr
cmp eax, -1 // Has drug_pid? mov edx, 2; // type = addiction
je skip // No cmp eax, -1; // Has drug_pid?
mov ebx, eax // ebx = drug_pid jne skip; // No
mov eax, esi // eax = who mov eax, dword ptr ds:[_obj_dude];
call queue_find_first_ jmp queue_find_first_; // return player addiction
loopQueue:
test eax, eax // Has something in the list?
jz end // No
cmp ebx, dword ptr [eax+0x4] // drug_pid == queue_addict.drug_pid?
je end // Has specific addiction
mov eax, esi // eax = who
mov edx, 2 // type = addiction
call queue_find_next_
jmp loopQueue
skip: skip:
mov eax, dword ptr ds:[_obj_dude] mov ebx, eax; // ebx = drug_pid
call queue_find_first_ mov eax, esi; // eax = who
call queue_find_first_;
loopQueue:
test eax, eax; // Has something in the list?
jz end; // No
cmp ebx, dword ptr [eax + 0x4]; // drug_pid == queue_addict.drug_pid?
je end; // Has specific addiction
mov eax, esi; // eax = who
mov edx, 2; // type = addiction
call queue_find_next_;
jmp loopQueue;
end: end:
push 0x47A6A1 retn;
retn
} }
} }
static void __declspec(naked) remove_jet_addict() { static void __declspec(naked) RemoveJetAddictFunc() {
__asm { __asm {
cmp eax, dword ptr ds:[_wd_obj] cmp eax, dword ptr ds:[_wd_obj];
jne end jne end;
cmp dword ptr [edx+0x4], PID_JET // queue_addict.drug_pid == PID_JET? cmp dword ptr [edx + 0x4], PID_JET; // queue_addict.drug_pid == PID_JET?
jne end
xor eax, eax
inc eax // Delete from queue
retn
end: end:
xor eax, eax // Don't touch sete al; // 1 = Delete from queue, 0 = Don't touch
retn and eax, 0xFF;
retn;
} }
} }
static void __declspec(naked) item_d_take_drug_hack() { static void __declspec(naked) item_d_take_drug_hack() {
__asm { __asm {
cmp dword ptr [eax], 0 // queue_addict.init cmp dword ptr [eax], 0; // queue_addict.init
jne skip // Addiction is not active yet jne skip; // Addiction is not active yet
mov edx, PERK_add_jet mov edx, PERK_add_jet;
mov eax, esi mov eax, esi;
call perform_withdrawal_end_ call perform_withdrawal_end_;
skip: skip:
mov dword ptr ds:[_wd_obj], esi mov dword ptr ds:[_wd_obj], esi;
mov eax, 2 // type = addiction mov eax, 2; // type = addiction
mov edx, offset remove_jet_addict mov edx, offset RemoveJetAddictFunc;
call queue_clear_type_ call queue_clear_type_;
push 0x479FD1 push 0x479FD1;
retn retn;
} }
} }
static void __declspec(naked) item_d_load_hack() { static void __declspec(naked) item_d_load_hack() {
__asm { __asm {
sub esp, 4 sub esp, 4; // proto buf
mov [ebp], edi // edi->queue_drug mov [ebp], edi; // edi->queue_drug
mov ecx, 7 mov ecx, 7;
mov esi, _drugInfoList+12 mov esi, _drugInfoList + 12;
loopDrug: loopDrug:
cmp dword ptr [esi+8], 0 // drugInfoList.numeffects cmp dword ptr [esi + 8], 0; // drugInfoList.numeffects
je nextDrug je nextDrug;
mov edx, esp mov edx, esp;
mov eax, [esi] // drugInfoList.pid mov eax, [esi]; // drugInfoList.pid
call proto_ptr_ call proto_ptr_;
mov edx, [esp] mov edx, [esp];
mov eax, [edx+0x24] // drug.stat0 mov eax, [edx + 0x24]; // drug.stat0
cmp eax, [edi+0x4] // drug.stat0 == queue_drug.stat0? cmp eax, [edi + 0x4]; // drug.stat0 == queue_drug.stat0?
jne nextDrug // No jne nextDrug; // No
mov eax, [edx+0x28] // drug.stat1 mov eax, [edx + 0x28]; // drug.stat1
cmp eax, [edi+0x8] // drug.stat1 == queue_drug.stat1? cmp eax, [edi + 0x8]; // drug.stat1 == queue_drug.stat1?
jne nextDrug // No jne nextDrug; // No
mov eax, [edx+0x2C] // drug.stat2 mov eax, [edx + 0x2C]; // drug.stat2
cmp eax, [edi+0xC] // drug.stat2 == queue_drug.stat2? cmp eax, [edi + 0xC]; // drug.stat2 == queue_drug.stat2?
je foundPid // Yes je foundPid; // Yes
nextDrug: nextDrug:
add esi, 12 add esi, 12;
loop loopDrug dec ecx;
jnz loopDrug;
jz end;
foundPid: foundPid:
jecxz end mov eax, [esi]; // drugInfoList.pid
mov eax, [esi] // drugInfoList.pid mov [edi], eax; // queue_drug.drug_pid
mov [edi], eax // queue_drug.drug_pid
end: end:
xor eax, eax xor eax, eax;
add esp, 4 add esp, 4;
retn retn;
} }
} }
@@ -655,7 +653,8 @@ found:
add edx, [esp+0x40] // inventory_offset add edx, [esp+0x40] // inventory_offset
mov eax, ds:[_pud] mov eax, ds:[_pud]
mov ecx, [eax] // itemsCount mov ecx, [eax] // itemsCount
jecxz skip test ecx, ecx
jz skip
dec ecx dec ecx
cmp edx, ecx cmp edx, ecx
ja skip ja skip
@@ -679,13 +678,15 @@ static void __declspec(naked) drop_ammo_into_weapon_hook() {
jge skip // Yes jge skip // Yes
lea edx, [eax+0x2C] // Inventory lea edx, [eax+0x2C] // Inventory
mov ecx, [edx] // itemsCount mov ecx, [edx] // itemsCount
jcxz skip // inventory is empty (another excess check, but leave it) test ecx, ecx
jz skip // inventory is empty (another excess check, but leave it)
mov edx, [edx+8] // FirstItem mov edx, [edx+8] // FirstItem
nextItem: nextItem:
cmp ebp, [edx] // Our weapon? cmp ebp, [edx] // Our weapon?
je foundItem // Yes je foundItem // Yes
add edx, 8 // Go to the next add edx, 8 // Go to the next
loop nextItem dec ecx
jnz nextItem
jmp skip // Our weapon is not in inventory jmp skip // Our weapon is not in inventory
foundItem: foundItem:
cmp dword ptr [edx+4], 1 // Only one weapon? cmp dword ptr [edx+4], 1 // Only one weapon?
+2 -2
View File
@@ -100,7 +100,6 @@ static void SaveRealDudeState() {
real_Experience = *ptr_Experience_; real_Experience = *ptr_Experience_;
real_free_perk = *ptr_free_perk; real_free_perk = *ptr_free_perk;
real_unspent_skill_points = ptr_curr_pc_stat[0]; real_unspent_skill_points = ptr_curr_pc_stat[0];
//real_map_elevation = *ptr_map_elevation;
real_sneak_working = *ptr_sneak_working; real_sneak_working = *ptr_sneak_working;
SkillGetTags(real_tag_skill, 4); SkillGetTags(real_tag_skill, 4);
@@ -169,6 +168,8 @@ static void TakeControlOfNPC(TGameObj* npc) {
// restores the real dude state // restores the real dude state
static void RestoreRealDudeState() { static void RestoreRealDudeState() {
*ptr_map_elevation = real_dude->elevation;
*ptr_obj_dude = real_dude; *ptr_obj_dude = real_dude;
*ptr_inven_dude = real_dude; *ptr_inven_dude = real_dude;
@@ -182,7 +183,6 @@ static void RestoreRealDudeState() {
*ptr_Experience_ = real_Experience; *ptr_Experience_ = real_Experience;
*ptr_free_perk = real_free_perk; *ptr_free_perk = real_free_perk;
ptr_curr_pc_stat[0] = real_unspent_skill_points; ptr_curr_pc_stat[0] = real_unspent_skill_points;
//real_map_elevation = *ptr_map_elevation; -- why save elevation?
*ptr_sneak_working = real_sneak_working; *ptr_sneak_working = real_sneak_working;
SkillSetTags(real_tag_skill, 4); SkillSetTags(real_tag_skill, 4);
+5 -3
View File
@@ -181,7 +181,7 @@ static void __declspec(naked) funcGetShaderTexture() {
pop ecx; pop ecx;
jmp end; jmp end;
fail: fail:
mov edx, -1 mov edx, -1;
end: end:
//Pass back the result //Pass back the result
mov eax, ecx; mov eax, ecx;
@@ -388,7 +388,8 @@ argloopstart:
mov eax, ebp; mov eax, ebp;
call interpretPopLong_; call interpretPopLong_;
mov [esp + ecx * 4 - 0x4], eax; mov [esp + ecx * 4 - 0x4], eax;
loop argloopstart; dec ecx;
jnz argloopstart;
//Error check //Error check
mov ecx, 4; mov ecx, 4;
checkloopstart: checkloopstart:
@@ -399,7 +400,8 @@ checkloopstart:
fild [esp + ecx * 4 + 0x4]; fild [esp + ecx * 4 + 0x4];
fstp [esp + ecx * 4 + 0x4]; fstp [esp + ecx * 4 + 0x4];
paramWasFloat: paramWasFloat:
loop checkloopstart; dec ecx;
jnz checkloopstart;
cmp word ptr [esp + 0x1a], VAR_TYPE_STR2; cmp word ptr [esp + 0x1a], VAR_TYPE_STR2;
jz next; jz next;
cmp word ptr [esp + 0x1a], VAR_TYPE_STR; cmp word ptr [esp + 0x1a], VAR_TYPE_STR;
+2 -1
View File
@@ -474,7 +474,8 @@ static void __declspec(naked) game_init_databases_hook() {
__asm { __asm {
mov ecx, ds:[_critter_db_handle]; mov ecx, ds:[_critter_db_handle];
mov edx, ds:[_paths]; mov edx, ds:[_paths];
jecxz skip; test ecx, ecx;
jz skip;
mov [ecx + 0xC], edx; // critter_patches.next->_paths mov [ecx + 0xC], edx; // critter_patches.next->_paths
mov edx, ecx; mov edx, ecx;
skip: skip: