From d76f41deb9e1322a047c3ac1d7290f97e6ee8f5f Mon Sep 17 00:00:00 2001 From: Caball Date: Tue, 31 Dec 2024 00:30:58 +0100 Subject: [PATCH] Added changes to outside code. --- src/client/component/dvar_cheats.cpp | 7 +++++++ src/client/component/fps.cpp | 6 ++++++ src/client/component/fps.hpp | 6 ++++++ src/client/component/party.cpp | 6 ++++++ src/client/component/party.hpp | 2 ++ 5 files changed, 27 insertions(+) create mode 100644 src/client/component/fps.hpp diff --git a/src/client/component/dvar_cheats.cpp b/src/client/component/dvar_cheats.cpp index bda4b71..4b96ba3 100644 --- a/src/client/component/dvar_cheats.cpp +++ b/src/client/component/dvar_cheats.cpp @@ -5,6 +5,7 @@ #include "game/dvars.hpp" #include "console.hpp" +#include "demo_playback.hpp" #include #include @@ -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 diff --git a/src/client/component/fps.cpp b/src/client/component/fps.cpp index 154cf8c..d38ca1c 100644 --- a/src/client/component/fps.cpp +++ b/src/client/component/fps.cpp @@ -1,5 +1,6 @@ #include #include "loader/component_loader.hpp" +#include "fps.hpp" #include "scheduler.hpp" #include "game/game.hpp" @@ -173,6 +174,11 @@ namespace fps } } + float get_avg_fps() + { + return 1000.0f / (cg_perf.average + std::numeric_limits::epsilon()); + } + class component final : public component_interface { public: diff --git a/src/client/component/fps.hpp b/src/client/component/fps.hpp new file mode 100644 index 0000000..d0a537f --- /dev/null +++ b/src/client/component/fps.hpp @@ -0,0 +1,6 @@ +#pragma once + +namespace fps +{ + [[nodiscard]] float get_avg_fps(); +} diff --git a/src/client/component/party.cpp b/src/client/component/party.cpp index 5316622..628b159 100644 --- a/src/client/component/party.cpp +++ b/src/client/component/party.cpp @@ -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; diff --git a/src/client/component/party.hpp b/src/client/component/party.hpp index 85d1a82..d3e985b 100644 --- a/src/client/component/party.hpp +++ b/src/client/component/party.hpp @@ -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();