Fixed the start procedure not being called correctly

* If the required standard script procedure is missing, the procedure
above the start proc is called instead of the start (from Crafty)

Added a id reversion mechanism to remove_weapon_knockback.
This commit is contained in:
NovaRain
2019-04-15 13:04:15 +08:00
parent 6791b15af1
commit ceb55cdfa9
7 changed files with 39 additions and 5 deletions
+1 -1
View File
@@ -71,7 +71,7 @@ GraphicsHeight=0
GPUBlt=0
;Set to 1 to allow using 32 bit graphics for talking heads
;Requires graphics mode 4 or 5, and GPUBlt set to 1
;Requires DX9 graphics mode and v2.0 pixel shader support (see GPUBlt option)
Use32BitHeadGraphics=0
;Set to 1 to automatically search for alternative avi video files when Fallout tries to play the game movies
+26
View File
@@ -2014,6 +2014,28 @@ skip:
}
}
static void __declspec(naked) exec_script_proc_hack() {
__asm {
mov eax, [esi + 0x58];
test eax, eax;
ja end;
inc eax; // start proc
end:
retn;
}
}
static void __declspec(naked) exec_script_proc_hack1() {
__asm {
mov esi, [edi + 0x58];
test esi, esi;
ja end;
inc esi; // start proc
end:
retn;
}
}
void BugsInit()
{
// fix vanilla negate operator on float values
@@ -2544,4 +2566,8 @@ void BugsInit()
HookCall(0x48D666, obj_load_dude_hook1);
BlockCall(0x48D675);
BlockCall(0x48D69D);
// Fix for the start procedure not being called correctly if the required standard script procedure is missing
MakeCall(0x4A4926, exec_script_proc_hack);
MakeCall(0x4A4979, exec_script_proc_hack1);
}
+4
View File
@@ -986,6 +986,10 @@ long __stdcall QueueFindFirst(TGameObj* object, long qType) {
}
}
long __stdcall NewObjId() {
__asm call new_obj_id_;
}
// for the backported AmmoCostHook from 4.x
long __stdcall ItemWAnimWeap(TGameObj* item, DWORD hitMode) {
__asm {
+2
View File
@@ -1008,6 +1008,8 @@ long __stdcall StatLevel(TGameObj* critter, long statId);
long __stdcall QueueFindFirst(TGameObj* object, long qType);
long __stdcall NewObjId();
// for the backported AmmoCostHook from 4.x
long __stdcall ItemWAnimWeap(TGameObj* item, DWORD hitMode);
long __stdcall ItemWComputeAmmoCost(TGameObj* item, DWORD* rounds);
+3 -1
View File
@@ -202,8 +202,10 @@ void _stdcall KnockbackSetMod(TGameObj* object, DWORD type, float val, DWORD on)
void _stdcall KnockbackRemoveMod(TGameObj* object, DWORD on) {
std::vector<KnockbackModifier>* mods;
int id = object->ID;
switch (on) {
case 0:
object->ID = NewObjId(); // revert to engine range id
mods = &mWeapons;
break;
case 1:
@@ -216,7 +218,7 @@ void _stdcall KnockbackRemoveMod(TGameObj* object, DWORD on) {
return;
}
for (DWORD i = 0; i < mods->size(); i++) {
if ((*mods)[i].id == object->ID) {
if ((*mods)[i].id == id) {
mods->erase(mods->begin() + i);
return;
}
+1 -1
View File
@@ -29,7 +29,7 @@ enum SfallDataType {
};
enum UniqueID {
UID_START = 0x10000000,
UID_START = 0x0FFFFFFF, // start at 0x10000000
UID_END = 0x7FFFFFFF
};
+2 -2
View File
@@ -269,7 +269,7 @@ static void __declspec(naked) PlayFrameHook2() {
}
}
static DWORD _cdecl PreparePlayMovie(const DWORD id) {
static DWORD __cdecl PreparePlayMovie(const DWORD id) {
//Get file path in unicode
wchar_t path[MAX_PATH];
char* master_patches = *(char**)_patches;
@@ -538,7 +538,7 @@ static sDSSound* PlayingSound(wchar_t* path, bool loop) {
}
static const wchar_t *SoundExtensions[] = { L"mp3", L"wma", L"wav" };
static bool _cdecl SoundFileLoad(DWORD called, const char* path) {
static bool __cdecl SoundFileLoad(DWORD called, const char* path) {
if (!path || strlen(path) < 4) return false;
wchar_t buf[256];
mbstowcs_s(0, buf, path, 256);