]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - svvm_cmds.c
Merge intoverflow.h into qdefs.h
[xonotic/darkplaces.git] / svvm_cmds.c
index 18997ba51c9afdbc467f7b17e1b72a143ec50956..e17c24ea7feb7646d1f668204b3d61441d340358 100644 (file)
@@ -488,6 +488,9 @@ static void VM_SV_ambientsound(prvm_prog_t *prog)
        if (soundnum >= 256)
                large = true;
 
+       if(sv.protocol == PROTOCOL_NEHAHRABJP)
+               large = false;
+
        // add an svc_spawnambient command to the level signon packet
 
        if (large)
@@ -497,7 +500,7 @@ static void VM_SV_ambientsound(prvm_prog_t *prog)
 
        MSG_WriteVector(&sv.signon, pos, sv.protocol);
 
-       if (large || sv.protocol == PROTOCOL_NEHAHRABJP || sv.protocol == PROTOCOL_NEHAHRABJP2 || sv.protocol == PROTOCOL_NEHAHRABJP3)
+       if (large || sv.protocol == PROTOCOL_NEHAHRABJP2 || sv.protocol == PROTOCOL_NEHAHRABJP3)
                MSG_WriteShort (&sv.signon, soundnum);
        else
                MSG_WriteByte (&sv.signon, soundnum);
@@ -1542,17 +1545,17 @@ static void VM_SV_makestatic(prvm_prog_t *prog)
        if (PRVM_serveredictfloat(ent, modelindex) >= 256 || PRVM_serveredictfloat(ent, frame) >= 256)
                large = true;
 
-       if (large)
+       if (sv.protocol == PROTOCOL_NEHAHRABJP || sv.protocol == PROTOCOL_NEHAHRABJP2 || sv.protocol == PROTOCOL_NEHAHRABJP3)
        {
-               MSG_WriteByte (&sv.signon,svc_spawnstatic2);
+               MSG_WriteByte (&sv.signon,svc_spawnstatic);
                MSG_WriteShort (&sv.signon, (int)PRVM_serveredictfloat(ent, modelindex));
-               MSG_WriteShort (&sv.signon, (int)PRVM_serveredictfloat(ent, frame));
+               MSG_WriteByte (&sv.signon, (int)PRVM_serveredictfloat(ent, frame));
        }
-       else if (sv.protocol == PROTOCOL_NEHAHRABJP || sv.protocol == PROTOCOL_NEHAHRABJP2 || sv.protocol == PROTOCOL_NEHAHRABJP3)
+       else if (large)
        {
-               MSG_WriteByte (&sv.signon,svc_spawnstatic);
+               MSG_WriteByte (&sv.signon,svc_spawnstatic2);
                MSG_WriteShort (&sv.signon, (int)PRVM_serveredictfloat(ent, modelindex));
-               MSG_WriteByte (&sv.signon, (int)PRVM_serveredictfloat(ent, frame));
+               MSG_WriteShort (&sv.signon, (int)PRVM_serveredictfloat(ent, frame));
        }
        else
        {
@@ -2356,7 +2359,7 @@ static void VM_SV_clientcommand(prvm_prog_t *prog)
 
        temp_client = host_client;
        host_client = svs.clients + i;
-       Cmd_ExecuteString(&cmd_serverfromclient, PRVM_G_STRING(OFS_PARM1), src_client, true);
+       Cmd_ExecuteString(cmd_serverfromclient, PRVM_G_STRING(OFS_PARM1), src_client, true);
        host_client = temp_client;
 }
 
