mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Changed the implementation of ProcessorIdle
* now the same as CPU_USAGE_FIX in Mash's HRP, with a simpler toggle setting. * also avoids slowdowns if the player happens to enable both of them.
This commit is contained in:
+3
-6
@@ -1,5 +1,5 @@
|
|||||||
;sfall configuration settings
|
;sfall configuration settings
|
||||||
;v3.8.46
|
;v3.8.46.1
|
||||||
|
|
||||||
[Main]
|
[Main]
|
||||||
;Set to 1 if you want to use command line arguments to tell sfall to use another ini file
|
;Set to 1 if you want to use command line arguments to tell sfall to use another ini file
|
||||||
@@ -464,11 +464,8 @@ PlayIdleAnimOnReload=0
|
|||||||
;Default is 6. Set to 0 for a 12-hour timer
|
;Default is 6. Set to 0 for a 12-hour timer
|
||||||
CorpseDeleteTime=6
|
CorpseDeleteTime=6
|
||||||
|
|
||||||
;Set a number of milliseconds to idle each input loop
|
;Set to 1 to allow the game to go idle during each input loop, preventing 100% CPU usage
|
||||||
;Set to -1 to disable
|
ProcessorIdle=0
|
||||||
;Set to 0 to idle only if other processes are waiting for processor time (WinXP/2000: if processes have equal priority)
|
|
||||||
;Set to 1 (or some higher number if needed) to prevent 100% CPU use. The maximum is 50
|
|
||||||
ProcessorIdle=-1
|
|
||||||
|
|
||||||
;Set to 1 if using the hero appearance mod
|
;Set to 1 if using the hero appearance mod
|
||||||
;Set to 2 for backward compatibility with scripts that manually fix obj_art_fid/art_change_fid_num script functions for dude_obj
|
;Set to 2 for backward compatibility with scripts that manually fix obj_art_fid/art_change_fid_num script functions for dude_obj
|
||||||
|
|||||||
@@ -29,8 +29,6 @@
|
|||||||
namespace sfall
|
namespace sfall
|
||||||
{
|
{
|
||||||
|
|
||||||
static int idle = -1;
|
|
||||||
|
|
||||||
static char mapName[16] = {};
|
static char mapName[16] = {};
|
||||||
static char patchName[65] = {};
|
static char patchName[65] = {};
|
||||||
static char versionString[65] = {};
|
static char versionString[65] = {};
|
||||||
@@ -39,16 +37,23 @@ static int* scriptDialog = nullptr;
|
|||||||
|
|
||||||
bool disableHorrigan = false;
|
bool disableHorrigan = false;
|
||||||
|
|
||||||
static void __stdcall Sleep2(DWORD dwMilliseconds) {
|
// Implementation from HRP by Mash
|
||||||
Sleep(dwMilliseconds);
|
static void __stdcall CheckMessages() {
|
||||||
|
MSG msg;
|
||||||
|
MsgWaitForMultipleObjectsEx(0, 0, 1, 0xFF, 0);
|
||||||
|
while (PeekMessageA(&msg, 0, 0, 0, 0)) {
|
||||||
|
if (GetMessageA(&msg, 0, 0, 0)) {
|
||||||
|
TranslateMessage(&msg);
|
||||||
|
DispatchMessageA(&msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static __declspec(naked) void GNW95_process_message_hack() {
|
static __declspec(naked) void GNW95_process_message_hack() {
|
||||||
|
static const DWORD GNW95_process_message_Ret = 0x4C9DE6;
|
||||||
__asm {
|
__asm {
|
||||||
push idle;
|
call CheckMessages;
|
||||||
call Sleep2;
|
jmp GNW95_process_message_Ret;
|
||||||
cmp dword ptr ds:[FO_VAR_GNW95_isActive], 0;
|
|
||||||
retn;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1025,9 +1030,9 @@ void MiscPatches::init() {
|
|||||||
*fo::ptr::idle_func = reinterpret_cast<void*>(Sleep);
|
*fo::ptr::idle_func = reinterpret_cast<void*>(Sleep);
|
||||||
SafeWrite16(0x4C9F12, 0x7D6A); // push 125 (ms)
|
SafeWrite16(0x4C9F12, 0x7D6A); // push 125 (ms)
|
||||||
|
|
||||||
int ms = IniReader::GetConfigInt("Misc", "ProcessorIdle", -1);
|
if (IniReader::GetConfigInt("Misc", "ProcessorIdle", -1) > 0) {
|
||||||
if (ms > idle) idle = (ms > 50) ? 50 : ms;
|
MakeJump(0x4C9DA9, GNW95_process_message_hack, 3); // replace hack function from HRP by Mash
|
||||||
if (idle >= 0) MakeCall(0x4C9CF8, GNW95_process_message_hack, 2);
|
}
|
||||||
|
|
||||||
BlockCall(0x4425E6); // Patch out ereg call
|
BlockCall(0x4425E6); // Patch out ereg call
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user