]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - clvm_cmds.c
protocol: Fix off-by-one when appending space in Protocol_Names
[xonotic/darkplaces.git] / clvm_cmds.c
index 547a5fb0f65523613782f1180394211aee4bfe3f..2a2cefa68a67f07024856b4f513eae87c56bbb55 100644 (file)
@@ -50,7 +50,7 @@ static void VM_CL_setorigin (prvm_prog_t *prog)
                VM_Warning(prog, "setorigin: can not modify world entity\n");
                return;
        }
-       if (e->priv.required->free)
+       if (e->free)
        {
                VM_Warning(prog, "setorigin: can not modify free entity\n");
                return;
@@ -151,7 +151,7 @@ static void VM_CL_setsize (prvm_prog_t *prog)
                VM_Warning(prog, "setsize: can not modify world entity\n");
                return;
        }
-       if (e->priv.server->free)
+       if (e->free)
        {
                VM_Warning(prog, "setsize: can not modify free entity\n");
                return;
@@ -537,7 +537,7 @@ static void VM_CL_droptofloor (prvm_prog_t *prog)
                VM_Warning(prog, "droptofloor: can not modify world entity\n");
                return;
        }
-       if (ent->priv.server->free)
+       if (ent->free)
        {
                VM_Warning(prog, "droptofloor: can not modify free entity\n");
                return;
@@ -761,14 +761,14 @@ static void VM_CL_R_AddEntities (prvm_prog_t *prog)
                // so we can easily check if CSQC entity #edictnum is currently drawn
                cl.csqcrenderentities[i].entitynumber = 0;
                ed = &prog->edicts[i];
-               if(ed->priv.required->free)
+               if(ed->free)
                        continue;
                CSQC_Think(ed);
-               if(ed->priv.required->free)
+               if(ed->free)
                        continue;
                // note that for RF_USEAXIS entities, Predraw sets v_forward/v_right/v_up globals that are read by CSQC_AddRenderEdict
                CSQC_Predraw(ed);
-               if(ed->priv.required->free)
+               if(ed->free)
                        continue;
                if(!((int)PRVM_clientedictfloat(ed, drawmask) & drawmask))
                        continue;
@@ -2402,7 +2402,7 @@ static void VM_CL_setlistener (prvm_prog_t *prog)
 static void VM_CL_registercmd (prvm_prog_t *prog)
 {
        VM_SAFEPARMCOUNT(1, VM_CL_registercmd);
-       if(!Cmd_Exists(&cmd_client, PRVM_G_STRING(OFS_PARM0)))
+       if(!Cmd_Exists(cmd_local, PRVM_G_STRING(OFS_PARM0)))
                Cmd_AddCommand(CF_CLIENT, PRVM_G_STRING(OFS_PARM0), NULL, "console command created by QuakeC");
 }
 
@@ -2523,7 +2523,7 @@ static void VM_CL_makestatic (prvm_prog_t *prog)
                VM_Warning(prog, "makestatic: can not modify world entity\n");
                return;
        }
-       if (ent->priv.server->free)
+       if (ent->free)
        {
                VM_Warning(prog, "makestatic: can not modify free entity\n");
                return;
@@ -2619,7 +2619,7 @@ static void VM_CL_copyentity (prvm_prog_t *prog)
                VM_Warning(prog, "copyentity: can not read world entity\n");
                return;
        }
-       if (in->priv.server->free)
+       if (in->free)
        {
                VM_Warning(prog, "copyentity: can not read free entity\n");
                return;
@@ -2630,7 +2630,7 @@ static void VM_CL_copyentity (prvm_prog_t *prog)
                VM_Warning(prog, "copyentity: can not modify world entity\n");
                return;
        }
-       if (out->priv.server->free)
+       if (out->free)
        {
                VM_Warning(prog, "copyentity: can not modify free entity\n");
                return;
@@ -3089,7 +3089,7 @@ static void VM_CL_setattachment (prvm_prog_t *prog)
                VM_Warning(prog, "setattachment: can not modify world entity\n");
                return;
        }