@@ -2478,9 +2481,6 @@ static int SV_GetEntityLocalTagMatrix(prvm_prog_t *prog, prvm_edict_t *ent, int
 // 3 - null or non-precached model
 // 4 - no tags with requested index
 // 5 - runaway loop at attachment chain
-extern cvar_t cl_bob;
-extern cvar_t cl_bobcycle;
-extern cvar_t cl_bobup;
 static int SV_GetTagMatrix (prvm_prog_t *prog, matrix4x4_t *out, prvm_edict_t *ent, int tagindex)
 {
        int ret;
@@ -2539,29 +2539,6 @@ static int SV_GetTagMatrix (prvm_prog_t *prog, matrix4x4_t *out, prvm_edict_t *e
 
                SV_GetEntityMatrix(prog, ent, &entitymatrix, true);
                Matrix4x4_Concat(out, &entitymatrix, &tagmatrix);
-
-               /*
-               // Cl_bob, ported from rendering code
-               if (PRVM_serveredictfloat(ent, health) > 0 && cl_bob.value && cl_bobcycle.value)
-               {
-                       double bob, cycle;
-                       // LadyHavoc: this code is *weird*, but not replacable (I think it
-                       // should be done in QC on the server, but oh well, quake is quake)
-                       // LadyHavoc: figured out bobup: the time at which the sin is at 180
-                       // degrees (which allows lengthening or squishing the peak or valley)
-                       cycle = sv.time/cl_bobcycle.value;
-                       cycle -= (int)cycle;
-                       if (cycle < cl_bobup.value)
-                               cycle = sin(M_PI * cycle / cl_bobup.value);
-                       else
-                               cycle = sin(M_PI + M_PI * (cycle-cl_bobup.value)/(1.0 - cl_bobup.value));
-                       // bob is proportional to velocity in the xy plane
-                       // (don't count Z, or jumping messes it up)
-                       bob = sqrt(PRVM_serveredictvector(ent, velocity)[0]*PRVM_serveredictvector(ent, velocity)[0] + PRVM_serveredictvector(ent, velocity)[1]*PRVM_serveredictvector(ent, velocity)[1])*cl_bob.value;
-                       bob = bob*0.3 + bob*0.7*cycle;
-                       Matrix4x4_AdjustOrigin(out, 0, 0, bound(-7, bob, 4));
-               }
-               */
        }
        return 0;
 }
@@ -2873,6 +2850,20 @@ static void VM_SV_pointparticles(prvm_prog_t *prog)
        SV_FlushBroadcastMessages();
 }
 
+qbool SV_VM_ConsoleCommand (const char *text)
+{
+       prvm_prog_t *prog = SVVM_prog;
+       return PRVM_ConsoleCommand(prog, text, &prog->funcoffsets.ConsoleCmd, true, PRVM_EDICT_TO_PROG(sv.world.prog->edicts), sv.time,  !(!sv.active || !prog || !prog->loaded), "QC function ConsoleCmd is missing"); 
+}
+
+// #352 void(string cmdname) registercommand (EXT_CSQC)
+static void VM_SV_registercommand (prvm_prog_t *prog)
+{
+       VM_SAFEPARMCOUNT(1, VM_SV_registercmd);
+       if(!Cmd_Exists(cmd_local, PRVM_G_STRING(OFS_PARM0)))
+               Cmd_AddCommand(CF_SERVER, PRVM_G_STRING(OFS_PARM0), NULL, "console command created by QuakeC");
+}
+
 //PF_setpause,    // void(float pause) setpause        = #531;
 static void VM_SV_setpause(prvm_prog_t *prog) {
        int pauseValue;
@@ -3446,7 +3437,7 @@ NULL,                                                     // #241
 NULL,                                                  // #242
 NULL,                                                  // #243
 NULL,                                                  // #244
-NULL,                                                  // #245
+VM_modulo,                                             // #245
 NULL,                                                  // #246
 NULL,                                                  // #247
 NULL,                                                  // #248
@@ -3554,7 +3545,7 @@ NULL,                                                     // #348 string(float playernum, string keyname) getplayerkeyvalue (E
 NULL,                                                  // #349 float() isdemo (EXT_CSQC)
 VM_isserver,                                   // #350 float() isserver (EXT_CSQC)
 NULL,                                                  // #351 void(vector origin, vector forward, vector right, vector up) SetListener (EXT_CSQC)
-NULL,                                                  // #352 void(string cmdname) registercommand (EXT_CSQC)
+VM_SV_registercommand,                 // #352 void(string cmdname) registercommand (EXT_CSQC)
 VM_wasfreed,                                   // #353 float(entity ent) wasfreed (EXT_CSQC) (should be availabe on server too)
 VM_SV_serverkey,                               // #354 string(string key) serverkey (EXT_CSQC)
 NULL,                                                  // #355