Skip to content

Commit e36e66f

Browse files
committed
feat: revert precision ban for LP
1 parent 2ca7a42 commit e36e66f

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

docs/cvars.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@
269269
|sar_hud_portals|0|Draws total portal count.|
270270
|sar_hud_position|0|Draws absolute position of the client.<br>0 = Default,<br>1 = Player position,<br>2 = Camera (shoot) position.|
271271
|sar_hud_precision|2|Precision of HUD numbers.|
272+
|sar_hud_precision_disable_warning|cmd|sar_hud_precision_disable_warning {lp\|reset} - Disables the warning about high precision values in HUD.|
272273
|sar_hud_rainbow|-1|Enables the rainbow HUD mode. -1 = default, 0 = disable, 1 = enable.|
273274
|sar_hud_session|0|Draws current session tick.|
274275
|sar_hud_set_text|cmd|sar_hud_set_text \<id> \<text>... - sets and shows the nth text value in the HUD|

src/Features/Hud/CheatWarn.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ static Cheat g_cheats[] = {
6868
return fabsf(engine->GetIPT() - 1.0f / sar.game->Tickrate()) > 0.00001f;
6969
}, "tickrate is not default", "remove '-tickrate' from the game launch options" },
7070

71+
{ +[]() {
72+
return sar_hud_precision.GetInt() > 2 && g_hudPrecisionWarn;
73+
}, "sar_hud_precision is at a banned value", "(really!) run 'sar_hud_precision 2'" },
74+
7175
{ +[]() {
7276
return g_update_status == 0;
7377
}, "SAR is not up-to-date", "run 'sar_update'" }

src/Features/Hud/Hud.cpp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,34 @@ ON_EVENT(FRAME) {
6666
}
6767
}
6868

69+
bool g_hudPrecisionWarn = true;
70+
CON_COMMAND(sar_hud_precision_disable_warning, "sar_hud_precision_disable_warning {lp|reset} - Disables the warning about high precision values in HUD.\n") {
71+
if (args.ArgC() > 2) {
72+
return console->Print(sar_hud_precision_disable_warning.ThisPtr()->m_pszHelpString);
73+
}
74+
if (args.ArgC() == 1) {
75+
if (g_hudPrecisionWarn) return console->Print("HUD precision above 2 is only allowed in Least Portals. Run \"sar_hud_precision_disable_warning lp\" to confirm.\n");
76+
return console->Print(sar_hud_precision_disable_warning.ThisPtr()->m_pszHelpString);
77+
}
78+
if (!strcmp(args[1], "reset")) {
79+
g_hudPrecisionWarn = true;
80+
return;
81+
} else if (!strcmp(args[1], "lp")) {
82+
g_hudPrecisionWarn = false;
83+
return;
84+
} else {
85+
return console->Print(sar_hud_precision_disable_warning.ThisPtr()->m_pszHelpString);
86+
}
87+
}
88+
ON_EVENT_P(CONFIG_EXEC, -1) {
89+
g_hudPrecisionWarn = true;
90+
}
91+
6992
static inline int getPrecision(bool velocity = false) {
7093
int p = velocity ? sar_hud_velocity_precision.GetInt() : sar_hud_precision.GetInt();
7194
if (p < 0) p = 0;
7295
if (!sv_cheats.GetBool()) {
73-
const int max = 2;
96+
const int max = velocity ? 2 : 6;
7497
if (p > max) p = max;
7598
}
7699
return p;

src/Features/Hud/Hud.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ extern Variable sar_hud_precision;
172172
extern Variable sar_hud_shorthand;
173173
extern QAngle g_bluePortalAngles[2];
174174
extern QAngle g_orangePortalAngles[2];
175+
extern bool g_hudPrecisionWarn;
175176

176177
DECL_DECLARE_AUTOCOMPLETION_FUNCTION(HudSetPos);
177178

0 commit comments

Comments
 (0)