-       if (e->priv.server->free)
+       if (e->free)
        {
                VM_Warning(prog, "setattachment: can not modify free entity\n");
                return;
@@ -3229,7 +3229,7 @@ int CL_GetTagMatrix (prvm_prog_t *prog, matrix4x4_t *out, prvm_edict_t *ent, int
 
        if (ent == prog->edicts)
                return 1;
-       if (ent->priv.server->free)
+       if (ent->free)
                return 2;
 
        model = CL_GetModelFromEdict(ent);
@@ -3321,7 +3321,7 @@ static void VM_CL_gettagindex (prvm_prog_t *prog)
                VM_Warning(prog, "VM_CL_gettagindex(entity #%i): can't affect world entity\n", PRVM_NUM_FOR_EDICT(ent));
                return;
        }
-       if (ent->priv.server->free)
+       if (ent->free)
        {
                VM_Warning(prog, "VM_CL_gettagindex(entity #%i): can't affect free entity\n", PRVM_NUM_FOR_EDICT(ent));
                return;
@@ -3706,12 +3706,12 @@ static void VM_CL_SpawnParticle (prvm_prog_t *prog)
        if (vmpartspawner.verified == false)
        {
                VM_Warning(prog, "VM_CL_SpawnParticle: particle spawner not initialized\n");
-               PRVM_G_FLOAT(OFS_RETURN) = 0; 
+               PRVM_G_FLOAT(OFS_RETURN) = 0;
                return;
        }
        VectorCopy(PRVM_G_VECTOR(OFS_PARM0), org);
        VectorCopy(PRVM_G_VECTOR(OFS_PARM1), dir);
-       
+
        if (prog->argc < 3) // global-set particle
        {
                part = CL_NewParticle(org,
@@ -3750,7 +3750,7 @@ static void VM_CL_SpawnParticle (prvm_prog_t *prog)
                        NULL);
                if (!part)
                {
-                       PRVM_G_FLOAT(OFS_RETURN) = 0; 
+                       PRVM_G_FLOAT(OFS_RETURN) = 0;
                        return;
                }
                if (PRVM_clientglobalfloat(particle_delayspawn))
@@ -3764,7 +3764,7 @@ static void VM_CL_SpawnParticle (prvm_prog_t *prog)
                if (themenum <= 0 || themenum >= vmpartspawner.max_themes)
                {
                        VM_Warning(prog, "VM_CL_SpawnParticle: bad theme number %i\n", themenum);
-                       PRVM_G_FLOAT(OFS_RETURN) = 0; 
+                       PRVM_G_FLOAT(OFS_RETURN) = 0;
                        return;
                }
                theme = &vmpartspawner.themes[themenum];
@@ -3804,7 +3804,7 @@ static void VM_CL_SpawnParticle (prvm_prog_t *prog)
                        NULL);
                if (!part)
                {
-                       PRVM_G_FLOAT(OFS_RETURN) = 0; 
+                       PRVM_G_FLOAT(OFS_RETURN) = 0;
                        return;
                }
                if (theme->delayspawn)
@@ -3812,7 +3812,7 @@ static void VM_CL_SpawnParticle (prvm_prog_t *prog)
                //if (theme->delaycollision)
                //      part->delayedcollisions = cl.time + theme->delaycollision;
        }
-       PRVM_G_FLOAT(OFS_RETURN) = 1; 
+       PRVM_G_FLOAT(OFS_RETURN) = 1;
 }
 
 // float(vector org, vector dir, float spawndelay, float collisiondelay, [float theme]) delayedparticle
@@ -3828,7 +3828,7 @@ static void VM_CL_SpawnParticleDelayed (prvm_prog_t *prog)
        if (vmpartspawner.verified == false)
        {
                VM_Warning(prog, "VM_CL_SpawnParticleDelayed: particle spawner not initialized\n");
-               PRVM_G_FLOAT(OFS_RETURN) = 0; 
+               PRVM_G_FLOAT(OFS_RETURN) = 0;
                return;
        }
        VectorCopy(PRVM_G_VECTOR(OFS_PARM0), org);
