diff --git a/DockerFile b/DockerFile index 7334cdc..f053524 100644 --- a/DockerFile +++ b/DockerFile @@ -1,2 +1,2 @@ -FROM opensuse/tumbleweed -RUN zypper install -y mingw32-cross-gcc-c++ +FROM ubuntu:22.04 +RUN apt update; DEBIAN_FRONTEND=noninteractive apt install -y g++-mingw-w64-i686 diff --git a/README.md b/README.md index 9b6f21b..0ad7091 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,10 @@ - game runs on rough milisecond precision, recommend keeping framerate below 300 - `framelimiter_full_busy_loop` in `s4_league_fps_unlock.json` adjusts the built-in frame limiter's behavior when fps limit is non 0 - it is set to `false` by default to not fully busy loop before the next frame - - setting it to `true` might improve latency at lower framerates, at the cost of busy looping power usage + - setting it to `true` might improve latency when the game is rendering faster than the frame limiter, at the cost of busy looping cpu power usage +- `framelimiter_busy_loop_buffer_100ns` is a mixed approach of `framelimiter_full_busy_loop`, enforcing some busy loop right before the next frame + - `framelimiter_full_busy_loop` has to be set to false for this to take effect + - it is set to `15000` by default to not always busy loop but still try and secure cpu resources timely for the next frame + - when the game is rendering faster than the frame limiter, setting it to `0` would reduce cpu power usage, but might introduce latency and frametime jitter when there are active background tasks json.hpp is optained from https://github.com/nlohmann v3.11.3 release diff --git a/s4_league_fps_unlock.cpp b/s4_league_fps_unlock.cpp index a51dd89..f836ed1 100644 --- a/s4_league_fps_unlock.cpp +++ b/s4_league_fps_unlock.cpp @@ -52,8 +52,6 @@ NtSetTimerResolution( static ULONG min_nt_delay_100ns; -#define SLEEP_BUFFER_100NS (10000 + 5000) - #define ENABLE_LOGGING 0 #if ENABLE_LOGGING @@ -113,6 +111,7 @@ struct config{ int field_of_view; int sprint_field_of_view; bool framelimiter_full_busy_loop; + int framelimiter_busy_loop_buffer_100ns; }; static uint32_t target_frametime_ns; @@ -123,10 +122,11 @@ static uint8_t weapon_slot; static float set_drop_val; struct config config = { - .max_framerate = -1, + .max_framerate = 300, .field_of_view = 60, .sprint_field_of_view = 80, .framelimiter_full_busy_loop = false, + .framelimiter_busy_loop_buffer_100ns = 15000, }; static void parse_config(){ @@ -177,6 +177,12 @@ static void parse_config(){ staging_config.framelimiter_full_busy_loop = parsed_config_file["framelimiter_full_busy_loop"]; LOG_VERBOSE("setting framelimiter full busy loop to %s", staging_config.framelimiter_full_busy_loop ? "true" : "false"); } + if(!parsed_config_file["framelimiter_busy_loop_buffer_100ns"].is_number()){ + LOG("failed reading framelimiter_busy_loop_buffer_100ns from %s, ", config_file_name) + }else{ + staging_config.framelimiter_busy_loop_buffer_100ns = parsed_config_file["framelimiter_busy_loop_buffer_100ns"]; + LOG_VERBOSE("setting framelimiter busy loop buffer (100ns) to %s", framelimiter_busy_loop_buffer_100ns); + } }catch(nlohmann::json::exception e){ LOG("failed reading %s after parsing, %s", config_file_name, e.what()); } @@ -637,8 +643,8 @@ void __attribute__((thiscall)) patched_game_tick(void *tick_ctx){ // spin it all }else{ uint32_t diff_100ns = diff_ns / 100; - if(target_frametime_100ns > diff_100ns + SLEEP_BUFFER_100NS){ - uint32_t sleep_100ns = target_frametime_100ns - (diff_100ns + SLEEP_BUFFER_100NS); + if(target_frametime_100ns > diff_100ns + config.framelimiter_busy_loop_buffer_100ns){ + uint32_t sleep_100ns = target_frametime_100ns - (diff_100ns + config.framelimiter_busy_loop_buffer_100ns); #if LOG_VERBOSE uint32_t sleep_100ns_pre_correct = sleep_100ns; #endif diff --git a/s4_league_fps_unlock.json b/s4_league_fps_unlock.json index 4fc9469..87749a2 100644 --- a/s4_league_fps_unlock.json +++ b/s4_league_fps_unlock.json @@ -2,5 +2,6 @@ "max_framerate":300, "field_of_view":60, "sprint_field_of_view":80, - "framelimiter_full_busy_loop":false + "framelimiter_full_busy_loop":false, + "framelimiter_busy_loop_buffer_100ns":15000 }