Moved static addresses into respective funcs in Stats.cpp

This commit is contained in:
NovaRain
2020-06-13 00:26:31 +08:00
parent cc9807344a
commit 2cd79c1033
7 changed files with 19 additions and 11 deletions
+2
View File
@@ -1557,6 +1557,7 @@ static void __declspec(naked) compute_damage_hack() {
static int currDescLen = 0;
static bool showItemDescription = false;
static void __stdcall AppendText(const char* text, const char* desc) {
if (showItemDescription && currDescLen == 0) {
strncpy_s(tempBuffer, desc, 161);
@@ -1630,6 +1631,7 @@ skip:
}
static DWORD expSwiftLearner; // experience points for print
static void __declspec(naked) statPCAddExperienceCheckPMs_hack() {
__asm {
mov expSwiftLearner, edi;
+1
View File
@@ -44,6 +44,7 @@ skip:
}
static DWORD explosion_effect_starting_dir = 0;
static void __declspec(naked) explosion_effect_hook() {
static const DWORD explosion_effect_hook_back = 0x411AB9;
__asm {
+3 -1
View File
@@ -451,8 +451,10 @@ static DWORD __stdcall QuickSaveGame(DbFile* file, char* filename) {
FILETIME ftCurrSlot;
GetSaveFileTime(filename, &ftCurrSlot);
if (currSlot == 0 || ftCurrSlot.dwHighDateTime > ftPrevSlot.dwHighDateTime
|| (ftCurrSlot.dwHighDateTime == ftPrevSlot.dwHighDateTime && ftCurrSlot.dwLowDateTime > ftPrevSlot.dwLowDateTime)) {
|| (ftCurrSlot.dwHighDateTime == ftPrevSlot.dwHighDateTime && ftCurrSlot.dwLowDateTime > ftPrevSlot.dwLowDateTime))
{
ftPrevSlot.dwHighDateTime = ftCurrSlot.dwHighDateTime;
ftPrevSlot.dwLowDateTime = ftCurrSlot.dwLowDateTime;
+1 -1
View File
@@ -1174,7 +1174,7 @@ capsMultiDrop:
__asm retn;
}
__asm add esp, 4;
__asm jmp InvenActionObjDropRet; // no caps drop
__asm jmp InvenActionObjDropRet; // no caps drop
}
static void __declspec(naked) InvenActionExplosiveDropHack() {
+2
View File
@@ -116,6 +116,7 @@ void GetSavePath(char* buf, char* ftype) {
}
static char SaveSfallDataFailMsg[128];
static void __stdcall SaveGame2() {
char buf[MAX_PATH];
GetSavePath(buf, "gv");
@@ -156,6 +157,7 @@ errorSave:
}
static char SaveFailMsg[128];
static DWORD __stdcall CombatSaveTest() {
if (!saveInCombatFix && !IsNpcControlled()) return 1;
if (inLoop & COMBAT) {
+4 -3
View File
@@ -52,7 +52,8 @@ static const SfallMetarule* currentMetarule;
// Example handler. Feel free to add handlers in other files.
#ifndef NDEBUG
static std::string mf_test_stringBuf;
static std::string test_stringBuf;
static void mf_test() {
std::ostringstream sstream;
sstream << "sfall_funcX(\"test\"";
@@ -76,8 +77,8 @@ static void mf_test() {
}
sstream << ")";
mf_test_stringBuf = sstream.str();
opHandler.setReturn(mf_test_stringBuf.c_str());
test_stringBuf = sstream.str();
opHandler.setReturn(test_stringBuf.c_str());
}
#endif
+6 -6
View File
@@ -64,8 +64,8 @@ static int __fastcall check_stat_level(register int value, DWORD stat) {
return value;
}
static const DWORD StatLevelHackCheck_Ret = 0x4AF3D7;
static void __declspec(naked) stat_level_hack_check() {
static const DWORD StatLevelHackCheck_Ret = 0x4AF3D7;
__asm {
mov edx, esi; // stat
call check_stat_level; // ecx - value
@@ -73,10 +73,10 @@ static void __declspec(naked) stat_level_hack_check() {
}
}
static const DWORD StatSetBaseHack_RetMin = 0x4AF57E;
static const DWORD StatSetBaseHack_RetMax = 0x4AF591;
static const DWORD StatSetBaseHack_Ret = 0x4AF59C;
static void __declspec(naked) stat_set_base_hack_check() {
static const DWORD StatSetBaseHack_RetMin = 0x4AF57E;
static const DWORD StatSetBaseHack_RetMax = 0x4AF591;
static const DWORD StatSetBaseHack_Ret = 0x4AF59C;
__asm {
cmp esi, dword ptr ds:[_obj_dude];
jz pc;
@@ -175,8 +175,8 @@ static void __declspec(naked) stat_recalc_derived_hack() {
}
}
static const DWORD StatSetBaseRet = 0x4AF559;
static void __declspec(naked) stat_set_base_hack_allow() {
static const DWORD StatSetBaseRet = 0x4AF559;
__asm {
cmp ecx, STAT_unused;
je allow;
@@ -193,8 +193,8 @@ notAllow:
}
}
static const DWORD SetCritterStatRet = 0x455D8A;
static void __declspec(naked) op_set_critter_stat_hack() {
static const DWORD SetCritterStatRet = 0x455D8A;
__asm {
cmp dword ptr [esp + 0x2C - 0x28 + 4], STAT_unused;
je allow;