@@ -3874,7 +3874,7 @@ static void VM_CL_SpawnParticleDelayed (prvm_prog_t *prog)
                if (themenum <= 0 || themenum >= vmpartspawner.max_themes)
                {
                        VM_Warning(prog, "VM_CL_SpawnParticleDelayed: bad theme number %i\n", themenum);
-                       PRVM_G_FLOAT(OFS_RETURN) = 0;  
+                       PRVM_G_FLOAT(OFS_RETURN) = 0;
                        return;
                }
                theme = &vmpartspawner.themes[themenum];
@@ -3913,10 +3913,10 @@ static void VM_CL_SpawnParticleDelayed (prvm_prog_t *prog)
                        theme->spin,
                        NULL);
        }
-       if (!part) 
-       { 
-               PRVM_G_FLOAT(OFS_RETURN) = 0; 
-               return; 
+       if (!part)
+       {
+               PRVM_G_FLOAT(OFS_RETURN) = 0;
+               return;
        }
        part->delayedspawn = cl.time + PRVM_G_FLOAT(OFS_PARM2);
        //part->delayedcollisions = cl.time + PRVM_G_FLOAT(OFS_PARM3);
@@ -3952,7 +3952,7 @@ static void VM_CL_GetEntity (prvm_prog_t *prog)
                case 1: // origin
                        Matrix4x4_OriginFromMatrix(&cl.entities[entnum].render.matrix, org);
                        VectorCopy(org, PRVM_G_VECTOR(OFS_RETURN));
-                       break; 
+                       break;
                case 2: // forward
                        Matrix4x4_ToVectors(&cl.entities[entnum].render.matrix, forward, left, up, org);
                        VectorCopy(forward, PRVM_G_VECTOR(OFS_RETURN));
@@ -3967,17 +3967,17 @@ static void VM_CL_GetEntity (prvm_prog_t *prog)
                        break;
                case 5: // scale
                        PRVM_G_FLOAT(OFS_RETURN) = Matrix4x4_ScaleFromMatrix(&cl.entities[entnum].render.matrix);
-                       break;  
+                       break;
                case 6: // origin + v_forward, v_right, v_up
                        Matrix4x4_ToVectors(&cl.entities[entnum].render.matrix, forward, left, up, org);
                        VectorCopy(forward, PRVM_clientglobalvector(v_forward));
                        VectorNegate(left, PRVM_clientglobalvector(v_right));
                        VectorCopy(up, PRVM_clientglobalvector(v_up));
                        VectorCopy(org, PRVM_G_VECTOR(OFS_RETURN));
-                       break;  
+                       break;
                case 7: // alpha
                        PRVM_G_FLOAT(OFS_RETURN) = cl.entities[entnum].render.alpha;
-                       break;  
+                       break;
                case 8: // colormor
                        VectorCopy(cl.entities[entnum].render.colormod, PRVM_G_VECTOR(OFS_RETURN));
                        break;
@@ -3989,24 +3989,24 @@ static void VM_CL_GetEntity (prvm_prog_t *prog)
                        break;
                case 11: // skinnum
                        PRVM_G_FLOAT(OFS_RETURN) = cl.entities[entnum].render.skinnum;
-                       break;  
+                       break;
                case 12: // mins
-                       VectorCopy(cl.entities[entnum].render.mins, PRVM_G_VECTOR(OFS_RETURN));         
-                       break;  
+                       VectorCopy(cl.entities[entnum].render.mins, PRVM_G_VECTOR(OFS_RETURN));
+                       break;
                case 13: // maxs
-                       VectorCopy(cl.entities[entnum].render.maxs, PRVM_G_VECTOR(OFS_RETURN));         
-                       break;  
+                       VectorCopy(cl.entities[entnum].render.maxs, PRVM_G_VECTOR(OFS_RETURN));
+                       break;
                case 14: // absmin
                        Matrix4x4_OriginFromMatrix(&cl.entities[entnum].render.matrix, org);
-                       VectorAdd(cl.entities[entnum].render.mins, org, PRVM_G_VECTOR(OFS_RETURN));             
-                       break;  
+                       VectorAdd(cl.entities[entnum].render.mins, org, PRVM_G_VECTOR(OFS_RETURN));
+                       break;
                case 15: // absmax
                        Matrix4x4_OriginFromMatrix(&cl.entities[entnum].render.matrix, org);
-                       VectorAdd(cl.entities[entnum].render.maxs, org, PRVM_G_VECTOR(OFS_RETURN));             
+                       VectorAdd(cl.entities[entnum].render.maxs, org, PRVM_G_VECTOR(OFS_RETURN));
                        break;
                case 16: // light
                        VectorMA(cl.entities[entnum].render.render_modellight_ambient, 0.5, cl.entities[entnum].render.render_modellight_diffuse, PRVM_G_VECTOR(OFS_RETURN));
-                       break;  
+                       break;
                default:
                        PRVM_G_FLOAT(OFS_RETURN) = 0;
                        break;
@@ -4416,7 +4416,7 @@ static void VM_CL_walkmove (prvm_prog_t *prog)
                VM_Warning(prog, "walkmove: can not modify world entity\n");
                return;
        }
