From 01f19c6c3ff8d4645b8589b3c8274d08a5775af6 Mon Sep 17 00:00:00 2001 From: divverent Date: Thu, 19 Sep 2013 12:19:24 +0000 Subject: [PATCH] Rework game specific hacks to have a special group for Nexuiz-derived games. From: Rudolf Polzer git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12009 d7cf8633-e32d-0410-b094-e92efae38249 --- cl_collision.c | 12 ++++++------ cl_input.c | 4 ++-- cl_main.c | 6 +++--- cl_parse.c | 6 +++--- cl_screen.c | 2 +- common.c | 2 +- common.h | 5 +++++ console.c | 4 ++-- host.c | 2 +- netconn.c | 2 +- sbar.c | 32 ++++++++++++++++++-------------- sv_main.c | 4 ++-- 12 files changed, 45 insertions(+), 36 deletions(-) diff --git a/cl_collision.c b/cl_collision.c index f0e0f7de..713522d3 100644 --- a/cl_collision.c +++ b/cl_collision.c @@ -326,7 +326,7 @@ trace_t CL_TracePoint(const vec3_t start, int type, prvm_edict_t *passedict, int vec3_t origin, entmins, entmaxs; matrix4x4_t entmatrix, entinversematrix; - if(gamemode == GAME_NEXUIZ || gamemode == GAME_XONOTIC) + if(IS_OLDNEXUIZ_DERIVED(gamemode)) { // don't hit network players, if we are a nonsolid player if(cl.scores[cl.playerentity-1].frags == -666 || cl.scores[cl.playerentity-1].frags == -616) @@ -345,7 +345,7 @@ trace_t CL_TracePoint(const vec3_t start, int type, prvm_edict_t *passedict, int if (!cl.scores[i-1].name[0]) continue; - if(gamemode == GAME_NEXUIZ || gamemode == GAME_XONOTIC) + if(IS_OLDNEXUIZ_DERIVED(gamemode)) { // don't hit spectators or nonsolid players if(cl.scores[i-1].frags == -666 || cl.scores[i-1].frags == -616) @@ -564,7 +564,7 @@ trace_t CL_TraceLine(const vec3_t start, const vec3_t end, int type, prvm_edict_ vec3_t origin, entmins, entmaxs; matrix4x4_t entmatrix, entinversematrix; - if(gamemode == GAME_NEXUIZ || gamemode == GAME_XONOTIC) + if(IS_OLDNEXUIZ_DERIVED(gamemode)) { // don't hit network players, if we are a nonsolid player if(cl.scores[cl.playerentity-1].frags == -666 || cl.scores[cl.playerentity-1].frags == -616) @@ -583,7 +583,7 @@ trace_t CL_TraceLine(const vec3_t start, const vec3_t end, int type, prvm_edict_ if (!cl.scores[i-1].name[0]) continue; - if(gamemode == GAME_NEXUIZ || gamemode == GAME_XONOTIC) + if(IS_OLDNEXUIZ_DERIVED(gamemode)) { // don't hit spectators or nonsolid players if(cl.scores[i-1].frags == -666 || cl.scores[i-1].frags == -616) @@ -843,7 +843,7 @@ trace_t CL_TraceBox(const vec3_t start, const vec3_t mins, const vec3_t maxs, co vec3_t origin, entmins, entmaxs; matrix4x4_t entmatrix, entinversematrix; - if(gamemode == GAME_NEXUIZ || gamemode == GAME_XONOTIC) + if(IS_OLDNEXUIZ_DERIVED(gamemode)) { // don't hit network players, if we are a nonsolid player if(cl.scores[cl.playerentity-1].frags == -666 || cl.scores[cl.playerentity-1].frags == -616) @@ -862,7 +862,7 @@ trace_t CL_TraceBox(const vec3_t start, const vec3_t mins, const vec3_t maxs, co if (!cl.scores[i-1].name[0]) continue; - if(gamemode == GAME_NEXUIZ || gamemode == GAME_XONOTIC) + if(IS_OLDNEXUIZ_DERIVED(gamemode)) { // don't hit spectators or nonsolid players if(cl.scores[i-1].frags == -666 || cl.scores[i-1].frags == -616) diff --git a/cl_input.c b/cl_input.c index f76c15c4..af510b47 100644 --- a/cl_input.c +++ b/cl_input.c @@ -1072,7 +1072,7 @@ static void CL_ClientMovement_Physics_Swim(cl_clientmovement_state_t *s) s->velocity[2] = 80; else { - if (gamemode == GAME_NEXUIZ || gamemode == GAME_XONOTIC) + if (IS_NEXUIZ_DERIVED(gamemode)) s->velocity[2] = 200; else s->velocity[2] = 100; @@ -1546,7 +1546,7 @@ void CL_UpdateMoveVars(void) if(!(cl.moveflags & MOVEFLAG_VALID)) { - if(gamemode == GAME_NEXUIZ) + if(gamemode == GAME_NEXUIZ) // Legacy hack to work with old servers of Nexuiz. cl.moveflags = MOVEFLAG_Q2AIRACCELERATE; } diff --git a/cl_main.c b/cl_main.c index ec4ca8b6..509608b2 100644 --- a/cl_main.c +++ b/cl_main.c @@ -171,7 +171,7 @@ void CL_ClearState(void) cl.entities[i].state_current = defaultstate; } - if (gamemode == GAME_NEXUIZ || gamemode == GAME_XONOTIC) + if (IS_NEXUIZ_DERIVED(gamemode)) { VectorSet(cl.playerstandmins, -16, -16, -24); VectorSet(cl.playerstandmaxs, 16, 16, 45); @@ -1218,7 +1218,7 @@ static void CL_UpdateNetworkEntityTrail(entity_t *e) { if (e->render.effects & EF_BRIGHTFIELD) { - if (gamemode == GAME_NEXUIZ || gamemode == GAME_XONOTIC) + if (IS_NEXUIZ_DERIVED(gamemode)) trailtype = EFFECT_TR_NEXUIZPLASMA; else CL_EntityParticles(e); @@ -1445,7 +1445,7 @@ static void CL_LinkNetworkEntity(entity_t *e) { if (e->render.effects & EF_BRIGHTFIELD) { - if (gamemode == GAME_NEXUIZ || gamemode == GAME_XONOTIC) + if (IS_NEXUIZ_DERIVED(gamemode)) trailtype = EFFECT_TR_NEXUIZPLASMA; } if (e->render.effects & EF_DIMLIGHT) diff --git a/cl_parse.c b/cl_parse.c index 3ae26aa9..48de06e7 100644 --- a/cl_parse.c +++ b/cl_parse.c @@ -1220,7 +1220,7 @@ static void CL_BeginDownloads(qboolean aborteddownload) // finished loading sounds } - if(gamemode == GAME_NEXUIZ || gamemode == GAME_XONOTIC) + if(IS_NEXUIZ_DERIVED(gamemode)) Cvar_SetValueQuick(&cl_serverextension_download, false); // in Nexuiz/Xonotic, the built in download protocol is kinda broken (misses lots // of dependencies) anyway, and can mess around with the game directory; @@ -1399,7 +1399,7 @@ static void CL_StopDownload(int size, int crc) // save to disk only if we don't already have it // (this is mainly for playing back demos) existingcrc = FS_CRCFile(cls.qw_downloadname, &existingsize); - if (existingsize || gamemode == GAME_NEXUIZ || gamemode == GAME_XONOTIC || !strcmp(cls.qw_downloadname, csqc_progname.string)) + if (existingsize || IS_NEXUIZ_DERIVED(gamemode) || !strcmp(cls.qw_downloadname, csqc_progname.string)) // let csprogs ALWAYS go to dlcache, to prevent "viral csprogs"; also, never put files outside dlcache for Nexuiz/Xonotic { if ((int)existingsize != size || existingcrc != crc) @@ -2219,7 +2219,7 @@ static void CL_ParseClientdata (void) cl.stats[STAT_NAILS] = MSG_ReadByte(&cl_message); cl.stats[STAT_ROCKETS] = MSG_ReadByte(&cl_message); cl.stats[STAT_CELLS] = MSG_ReadByte(&cl_message); - if (gamemode == GAME_HIPNOTIC || gamemode == GAME_ROGUE || gamemode == GAME_QUOTH || gamemode == GAME_NEXUIZ) + if (gamemode == GAME_HIPNOTIC || gamemode == GAME_ROGUE || gamemode == GAME_QUOTH || IS_OLDNEXUIZ_DERIVED(gamemode)) cl.stats[STAT_ACTIVEWEAPON] = (1< 0)) + if (IS_NEXUIZ_DERIVED(gamemode) && (teamplay.integer > 0)) { if(cl->frags == -666) // spectator strlcpy(teambuf, " 0", sizeof(teambuf)); diff --git a/sbar.c b/sbar.c index 43888d5e..b537bcd3 100644 --- a/sbar.c +++ b/sbar.c @@ -156,7 +156,7 @@ static void sbar_start(void) if (gamemode == GAME_DELUXEQUAKE || gamemode == GAME_BLOODOMNICIDE) { } - else if (gamemode == GAME_NEXUIZ) + else if (IS_OLDNEXUIZ_DERIVED(gamemode)) { for (i = 0;i < 10;i++) sb_nums[0][i] = Draw_CachePic_Flags (va(vabuf, sizeof(vabuf), "gfx/num_%i",i), CACHEPICFLAG_QUIET); @@ -515,7 +515,7 @@ static void Sbar_DrawXNum (int x, int y, int num, int digits, int lettersize, fl static int Sbar_IsTeammatch(void) { // currently only nexuiz uses the team score board - return ((gamemode == GAME_NEXUIZ) + return (IS_OLDNEXUIZ_DERIVED(gamemode) && (teamplay.integer > 0)); } @@ -692,7 +692,7 @@ static void Sbar_SoloScoreboard (void) int minutes, seconds, tens, units; int l; - if (gamemode != GAME_NEXUIZ) { + if (IS_OLDNEXUIZ_DERIVED(gamemode)) { dpsnprintf (str, sizeof(str), "Monsters:%3i /%3i", cl.stats[STAT_MONSTERS], cl.stats[STAT_TOTALMONSTERS]); Sbar_DrawString (8, 4, str); @@ -709,7 +709,7 @@ static void Sbar_SoloScoreboard (void) Sbar_DrawString (184, 4, str); // draw level name - if (gamemode == GAME_NEXUIZ) { + if (IS_OLDNEXUIZ_DERIVED(gamemode)) { l = (int) strlen (cl.worldname); Sbar_DrawString (232 - l*4, 12, cl.worldname); } else { @@ -1037,7 +1037,7 @@ static void get_showspeed_unit(int unitnumber, double *conversion_factor, const { default: case 1: - if(gamemode == GAME_NEXUIZ || gamemode == GAME_XONOTIC) + if(IS_NEXUIZ_DERIVED(gamemode)) *unit = "in/s"; else *unit = "qu/s"; @@ -1046,23 +1046,27 @@ static void get_showspeed_unit(int unitnumber, double *conversion_factor, const case 2: *unit = "m/s"; *conversion_factor = 0.0254; - if(gamemode != GAME_NEXUIZ && gamemode != GAME_XONOTIC) *conversion_factor *= 1.5; + if(!IS_NEXUIZ_DERIVED(gamemode)) + *conversion_factor *= 1.5; // 1qu=1.5in is for non-Nexuiz/Xonotic only - Nexuiz/Xonotic players are overly large, but 1qu=1in fixes that break; case 3: *unit = "km/h"; *conversion_factor = 0.0254 * 3.6; - if(gamemode != GAME_NEXUIZ && gamemode != GAME_XONOTIC) *conversion_factor *= 1.5; + if(!IS_NEXUIZ_DERIVED(gamemode)) + *conversion_factor *= 1.5; break; case 4: *unit = "mph"; *conversion_factor = 0.0254 * 3.6 * 0.6213711922; - if(gamemode != GAME_NEXUIZ && gamemode != GAME_XONOTIC) *conversion_factor *= 1.5; + if(!IS_NEXUIZ_DERIVED(gamemode)) + *conversion_factor *= 1.5; break; case 5: *unit = "knots"; *conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h - if(gamemode != GAME_NEXUIZ && gamemode != GAME_XONOTIC) *conversion_factor *= 1.5; + if(!IS_NEXUIZ_DERIVED(gamemode)) + *conversion_factor *= 1.5; break; } } @@ -1332,7 +1336,7 @@ void Sbar_Draw (void) Sbar_DrawScoreboard (); else if (cl.intermission == 1) { - if(gamemode == GAME_NEXUIZ) // display full scoreboard (that is, show scores + map name) + if(IS_OLDNEXUIZ_DERIVED(gamemode)) // display full scoreboard (that is, show scores + map name) { Sbar_DrawScoreboard(); return; @@ -1344,7 +1348,7 @@ void Sbar_Draw (void) else if (gamemode == GAME_DELUXEQUAKE) { } - else if (gamemode == GAME_NEXUIZ) + else if (IS_OLDNEXUIZ_DERIVED(gamemode)) { if (sb_showscores || (cl.stats[STAT_HEALTH] <= 0 && cl_deathscoreboard.integer)) { @@ -1867,7 +1871,7 @@ void Sbar_DeathmatchOverlay (void) xmin = (int) (vid_conwidth.integer - (16 + 25) * 8 * FONT_SBAR->maxwidth) / 2; // 16 characters until name, then we assume 25 character names (they can be longer but usually aren't) xmax = vid_conwidth.integer - xmin; - if(gamemode == GAME_NEXUIZ) + if(IS_OLDNEXUIZ_DERIVED(gamemode)) DrawQ_Pic (xmin - 8, ymin - 8, 0, xmax-xmin+1 + 2*8, ymax-ymin+1 + 2*8, 0, 0, 0, sbar_alpha_bg.value, 0); DrawQ_Pic ((vid_conwidth.integer - sb_ranking->width)/2, 8, sb_ranking, 0, 0, 1, 1, 1, 1 * sbar_alpha_fg.value, 0); @@ -2183,7 +2187,7 @@ void Sbar_IntermissionOverlay (void) if(cl.stats[STAT_TOTALSECRETS]) { Sbar_DrawNum (160, 104, cl.stats[STAT_SECRETS], 3, 0); - if (gamemode != GAME_NEXUIZ) + if (!IS_OLDNEXUIZ_DERIVED(gamemode)) Sbar_DrawPic (232, 104, sb_slash); Sbar_DrawNum (240, 104, cl.stats[STAT_TOTALSECRETS], 3, 0); } @@ -2195,7 +2199,7 @@ void Sbar_IntermissionOverlay (void) if(cl.stats[STAT_TOTALMONSTERS]) { Sbar_DrawNum (160, 144, cl.stats[STAT_MONSTERS], 3, 0); - if (gamemode != GAME_NEXUIZ) + if (!IS_OLDNEXUIZ_DERIVED(gamemode)) Sbar_DrawPic (232, 144, sb_slash); Sbar_DrawNum (240, 144, cl.stats[STAT_TOTALMONSTERS], 3, 0); } diff --git a/sv_main.c b/sv_main.c index 0c162703..84a4d8c3 100644 --- a/sv_main.c +++ b/sv_main.c @@ -2209,7 +2209,7 @@ void SV_WriteClientdataToMessage (client_t *client, prvm_edict_t *ent, sizebuf_t MSG_WriteByte (msg, stats[STAT_NAILS]); MSG_WriteByte (msg, stats[STAT_ROCKETS]); MSG_WriteByte (msg, stats[STAT_CELLS]); - if (gamemode == GAME_HIPNOTIC || gamemode == GAME_ROGUE || gamemode == GAME_QUOTH || gamemode == GAME_NEXUIZ) + if (gamemode == GAME_HIPNOTIC || gamemode == GAME_ROGUE || gamemode == GAME_QUOTH || IS_OLDNEXUIZ_DERIVED(gamemode)) { for (i = 0;i < 32;i++) if (stats[STAT_ACTIVEWEAPON] & (1<frags = (int)PRVM_serveredictfloat(host_client->edict, frags); - if(gamemode == GAME_NEXUIZ || gamemode == GAME_XONOTIC) + if(IS_OLDNEXUIZ_DERIVED(gamemode)) if(!host_client->begun && host_client->netconnection) host_client->frags = -666; if (host_client->old_frags != host_client->frags) -- 2.39.2