Add better hud ping & fps counter
This commit is contained in:
@ -1,6 +1,8 @@
|
||||
#include <std_include.hpp>
|
||||
#include "loader/component_loader.hpp"
|
||||
|
||||
#include "fps.hpp"
|
||||
|
||||
#include "game/game.hpp"
|
||||
#include "game/dvars.hpp"
|
||||
|
||||
@ -93,9 +95,7 @@ namespace fps
|
||||
{
|
||||
if (cg_drawfps->current.integer > 0)
|
||||
{
|
||||
const auto fps = static_cast<std::int32_t>(static_cast<float>(1000.0f / static_cast<float>(cg_perf.
|
||||
average))
|
||||
+ 9.313225746154785e-10);
|
||||
const auto fps = fps::get_fps();
|
||||
|
||||
const auto font = game::R_RegisterFont("fonts/fira_mono_regular.ttf", 25);
|
||||
const auto fps_string = utils::string::va("%i", fps);
|
||||
@ -113,10 +113,8 @@ namespace fps
|
||||
{
|
||||
if (cg_drawping->current.integer > 0 && game::CL_IsCgameInitialized() && !game::VirtualLobby_Loaded())
|
||||
{
|
||||
const auto ping = *reinterpret_cast<int*>(0x142D106F0);
|
||||
|
||||
const auto font = game::R_RegisterFont("fonts/consolefont", 20);
|
||||
const auto ping_string = utils::string::va("Ping: %i", ping);
|
||||
const auto ping_string = utils::string::va("Ping: %i", *game::mp::ping);
|
||||
|
||||
const auto x = (game::ScrPlace_GetViewPlacement()->realViewportSize[0] - 375.0f) - game::R_TextWidth(
|
||||
ping_string, 0x7FFFFFFF, font);
|
||||
@ -134,6 +132,13 @@ namespace fps
|
||||
}
|
||||
}
|
||||
|
||||
int get_fps()
|
||||
{
|
||||
return static_cast<std::int32_t>(static_cast<float>(1000.0f / static_cast<float>(cg_perf.
|
||||
average))
|
||||
+ 9.313225746154785e-10);
|
||||
}
|
||||
|
||||
class component final : public component_interface
|
||||
{
|
||||
public:
|
||||
@ -167,6 +172,9 @@ namespace fps
|
||||
|
||||
scheduler::loop(cg_draw_ping, scheduler::pipeline::renderer);
|
||||
}
|
||||
|
||||
dvars::register_bool("cg_infobar_fps", false, game::DVAR_FLAG_SAVED, true);
|
||||
dvars::register_bool("cg_infobar_ping", false, game::DVAR_FLAG_SAVED, true);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
6
src/client/component/fps.hpp
Normal file
6
src/client/component/fps.hpp
Normal file
@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
namespace fps
|
||||
{
|
||||
int get_fps();
|
||||
}
|
@ -266,7 +266,7 @@ namespace patches
|
||||
|
||||
dvars::register_int("scr_game_spectatetype", 1, 0, 99, game::DVAR_FLAG_REPLICATED);
|
||||
|
||||
dvars::override::register_int("com_maxfps", 0, 10, 1000, game::DVAR_FLAG_SAVED);
|
||||
dvars::override::register_int("com_maxfps", 0, 0, 1000, game::DVAR_FLAG_SAVED);
|
||||
|
||||
// Prevent clients from ending the game as non host by sending 'end_game' lui notification
|
||||
// cmd_lui_notify_server_hook.create(0x140335A70, cmd_lui_notify_server_stub); // H1(1.4)
|
||||
|
Reference in New Issue
Block a user