Skip to content

Add colors for ammo hud#15

Open
rtxa wants to merge 3 commits intoLevShisterov:masterfrom
rtxa:add-colors-for-ammo-hud
Open

Add colors for ammo hud#15
rtxa wants to merge 3 commits intoLevShisterov:masterfrom
rtxa:add-colors-for-ammo-hud

Conversation

@rtxa
Copy link
Contributor

@rtxa rtxa commented Feb 11, 2019

Info

It will color ammo depending on how much you have.

  • 0..20% ammo - red;
  • 21..50% ammo - orange;
  • 51..90% ammo - yellow;
  • 91..100% ammo - green.

Fixed

  • Fixed backpack ammo not flashing when it changes
  • Fixed inconsistent dimming in backpack ammo

Screens

Red ammo
Orange ammo
Yellow ammo
Green ammo

@tmp64
Copy link

tmp64 commented May 20, 2019

CHud::GetHudAmmoColor may cause "Integer division by zero" exception if maxvalue = 0 for whatever reason. Although I have no idea how to reproduce it (it happened on one particular server when dropping all weapons), I have received a crash report with that error.

diff --git a/cl_dll/CHud.cpp b/cl_dll/CHud.cpp
index de1a1cd..f74a385 100644
--- a/cl_dll/CHud.cpp
+++ b/cl_dll/CHud.cpp
@@ -1037,7 +1037,7 @@ void CHud::GetHudColor( int hudPart, int value, int &r, int &g, int &b )
 void CHud::GetHudAmmoColor(int value, int maxvalue, int &r, int &g, int &b)
 {
 	RGBA *c;
-	if (maxvalue == -1) // if you are using custom weapons, then default colors are going to be used....
+	if (maxvalue == -1 || maxvalue == 0) // if you are using custom weapons, then default colors are going to be used....
 	{
 		ParseColor(m_pCvarColor->string, m_hudColor); c = &m_hudColor;
 	}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants