From 4ea01cf8c6c4b5f5f9df94c055ade43d97d580a6 Mon Sep 17 00:00:00 2001 From: Bryce Hutchings Date: Thu, 22 Aug 2002 03:32:10 +0000 Subject: [PATCH] countdown code added --- reaction/cgame/cg_draw.c | 74 +++++++++++++++++++++++++++------- reaction/cgame/cg_local.h | 5 +++ reaction/cgame/cg_servercmds.c | 11 +++-- 3 files changed, 72 insertions(+), 18 deletions(-) diff --git a/reaction/cgame/cg_draw.c b/reaction/cgame/cg_draw.c index 7181560e..a3848857 100644 --- a/reaction/cgame/cg_draw.c +++ b/reaction/cgame/cg_draw.c @@ -5,6 +5,9 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.63 2002/08/22 03:32:10 niceass +// countdown code added +// // Revision 1.62 2002/08/21 07:00:07 jbravo // Added CTB respawn queue and fixed game <-> cgame synch problem in CTB // @@ -566,6 +569,35 @@ static void CG_DrawStatusBar(void) =========================================================================================== */ +static float CG_DrawCTBCountDown(float y) +{ + char *s; + int w; + int x = 0; + float Color[4]; + + if ( cg.CTBcountdowntime - cg.time < 0 ) { + cg.CTBcountdowntime = 0; + return y; + } + + y += 4; + s = va("Respawn in %d", (int)ceil( (cg.CTBcountdowntime - cg.time) / 1000.0f) ); + w = CG_DrawStrlen(s) * SMALLCHAR_WIDTH; + x = w; + + MAKERGBA(Color, 0.0f, 0.0f, 0.0f, 0.4f); + CG_FillRect(631 - x - 3, y - 1, w + 6, SMALLCHAR_HEIGHT + 6, Color); + + MAKERGBA(Color, 0.0f, 0.0f, 0.0f, 1.0f); + CG_DrawCleanRect(631 - x - 3, y - 1, w + 6, SMALLCHAR_HEIGHT + 6, 1, Color); + + CG_DrawSmallString(631 - x, y + 2, s, 1.0F); + + return y + SMALLCHAR_HEIGHT + 4; +} + + /* ================ CG_DrawAttacker @@ -844,7 +876,10 @@ static float CG_DrawTimer(float y) int w; int mins, seconds, tens; int msec; + int x = 0; + float Color[4]; + y += 4; msec = cg.time - cgs.levelStartTime; seconds = msec / 1000; @@ -854,9 +889,16 @@ static float CG_DrawTimer(float y) seconds -= tens * 10; s = va("%i:%i%i", mins, tens, seconds); - w = CG_DrawStrlen(s) * BIGCHAR_WIDTH; + w = CG_DrawStrlen(s) * SMALLCHAR_WIDTH; + x = w; - CG_DrawBigString(635 - w, y + 2, s, 1.0F); + MAKERGBA(Color, 0.0f, 0.0f, 0.0f, 0.4f); + CG_FillRect(631 - x - 3, y - 1, w + 6, SMALLCHAR_HEIGHT + 6, Color); + + MAKERGBA(Color, 0.0f, 0.0f, 0.0f, 1.0f); + CG_DrawCleanRect(631 - x - 3, y - 1, w + 6, SMALLCHAR_HEIGHT + 6, 1, Color); + + CG_DrawSmallString(631 - x, y + 2, s, 1.0F); return y + BIGCHAR_HEIGHT + 4; } @@ -1035,21 +1077,23 @@ static void CG_DrawUpperRight(void) y = 0; - if (cgs.gametype >= GT_TEAM && cg_drawTeamOverlay.integer == 1) { + if (cgs.gametype >= GT_TEAM && cg_drawTeamOverlay.integer == 1) y = CG_DrawTeamOverlay(y, qtrue, qtrue); - } - if (cg_drawSnapshot.integer) { + + if (cg_drawSnapshot.integer) y = CG_DrawSnapshot(y); - } + y = CG_DrawScore(y); y = CG_DrawFPSandPing(y); - if (cg_drawTimer.integer) { - y = CG_DrawTimer(y); - } - if (cg_drawAttacker.integer) { - y = CG_DrawAttacker(y); - } + if (cg_drawTimer.integer) + y = CG_DrawTimer(y); + + if (cg.CTBcountdowntime) + y = CG_DrawCTBCountDown(y); + + if (cg_drawAttacker.integer) + y = CG_DrawAttacker(y); } /* @@ -1928,12 +1972,14 @@ CG_DrawSpectator */ static void CG_DrawSpectator(void) { - float Color[4]; + float Color[4]; + int team; MAKERGBA(Color, 0.0f, 0.0f, 0.0f, 0.4f); if (cgs.gametype == GT_TEAMPLAY || cgs.gametype == GT_CTF) { - CG_TeamColor(cg.snap->ps.persistant[PERS_SAVEDTEAM], Color); + team = (cgs.gametype == GT_TEAMPLAY) ? cg.snap->ps.persistant[PERS_SAVEDTEAM] : cg.snap->ps.persistant[PERS_TEAM]; + CG_TeamColor(team, Color); Color[0] *= 0.7f; Color[1] *= 0.7f; Color[2] *= 0.7f; diff --git a/reaction/cgame/cg_local.h b/reaction/cgame/cg_local.h index f124e3de..2a793408 100644 --- a/reaction/cgame/cg_local.h +++ b/reaction/cgame/cg_local.h @@ -5,6 +5,9 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.116 2002/08/22 03:30:20 niceass +// countdown code added +// // Revision 1.115 2002/08/07 04:45:07 niceass // ctb changes // @@ -997,6 +1000,8 @@ typedef struct { int matchTime; int team1ready; int team2ready; + + int CTBcountdowntime; } cg_t; //Blaze: struct to hold the func_breakable stuff diff --git a/reaction/cgame/cg_servercmds.c b/reaction/cgame/cg_servercmds.c index 2b9aca90..5464d407 100644 --- a/reaction/cgame/cg_servercmds.c +++ b/reaction/cgame/cg_servercmds.c @@ -5,6 +5,9 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.62 2002/08/22 03:29:36 niceass +// countdown code added +// // Revision 1.61 2002/08/21 07:00:07 jbravo // Added CTB respawn queue and fixed game <-> cgame synch problem in CTB // @@ -1177,9 +1180,9 @@ void RemoveColorEscapeSequences(char *text) text[l] = '\0'; } -void CG_CtbCountDown(int delay) +void CG_CtbCountDown(int delay) { - // NiceAss, do your magic here :) + cg.CTBcountdowntime = cg.time + delay * 1000; } /* @@ -1319,7 +1322,7 @@ void CG_RQ3_Cmd() } break; case SETWEAPON: - i = atoi(CG_Argv(1)); + i = atoi(CG_Argv(2)); cg.weaponSelect = i; cg.weaponSelectTime = cg.time; break; @@ -1341,7 +1344,7 @@ void CG_RQ3_Cmd() CG_CvarSet(); break; case CTBCOUNTDOWN: - i = atoi(CG_Argv(1)); + i = atoi(CG_Argv(2)); CG_CtbCountDown(i); break; default: