[nexuiz-commits] r7642 - trunk/data/qcsrc/client

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Sat Sep 5 07:27:46 EDT 2009


Author: fruitiex
Date: 2009-09-05 07:27:46 -0400 (Sat, 05 Sep 2009)
New Revision: 7642

Modified:
   trunk/data/qcsrc/client/sbar.qc
Log:
[NOT FOR 2.5.2] huge sbar.qc cleanup


Modified: trunk/data/qcsrc/client/sbar.qc
===================================================================
--- trunk/data/qcsrc/client/sbar.qc	2009-09-05 10:52:44 UTC (rev 7641)
+++ trunk/data/qcsrc/client/sbar.qc	2009-09-05 11:27:46 UTC (rev 7642)
@@ -1,5 +1,6 @@
 void drawstringright(vector, string, vector, vector, float, float);
 void drawstringcenter(vector, string, vector, vector, float, float);
+
 float weapon_hits[WEP_COUNT];
 float weapon_fired[WEP_COUNT];
 float weapon_number;
@@ -19,8 +20,7 @@
 float ps_primary, ps_secondary;
 float ts_primary, ts_secondary;
 
-vector sbar, color;
-vector element_offset = '0 6 0'; // global item offset from the bottom edge
+vector color;
 float SCOREBOARD_OFFSET = 50;
 
 void CSQC_kh_hud();
@@ -117,20 +117,24 @@
 	vsize_x = vsize_y = lettersize;
 	vsize_z = 0;
 
-	if(num < 0 || (showminusplus == 1 && num <= 0)) // showminusplus is used in the race timer, force showing minus sign if seconds <= 0
+	// showminusplus 1: always prefix with minus sign (useful in race distribution display)
+	// showminusplus 2: always prefix with plus sign (useful in race distribution display)
+	// showminusplus 3: prefix with minus sign if negative, plus sign if positive (useful in score distribution display)
+
+	if((showminusplus == 2 && num >= 0) || (num > 0 && showminusplus == 3))
 	{
-		minus = true;
-		num = -num;
+		plus = true;
 		pos_x -= lettersize;
 	} else
-		minus = false;
+		plus = false;	
 
-	if(showminusplus == 2 && num >= 0) // showminusplus is used in the race timer, force showing plus sign
+	if(num < 0 || (num < 0 && showminusplus == 3) || (showminusplus == 1 && num <= 0))
 	{
-		plus = true;
+		minus = true;
+		num = -num;
 		pos_x -= lettersize;
 	} else
