Rework game specific hacks to have a special group for Nexuiz-derived games.
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 19 Sep 2013 12:19:24 +0000 (12:19 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 19 Sep 2013 12:19:24 +0000 (12:19 +0000)
From: Rudolf Polzer <divverent@xonotic.org>

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12009 d7cf8633-e32d-0410-b094-e92efae38249

12 files changed:
cl_collision.c
cl_input.c
cl_main.c
cl_parse.c
cl_screen.c
common.c
common.h
console.c
host.c
netconn.c
sbar.c
sv_main.c

index f0e0f7d..713522d 100644 (file)
@@ -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)
index f76c15c..af510b4 100644 (file)
@@ -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;
        }
 
index ec4ca8b..509608b 100644 (file)
--- 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)
index 3ae26aa..48de06e 100644 (file)
@@ -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<<MSG_ReadByte(&cl_message));
                else
                        cl.stats[STAT_ACTIVEWEAPON] = MSG_ReadByte(&cl_message);
index 2867607..4b6100f 100644 (file)
@@ -2770,7 +2770,7 @@ void CL_UpdateScreen(void)
 
        loadingscreendone = false;
 
-       if(gamemode == GAME_NEXUIZ || gamemode == GAME_XONOTIC)
+       if(IS_NEXUIZ_DERIVED(gamemode))
        {
                // play a bit with the palette (experimental)
                palette_rgb_pantscolormap[15][0] = (unsigned char) (128 + 127 * sin(cl.time / exp(1.0f) + 0.0f*M_PI/3.0f));
index 12666d5..b119f04 100644 (file)
--- a/common.c
+++ b/common.c
@@ -1475,7 +1475,7 @@ static const gamemode_info_t gamemode_info [GAME_COUNT] =
 { GAME_TOMESOFMEPHISTOPHELES,          GAME_TOMESOFMEPHISTOPHELES,             "tomesofmephistopheles",                "-tomesofmephistopheles",               "Tomes of Mephistopheles",                      "gamedata",     NULL,                   "tom",                  "tomesofmephistopheles"         }, // COMMANDLINEOPTION: Game: -steelstorm runs the game Steel Storm
 { GAME_STRAPBOMB,              GAME_STRAPBOMB,                 "strapbomb",            "-strapbomb",           "Strap-on-bomb Car",    "id1",          NULL,                   "strap",                "strapbomb"                     }, // COMMANDLINEOPTION: Game: -strapbomb runs the game Strap-on-bomb Car
 { GAME_MOONHELM,               GAME_MOONHELM,                  "moonhelm",                     "-moonhelm",            "MoonHelm",                             "data",         NULL,                   "mh",                   "moonhelm"                      }, // COMMANDLINEOPTION: Game: -moonhelm runs the game MoonHelm
-{ GAME_VORETOURNAMENT, GAME_NORMAL,                    "voretournament",       "-voretournament",      "Vore Tournament",              "data",         NULL,                   "voretournament","voretournament"       }, // COMMANDLINEOPTION: Game: -voretournament runs the multiplayer game Vore Tournament
+{ GAME_VORETOURNAMENT,         GAME_VORETOURNAMENT,            "voretournament",               "-voretournament",      "Vore Tournament",                      "data",         NULL,                   "voretournament",       "voretournament"        }, // COMMANDLINEOPTION: Game: -voretournament runs the multiplayer game Vore Tournament
 };
 
 static void COM_SetGameType(int index);
index b18064b..3d96221 100644 (file)
--- a/common.h
+++ b/common.h
@@ -300,6 +300,11 @@ typedef enum gamemode_e
 }
 gamemode_t;
 
+// Master switch for some hacks/changes that eventually should become cvars.
+#define IS_NEXUIZ_DERIVED(g) ((g) == GAME_NEXUIZ || (g) == GAME_XONOTIC || (g) == GAME_VORETOURNAMENT)
+// Pre-csqcmodels era.
+#define IS_OLDNEXUIZ_DERIVED(g) ((g) == GAME_NEXUIZ || (g) == GAME_VORETOURNAMENT)
+
 extern gamemode_t gamemode;
 extern const char *gamename;
 extern const char *gamedirname1;
index 983786d..e4be3da 100644 (file)
--- a/console.c
+++ b/console.c
@@ -1070,7 +1070,7 @@ void Con_MaskPrint(int additionalmask, const char *msg)
                                {
                                        if (con_chatsound.value)
                                        {
-                                               if(gamemode == GAME_NEXUIZ || gamemode == GAME_XONOTIC)
+                                               if(IS_NEXUIZ_DERIVED(gamemode))
                                                {
                                                        if(msg[1] == '\r' && cl.foundtalk2wav)
                                                                S_LocalSound ("sound/misc/talk2.wav");
@@ -1688,7 +1688,7 @@ void Con_DrawNotify (void)
        align = con_notifyalign.value;
        if(!*con_notifyalign.string) // empty string, evaluated to 0 above
        {
-               if(gamemode == GAME_NEXUIZ)
+               if(IS_OLDNEXUIZ_DERIVED(gamemode))
                        align = 0.5;
        }
 
diff --git a/host.c b/host.c
index a54067a..3a7965e 100644 (file)
--- a/host.c
+++ b/host.c
@@ -212,7 +212,7 @@ static void Host_ServerOptions (void)
                else
                {
                        // default players in some games, singleplayer in most
-                       if (gamemode != GAME_GOODVSBAD2 && gamemode != GAME_NEXUIZ && gamemode != GAME_XONOTIC && gamemode != GAME_BATTLEMECH)
+                       if (gamemode != GAME_GOODVSBAD2 && !IS_NEXUIZ_DERIVED(gamemode) && gamemode != GAME_BATTLEMECH)
                                svs.maxclients = 1;
                }
        }
index 00adb61..eb99dbd 100755 (executable)
--- a/netconn.c
+++ b/netconn.c
@@ -2509,7 +2509,7 @@ static qboolean NetConn_BuildStatusResponse(const char* challenge, char* out_msg
                                        *p = 0;
                                }
 
-                               if ((gamemode == GAME_NEXUIZ || gamemode == GAME_XONOTIC) && (teamplay.integer > 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 43888d5..b537bcd 100644 (file)
--- 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);
        }
index 0c16270..84a4d8c 100644 (file)
--- 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<<i))
@@ -2533,7 +2533,7 @@ static void SV_UpdateToReliableMessages (void)
 
                // frags
                host_client->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)