Speed graph fix

This commit is contained in:
Federico Cecchetto 2022-07-04 18:31:05 +02:00
parent c1c22a9642
commit 8b7e5d46dd
2 changed files with 10 additions and 9 deletions

View File

@ -142,9 +142,9 @@ namespace fps
}
const auto speed = static_cast<float>(sqrt(
pow(game::g_entities[0].client->velocity[0], 2) +
pow(game::g_entities[0].client->velocity[1], 2) +
pow(game::g_entities[0].client->velocity[2], 2)
pow(game::g_clients[0].velocity[0], 2) +
pow(game::g_clients[0].velocity[1], 2) +
pow(game::g_clients[0].velocity[2], 2)
));
const auto font = speed_font;
@ -165,7 +165,7 @@ namespace fps
void draw_box(const float x, const float y, const float w, const float h, float* color)
{
game::vec4_t dark_color;
game::vec4_t dark_color{};
dark_color[0] = color[0] * 0.5f;
dark_color[1] = color[1] * 0.5f;
@ -189,9 +189,9 @@ namespace fps
}
const auto speed = static_cast<float>(sqrt(
pow(game::g_entities[0].client->velocity[0], 2) +
pow(game::g_entities[0].client->velocity[1], 2) +
(cg_speedGraphIncludeZAxis->current.enabled ? pow(game::g_entities[0].client->velocity[2], 2) : 0)
pow(game::g_clients[0].velocity[0], 2) +
pow(game::g_clients[0].velocity[1], 2) +
(cg_speedGraphIncludeZAxis->current.enabled ? pow(game::g_clients[0].velocity[2], 2) : 0)
));
const auto base_width = relative(cg_speedGraphWidth->current.integer);
@ -230,7 +230,7 @@ namespace fps
for (auto i = 0; i < speed_history.size(); i++)
{
const auto percentage = std::min(speed_history[i] / std::max(1500.f, max_speed), 1.f);
const auto percentage = std::min(speed_history[i] / std::max(500.f, max_speed), 1.f);
const auto height = percentage * base_height;
const auto x = base_x + static_cast<float>(diff + i) * width + 2.f;
@ -295,7 +295,7 @@ namespace fps
check_resize();
draw_fps();
if (!game::CL_IsCgameInitialized() || !game::g_entities[0].client)
if (!game::CL_IsCgameInitialized() || game::g_entities[0].client == nullptr)
{
return;
}

View File

@ -175,6 +175,7 @@ namespace game
WEAK symbol<int> g_poolSize{0x140BF2E40};
WEAK symbol<gentity_s> g_entities{0x1452DDDA0};
WEAK symbol<gclient_s> g_clients{0x1455DA980};
WEAK symbol<int> num_entities{0x1455CC738};
WEAK symbol<PathData> pathData{0x1452CCDA0};
WEAK symbol<int> vehicle_pathnode_count{0x14D009A30};