diff --git a/artifacts/ddraw.ini b/artifacts/ddraw.ini index 0369f43f..45ca8ca0 100644 --- a/artifacts/ddraw.ini +++ b/artifacts/ddraw.ini @@ -352,6 +352,11 @@ PlayIdleAnimOnReload=0 ;Set to 1 to prevent corpses from blocking line of fire CorpseLineOfFireFix=0 +;Changes the timer (in days) for deleting corpses on a map after you leave (valid range: 0..13) +;Default is 6. Set to 0 for a 12-hour timer +;The corpses of critters with 'Ages' flag or on maps with 'dead_bodies_age=No' set in maps.txt will not disappear +CorpseDeleteTime=6 + ;Set a number of milliseconds to idle each input loop ;Set to -1 to disable ;Set to 0 to idle only if other processes are waiting for processor time diff --git a/sfall/Modules/BugFixes.cpp b/sfall/Modules/BugFixes.cpp index 366415f9..29e398f1 100644 --- a/sfall/Modules/BugFixes.cpp +++ b/sfall/Modules/BugFixes.cpp @@ -1956,6 +1956,7 @@ isDead: cmp eax, -1; je noBlood; mov eax, [esp - 4]; // object +// mov [eax + frm], 3; // set frame mov ebx, [esi + elevation]; mov edx, [esi + tile]; xor ecx, ecx; diff --git a/sfall/Modules/MiscPatches.cpp b/sfall/Modules/MiscPatches.cpp index e2981cb9..dadc7268 100644 --- a/sfall/Modules/MiscPatches.cpp +++ b/sfall/Modules/MiscPatches.cpp @@ -351,7 +351,7 @@ fail: static void __declspec(naked) op_obj_can_see_obj_hook() { __asm { push fo::funcoffs::obj_shoot_blocking_at_; // check hex objects func pointer - push 0x20; // flags, 0x20 = check shootthru + push 0x20; // flags, 0x20 = check ShootThru mov ecx, dword ptr [esp + 0x0C]; // buf **ret_objStruct push ecx; xor ecx, ecx; @@ -910,6 +910,20 @@ void MiscPatches::init() { dlogr(" Done", DL_INIT); } + int time = GetConfigInt("Misc", "CorpseDeleteTime", 6); // time in days + if (time != 6) { + dlog("Applying corpse deletion time patch.", DL_INIT); + if (time <= 0) { + time = 12; // hours + } else if (time > 13) { + time = 13 * 24; + } else { + time *= 24; + } + SafeWrite32(0x483348, time); + dlogr(" Done", DL_INIT); + } + LoadGameHook::OnBeforeGameStart() += BodypartHitChances; // set on start & load CombatProcFix(); diff --git a/sfall/Modules/Perks.cpp b/sfall/Modules/Perks.cpp index 177abd01..f55ac363 100644 --- a/sfall/Modules/Perks.cpp +++ b/sfall/Modules/Perks.cpp @@ -30,7 +30,7 @@ using namespace fo; constexpr int maxNameLen = 64; // don't change size constexpr int maxDescLen = 512; // don't change size -const int descLen = 256; // maximum text length for interface +static const int descLen = 256; // maximum text length for interface static char perksFile[MAX_PATH] = {0}; @@ -206,7 +206,8 @@ void _stdcall SetSelectablePerk(char* name, int active, int image, char* desc) { if (!strcmp(name, fakeSelectablePerks[i].Name)) { fakeSelectablePerks[i].Level = active; fakeSelectablePerks[i].Image = image; - strncpy_s(fakeSelectablePerks[i].Desc, desc, _TRUNCATE); + strncpy(fakeSelectablePerks[i].Desc, desc, descLen - 1); + fakeSelectablePerks[i].Desc[descLen - 1] = 0; return; } } @@ -230,7 +231,8 @@ void _stdcall SetFakePerk(char* name, int level, int image, char* desc) { if (!strcmp(name, fakePerks[i].Name)) { fakePerks[i].Level = level; fakePerks[i].Image = image; - strncpy_s(fakePerks[i].Desc, desc, _TRUNCATE); + strncpy(fakePerks[i].Desc, desc, descLen - 1); + fakePerks[i].Desc[descLen - 1] = 0; return; } } @@ -254,7 +256,8 @@ void _stdcall SetFakeTrait(char* name, int active, int image, char* desc) { if (!strcmp(name, fakeTraits[i].Name)) { fakeTraits[i].Level = active; fakeTraits[i].Image = image; - strncpy_s(fakeTraits[i].Desc, desc, _TRUNCATE); + strncpy(fakeTraits[i].Desc, desc, descLen - 1); + fakeTraits[i].Desc[descLen - 1] = 0; return; } } @@ -806,9 +809,15 @@ static void PerkEngineInit() { // perk_owed hooks MakeCall(0x4AFB2F, LevelUpHack, 1); // replaces 'mov edx, ds:[PlayerLevel]' SafeWrite8(0x43C2EC, 0xEB); // skip the block of code which checks if the player has gained a perk (now handled in level up code) + + // Disable losing unused perks + SafeWrite16(0x43C369, 0x0DFE); // dec byte ptr ds:_free_perk + SafeWrite8(0x43C370, 0xB1); // jmp 0x43C322 } static void PerkSetup() { + memcpy(perks, var::perk_data, sizeof(PerkInfo) * PERK_count); // copy vanilla data + if (!perksReInit) { // _perk_data SafeWriteBatch((DWORD)perks, {0x496669, 0x496837, 0x496BAD, 0x496C41, 0x496D25}); @@ -817,8 +826,6 @@ static void PerkSetup() { SafeWrite32(0x496BF5, (DWORD)perks + 8); SafeWrite32(0x496AD4, (DWORD)perks + 12); } - memcpy(perks, var::perk_data, sizeof(PerkInfo) * PERK_count); // copy vanilla data - if (perksFile[0] != '\0') { char num[4]; for (int i = 0; i < PERK_count; i++) { @@ -925,10 +932,6 @@ static void PerkSetup() { } } perksReInit = false; - - // Disable losing unused perks - SafeWrite16(0x43C369, 0x0DFE); // dec byte ptr ds:_free_perk - SafeWrite8(0x43C370, 0xB1); // jmp 0x43C322 } static __declspec(naked) void PerkInitWrapper() {