Skip to content

Commit

Permalink
Fix HUD positions due of new line in 'bxt_hud_viewangles'
Browse files Browse the repository at this point in the history
  • Loading branch information
SmileyAG committed Sep 25, 2022
1 parent e073b4c commit 19f3a8e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
4 changes: 1 addition & 3 deletions BunnymodXT/cvars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ namespace CVars
CVarWrapper skill;

// Serverside CVars
CVarWrapper bxt_fire_on_stuck("bxt_fire_on_stuck", "0");
CVarWrapper bxt_fire_on_stuck_command("bxt_fire_on_stuck_command", "");
CVarWrapper bxt_fire_on_stuck("bxt_fire_on_stuck", "");
CVarWrapper bxt_autojump("bxt_autojump", "0");
CVarWrapper bxt_autojump_priority("bxt_autojump_priority", "1");
CVarWrapper bxt_bhopcap("bxt_bhopcap", "1");
Expand Down Expand Up @@ -246,7 +245,6 @@ namespace CVars
&default_fov,
&skill,
&bxt_fire_on_stuck,
&bxt_fire_on_stuck_command,
&bxt_autojump,
&bxt_bhopcap,
&bxt_timer_autostop,
Expand Down
1 change: 0 additions & 1 deletion BunnymodXT/cvars.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ namespace CVars

// Serverside CVars
extern CVarWrapper bxt_fire_on_stuck;
extern CVarWrapper bxt_fire_on_stuck_command;
extern CVarWrapper bxt_autojump;
extern CVarWrapper bxt_autojump_priority;
extern CVarWrapper bxt_bhopcap;
Expand Down
20 changes: 11 additions & 9 deletions BunnymodXT/hud_custom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -568,12 +568,14 @@ namespace CustomHud

if (CVars::bxt_hud_viewangles.GetInt() == 2)
{
out << "Pitch: " << cl.last_viewangles[0] << "\n"
out << "Angles (incl. punch):" << "\n"
<< "Pitch: " << cl.last_viewangles[0] << "\n"
<< "Yaw: " << cl.last_viewangles[1];
}
else
{
out << "Pitch: " << player.viewangles[0] << "\n"
out << "Angles:" << "\n"
<< "Pitch: " << player.viewangles[0] << "\n"
<< "Yaw: " << player.viewangles[1];
}