-       if (ent->priv.server->free)
+       if (ent->free)
        {
                VM_Warning(prog, "walkmove: can not modify free entity\n");
                return;
@@ -4487,7 +4487,7 @@ static void VM_CL_checkpvs (prvm_prog_t *prog)
        VectorCopy(PRVM_G_VECTOR(OFS_PARM0), viewpos);
        viewee = PRVM_G_EDICT(OFS_PARM1);
 
-       if(viewee->priv.required->free)
+       if(viewee->free)
        {
                VM_Warning(prog, "checkpvs: can not check free entity\n");
                PRVM_G_FLOAT(OFS_RETURN) = 4;
@@ -4982,7 +4982,7 @@ NULL,                                                     // #42 (QUAKE)
 VM_fabs,                                               // #43 float(float f) fabs (QUAKE)
 NULL,                                                  // #44 vector(entity e, float speed) aim (QUAKE)
 VM_cvar,                                               // #45 float(string s) cvar (QUAKE)
-VM_localcmd_client,                            // #46 void(string s) localcmd (QUAKE)
+VM_localcmd_local,                             // #46 void(string s) localcmd (QUAKE)
 VM_nextent,                                            // #47 entity(entity e) nextent (QUAKE)
 VM_CL_particle,                                        // #48 void(vector o, vector d, float color, float count) particle (QUAKE)
 VM_changeyaw,                                  // #49 void() ChangeYaw (QUAKE)
@@ -5114,7 +5114,7 @@ NULL,                                                     // #173
 NULL,                                                  // #174
 NULL,                                                  // #175
 NULL,                                                  // #176
-NULL,                                                  // #177
+VM_localsound,                                 // #177
 NULL,                                                  // #178
 NULL,                                                  // #179
 NULL,                                                  // #180
@@ -5183,7 +5183,7 @@ NULL,                                                     // #241
 NULL,                                                  // #242
 NULL,                                                  // #243
 NULL,                                                  // #244
-NULL,                                                  // #245
+VM_modulo,                                             // #245
 NULL,                                                  // #246
 NULL,                                                  // #247
 NULL,                                                  // #248
@@ -5266,7 +5266,7 @@ VM_drawfill,                                      // #323 float(vector position, vector size, vector rgb, float a
 VM_drawsetcliparea,                            // #324 void(float x, float y, float width, float height) drawsetcliparea
 VM_drawresetcliparea,                  // #325 void(void) drawresetcliparea
 VM_drawcolorcodedstring,               // #326 float drawcolorcodedstring(vector position, string text, vector scale, vector rgb, float alpha, float flag) (EXT_CSQC)
-VM_stringwidth,                 // #327 // FIXME is this okay?
+VM_stringwidth,                                        // #327 // FIXME is this okay?
 VM_drawsubpic,                                 // #328 // FIXME is this okay?
 VM_drawrotpic,                                 // #329 // FIXME is this okay?
 VM_CL_getstatf,                                        // #330 float(float stnum) getstatf (EXT_CSQC)