forked from alterware/iw6-mod
Compare commits
2 Commits
misc_chang
...
changed_co
Author | SHA1 | Date | |
---|---|---|---|
d76f41deb9 | |||
d424dc2c45 |
@ -5,6 +5,7 @@
|
||||
#include "game/dvars.hpp"
|
||||
|
||||
#include "console.hpp"
|
||||
#include "demo_playback.hpp"
|
||||
|
||||
#include <utils/hook.hpp>
|
||||
#include <utils/string.hpp>
|
||||
@ -13,6 +14,12 @@ namespace dvar_cheats
|
||||
{
|
||||
void apply_sv_cheats(const game::dvar_t* dvar, const game::DvarSetSource source, game::dvar_value* value)
|
||||
{
|
||||
// return early because sv_cheats is enabled when playing back demos
|
||||
if (demo_playback::playing())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (dvar && dvar->name == "sv_cheats"s)
|
||||
{
|
||||
// if dedi, do not allow internal to change value so servers can allow cheats if they want to
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <std_include.hpp>
|
||||
#include "loader/component_loader.hpp"
|
||||
#include "fps.hpp"
|
||||
#include "scheduler.hpp"
|
||||
|
||||
#include "game/game.hpp"
|
||||
@ -74,6 +75,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 +102,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));
|
||||
}
|
||||
@ -155,6 +174,11 @@ namespace fps
|
||||
}
|
||||
}
|
||||
|
||||
float get_avg_fps()
|
||||
{
|
||||
return 1000.0f / (cg_perf.average + std::numeric_limits<float>::epsilon());
|
||||
}
|
||||
|
||||
class component final : public component_interface
|
||||
{
|
||||
public:
|
||||
|
6
src/client/component/fps.hpp
Normal file
6
src/client/component/fps.hpp
Normal file
@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
namespace fps
|
||||
{
|
||||
[[nodiscard]] float get_avg_fps();
|
||||
}
|
@ -83,6 +83,12 @@ namespace party
|
||||
});
|
||||
}
|
||||
|
||||
void connect_to_dummy_party(const std::string& mapname, const std::string& gametype)
|
||||
{
|
||||
const game::netadr_t dummy_target{};
|
||||
connect_to_party(dummy_target, mapname, gametype);
|
||||
}
|
||||
|
||||
void switch_gamemode_if_necessary(const std::string& gametype)
|
||||
{
|
||||
const auto target_mode = gametype == "aliens" ? game::CODPLAYMODE_ALIENS : game::CODPLAYMODE_CORE;
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
namespace party
|
||||
{
|
||||
void connect_to_dummy_party(const std::string& mapname, const std::string& gametype);
|
||||
|
||||
void switch_gamemode_if_necessary(const std::string& gametype);
|
||||
void perform_game_initialization();
|
||||
|
||||
|
Reference in New Issue
Block a user