]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cl_parse.c
Fix texture binding issues that were breaking r_shadow_bouncegrid.
[xonotic/darkplaces.git] / cl_parse.c
index 26a0ed1120a4891854fdf6a8fcb68a80bd32adef..5d8ff31fa2f1a6a66e7f4233ec50534647d6602e 100644 (file)
@@ -20,9 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 // cl_parse.c  -- parse a message received from the server
 
 #include "quakedef.h"
-#ifdef CONFIG_CD
 #include "cdaudio.h"
-#endif
 #include "cl_collision.h"
 #include "csprogs.h"
 #include "libcurl.h"
@@ -208,7 +206,7 @@ static void CL_ParseStartSoundPacket(int largesoundindex)
        vec3_t  pos;
        int     channel, ent;
        int     sound_num;
-       int     volume;
+       int     nvolume;
        int     field_mask;
        float   attenuation;
        float   speed;
@@ -219,9 +217,9 @@ static void CL_ParseStartSoundPacket(int largesoundindex)
                channel = MSG_ReadShort(&cl_message);
 
                if (channel & (1<<15))
-                       volume = MSG_ReadByte(&cl_message);
+                       nvolume = MSG_ReadByte(&cl_message);
                else
-                       volume = DEFAULT_SOUND_PACKET_VOLUME;
+                       nvolume = DEFAULT_SOUND_PACKET_VOLUME;
 
                if (channel & (1<<14))
                        attenuation = MSG_ReadByte(&cl_message) / 64.0;
@@ -240,9 +238,9 @@ static void CL_ParseStartSoundPacket(int largesoundindex)
                field_mask = MSG_ReadByte(&cl_message);
 
                if (field_mask & SND_VOLUME)
-                       volume = MSG_ReadByte(&cl_message);
+                       nvolume = MSG_ReadByte(&cl_message);
                else
-                       volume = DEFAULT_SOUND_PACKET_VOLUME;
+                       nvolume = DEFAULT_SOUND_PACKET_VOLUME;
 
                if (field_mask & SND_ATTENUATION)
                        attenuation = MSG_ReadByte(&cl_message) / 64.0;
@@ -291,8 +289,8 @@ static void CL_ParseStartSoundPacket(int largesoundindex)
        if (ent >= cl.max_entities)
                CL_ExpandEntities(ent);
 