Expand Down Expand Up @@ -717,7 +719,7 @@ namespace CustomHud
if (CVars::bxt_hud_distance.GetBool())
{
int x, y;
GetPosition(CVars::bxt_hud_distance_offset, CVars::bxt_hud_distance_anchor, &x, &y, -200, (si.iCharHeight * 12) + 3);
GetPosition(CVars::bxt_hud_distance_offset, CVars::bxt_hud_distance_anchor, &x, &y, -200, (si.iCharHeight * 13) + 3);

float view[3], end[3];
SetupTraceVectors(view, end);
Expand Down Expand Up @@ -745,7 +747,7 @@ namespace CustomHud
if (CVars::bxt_hud_entity_info.GetBool())
{
int x, y;
GetPosition(CVars::bxt_hud_entity_info_offset, CVars::bxt_hud_entity_info_anchor, &x, &y, -200, (si.iCharHeight * 16) + 3);
GetPosition(CVars::bxt_hud_entity_info_offset, CVars::bxt_hud_entity_info_anchor, &x, &y, -200, (si.iCharHeight * 17) + 3);

const auto& hw = HwDLL::GetInstance();
const auto& sv = ServerDLL::GetInstance();
Expand Down Expand Up @@ -876,7 +878,7 @@ namespace CustomHud
if (CVars::bxt_hud_selfgauss.GetBool())
{
int x, y;
GetPosition(CVars::bxt_hud_selfgauss_offset, CVars::bxt_hud_selfgauss_anchor, &x, &y, -200, (si.iCharHeight * 30) + 3);
GetPosition(CVars::bxt_hud_selfgauss_offset, CVars::bxt_hud_selfgauss_anchor, &x, &y, -200, (si.iCharHeight * 31) + 3);

bool selfgaussable;
int hitGroup = 0; // It's always initialized if selfgaussable is set to true, but GCC issues a warning anyway.
Expand Down Expand Up @@ -934,7 +936,7 @@ namespace CustomHud
if (CVars::bxt_hud_armor.GetBool())
{
int x, y;
GetPosition(CVars::bxt_hud_armor_offset, CVars::bxt_hud_armor_anchor, &x, &y, -200, (si.iCharHeight * 33) + 3);
GetPosition(CVars::bxt_hud_armor_offset, CVars::bxt_hud_armor_anchor, &x, &y, -200, (si.iCharHeight * 34) + 3);

std::ostringstream out;
out.setf(std::ios::fixed);
Expand All @@ -950,7 +952,7 @@ namespace CustomHud
if (CVars::bxt_hud_waterlevel.GetBool())
{
int x, y;
GetPosition(CVars::bxt_hud_waterlevel_offset, CVars::bxt_hud_waterlevel_anchor, &x, &y, -200, (si.iCharHeight * 34) + 3);
GetPosition(CVars::bxt_hud_waterlevel_offset, CVars::bxt_hud_waterlevel_anchor, &x, &y, -200, (si.iCharHeight * 35) + 3);

std::ostringstream out;
out.setf(std::ios::fixed);
Expand All @@ -968,7 +970,7 @@ namespace CustomHud
if (CVars::bxt_hud_nihilanth.GetBool())
{
int x, y;
GetPosition(CVars::bxt_hud_nihilanth_offset, CVars::bxt_hud_nihilanth_anchor, &x, &y, -200, (si.iCharHeight * 35) + 3);
GetPosition(CVars::bxt_hud_nihilanth_offset, CVars::bxt_hud_nihilanth_anchor, &x, &y, -200, (si.iCharHeight * 36) + 3);

std::ostringstream out;
out << "Nihilanth:\n";
Expand Down Expand Up @@ -1002,7 +1004,7 @@ namespace CustomHud
if (CVars::bxt_hud_gonarch.GetBool())
{
int x, y;
GetPosition(CVars::bxt_hud_gonarch_offset, CVars::bxt_hud_gonarch_anchor, &x, &y, -200, (si.iCharHeight * 42) + 3);
GetPosition(CVars::bxt_hud_gonarch_offset, CVars::bxt_hud_gonarch_anchor, &x, &y, -200, (si.iCharHeight * 43) + 3);

std::ostringstream out;
out << "Gonarch:\n";
Expand Down
13 changes: 8 additions & 5 deletions BunnymodXT/modules/ServerDLL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1243,10 +1243,8 @@ void ServerDLL::RegisterCVarsAndCommands()
REG(bxt_show_triggers_legacy);
REG(bxt_render_far_entities);
}
if (ORIG_PM_CheckStuck) {
if (ORIG_PM_CheckStuck)
REG(bxt_fire_on_stuck);
REG(bxt_fire_on_stuck_command);
}
if (ORIG_CTriggerSave__SaveTouch || ORIG_CTriggerSave__SaveTouch_Linux)
REG(bxt_disable_autosave);
if (pCS_Stamina_Value)
Expand Down Expand Up @@ -1444,10 +1442,13 @@ void ServerDLL::LogPlayerMove(bool pre, uintptr_t pmove) const

HOOK_DEF_1(ServerDLL, void, __cdecl, PM_PlayerMove, qboolean, server)
{
if (CVars::bxt_fire_on_stuck.GetBool() && !CVars::bxt_fire_on_stuck_command.IsEmpty() && ORIG_PM_CheckStuck())
bool stuck_cur_frame = ORIG_PM_CheckStuck();
static bool not_stuck_prev_frame = false;

if (!CVars::bxt_fire_on_stuck.IsEmpty() && stuck_cur_frame && not_stuck_prev_frame)
{
std::ostringstream ss;
ss << CVars::bxt_fire_on_stuck_command.GetString().c_str() << "\n";
ss << CVars::bxt_fire_on_stuck.GetString().c_str() << "\n";

HwDLL::GetInstance().ORIG_Cbuf_InsertText(ss.str().c_str());
}
Expand Down Expand Up @@ -1520,6 +1521,8 @@ HOOK_DEF_1(ServerDLL, void, __cdecl, PM_PlayerMove, qboolean, server)
}

CustomHud::UpdatePlayerInfo(velocity, origin);

not_stuck_prev_frame = stuck_cur_frame ? false : true;
}

HOOK_DEF_4(ServerDLL, int, __cdecl, PM_ClipVelocity, float*, in, float*, normal, float*, out, float, overbounce)
Expand Down

0 comments on commit 19f3a8e

Please # to comment.