From c44fd6899276bed6c8505a189c00213dd2e696fb Mon Sep 17 00:00:00 2001 From: FruitieX Date: Wed, 13 Apr 2011 18:58:50 +0300 Subject: [PATCH] fix health/armor wrapping around when someone was fragged --- defaultXonotic.cfg | 2 +- qcsrc/client/shownames.qc | 16 +++++++++++----- qcsrc/server/cl_player.qc | 6 +++--- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/defaultXonotic.cfg b/defaultXonotic.cfg index ccb04f6c1..cec44a571 100644 --- a/defaultXonotic.cfg +++ b/defaultXonotic.cfg @@ -1490,7 +1490,7 @@ seta hud_shownames_fontsize 8 "font size" seta hud_shownames_decolorize 1 "1 = decolorize name in team games, 2 = decolorize always" seta hud_shownames_alpha 0.7 "alpha" seta hud_shownames_resize 1 "enable resizing of the names, then the size cvars will correspond to the maximum size" -seta hud_shownames_mindistance 1000 "start fading alpha/size at this distance" +seta hud_shownames_mindistance 1500 "start fading alpha/size at this distance" seta hud_shownames_maxdistance 2000 "alpha/size is 0 at this distance" // scoreboard diff --git a/qcsrc/client/shownames.qc b/qcsrc/client/shownames.qc index 5cbcfcea4..1c3eeb629 100644 --- a/qcsrc/client/shownames.qc +++ b/qcsrc/client/shownames.qc @@ -91,11 +91,17 @@ void Draw_ShowNames() drawpic_aspect_skin(iconpos, "health", '1 1 0' * iconsize_y, '0 0 0', a * 0.5, DRAWFLAG_NORMAL); drawpic_aspect_skin(iconpos + '0.5 0 0' * iconsize_x, "armor", '1 1 0' * iconsize_y, '0 0 0', a * 0.5, DRAWFLAG_NORMAL); - drawsetcliparea(0, myPos_y + iconsize_y - iconsize_y * min(1, self.healthvalue/autocvar_hud_panel_healtharmor_maxhealth), vid_conwidth, myPos_y + iconsize_y); - drawpic_aspect_skin(iconpos, "health", '1 1 0' * iconsize_y, '1 1 1', a, DRAWFLAG_NORMAL); - - drawsetcliparea(0, myPos_y + iconsize_y - iconsize_y * min(1, self.armorvalue/autocvar_hud_panel_healtharmor_maxarmor), vid_conwidth, myPos_y + iconsize_y); - drawpic_aspect_skin(iconpos + '0.5 0 0' * iconsize_x, "armor", '1 1 0' * iconsize_y, '1 1 1', a, DRAWFLAG_NORMAL); + if(self.healthvalue > 0) + { + drawsetcliparea(0, myPos_y + iconsize_y - iconsize_y * min(1, self.healthvalue/autocvar_hud_panel_healtharmor_maxhealth), vid_conwidth, myPos_y + iconsize_y); + drawpic_aspect_skin(iconpos, "health", '1 1 0' * iconsize_y, '1 1 1', a, DRAWFLAG_NORMAL); + } + + if(self.armorvalue > 0) + { + drawsetcliparea(0, myPos_y + iconsize_y - iconsize_y * min(1, self.armorvalue/autocvar_hud_panel_healtharmor_maxarmor), vid_conwidth, myPos_y + iconsize_y); + drawpic_aspect_skin(iconpos + '0.5 0 0' * iconsize_x, "armor", '1 1 0' * iconsize_y, '1 1 1', a, DRAWFLAG_NORMAL); + } drawresetcliparea(); } else if(autocvar_hud_shownames_status == 2 && teamplay) diff --git a/qcsrc/server/cl_player.qc b/qcsrc/server/cl_player.qc index 6c662cf5c..bd5bb8d1c 100644 --- a/qcsrc/server/cl_player.qc +++ b/qcsrc/server/cl_player.qc @@ -766,10 +766,10 @@ void shownames_think() setorigin(self, self.owner.origin + SHOWNAMES_ORIGIN_OFFSET); self.SendFlags |= 1; } - if(self.health != floor(self.owner.health) || self.armorvalue != floor(self.owner.armorvalue)) + if(self.health != max(0, floor(self.owner.health)) || self.armorvalue != max(0, floor(self.owner.armorvalue))) { - self.health = floor(self.owner.health); - self.armorvalue = floor(self.owner.armorvalue); + self.health = max(0, floor(self.owner.health)); + self.armorvalue = max(0, floor(self.owner.armorvalue)); self.SendFlags |= 2; } self.nextthink = time; -- 2.39.2