-       if( !CL_VM_Event_Sound(sound_num, volume / 255.0f, channel, attenuation, ent, pos, fflags, speed) )
-               S_StartSound_StartPosition_Flags (ent, channel, cl.sound_precache[sound_num], pos, volume/255.0f, attenuation, 0, fflags, speed);
+       if( !CL_VM_Event_Sound(sound_num, nvolume / 255.0f, channel, attenuation, ent, pos, fflags, speed) )
+               S_StartSound_StartPosition_Flags (ent, channel, cl.sound_precache[sound_num], pos, nvolume/255.0f, attenuation, 0, fflags, speed);
 }
 
 /*
@@ -366,7 +364,7 @@ void CL_KeepaliveMessage (qboolean readmessages)
                unsigned char           buf[4];
                countdownmsg = 5;
                // write out a nop
-               // LordHavoc: must use unreliable because reliable could kill the sigon message!
+               // LadyHavoc: must use unreliable because reliable could kill the sigon message!
                Con_Print("--> client to server keepalive\n");
                memset(&msg, 0, sizeof(msg));
                msg.data = buf;
@@ -383,8 +381,8 @@ void CL_ParseEntityLump(char *entdata)
        qboolean loadedsky = false;
        const char *data;
        char key[128], value[MAX_INPUTLINE];
-       FOG_clear(); // LordHavoc: no fog until set
-       // LordHavoc: default to the map's sky (q3 shader parsing sets this)
+       FOG_clear(); // LadyHavoc: no fog until set
+       // LadyHavoc: default to the map's sky (q3 shader parsing sets this)
        R_SetSkyBox(cl.worldmodel->brush.skybox);
        data = entdata;
        if (!data)
@@ -1633,11 +1631,11 @@ static void CL_SignonReply (void)
        case 2:
                if (cls.netcon)
                {
-                       // LordHavoc: quake sent the player info here but due to downloads
+                       // LadyHavoc: quake sent the player info here but due to downloads
                        // it is sent earlier instead
                        // CL_SendPlayerInfo();
 
-                       // LordHavoc: changed to begin a loading stage and issue this when done
+                       // LadyHavoc: changed to begin a loading stage and issue this when done
                        MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
                        MSG_WriteString (&cls.netcon->message, "spawn");
                }
@@ -2204,7 +2202,7 @@ static void CL_ParseClientdata (void)
                }
        }
 
-       // LordHavoc: hipnotic demos don't have this bit set but should
+       // LadyHavoc: hipnotic demos don't have this bit set but should
        if (bits & SU_ITEMS || cls.protocol == PROTOCOL_QUAKE || cls.protocol == PROTOCOL_QUAKEDP || cls.protocol == PROTOCOL_NEHAHRAMOVIE || cls.protocol == PROTOCOL_NEHAHRABJP || cls.protocol == PROTOCOL_NEHAHRABJP2 || cls.protocol == PROTOCOL_NEHAHRABJP3 || cls.protocol == PROTOCOL_DARKPLACES1 || cls.protocol == PROTOCOL_DARKPLACES2 || cls.protocol == PROTOCOL_DARKPLACES3 || cls.protocol == PROTOCOL_DARKPLACES4 || cls.protocol == PROTOCOL_DARKPLACES5)
                cl.stats[STAT_ITEMS] = MSG_ReadLong(&cl_message);
 
@@ -2657,7 +2655,7 @@ static void CL_ParseTempEntity(void)
                                        S_StartSound(-1, 0, cl.sfx_ric3, pos, 1, 1);
                        }
                        break;
-                       // LordHavoc: added for improved blood splatters
+                       // LadyHavoc: added for improved blood splatters
                case TE_BLOOD:
                        // blood puff
                        MSG_ReadVector(&cl_message, pos, cls.protocol);
@@ -2683,7 +2681,7 @@ static void CL_ParseTempEntity(void)
                        CL_FindNonSolidLocation(pos, pos, 4);
                        CL_ParticleEffect(EFFECT_TE_PLASMABURN, 1, pos, pos, vec3_origin, vec3_origin, NULL, 0);
                        break;
-                       // LordHavoc: added for improved gore
+                       // LadyHavoc: added for improved gore
                case TE_BLOODSHOWER:
                        // vaporized body
                        MSG_ReadVector(&cl_message, pos, cls.protocol); // mins
@@ -2872,7 +2870,7 @@ static void CL_ParseTempEntity(void)
                        break;
        // PGM 01/21/97
 
-       // LordHavoc: for compatibility with the Nehahra movie...
+       // LadyHavoc: for compatibility with the Nehahra movie...
                case TE_LIGHTNING4NEH:
                        CL_ParseBeam(Mod_ForName(MSG_ReadString(&cl_message, cl_readstring, sizeof(cl_readstring)), true, false, NULL), false);
                        break;
@@ -2893,6 +2891,8 @@ static void CL_ParseTempEntity(void)
                        CL_FindNonSolidLocation(pos, pos, 10);
                        colorStart = MSG_ReadByte(&cl_message);
                        colorLength = MSG_ReadByte(&cl_message);
+                       if (colorLength == 0)
+                               colorLength = 1;
                        CL_ParticleExplosion2(pos, colorStart, colorLength);
                        tempcolor = palette_rgb[(rand()%colorLength) + colorStart];
                        color[0] = tempcolor[0] * (2.0f / 255.0f);
@@ -3399,7 +3399,7 @@ void CL_ParseServerMessage(void)
        qboolean        strip_pqc;
        char vabuf[1024];
 
-       // LordHavoc: moved demo message writing from before the packet parse to
+       // LadyHavoc: moved demo message writing from before the packet parse to
        // after the packet parse so that CL_Stop_f can be called by cl_autodemo
        // code in CL_ParseServerinfo
        //if (cls.demorecording)
@@ -3459,9 +3459,9 @@ void CL_ParseServerMessage(void)
                        cmdlogname[cmdindex] = qw_svc_strings[cmd];
                        if (!cmdlogname[cmdindex])
                        {
-                               // LordHavoc: fix for bizarre problem in MSVC that I do not understand (if I assign the string pointer directly it ends up storing a NULL pointer)
-                               temp = "<unknown>";
-                               cmdlogname[cmdindex] = temp;
+                               // LadyHavoc: fix for bizarre problem in MSVC that I do not understand (if I assign the string pointer directly it ends up storing a NULL pointer)
+                               const char *d = "<unknown>";
+                               cmdlogname[cmdindex] = d;
                        }
 
                        // other commands
@@ -3469,7 +3469,7 @@ void CL_ParseServerMessage(void)
                        {
                        default:
                                {
-                                       char description[32*64], temp[64];
+                                       char description[32*64], logtemp[64];
                                        int count;
                                        strlcpy(description, "packet dump: ", sizeof(description));
                                        i = cmdcount - 32;
@@ -3479,8 +3479,8 @@ void CL_ParseServerMessage(void)
                                        i &= 31;
                                        while(count > 0)
                                        {
-                                               dpsnprintf(temp, sizeof(temp), "%3i:%s ", cmdlog[i], cmdlogname[i]);
-                                               strlcat(description, temp, sizeof(description));
+                                               dpsnprintf(logtemp, sizeof(logtemp), "%3i:%s ", cmdlog[i], cmdlogname[i]);
+                                               strlcat(description, logtemp, sizeof(description));
                                                count--;
                                                i++;
                                                i &= 31;
@@ -3640,12 +3640,10 @@ void CL_ParseServerMessage(void)
 
                        case qw_svc_cdtrack:
                                cl.cdtrack = cl.looptrack = MSG_ReadByte(&cl_message);
-#ifdef CONFIG_CD
                                if ( (cls.demoplayback || cls.demorecording) && (cls.forcetrack != -1) )
                                        CDAudio_Play ((unsigned char)cls.forcetrack, true);
                                else
                                        CDAudio_Play ((unsigned char)cl.cdtrack, true);
-#endif
                                break;
 
                        case qw_svc_intermission:
@@ -3764,12 +3762,10 @@ void CL_ParseServerMessage(void)
 
                        case qw_svc_setpause:
                                cl.paused = MSG_ReadByte(&cl_message) != 0;
-#ifdef CONFIG_CD
                                if (cl.paused)
                                        CDAudio_Pause ();
                                else
                                        CDAudio_Resume ();
-#endif
                                S_PauseGameSounds (cl.paused);
                                break;
                        }
@@ -3806,7 +3802,7 @@ void CL_ParseServerMessage(void)
                        // if the high bit of the command byte is set, it is a fast update
                        if (cmd & 128)
                        {
-                               // LordHavoc: fix for bizarre problem in MSVC that I do not understand (if I assign the string pointer directly it ends up storing a NULL pointer)
+                               // LadyHavoc: fix for bizarre problem in MSVC that I do not understand (if I assign the string pointer directly it ends up storing a NULL pointer)
                                temp = "entity";
                                cmdlogname[cmdindex] = temp;
                                SHOWNET("fast update");
@@ -3824,9 +3820,9 @@ void CL_ParseServerMessage(void)
                        cmdlogname[cmdindex] = svc_strings[cmd];
                        if (!cmdlogname[cmdindex])
                        {
-                               // LordHavoc: fix for bizarre problem in MSVC that I do not understand (if I assign the string pointer directly it ends up storing a NULL pointer)
-                               temp = "<unknown>";
-                               cmdlogname[cmdindex] = temp;
+                               // LadyHavoc: fix for bizarre problem in MSVC that I do not understand (if I assign the string pointer directly it ends up storing a NULL pointer)
+                               const char *d = "<unknown>";
+                               cmdlogname[cmdindex] = d;
                        }
 
                        // other commands
@@ -3834,7 +3830,7 @@ void CL_ParseServerMessage(void)
                        {
                        default:
                                {
-                                       char description[32*64], temp[64];
+                                       char description[32*64], tempdesc[64];
                                        int count;
                                        strlcpy (description, "packet dump: ", sizeof(description));
                                        i = cmdcount - 32;
@@ -3844,8 +3840,8 @@ void CL_ParseServerMessage(void)
                                        i &= 31;
                                        while(count > 0)
                                        {
-                                               dpsnprintf (temp, sizeof (temp), "%3i:%s ", cmdlog[i], cmdlogname[i]);
-                                               strlcat (description, temp, sizeof (description));
+                                               dpsnprintf (tempdesc, sizeof (tempdesc), "%3i:%s ", cmdlog[i], cmdlogname[i]);
+                                               strlcat (description, tempdesc, sizeof (description));
                                                count--;
                                                i++;
                                                i &= 31;
@@ -3964,7 +3960,7 @@ void CL_ParseServerMessage(void)
                                        Host_Error("svc_setview >= MAX_EDICTS");
                                if (cl.viewentity >= cl.max_entities)
                                        CL_ExpandEntities(cl.viewentity);
-                               // LordHavoc: assume first setview recieved is the real player entity
+                               // LadyHavoc: assume first setview recieved is the real player entity
                                if (!cl.realplayerentity)
                                        cl.realplayerentity = cl.viewentity;
                                // update cl.playerentity to this one if it is a valid player
@@ -3996,8 +3992,9 @@ void CL_ParseServerMessage(void)
                                }
                                else
                                {
-                                       int i = (unsigned short)MSG_ReadShort(&cl_message);
-                                       char *s = MSG_ReadString(&cl_message, cl_readstring, sizeof(cl_readstring));
+                                       char *s;
+                                       i = (unsigned short)MSG_ReadShort(&cl_message);
+                                       s = MSG_ReadString(&cl_message, cl_readstring, sizeof(cl_readstring));
                                        if (i < 32768)
                                        {
                                                if (i >= 1 && i < MAX_MODELS)
@@ -4093,18 +4090,16 @@ void CL_ParseServerMessage(void)
 
                        case svc_setpause:
                                cl.paused = MSG_ReadByte(&cl_message) != 0;
-#ifdef CONFIG_CD
                                if (cl.paused)
                                        CDAudio_Pause ();
                                else
                                        CDAudio_Resume ();
-#endif
                                S_PauseGameSounds (cl.paused);
                                break;
 
                        case svc_signonnum:
                                i = MSG_ReadByte(&cl_message);
-                               // LordHavoc: it's rude to kick off the client if they missed the
+                               // LadyHavoc: it's rude to kick off the client if they missed the
                                // reconnect somehow, so allow signon 1 even if at signon 1
                                if (i <= cls.signon && i != 1)
                                        Host_Error ("Received signon %i when at %i", i, cls.signon);
@@ -4145,12 +4140,10 @@ void CL_ParseServerMessage(void)
                        case svc_cdtrack:
                                cl.cdtrack = MSG_ReadByte(&cl_message);
                                cl.looptrack = MSG_ReadByte(&cl_message);
-#ifdef CONFIG_CD
                                if ( (cls.demoplayback || cls.demorecording) && (cls.forcetrack != -1) )
                                        CDAudio_Play ((unsigned char)cls.forcetrack, true);
                                else
                                        CDAudio_Play ((unsigned char)cl.cdtrack, true);
-#endif
                                break;
 
                        case svc_intermission:
@@ -4259,7 +4252,7 @@ void CL_ParseServerMessage(void)
 
        parsingerror = false;
 
-       // LordHavoc: this was at the start of the function before cl_autodemo was
+       // LadyHavoc: this was at the start of the function before cl_autodemo was
        // implemented
        if (cls.demorecording)
        {