forked from alterware/iw6-mod
Compare commits
2 Commits
update_sym
...
enforce_fp
Author | SHA1 | Date | |
---|---|---|---|
d424dc2c45 | |||
d26a5fe43f |
@ -59,7 +59,7 @@ namespace dedicated_info
|
||||
utils::string::strip(sv_hostname->current.string, cleaned_hostname.data(),
|
||||
cleaned_hostname.size() + 1);
|
||||
|
||||
console::set_title(utils::string::va("%s on %s [%d/%d] (%d)", cleaned_hostname.data(),
|
||||
console::set_title(utils::string::va("%s on %s [%d/%d] (%d)", cleaned_hostname.c_str(),
|
||||
mapname->current.string, client_count,
|
||||
sv_maxclients->current.integer, bot_count));
|
||||
}, scheduler::pipeline::main, 1s);
|
||||
|
@ -74,6 +74,23 @@ namespace fps
|
||||
++data->index;
|
||||
}
|
||||
|
||||
void enforce_fps_limit()
|
||||
{
|
||||
const auto* maxfps = game::Dvar_FindVar("com_maxfps");
|
||||
const auto max = (maxfps) ? std::min(2 * maxfps->current.integer, maxfps->domain.integer.max + 250) : 1250;
|
||||
const auto fps = static_cast<std::int32_t>(static_cast<float>(1000.0f /
|
||||
static_cast<float>(cg_perf.average)) + 9.313225746154785e-10);
|
||||
|
||||
if (fps > max)
|
||||
{
|
||||
// workaround to limit fps
|
||||
scheduler::once([]()
|
||||
{
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(5));
|
||||
}, scheduler::pipeline::renderer);
|
||||
}
|
||||
}
|
||||
|
||||
void perf_update()
|
||||
{
|
||||
cg_perf.count = 32;
|
||||
@ -84,6 +101,7 @@ namespace fps
|
||||
cg_perf.previous_ms = cg_perf.current_ms;
|
||||
|
||||
perf_calc_fps(&cg_perf, cg_perf.frame_ms);
|
||||
enforce_fps_limit();
|
||||
|
||||
utils::hook::invoke<void>(SELECT_VALUE(0x1405806E0, 0x140658E30));
|
||||
}
|
||||
|
@ -46,7 +46,10 @@
|
||||
#undef min
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <atomic>
|
||||
#include <cassert>
|
||||
#include <chrono>
|
||||
#include <filesystem>
|
||||
#include <format>
|
||||
@ -54,6 +57,7 @@
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
#include <numeric>
|
||||
#include <optional>
|
||||
#include <queue>
|
||||
#include <random>
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include "string.hpp"
|
||||
|
||||
#include <MinHook.h>
|
||||
#include <cassert>
|
||||
|
||||
namespace utils::hook
|
||||
{
|
||||
@ -279,6 +280,7 @@ namespace utils::hook
|
||||
void* result = nullptr;
|
||||
runtime.add(&result, &code);
|
||||
|
||||
assert(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user