mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Moved part of AnimationsAtOnceInit code from main.cpp to AnimationsAtOnceLimit.cpp.
Changed the if condition for ProcessorIdle to make sure out-of-bounds values not resulting in unexpected but valid values.
This commit is contained in:
@@ -20,8 +20,7 @@
|
||||
|
||||
#include "AnimationsAtOnceLimit.h"
|
||||
|
||||
|
||||
static bool AniLimitFixActive = false;
|
||||
static int aniMax = 32;
|
||||
|
||||
//pointers to new animation struct arrays
|
||||
static BYTE *anim_set;
|
||||
@@ -143,11 +142,10 @@ static const DWORD sad_28[] = {
|
||||
0x4173CE, 0x4174C1, 0x4175F1, 0x417730,
|
||||
};
|
||||
|
||||
void AnimationsAtOnceInit(signed char aniMax) {
|
||||
|
||||
if (aniMax <= 32) return;
|
||||
|
||||
AniLimitFixActive = true;
|
||||
void AnimationsAtOnceInit() {
|
||||
aniMax = GetPrivateProfileIntA("Misc", "AnimationsAtOnceLimit", 32, ini);
|
||||
if (aniMax > 32 && aniMax <= 127) {
|
||||
dlog("Applying AnimationsAtOnceLimit patch.", DL_INIT);
|
||||
|
||||
int i;
|
||||
|
||||
@@ -173,7 +171,6 @@ void AnimationsAtOnceInit(signed char aniMax) {
|
||||
SafeWrite32(AnimMaxSizeCheck[i], 2656*aniMax);
|
||||
}
|
||||
|
||||
|
||||
//divert old animation structure list pointers to newly alocated memory
|
||||
|
||||
//struct array 1///////////////////
|
||||
@@ -227,7 +224,6 @@ void AnimationsAtOnceInit(signed char aniMax) {
|
||||
//old addr 0x54CC48
|
||||
SafeWrite32(0x415C35, 2656+52+(DWORD)anim_set);
|
||||
|
||||
|
||||
//struct array 2///////////////////
|
||||
|
||||
//old addr 0x530014
|
||||
@@ -293,10 +289,12 @@ void AnimationsAtOnceInit(signed char aniMax) {
|
||||
SafeWrite32(sad_28[i], 40+(DWORD)sad);
|
||||
}
|
||||
|
||||
dlogr(" Done", DL_INIT);
|
||||
}
|
||||
}
|
||||
|
||||
void AnimationsAtOnceExit() {
|
||||
if (!AniLimitFixActive) return;
|
||||
if (aniMax <= 32) return;
|
||||
delete[] anim_set;
|
||||
delete[] sad;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
void AnimationsAtOnceInit(signed char aniMax);
|
||||
void AnimationsAtOnceInit();
|
||||
void AnimationsAtOnceExit();
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ void dlog_f(const char *fmt, int type, ...) {
|
||||
va_list args;
|
||||
va_start(args, type);
|
||||
char buf[4096];
|
||||
vsnprintf_s(buf, sizeof buf, _TRUNCATE, fmt, args);
|
||||
vsnprintf_s(buf, sizeof(buf), _TRUNCATE, fmt, args);
|
||||
Log << buf;
|
||||
Log.flush();
|
||||
va_end(args);
|
||||
|
||||
@@ -244,7 +244,7 @@ public:
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
char msg[1024];
|
||||
vsnprintf_s(msg, sizeof msg, _TRUNCATE, fmt, args);
|
||||
vsnprintf_s(msg, sizeof(msg), _TRUNCATE, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
const char* procName = FindCurrentProc(_program);
|
||||
@@ -391,7 +391,7 @@ static DWORD MotionSensorMode;
|
||||
static BYTE toggleHighlightsKey;
|
||||
static DWORD HighlightContainers;
|
||||
static DWORD Color_Containers;
|
||||
static signed char idle;
|
||||
static int idle;
|
||||
static char HighlightFail1[128];
|
||||
static char HighlightFail2[128];
|
||||
|
||||
@@ -1195,7 +1195,7 @@ void ScriptExtenderSetup() {
|
||||
GetPrivateProfileStringA("Sfall", "HighlightFail2", "Your motion sensor is out of charge.", HighlightFail2, 128, translationIni);
|
||||
|
||||
idle = GetPrivateProfileIntA("Misc", "ProcessorIdle", -1, ini);
|
||||
if (idle > -1) {
|
||||
if (idle > -1 && idle <= 127) {
|
||||
SafeWrite32(_idle_func, (DWORD)Sleep);
|
||||
SafeWrite8(0x4C9F12, 0x6A); // push
|
||||
SafeWrite8(0x4C9F13, idle);
|
||||
@@ -1740,7 +1740,7 @@ void AfterAttackCleanup() {
|
||||
}
|
||||
|
||||
static void RunGlobalScripts1() {
|
||||
if (idle > -1) Sleep(idle);
|
||||
if (idle > -1 && idle <= 127) Sleep(idle);
|
||||
if (toggleHighlightsKey) {
|
||||
//0x48C294 to toggle
|
||||
if (KeyDown(toggleHighlightsKey)) {
|
||||
@@ -1786,7 +1786,7 @@ static void RunGlobalScripts1() {
|
||||
}
|
||||
|
||||
void RunGlobalScripts2() {
|
||||
if (idle > -1) Sleep(idle);
|
||||
if (idle > -1 && idle <= 127) Sleep(idle);
|
||||
for (DWORD d = 0; d < globalScripts.size(); d++) {
|
||||
if (!globalScripts[d].repeat || globalScripts[d].mode != 1) continue;
|
||||
if (++globalScripts[d].count >= globalScripts[d].repeat) {
|
||||
@@ -1796,7 +1796,7 @@ void RunGlobalScripts2() {
|
||||
ResetStateAfterFrame();
|
||||
}
|
||||
void RunGlobalScripts3() {
|
||||
if (idle > -1) Sleep(idle);
|
||||
if (idle > -1 && idle <= 127) Sleep(idle);
|
||||
for (DWORD d = 0; d < globalScripts.size(); d++) {
|
||||
if (!globalScripts[d].repeat || (globalScripts[d].mode != 2 && globalScripts[d].mode != 3)) continue;
|
||||
if (++globalScripts[d].count >= globalScripts[d].repeat) {
|
||||
|
||||
+1
-6
@@ -1378,12 +1378,7 @@ static void DllMain2() {
|
||||
dlogr("Patching out ereg call.", DL_INIT);
|
||||
BlockCall(0x4425E6);
|
||||
|
||||
tmp = GetPrivateProfileIntA("Misc", "AnimationsAtOnceLimit", 32, ini);
|
||||
if ((signed char)tmp > 32) {
|
||||
dlog("Applying AnimationsAtOnceLimit patch.", DL_INIT);
|
||||
AnimationsAtOnceInit((signed char)tmp);
|
||||
dlogr(" Done", DL_INIT);
|
||||
}
|
||||
AnimationsAtOnceInit();
|
||||
|
||||
if (GetPrivateProfileIntA("Misc", "RemoveCriticalTimelimits", 0, ini)) {
|
||||
dlog("Removing critical time limits.", DL_INIT);
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ T SimplePatch(DWORD *addrs, int numAddrs, const char* iniSection, const char* in
|
||||
value = minValue;
|
||||
else if (value > maxValue)
|
||||
value = maxValue;
|
||||
_snprintf_s(msg, sizeof msg, _TRUNCATE, "Applying patch: %s = %d.", iniKey, value);
|
||||
_snprintf_s(msg, sizeof(msg), _TRUNCATE, "Applying patch: %s = %d.", iniKey, value);
|
||||
dlog((const char *)msg, DL_INIT);
|
||||
for (int i=0; i<numAddrs; i++)
|
||||
SafeWrite<T>(addrs[i], (T)value);
|
||||
|
||||
Reference in New Issue
Block a user