-		plus = false;
+		minus = false;
 
 	if(digits < 0)
 	{
@@ -1035,10 +1039,8 @@
 float scoreboard_bottom;
 void Sbar_DrawScoreboard()
 {
-	vector rgb, pos, tmp, sbar_save;
+	vector rgb, pos, tmp;
 	entity pl, tm;
-	float specs;
-	float center_x;
 
 	if(time > lastpingstime + 10)
 	{
@@ -1054,8 +1056,6 @@
 	xmax = vid_conwidth - xmin;
 	ymax = vid_conheight - 0.2*vid_conheight;
 
-	center_x = xmin + 0.5*sbwidth;
-
 	// Initializes position
 	pos_x = xmin;
 	pos_y = ymin;
@@ -1069,16 +1069,13 @@
 	pos_y += sbar_fontsize_y;
 
 	drawfont = sbar_font;
-
-	sbar_save = sbar;
-	sbar = '0 0 0';
-
+	
+	// Draw the scoreboard
 	vector bg_size;
 	bg_size = drawgetimagesize("gfx/hud/sb_scoreboard_bg");
 
 	if(teamplay)
 	{
-		//for(tm = sortedTeams.sort_next; tm; tm = tm.sort_next)
 		for(tm = teams.sort_next; tm; tm = tm.sort_next)
 		{
 			if(tm.team == COLOR_SPECTATOR)
@@ -1086,10 +1083,10 @@
 
 			rgb = GetTeamRGB(tm.team);
 
-			Sbar_DrawXNum(sbar + pos - '6.5 0 0' * sbar_fontsize_y + '0 1 0' * sbar_fontsize_y, tm.(teamscores[ts_primary]), 4, 0, sbar_fontsize_y * 1.5, rgb, 0, 1, 1, DRAWFLAG_NORMAL);
+			Sbar_DrawXNum(pos - '6.5 0 0' * sbar_fontsize_y + '0 1 0' * sbar_fontsize_y, tm.(teamscores[ts_primary]), 4, 0, sbar_fontsize_y * 1.5, rgb, 0, 1, 1, DRAWFLAG_NORMAL);
 
 			if(ts_primary != ts_secondary)
-				Sbar_DrawXNum(sbar + pos - '4.5 0 0' * sbar_fontsize_y + '0 2.5 0' * sbar_fontsize_y, tm.(teamscores[ts_secondary]), 4, 0, sbar_fontsize_y * 1, rgb, 0, 1, 1, DRAWFLAG_NORMAL);
+				Sbar_DrawXNum(pos - '4.5 0 0' * sbar_fontsize_y + '0 2.5 0' * sbar_fontsize_y, tm.(teamscores[ts_secondary]), 4, 0, sbar_fontsize_y * 1, rgb, 0, 1, 1, DRAWFLAG_NORMAL);
 
 			pos = Sbar_Scoreboard_MakeTable(pos, tm, rgb, bg_size);
 		}
@@ -1100,8 +1097,6 @@
 		rgb_y = cvar("sbar_color_bg_g");
 		rgb_z = cvar("sbar_color_bg_b");
 
-		tm = teams.sort_next;
-
 		for(tm = teams.sort_next; tm; tm = tm.sort_next)
 		{
 			if(tm.team == COLOR_SPECTATOR)
@@ -1113,6 +1108,9 @@
 
 	tmp = pos + '0 1.5 0' * sbar_fontsize_y;
 	pos_y += 3 * sbar_fontsize_y;
+	
+	// List spectators
+	float specs;
 	specs = 0;
 	for(pl = players.sort_next; pl; pl = pl.sort_next)
 	{
@@ -1126,6 +1124,7 @@
 	if(specs)
 		drawstring(tmp, "Spectators", sbar_fontsize, '1 1 1', 1, DRAWFLAG_NORMAL);
 
+	// Print info string
 	string str;
 	float tl, fl, ll;
 	str = strcat("playing on ^2", shortmapname, "^7");
@@ -1197,7 +1196,6 @@
 	pos_y += 1.2 * sbar_fontsize_y;
 	drawcolorcodedstring(pos + '0.5 0 0' * (sbwidth - sbar_fontsize_x * stringwidth(str, TRUE)), str, sbar_fontsize, 0.8, DRAWFLAG_NORMAL);
 
-	sbar = sbar_save;
 	scoreboard_bottom = pos_y + 2 * sbar_fontsize_y;
 }
 
@@ -1266,45 +1264,29 @@
 		return strcat(col, cpname, " (", timestr, " ", strcat(hisname, col, lapstr), ")");
 }
 
-void Sbar_Score(float margin)
+void Sbar_Score()
 {
-	float timelimit, minutes, seconds, timeleft, minutesLeft, secondsLeft, distribution, score, desiredPlayerId;
-	float racemin, racesec, racemsec;
-	float distsec, distmsec, minusplus;
-	vector sbar_save, score_offset, timer_color, offset, distribution_color, minuspos;
+	float score, distribution, leader;
+	vector score_pos, secondary_score_pos, distribution_color;
 	entity tm, pl, me;
-	sbar_save = sbar;
-
- 	vector bottomright;
- 	bottomright_x = vid_conwidth;
- 	bottomright_y = vid_conheight;
- 	bottomright_z = 0;
-
- 	vector topright;
- 	topright_x = vid_conwidth;
- 	topright_y = 0;
- 	topright_z = 0;
-
-	//get the ID (could be "me", or the player I'm spectating)
+	//me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
+	
+	float desiredPlayerId;
 	if (spectatee_status > 0)
 		desiredPlayerId = spectatee_status - 1;
 	else
 		desiredPlayerId = player_localentnum - 1;
 	me = playerslots[desiredPlayerId];
 
-	sbar_y = vid_conheight - (32+12);
-	sbar_x -= margin;
+ 	vector bottomright;
+ 	bottomright_x = vid_conwidth;
+ 	bottomright_y = vid_conheight;
+ 	bottomright_z = 0;
 
-	offset = '0 0 0';
+	score_pos = bottomright - '196 42 0';
+	secondary_score_pos = score_pos + '132 -6 0';
 
-	score_offset_x = 196;
-	score_offset_y = 36;
-	score_offset_z = 0;
-
-	if((scores_flags[ps_primary] & SFL_TIME) && !teamplay)
-	{
-		// me vector := [team/connected frags id]
-
+	if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
 		pl = players.sort_next;
 		if(pl == me)
 			pl = pl.sort_next;
@@ -1314,14 +1296,16 @@
 
 		score = me.(scores[ps_primary]);
 
+		float racemin, racesec, racemsec;
+		float distsec, distmsec, minusplus;
+		
 		racemin = floor(score/(60 * TIME_FACTOR));
 		racesec = floor((score - racemin*(60 * TIME_FACTOR))/TIME_FACTOR);
 		racemsec = score - racemin*60*TIME_FACTOR - racesec*TIME_FACTOR;
 
 		if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
 			// distribution display
-			distribution = me.(scores[ps_primary]);
-			distribution -= pl.(scores[ps_primary]);
+			distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
 
 			if (distribution < TIME_FACTOR && distribution > -TIME_FACTOR)
 				distmsec = fabs(distribution);
@@ -1334,19 +1318,17 @@
 
 			if (distribution <= 0) {
 				distribution_color = '0 1 0';
-				minusplus = 1;
+				minusplus = 1; // minusplus 1: always prefix with minus sign
 			}
 			else {
 				distribution_color = '1 0 0';
-				minusplus = 2;
+				minusplus = 2; // minusplus 1: always prefix with plus sign
 			}
-
 			Sbar_DrawXNum(bottomright - '0 48 0' - '16 0 0' * TIME_DECIMALS, distmsec, -TIME_DECIMALS, 0, 16, distribution_color, 0, 0, sbar_alpha_fg, DRAWFLAG_NORMAL);
 			Sbar_DrawXNum(bottomright - '68 48 0' - '16 0 0' * TIME_DECIMALS, distsec, 4, minusplus, 16, distribution_color, 0, 0, sbar_alpha_fg, DRAWFLAG_NORMAL);
 			drawpic(bottomright - '10 48 0' - '16 0 0' * TIME_DECIMALS, "gfx/hud/num_dot", '16 16 0', distribution_color, sbar_alpha_fg, DRAWFLAG_ADDITIVE);
 		}
-
-		// big timer
+		// race record display
 		if (distribution <= 0 || distribution == score) // draw the highlight background behind the timer if we have the lead
 			drawpic(bottomright - '0 32 0' - '32 0 0' * (4 + TIME_DECIMALS), "gfx/hud/sb_highlight_4", '0 28 0' + '32 0 0' * (4 + TIME_DECIMALS), '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
 
@@ -1357,151 +1339,58 @@
 		Sbar_DrawXNum(bottomright - '0 32 0' - TIME_DECIMALS * '30 0 0' - '132 0 0', racemin, -2, 0, 30, '1 1 1', 0, 0, sbar_alpha_fg, DRAWFLAG_NORMAL);
 		drawpic(bottomright - '0 32 0' - TIME_DECIMALS * '30 0 0' - '84 0 0', "gfx/hud/num_colon", '30 30 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_ADDITIVE);
 
-	}
-	else {
-		if(teamplay)
-		{
-			// Layout:
-			//
-			//   team1 team3 team4
-			//
-			//         TEAM2
-			//for(i = 0; i < 4; ++i)
+	} else if (!teamplay) { // non-teamgames, except race/cts
+		// me vector := [team/connected frags id]
+		pl = players.sort_next;
+		if(pl == me)
+			pl = pl.sort_next;
 
-			float max_fragcount;
-			max_fragcount = -999;
+		if(pl)
+			distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
+		else
+			distribution = 0;
 
-			for(tm = teams.sort_next; tm; tm = tm.sort_next)
-			{
-				if(tm.team == COLOR_SPECTATOR || !tm.team_size) // no players? don't display
-					continue;
-				// -32*4 = -128
-				score = tm.(teamscores[ts_primary]);
+		score = me.(scores[ps_primary]);
+		
+		if(distribution >= 5) {
+			distribution_color = '0 1 0';
+			leader = 1;
+		} else if(distribution >= 0) {
+			distribution_color = '1 1 1';
+			leader = 1;
+		} else if(distribution >= -5)
+			distribution_color = '1 1 0';
+		else
+			distribution_color = '1 0 0';
+		
+		Sbar_DrawXNum(secondary_score_pos, distribution, 4, 3, 16, distribution_color, 0, 0, sbar_alpha_fg, DRAWFLAG_NORMAL);
+		Sbar_DrawXNum(score_pos, score, 4, 0, 34, distribution_color, leader, 0, sbar_alpha_fg, DRAWFLAG_NORMAL);
+	} else { // teamgames
+		float max_fragcount;
+		max_fragcount = -999;
 
-				if (score > max_fragcount)
-					max_fragcount = score;
+		for(tm = teams.sort_next; tm; tm = tm.sort_next) {
+			if(tm.team == COLOR_SPECTATOR || !tm.team_size) // no players? don't display
+				continue;
+			score = tm.(teamscores[ts_primary]);
+			leader = 0;
 
-				if(tm.team == myteam) {
-					if (max_fragcount == score)
-						Sbar_DrawXNum(bottomright - element_offset - score_offset, score, 4, 0, 34, GetTeamRGB(tm.team) * 0.8, 1, 1, sbar_alpha_fg, DRAWFLAG_NORMAL);
-					else
-						Sbar_DrawXNum(bottomright - element_offset - score_offset, score, 4, 0, 34, GetTeamRGB(tm.team) * 0.8, 0, 1, sbar_alpha_fg, DRAWFLAG_NORMAL);
-				}
-				else
-				{
-					if (max_fragcount == score)
-						Sbar_DrawXNum(bottomright - element_offset - score_offset + '132 -6 0' - offset, score, 4, 0, 16, GetTeamRGB(tm.team) * 0.8, 1, 1, sbar_alpha_fg, DRAWFLAG_NORMAL);
-					else
-						Sbar_DrawXNum(bottomright - element_offset - score_offset + '132 -6 0' - offset, score, 4, 0, 16, GetTeamRGB(tm.team) * 0.8, 0, 1, sbar_alpha_fg, DRAWFLAG_NORMAL);
-					offset_y -= 16;
-				}
+			if (score > max_fragcount)
+				max_fragcount = score;
+	
+			if(tm.team == myteam) {
+				if (max_fragcount == score)
+					leader = 1;
+				Sbar_DrawXNum(score_pos, score, 4, 0, 34, GetTeamRGB(tm.team) * 0.8, leader, 1, sbar_alpha_fg, DRAWFLAG_NORMAL);
+			} else {
+				if (max_fragcount == score)
+					leader = 1;
+				Sbar_DrawXNum(secondary_score_pos, score, 4, 0, 16, GetTeamRGB(tm.team) * 0.8, leader, 1, sbar_alpha_fg, DRAWFLAG_NORMAL);
+				secondary_score_pos = secondary_score_pos + '0 16 0';
 			}
-		} else {
-			// me vector := [team/connected frags id]
-
-			pl = players.sort_next;
-			if(pl == me)
-				pl = pl.sort_next;
-
-			if(pl) {
-				distribution = me.(scores[ps_primary]);
-				distribution -= pl.(scores[ps_primary]);
-			} else
-				distribution = 0;
-
-			score = me.(scores[ps_primary]);
-
-			if(distribution >= 0)
-			{
-				if (distribution != 0) {
-					// draw a + sign in front of the score
-					if (distribution < 10) { drawpic(bottomright - element_offset - score_offset + '132 -6 0' + '32 0 0', "gfx/hud/num_plus", '16 16 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_ADDITIVE); }
-					else if (distribution < 100) { drawpic(bottomright - element_offset - score_offset + '132 -6 0' + '16 0 0', "gfx/hud/num_plus", '16 16 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_ADDITIVE); }
-					else if (distribution < 1000) { drawpic(bottomright - element_offset - score_offset + '132 -6 0', "gfx/hud/num_plus", '16 16 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_ADDITIVE); }
-				}
-
-				Sbar_DrawXNum(bottomright - element_offset - score_offset + '132 -6 0', distribution, 4, 0, 16, ' 1 1 1', 0, 0, sbar_alpha_fg, DRAWFLAG_NORMAL);
-				Sbar_DrawXNum(bottomright - element_offset - score_offset, score, 4, 0, 34, '1 1 1', 1, 0, sbar_alpha_fg, DRAWFLAG_NORMAL);
-			}
-			else if(distribution >= -5)
-			{
-				Sbar_DrawXNum(bottomright - element_offset - score_offset + '132 -6 0', distribution, 4, 0, 16, ' 1 1 0', 0, 0, sbar_alpha_fg, DRAWFLAG_NORMAL);
-				Sbar_DrawXNum(bottomright - element_offset - score_offset, score, 4, 0, 34, '1 1 0', 0, 0, sbar_alpha_fg, DRAWFLAG_NORMAL);
-			}
-			else {
-				Sbar_DrawXNum(bottomright - element_offset - score_offset + '132 -6 0', distribution, 4, 0, 16, ' 1 0 0', 0, 0, sbar_alpha_fg, DRAWFLAG_NORMAL);
-				Sbar_DrawXNum(bottomright - element_offset - score_offset, score, 4, 0, 34, '1 0 0', 0, 0, sbar_alpha_fg, DRAWFLAG_NORMAL);
-			}
 		}
 	}
 
-	//draw the remaining or elapsed time
-	timelimit = getstatf(STAT_TIMELIMIT);
-	vector bgpos;
-
-	timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
-	timeleft = ceil(timeleft);
-	minutesLeft = floor(timeleft / 60);
-	secondsLeft = timeleft - minutesLeft*60;
-
-	if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit
-		timer_color = '1 1 1'; //white
-	else if(minutesLeft >= 1)
-		timer_color = '1 1 0'; //yellow
-	else
-		timer_color = '1 0 0'; //red
-
-	if (cvar("sbar_increment_maptime") || timelimit == 0 || warmup_stage) {
-		if (time < getstatf(STAT_GAMESTARTTIME)) {
-			//while restart is still active, show 00:00
-			minutes = seconds = 0;
-		} else {
-			float elapsedTime;
-			elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
-			minutes = floor(elapsedTime / 60);
-			seconds = elapsedTime - minutes*60;
-		}
-		if (minutes < 10)
-			bgpos_x = topright_x - 54 - 17 - 12;
-		else if (minutes < 100)	// nudge the timer background left if more digits are drawn
-			bgpos_x = topright_x - 72 - 17 - 12;
-		else
-			bgpos_x = topright_x - 90 - 17 - 12;
-		bgpos_y = 0;
-		bgpos_z = 0;
-	} else {
-		minutes = minutesLeft;
-		seconds = secondsLeft;
-		if (minutes == 0)
-		bgpos_x = topright_x - 36 - 7 - 12;
-		else if (minutes < 10) // nudge the timer background left if more digits are drawn
-			bgpos_x = topright_x - 54 - 17 - 12;
-		else if (minutes < 100)
-			bgpos_x = topright_x - 72 - 17 - 12;
-		else
-			bgpos_x = topright_x - 90 - 17 - 12;
-		bgpos_y = 0;
-		bgpos_z = 0;
-	}
-
-	if (cvar("viewsize") <= 100) { // draw timer background when viewsize <= 100
-		if (teamplay)
-			drawpic(bgpos, "gfx/hud/sb_timerbg", '120 30 0', GetTeamRGB(myteam) * sbar_color_bg_team, sbar_alpha_bg, DRAWFLAG_NORMAL); // timer bg color = myteam color
-		else {
-			color_x = cvar("sbar_color_bg_r");
-			color_y = cvar("sbar_color_bg_g");
-			color_z = cvar("sbar_color_bg_b");
-
-			drawpic(bgpos, "gfx/hud/sb_timerbg", '120 30 0', color, sbar_alpha_bg, DRAWFLAG_NORMAL);
-		}
-	}
-
-	if(minutesLeft >= 1 || cvar("sbar_increment_maptime") || timelimit == 0 || warmup_stage) {
-		Sbar_DrawXNum(topright - '103 0 0' + '0 2 0', minutes, 3, 0, 18, timer_color, 0, 0, sbar_alpha_fg, DRAWFLAG_NORMAL);
-		drawpic(topright - '53 0 0' + '0 1 0', "gfx/hud/num_colon", '18 18 0', timer_color, sbar_alpha_fg, DRAWFLAG_NORMAL);
-	}
-	Sbar_DrawXNum(topright - '36 0 0' - '3 0 0' + '0 2 0', seconds, -2, 0, 18, timer_color, 0, 0, sbar_alpha_fg, DRAWFLAG_NORMAL);
-
 	if(gametype == GAME_RACE || gametype == GAME_CTS)
 	{
 		drawfont = sbar_bigfont;
@@ -1604,14 +1493,87 @@
 			}
 		}
 
-		drawfont = sbar_font;
+		drawfont = sbar_bigfont;
 	}
-
-	sbar = sbar_save;
 }
 
-float Sbar_WouldDrawScoreboard ()
+void Sbar_Timer()
 {
+	float timelimit, elapsedTime, minutes, seconds, timeleft, minutesLeft, secondsLeft;
+	vector bgpos, timer_color;
+	bgpos = '0 0 0';
+	
+	vector topright;
+	topright = '0 0 0';
+	topright_x = vid_conwidth;
+	
+	timelimit = getstatf(STAT_TIMELIMIT);
+	
+	timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
+	timeleft = ceil(timeleft);
+	minutesLeft = floor(timeleft / 60);
+	secondsLeft = timeleft - minutesLeft*60;
+
+	if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit
+		timer_color = '1 1 1'; //white
+	else if(minutesLeft >= 1)
+		timer_color = '1 1 0'; //yellow
+	else
+		timer_color = '1 0 0'; //red
+
+	if (cvar("sbar_increment_maptime") || timelimit == 0 || warmup_stage) {
+		if (time < getstatf(STAT_GAMESTARTTIME)) {
+			//while restart is still active, show 00:00
+			minutes = seconds = 0;
+		} else {
+			float elapsedTime;
+			elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
+			minutes = floor(elapsedTime / 60);
+			seconds = elapsedTime - minutes*60;
+		}
+		if (minutes < 10)
+			bgpos_x = topright_x - 54 - 17 - 12;
+		else if (minutes < 100)	// nudge the timer background left if more digits are drawn
+			bgpos_x = topright_x - 72 - 17 - 12;
+		else
+			bgpos_x = topright_x - 90 - 17 - 12;
+		bgpos_y = 0;
+		bgpos_z = 0;
+	} else {
+		minutes = minutesLeft;
+		seconds = secondsLeft;
+		if (minutes == 0)
+		bgpos_x = topright_x - 36 - 7 - 12;
+		else if (minutes < 10) // nudge the timer background left if more digits are drawn
+			bgpos_x = topright_x - 54 - 17 - 12;
+		else if (minutes < 100)
+			bgpos_x = topright_x - 72 - 17 - 12;
+		else
+			bgpos_x = topright_x - 90 - 17 - 12;
+		bgpos_y = 0;
+		bgpos_z = 0;
+	}
+
+	if (cvar("viewsize") <= 100) { // draw timer background when viewsize <= 100
+		if (teamplay)
+			drawpic(bgpos, "gfx/hud/sb_timerbg", '120 30 0', GetTeamRGB(myteam) * sbar_color_bg_team, sbar_alpha_bg, DRAWFLAG_NORMAL); // timer bg color = myteam color
+		else {
+			color_x = cvar("sbar_color_bg_r");
+			color_y = cvar("sbar_color_bg_g");
+			color_z = cvar("sbar_color_bg_b");
+
+			drawpic(bgpos, "gfx/hud/sb_timerbg", '120 30 0', color, sbar_alpha_bg, DRAWFLAG_NORMAL);
+		}
+	}
+
+	if(minutesLeft >= 1 || cvar("sbar_increment_maptime") || timelimit == 0 || warmup_stage) {
+		Sbar_DrawXNum(topright - '103 0 0' + '0 2 0', minutes, 3, 0, 18, timer_color, 0, 0, sbar_alpha_fg, DRAWFLAG_NORMAL);
+		drawpic(topright - '53 0 0' + '0 1 0', "gfx/hud/num_colon", '18 18 0', timer_color, sbar_alpha_fg, DRAWFLAG_NORMAL);
+	}
+	Sbar_DrawXNum(topright - '36 0 0' - '3 0 0' + '0 2 0', seconds, -2, 0, 18, timer_color, 0, 0, sbar_alpha_fg, DRAWFLAG_NORMAL);
+}
+
+float Sbar_WouldDrawScoreboard() {
 	if (sb_showscores)
 		return 1;
 	else if (intermission == 1)
@@ -2003,109 +1965,108 @@
 		self = get_weaponinfo(i);
 
 		//if ((weapon_number != 42))  // print them all :)
- 		if ((self.weapon_type == WEP_TYPE_SPLASH) && (weapon_damage))
-		{
-			weapon_stats = bound(0, rint(100 * weapon_hit / weapon_damage), 100);
+		if (weapon_damage) {
+			if (self.weapon_type == WEP_TYPE_SPLASH) {
+				weapon_stats = bound(0, rint(100 * weapon_hit / weapon_damage), 100);
 
-			fill_colour_x = 1 - 0.015 * weapon_stats;
-			fill_colour_y = 1 - 0.015 * (100 - weapon_stats);
+				fill_colour_x = 1 - 0.015 * weapon_stats;
+				fill_colour_y = 1 - 0.015 * (100 - weapon_stats);
 
-// 			how the background colour is calculated
-// 			%	red	green	red_2		green_2
-// 			0	1	0	1 - % * 0.015	1 - (100 - %) * 0.015
-// 			10	0.85	0	1 - % * 0.015	1 - (100 - %) * 0.015
-// 			20	0.70	0	1 - % * 0.015	1 - (100 - %) * 0.015
-// 			30	0.55	0	1 - % * 0.015	1 - (100 - %) * 0.015
-// 			40	0.40	0.10	1 - % * 0.015	1 - (100 - %) * 0.015
-// 			50	0.25	0.25	1 - % * 0.015	1 - (100 - %) * 0.015
-// 			60	0.10	0.40	1 - % * 0.015	1 - (100 - %) * 0.015
-// 			70	0	0.55	1 - % * 0.015	1 - (100 - %) * 0.015
-// 			80	0	0.70	1 - % * 0.015	1 - (100 - %) * 0.015
-// 			90	0	0.85	1 - % * 0.015	1 - (100 - %) * 0.015
-// 			100	0	1	1 - % * 0.015	1 - (100 - %) * 0.015
+				// how the background colour is calculated
+				// %	red		green	red_2			green_2
+				// 0	1		0		1 - % * 0.015	1 - (100 - %) * 0.015
+				// 10	0.85	0		1 - % * 0.015	1 - (100 - %) * 0.015
+				// 20	0.70	0		1 - % * 0.015	1 - (100 - %) * 0.015
+				// 30	0.55	0		1 - % * 0.015	1 - (100 - %) * 0.015
+				// 40	0.40	0.10	1 - % * 0.015	1 - (100 - %) * 0.015
+				// 50	0.25	0.25	1 - % * 0.015	1 - (100 - %) * 0.015
+				// 60	0.10	0.40	1 - % * 0.015	1 - (100 - %) * 0.015
+				// 70	0		0.55	1 - % * 0.015	1 - (100 - %) * 0.015
+				// 80	0		0.70	1 - % * 0.015	1 - (100 - %) * 0.015
+				// 90	0		0.85	1 - % * 0.015	1 - (100 - %) * 0.015
+				// 100	0		1		1 - % * 0.015	1 - (100 - %) * 0.015
 
-			if ((left_border + count_splash * (fill_size_x + col_margin) + fill_size_x) >= vid_conwidth)
-			{
-				count_splash = 0;
-				++row;
-				Sbar_DrawAccuracyStats_Description_Splash('1 0 0' * col_margin + '0 1 0' * (top_border_splash + row * (fill_size_y + row_margin)));
-			}
+				if ((left_border + count_splash * (fill_size_x + col_margin) + fill_size_x) >= vid_conwidth)
+				{
+					count_splash = 0;
+					++row;
+					Sbar_DrawAccuracyStats_Description_Splash('1 0 0' * col_margin + '0 1 0' * (top_border_splash + row * (fill_size_y + row_margin)));
+				}
 
-			pos_x = left_border + count_splash * (fill_size_x + col_margin);
-			pos_y = top_border_splash + row * (fill_size_y + row_margin);
+				pos_x = left_border + count_splash * (fill_size_x + col_margin);
+				pos_y = top_border_splash + row * (fill_size_y + row_margin);
 
-			// background
-			drawpic(pos, "gfx/hud/sb_accuracy", fill_size , fill_colour, sbar_alpha_bg, DRAWFLAG_NORMAL);
-			drawborderlines(sbar_border_thickness, pos, fill_size, '0 0 0', sbar_alpha_bg, DRAWFLAG_NORMAL);
+				// background
+				drawpic(pos, "gfx/hud/sb_accuracy", fill_size , fill_colour, sbar_alpha_bg, DRAWFLAG_NORMAL);
+				drawborderlines(sbar_border_thickness, pos, fill_size, '0 0 0', sbar_alpha_bg, DRAWFLAG_NORMAL);
 
-			// the weapon
-			drawpic(pos, strcat("gfx/hud/inv_weapon", ftos(i-1)), '1 0.5 0' * fill_size_x , '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
+				// the weapon
+				drawpic(pos, strcat("gfx/hud/inv_weapon", ftos(i-1)), '1 0.5 0' * fill_size_x , '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
 
-			// the amount of shots fired or max damage
-			drawstringright(pos + '4.5 0 0' * sbar_fontsize_x + '0 3 0' * sbar_fontsize_y, ftos(weapon_damage), sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
+				// the amount of shots fired or max damage
+				drawstringright(pos + '4.5 0 0' * sbar_fontsize_x + '0 3 0' * sbar_fontsize_y, ftos(weapon_damage), sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
 
-			// the amount of hits or actual damage
-			drawstringright(pos + '4.5 0 0' * sbar_fontsize_x + '0 5 0' * sbar_fontsize_y, ftos(weapon_hit), sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
+				// the amount of hits or actual damage
+				drawstringright(pos + '4.5 0 0' * sbar_fontsize_x + '0 5 0' * sbar_fontsize_y, ftos(weapon_hit), sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
 
-			// the accuracy
-			drawstringright(pos + '4.5 0 0' * sbar_fontsize_x + '0 7 0' * sbar_fontsize_y, strcat(ftos(weapon_stats),"%"), sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
+				// the accuracy
+				drawstringright(pos + '4.5 0 0' * sbar_fontsize_x + '0 7 0' * sbar_fontsize_y, strcat(ftos(weapon_stats),"%"), sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
 
-			// the amount of shots missed or damage wasted
-			drawstringright(pos + '4.5 0 0' * sbar_fontsize_x + '0 9 0' * sbar_fontsize_y, ftos(max(0, weapon_damage - weapon_hit)), sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
+				// the amount of shots missed or damage wasted
+				drawstringright(pos + '4.5 0 0' * sbar_fontsize_x + '0 9 0' * sbar_fontsize_y, ftos(max(0, weapon_damage - weapon_hit)), sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
 
-			++count_splash;
-		}
-		else if ((self.weapon_type == WEP_TYPE_HITSCAN) && (weapon_damage))
-		{
-			weapon_stats = bound(0, rint(100 * weapon_hit / weapon_damage), 100);
+				++count_splash;
+			} else if ((self.weapon_type == WEP_TYPE_HITSCAN) && (weapon_damage)) {
+				weapon_stats = bound(0, rint(100 * weapon_hit / weapon_damage), 100);
 
-			fill_colour_x = 1 - 0.015 * weapon_stats;
-			fill_colour_y = 1 - 0.015 * (100 - weapon_stats);
+				fill_colour_x = 1 - 0.015 * weapon_stats;
+				fill_colour_y = 1 - 0.015 * (100 - weapon_stats);
 
-// 			how the background colour is calculated
-// 			%	red	green	red_2		green_2
-// 			0	1	0	1 - % * 0.015	1 - (100 - %) * 0.015
-// 			10	0.85	0	1 - % * 0.015	1 - (100 - %) * 0.015
-// 			20	0.70	0	1 - % * 0.015	1 - (100 - %) * 0.015
-// 			30	0.55	0	1 - % * 0.015	1 - (100 - %) * 0.015
-// 			40	0.40	0.10	1 - % * 0.015	1 - (100 - %) * 0.015
-// 			50	0.25	0.25	1 - % * 0.015	1 - (100 - %) * 0.015
-// 			60	0.10	0.40	1 - % * 0.015	1 - (100 - %) * 0.015
-// 			70	0	0.55	1 - % * 0.015	1 - (100 - %) * 0.015
-// 			80	0	0.70	1 - % * 0.015	1 - (100 - %) * 0.015
-// 			90	0	0.85	1 - % * 0.015	1 - (100 - %) * 0.015
-// 			100	0	1	1 - % * 0.015	1 - (100 - %) * 0.015
+				// how the background colour is calculated
+				// %	red		green	red_2			green_2
+				// 0	1		0		1 - % * 0.015	1 - (100 - %) * 0.015
+				// 10	0.850	0		1 - % * 0.015	1 - (100 - %) * 0.015
+				// 20	0.70	0		1 - % * 0.015	1 - (100 - %) * 0.015
+				// 30	0.55	0		1 - % * 0.015	1 - (100 - %) * 0.015
+				// 40	0.40	0.10	1 - % * 0.015	1 - (100 - %) * 0.015
+				// 50	0.25	0.25	1 - % * 0.015	1 - (100 - %) * 0.015
+				// 60	0.10	0.40	1 - % * 0.015	1 - (100 - %) * 0.015
+				// 70	0		0.55	1 - % * 0.015	1 - (100 - %) * 0.015
+				// 80	0		0.70	1 - % * 0.015	1 - (100 - %) * 0.015
+				// 90	0		0.85	1 - % * 0.015	1 - (100 - %) * 0.015
+				// 100	0		1		1 - % * 0.015	1 - (100 - %) * 0.015
 
-			if ((left_border + count_hitscan * (fill_size_x + col_margin) + fill_size_x + cvar("stats_right_margin")) >= vid_conwidth)
-			{
-				count_hitscan = 0;
-				++row;
-				Sbar_DrawAccuracyStats_Description_Hitscan('1 0 0' * col_margin + '0 1 0' * (top_border_hitscan + row * (fill_size_y + row_margin)));
-			}
+				if ((left_border + count_hitscan * (fill_size_x + col_margin) + fill_size_x + cvar("stats_right_margin")) >= vid_conwidth)
+				{
+					count_hitscan = 0;
+					++row;
+					Sbar_DrawAccuracyStats_Description_Hitscan('1 0 0' * col_margin + '0 1 0' * (top_border_hitscan + row * (fill_size_y + row_margin)));
+				}
 
-			pos_x = left_border + count_hitscan * (fill_size_x + col_margin);
-			pos_y = top_border_hitscan + row * (fill_size_y + row_margin);
+				pos_x = left_border + count_hitscan * (fill_size_x + col_margin);
+				pos_y = top_border_hitscan + row * (fill_size_y + row_margin);
 
-			// background
-			drawpic(pos, "gfx/hud/sb_accuracy", fill_size , fill_colour, sbar_alpha_bg, DRAWFLAG_NORMAL);
-			drawborderlines(sbar_border_thickness, pos, fill_size, '0 0 0', sbar_alpha_bg, DRAWFLAG_NORMAL);
+				// background
+				drawpic(pos, "gfx/hud/sb_accuracy", fill_size , fill_colour, sbar_alpha_bg, DRAWFLAG_NORMAL);
+				drawborderlines(sbar_border_thickness, pos, fill_size, '0 0 0', sbar_alpha_bg, DRAWFLAG_NORMAL);
 
-			// the weapon
-			drawpic(pos, strcat("gfx/hud/inv_weapon", ftos(i-1)), '1 0.5 0' * fill_size_x , '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
+				// the weapon
+				drawpic(pos, strcat("gfx/hud/inv_weapon", ftos(i-1)), '1 0.5 0' * fill_size_x , '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
 
-			// the amount of shots fired or max damage
-			drawstringright(pos + '4.5 0 0' * sbar_fontsize_x + '0 3 0' * sbar_fontsize_y, ftos(weapon_damage), sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
+				// the amount of shots fired or max damage
+				drawstringright(pos + '4.5 0 0' * sbar_fontsize_x + '0 3 0' * sbar_fontsize_y, ftos(weapon_damage), sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
 
-			// the amount of hits or actual damage
-			drawstringright(pos + '4.5 0 0' * sbar_fontsize_x + '0 5 0' * sbar_fontsize_y, ftos(weapon_hit), sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
+				// the amount of hits or actual damage
+				drawstringright(pos + '4.5 0 0' * sbar_fontsize_x + '0 5 0' * sbar_fontsize_y, ftos(weapon_hit), sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
 
-			// the accuracy
-			drawstringright(pos + '4.5 0 0' * sbar_fontsize_x + '0 7 0' * sbar_fontsize_y, strcat(ftos(weapon_stats),"%"), sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
+				// the accuracy
+				drawstringright(pos + '4.5 0 0' * sbar_fontsize_x + '0 7 0' * sbar_fontsize_y, strcat(ftos(weapon_stats),"%"), sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
 
-			// the amount of shots missed or damage wasted
-			drawstringright(pos + '4.5 0 0' * sbar_fontsize_x + '0 9 0' * sbar_fontsize_y, ftos(max(0, weapon_damage - weapon_hit)), sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
+				// the amount of shots missed or damage wasted
+				drawstringright(pos + '4.5 0 0' * sbar_fontsize_x + '0 9 0' * sbar_fontsize_y, ftos(max(0, weapon_damage - weapon_hit)), sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
 
-			++count_hitscan;
+				++count_hitscan;
+			}
 		}
 	}
 }
@@ -2365,11 +2326,13 @@
 	{
 		if(sb_showscores) {
 			Sbar_DrawScoreboard();
-			Sbar_Score(16);
+			Sbar_Score();
+			Sbar_Timer();
 		}
 		else if(sb_showaccuracy) {
 			Sbar_DrawAccuracyStats();
-			Sbar_Score(16);
+			Sbar_Score();
+			Sbar_Timer();
 		}
   		else
 			Sbar_FinaleOverlay();
@@ -2380,7 +2343,8 @@
   			Sbar_DrawAccuracyStats();
   		else
 			Sbar_DrawScoreboard();
-		Sbar_Score(16);
+		Sbar_Score();
+		Sbar_Timer();
   	}
 	else
 	{
@@ -2400,9 +2364,7 @@
 		fade = bound(0.7, fade, 1);
 
 		vector bg_size; // hud background size
-		bg_size_x = 1600;
-		bg_size_y = 58;
-		bg_size_z = 0;
+		bg_size = '1600 58 0';
 
 		if (cvar("viewsize") <= 100 && vid_conwidth <= 1600) {
 			if (teamplay)
@@ -2423,7 +2385,7 @@
 			v = healtharmor_maxdamage(health, armor, armorblockpercent);
 
 			vector num_pos;
-			num_pos = bottom - element_offset - '0 22 0' + '-96 0 0';
+			num_pos = bottom - '96 28 0';
 
 			x = floor(v_x + 1);
 
@@ -2446,12 +2408,12 @@
 			vector health_pos, armor_pos;
 
 			if (sbar_hudselector == 0) { // old style layout with armor left of health
-				health_pos = bottom - element_offset - '0 22 0' + '14 0 0';
-				armor_pos = bottom - element_offset - '0 22 0' + '-96 0 0';
+				armor_pos = bottom - '96 28 0';
+				health_pos = bottom - '-14 28 0';
 			}
 			else {
-				health_pos = bottom - element_offset - '0 22 0' + '-96 0 0';
-				armor_pos = bottom - element_offset - '0 22 0' + '14 0 0';
+				health_pos = bottom - '96 28 0';				
+				armor_pos = bottom - '-14 28 0';
 			}
 
 			// armor
@@ -2493,30 +2455,26 @@
 		for (i = 0; i < 4; ++i) {
 			a = getstati(GetAmmoStat(i)); // how much ammo do we have of type i?
 
-			if(sbar_currentammo || vid_conwidth < 800) // force showing current ammo only with conwidths < 800
-			{
-				if (stat_items & GetAmmoItemCode(i))
-				{
+			if(sbar_currentammo || vid_conwidth < 800) { // force showing current ammo only with conwidths < 800
+				if (stat_items & GetAmmoItemCode(i)) {
 					if (vid_conwidth >= 800) {
 						pos_x = 230;
 						pos_y = 40;
-					}
-					else {
+					} else {
 						pos_x = 206;
 						pos_y = 33;
 					}
 
+					pos = bottom - pos;
 					if(vid_conwidth >= 800)
-						drawpic(bottom - pos + '0 1.5 0', "gfx/hud/sb_ammobg", '107 29 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
-					drawpic(bottom - pos + '76 3 0', GetAmmoPicture(i), '24 24 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
+						drawpic(pos + '0 1.5 0', "gfx/hud/sb_ammobg", '107 29 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
+					drawpic(pos + '76 3 0', GetAmmoPicture(i), '24 24 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
 					if(a < 10)
-						Sbar_DrawXNum(bottom - pos + '5 5 0', a, 3, 0, 24, '0.7 0 0', 0, 0, sbar_alpha_fg, DRAWFLAG_NORMAL);
+						Sbar_DrawXNum(pos + '5 5 0', a, 3, 0, 24, '0.7 0 0', 0, 0, sbar_alpha_fg, DRAWFLAG_NORMAL);
 					else
-						Sbar_DrawXNum(bottom - pos + '5 5 0', a, 3, 0, 24, '1 1 1', 0, 0, sbar_alpha_fg, DRAWFLAG_NORMAL);
+						Sbar_DrawXNum(pos + '5 5 0', a, 3, 0, 24, '1 1 1', 0, 0, sbar_alpha_fg, DRAWFLAG_NORMAL);
 				}
-			}
-			else
-			{
+			} else {
 				if (a > 0) {
 					switch (i) {
 						case 0: pos_x = 286; pos_y = 48; break; // shells
@@ -2525,19 +2483,20 @@
 						case 3: pos_x = 200; pos_y = 26; break; // cells
 					}
 
+					pos = bottom - pos;
 					if (stat_items & GetAmmoItemCode(i))
-						drawpic(bottom - pos + '0 1.5 0', "gfx/hud/sb_ammobg", '80 22 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
-					drawpic(bottom - pos + '56 3 0', GetAmmoPicture(i), '18 18 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
+						drawpic(pos + '0 1.5 0', "gfx/hud/sb_ammobg", '80 22 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
+					drawpic(pos + '56 3 0', GetAmmoPicture(i), '18 18 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
 					if (a < 10) {
 						if(stat_items & GetAmmoItemCode(i))
-							Sbar_DrawXNum(bottom - pos + '6 4.5 0', a, 3, 0, 16, '0.7 0 0', 0, 0, sbar_alpha_fg, DRAWFLAG_NORMAL);
+							Sbar_DrawXNum(pos + '6 4.5 0', a, 3, 0, 16, '0.7 0 0', 0, 0, sbar_alpha_fg, DRAWFLAG_NORMAL);
 						else
-							Sbar_DrawXNum(bottom - pos + '6 4.5 0', a, 3, 0, 16, '0.7 0 0', 0, 0, sbar_alpha_fg * 0.7, DRAWFLAG_NORMAL);
+							Sbar_DrawXNum(pos + '6 4.5 0', a, 3, 0, 16, '0.7 0 0', 0, 0, sbar_alpha_fg * 0.7, DRAWFLAG_NORMAL);
 					} else {
 						if(stat_items & GetAmmoItemCode(i))
-							Sbar_DrawXNum(bottom - pos + '6 4.5 0', a, 3, 0, 16, '1 1 1', 0, 0, sbar_alpha_fg, DRAWFLAG_NORMAL);
+							Sbar_DrawXNum(pos + '6 4.5 0', a, 3, 0, 16, '1 1 1', 0, 0, sbar_alpha_fg, DRAWFLAG_NORMAL);
 						else
-							Sbar_DrawXNum(bottom - pos + '6 4.5 0', a, 3, 0, 16, '0.7 0.7 0.7', 0, 0, sbar_alpha_fg * 0.7, DRAWFLAG_NORMAL);
+							Sbar_DrawXNum(pos + '6 4.5 0', a, 3, 0, 16, '0.7 0.7 0.7', 0, 0, sbar_alpha_fg * 0.7, DRAWFLAG_NORMAL);
 					}
 				}
 			}
@@ -2572,21 +2531,19 @@
 		}
 
 		// draw scores and timer
-		Sbar_Score(16);
+		Sbar_Score();
+		Sbar_Timer();
 
-		//show strength/invincibility ICON and timer:
+		// draw strength/invincibility icon and timer
 		CSQC_Strength_Timer();
-
+		
+		// draw gametype specific icons
 		if(gametype == GAME_KEYHUNT)
-		{
 			CSQC_kh_hud();
-		} else if(gametype == GAME_CTF)
-		{
+		else if(gametype == GAME_CTF)
 			CSQC_ctf_hud();
-		} else if(gametype == GAME_NEXBALL)
-		{
+		else if(gametype == GAME_NEXBALL)
 			CSQC_nb_hud();
-  		}
 	}
 }
 
@@ -2606,17 +2563,14 @@
 	blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
 
 	if (myteam == COLOR_TEAM1) { // always draw own flag on left
-		redflag_pos = bottomleft - element_offset - '-4 36 0';
-		blueflag_pos = bottomleft - element_offset - '-68 36 0';
+		redflag_pos = bottomleft - '-4 42 0';
+		blueflag_pos = bottomleft - '-68 42 0';
+	} else {
+		blueflag_pos = bottomleft - '-4 42 0';
+		redflag_pos = bottomleft - '-68 42 0';
 	}
 
-	else {
-		blueflag_pos = bottomleft - element_offset - '-4 36 0';
-		redflag_pos = bottomleft - element_offset - '-68 36 0';
-	}
-
-	switch(redflag)
-	{
+	switch(redflag) {
 	case 1: drawpic(redflag_pos, "gfx/hud/sb_flag_red_taken", '48 48 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); break;
 	case 2: drawpic(redflag_pos, "gfx/hud/sb_flag_red_lost", '48 48 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); break;
 	case 3: drawpic(redflag_pos, "gfx/hud/sb_flag_red_carrying", '48 48 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); break;
@@ -2626,8 +2580,7 @@
 				drawpic(redflag_pos, "gfx/hud/sb_flag_red_shielded", '48 48 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); break;
 	}
 
-	switch(blueflag)
-	{
+	switch(blueflag) {
 	case 1: drawpic(blueflag_pos, "gfx/hud/sb_flag_blue_taken", '48 48 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); break;
 	case 2: drawpic(blueflag_pos, "gfx/hud/sb_flag_blue_lost", '48 48 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); break;
 	case 3: drawpic(blueflag_pos, "gfx/hud/sb_flag_blue_carrying", '48 48 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); break;



More information about the nexuiz-commits mailing list