]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - pr_cmds.c
critical fix for COM_FileBase (could go hunting through mem for /)
[xonotic/darkplaces.git] / pr_cmds.c
index d8b63930fc4d03b0fee22a30aeb771d0b6613a91..91e435b5eb930fb47e5f3122ab71ade3da532a79 100644 (file)
--- a/pr_cmds.c
+++ b/pr_cmds.c
@@ -80,6 +80,7 @@ QSG_SCALE \
 QSG_SKYBOX \
 QSG_TRACETOSS \
 QSG_VIEWMODEL \
+QSG_COPYENT \
 ";
 
 qboolean checkextension(char *name)
@@ -89,12 +90,14 @@ qboolean checkextension(char *name)
        len = strlen(name);
        for (e = QSG_EXTENSIONS;*e;e++)
        {
-               if (!*e || e[len] == ' ' && !strnicmp(e, name, len))
+               while (*e == ' ')
+                       e++;
+               if (!*e)
+                       break;
+               if (!strncasecmp(e, name, len))
                        return TRUE;
                while (*e && *e != ' ')
                        e++;
-               while (*e == ' ')
-                       e++;
        }
        return FALSE;
 }
@@ -652,13 +655,13 @@ void PF_sound (void)
        attenuation = G_FLOAT(OFS_PARM4);
        
        if (volume < 0 || volume > 255)
-               Sys_Error ("SV_StartSound: volume = %i", volume);
+               Host_Error ("SV_StartSound: volume = %i", volume);
 
        if (attenuation < 0 || attenuation > 4)
-               Sys_Error ("SV_StartSound: attenuation = %f", attenuation);
+               Host_Error ("SV_StartSound: attenuation = %f", attenuation);
 
        if (channel < 0 || channel > 7)
-               Sys_Error ("SV_StartSound: channel = %i", channel);
+               Host_Error ("SV_StartSound: channel = %i", channel);
 
        SV_StartSound (entity, channel, sample, volume, attenuation);
 }
@@ -1556,14 +1559,14 @@ void PF_changepitch (void)
        
        ent = G_EDICT(OFS_PARM0);
        current = anglemod( ent->v.angles[0] );
-       if (val = GETEDICTFIELDVALUE(ent, eval_idealpitch))
+       if ((val = GETEDICTFIELDVALUE(ent, eval_idealpitch)))
                ideal = val->_float;
        else
        {
                PR_RunError ("PF_changepitch: .float idealpitch and .float pitch_speed must be defined to use changepitch");
                return;
        }
-       if (val = GETEDICTFIELDVALUE(ent, eval_pitch_speed))
+       if ((val = GETEDICTFIELDVALUE(ent, eval_pitch_speed)))
                speed = val->_float;
        else
        {
@@ -1936,6 +1939,55 @@ void PF_pow (void)
        G_FLOAT(OFS_RETURN) = pow(G_FLOAT(OFS_PARM0), G_FLOAT(OFS_PARM1));
 }
 
+/*
+=================
+PF_copyentity
+
+copies data from one entity to another
+
+copyentity(src, dst)
+=================
+*/
+void PF_copyentity (void)
+{
+       edict_t *in, *out;
+       in = G_EDICT(OFS_PARM0);
+       out = G_EDICT(OFS_PARM1);
+       memcpy(out, in, pr_edict_size);
+}
+
+/*
+=================
+PF_setcolor
+
+sets the color of a client and broadcasts the update to all connected clients
+
+setcolor(clientent, value)
+=================
+*/
+void PF_setcolor (void)
+{
+       client_t        *client;
+       int                     entnum, i;
+       
+       entnum = G_EDICTNUM(OFS_PARM0);
+       i = G_FLOAT(OFS_PARM1);
+       
+       if (entnum < 1 || entnum > svs.maxclients)
+       {
+               Con_Printf ("tried to setcolor a non-client\n");
+               return;
+       }
+               
+       client = &svs.clients[entnum-1];
+       client->colors = i;
+       client->edict->v.team = (i & 15) + 1;
+               
+       MSG_WriteByte (&sv.reliable_datagram, svc_updatecolors);
+       MSG_WriteByte (&sv.reliable_datagram, entnum - 1);
+       MSG_WriteByte (&sv.reliable_datagram, i);
+}
+
 void PF_Fixme (void)
 {
        PR_RunError ("unimplemented builtin"); // LordHavoc: was misspelled (bulitin)
@@ -2054,7 +2106,14 @@ PF_max,                          // #95
 PF_bound,                      // #96
 PF_pow,                                // #97
 PF_FindFloat,          // #98
-PF_checkextension      // #99
+PF_checkextension,     // #99
+#define a PF_Fixme, PF_Fixme, PF_Fixme, PF_Fixme, PF_Fixme, PF_Fixme, PF_Fixme, PF_Fixme, PF_Fixme, PF_Fixme,
+#define aa a a a a a a a a a a
+aa // #200
+aa // #300
+aa // #400
+PF_copyentity,         // #400 LordHavoc: builtin range (4xx)
+PF_setcolor,           // #401
 };
 
 builtin_t *pr_builtins = pr_builtin;