//============================================================================
// Server
-cvar_t sv_aim = {CVAR_SAVE, "sv_aim", "2", "maximum cosine angle for quake's vertical autoaim, a value above 1 completely disables the autoaim, quake used 0.93"}; //"0.93"}; // LordHavoc: disabled autoaim by default
+cvar_t sv_aim = {CVAR_SAVE, "sv_aim", "2", "maximum cosine angle for quake's vertical autoaim, a value above 1 completely disables the autoaim, quake used 0.93"};
char *vm_sv_extensions =
"DP_QC_STRFTIME "
"DP_QC_STRINGBUFFERS "
"DP_QC_STRINGCOLORFUNCTIONS "
+"DP_QC_TOKENIZEBYSEPARATOR "
"DP_QC_TRACEBOX "
"DP_QC_TRACETOSS "
"DP_QC_TRACE_MOVETYPE_HITMODEL "
"PRYDON_CLIENTCURSOR "
"TENEBRAE_GFX_DLIGHTS "
"TW_SV_STEPCONTROL "
+"DP_SV_CMD "
+"DP_QC_CMD "
;
/*
int entnum;
char string[VM_STRINGTEMP_LENGTH];
+ VM_VarString(1, string, sizeof(string));
+
VM_SAFEPARMCOUNTRANGE(2, 8, VM_SV_sprint);
entnum = PRVM_G_EDICTNUM(OFS_PARM0);
+ // LordHavoc: div0 requested that sprintto world operate like print
+ if (entnum == 0)
+ {
+ Con_Print(string);
+ return;
+ }
if (entnum < 1 || entnum > svs.maxclients || !svs.clients[entnum-1].active)
{
if (!client->netconnection)
return;
- VM_VarString(1, string, sizeof(string));
MSG_WriteChar(&client->netconnection->message,svc_print);
MSG_WriteString(&client->netconnection->message, string);
}
*/
static void VM_SV_checkbottom (void)
{
- VM_SAFEPARMCOUNT(0, VM_SV_checkbottom);
+ VM_SAFEPARMCOUNT(1, VM_SV_checkbottom);
PRVM_G_FLOAT(OFS_RETURN) = SV_CheckBottom (PRVM_G_EDICT(OFS_PARM0));
}
prvm_edict_t *ent;
int i, large;
- VM_SAFEPARMCOUNT(1, VM_SV_makestatic);
+ // allow 0 parameters due to an id1 qc bug in which this function is used
+ // with no parameters (but directly after setmodel with self in OFS_PARM0)
+ VM_SAFEPARMCOUNTRANGE(0, 1, VM_SV_makestatic);
- ent = PRVM_G_EDICT(OFS_PARM0);
+ if (prog->argc >= 1)
+ ent = PRVM_G_EDICT(OFS_PARM0);
+ else
+ ent = PRVM_PROG_TO_EDICT(prog->globals.server->self);
if (ent == prog->edicts)
{
VM_Warning("makestatic: can not modify world entity\n");
int i;
client_t *client;
- VM_SAFEPARMCOUNT(0, VM_SV_setspawnparms);
+ VM_SAFEPARMCOUNT(1, VM_SV_setspawnparms);
ent = PRVM_G_EDICT(OFS_PARM0);
i = PRVM_NUM_FOR_EDICT(ent);
{
unsigned char type; // 1/2/8 or other value if isn't used
int fieldoffset;
-}autosentstat_t;
+}customstat_t;
-static autosentstat_t *vm_autosentstats = NULL; //[515]: it starts from 0, not 32
-static int vm_autosentstats_last;
+static customstat_t *vm_customstats = NULL; //[515]: it starts from 0, not 32
+static int vm_customstats_last;
-void VM_AutoSentStats_Clear (void)
+void VM_CustomStats_Clear (void)
{
- if(vm_autosentstats)
+ if(vm_customstats)
{
- Z_Free(vm_autosentstats);
- vm_autosentstats = NULL;
- vm_autosentstats_last = -1;
+ Z_Free(vm_customstats);
+ vm_customstats = NULL;
+ vm_customstats_last = -1;
}
}
-//[515]: add check if even bigger ? "try to use two stats, cause it's too big" ?
-#define VM_SENDSTAT(a,b,c)\
-{\
-/* if((c))*/\
- if((c)==(unsigned char)(c))\
- {\
- MSG_WriteByte((a), svc_updatestatubyte);\
- MSG_WriteByte((a), (b));\
- MSG_WriteByte((a), (c));\
- }\
- else\
- {\
- MSG_WriteByte((a), svc_updatestat);\
- MSG_WriteByte((a), (b));\
- MSG_WriteLong((a), (c));\
- }\
-}\
-
-void VM_SV_WriteAutoSentStats (client_t *client, prvm_edict_t *ent, sizebuf_t *msg, int *stats)
+void VM_SV_UpdateCustomStats (client_t *client, prvm_edict_t *ent, sizebuf_t *msg, int *stats)
{
- int i, v, *si;
+ int i;
char s[17];
- const char *t;
- qboolean send;
- union
- {
- float f;
- int i;
- }k;
- if(!vm_autosentstats)
+ if(!vm_customstats)
return;
- send = (sv.protocol != PROTOCOL_QUAKE && sv.protocol != PROTOCOL_QUAKEDP && sv.protocol != PROTOCOL_NEHAHRAMOVIE && sv.protocol != PROTOCOL_DARKPLACES1 && sv.protocol != PROTOCOL_DARKPLACES2 && sv.protocol != PROTOCOL_DARKPLACES3 && sv.protocol != PROTOCOL_DARKPLACES4 && sv.protocol != PROTOCOL_DARKPLACES5);
-
- for(i=0; i<vm_autosentstats_last+1 ;i++)
+ for(i=0; i<vm_customstats_last+1 ;i++)
{
- if(!vm_autosentstats[i].type)
+ if(!vm_customstats[i].type)
continue;
- switch(vm_autosentstats[i].type)
+ switch(vm_customstats[i].type)
{
- //string
+ //string as 16 bytes
case 1:
- t = PRVM_E_STRING(ent, vm_autosentstats[i].fieldoffset);
- if(t && t[0])
- {
- memset(s, 0, 17);
- strlcpy(s, t, 16);
- si = (int*)s;
- if (!send)
- {
- stats[i+32] = si[0];
- stats[i+33] = si[1];
- stats[i+34] = si[2];
- stats[i+35] = si[3];
- }
- else
- {
- VM_SENDSTAT(msg, i+32, si[0]);
- VM_SENDSTAT(msg, i+33, si[1]);
- VM_SENDSTAT(msg, i+34, si[2]);
- VM_SENDSTAT(msg, i+35, si[3]);
- }
- }
+ memset(s, 0, 17);
+ strlcpy(s, PRVM_E_STRING(ent, vm_customstats[i].fieldoffset), 16);
+ stats[i+32] = s[ 0] + s[ 1] * 256 + s[ 2] * 65536 + s[ 3] * 16777216;
+ stats[i+33] = s[ 4] + s[ 5] * 256 + s[ 6] * 65536 + s[ 7] * 16777216;
+ stats[i+34] = s[ 8] + s[ 9] * 256 + s[10] * 65536 + s[11] * 16777216;
+ stats[i+35] = s[12] + s[13] * 256 + s[14] * 65536 + s[15] * 16777216;
break;
- //float
+ //float field sent as-is
case 2:
- k.f = PRVM_E_FLOAT(ent, vm_autosentstats[i].fieldoffset); //[515]: use PRVM_E_INT ?
- k.i = LittleLong (k.i);
- if (!send)
- stats[i+32] = k.i;
- else
- VM_SENDSTAT(msg, i+32, k.i);
+ stats[i+32] = PRVM_E_INT(ent, vm_customstats[i].fieldoffset);
break;
- //integer
+ //integer value of float field
case 8:
- v = (int)PRVM_E_FLOAT(ent, vm_autosentstats[i].fieldoffset); //[515]: use PRVM_E_INT ?
- if (!send)
- stats[i+32] = v;
- else
- VM_SENDSTAT(msg, i+32, v);
+ stats[i+32] = (int)PRVM_E_FLOAT(ent, vm_customstats[i].fieldoffset);
break;
default:
break;
}
}
-// void(float index, float type, .void field) SV_AddStat = #470;
+// void(float index, float type, .void field) SV_AddStat = #232;
// Set up an auto-sent player stat.
// Client's get thier own fields sent to them. Index may not be less than 32.
// Type is a value equating to the ev_ values found in qcc to dictate types. Valid ones are:
int off, i;
unsigned char type;
- VM_SAFEPARMCOUNT(2, VM_SV_AddStat);
+ VM_SAFEPARMCOUNT(3, VM_SV_AddStat);
- if(!vm_autosentstats)
+ if(!vm_customstats)
{
- vm_autosentstats = (autosentstat_t *)Z_Malloc((MAX_CL_STATS-32) * sizeof(autosentstat_t));
- if(!vm_autosentstats)
+ vm_customstats = (customstat_t *)Z_Malloc((MAX_CL_STATS-32) * sizeof(customstat_t));
+ if(!vm_customstats)
{
VM_Warning("PF_SV_AddStat: not enough memory\n");
return;
VM_Warning("PF_SV_AddStat: index > (MAX_CL_STATS-4) with string\n");
return;
}
- vm_autosentstats[i].type = type;
- vm_autosentstats[i].fieldoffset = off;
- if(vm_autosentstats_last < i)
- vm_autosentstats_last = i;
+ vm_customstats[i].type = type;
+ vm_customstats[i].fieldoffset = off;
+ if(vm_customstats_last < i)
+ vm_customstats_last = i;
}
/*
MSG_WriteByte(&sv.datagram, bound(-128, (int) PRVM_G_VECTOR(OFS_PARM1)[2], 127));
// count
MSG_WriteByte(&sv.datagram, bound(0, (int) PRVM_G_FLOAT(OFS_PARM2), 255));
+ SV_FlushBroadcastMessages();
}
static void VM_SV_te_bloodshower (void)
MSG_WriteCoord(&sv.datagram, PRVM_G_FLOAT(OFS_PARM2), sv.protocol);
// count
MSG_WriteShort(&sv.datagram, (int)bound(0, PRVM_G_FLOAT(OFS_PARM3), 65535));
+ SV_FlushBroadcastMessages();
}
static void VM_SV_te_explosionrgb (void)
MSG_WriteByte(&sv.datagram, bound(0, (int) (PRVM_G_VECTOR(OFS_PARM1)[0] * 255), 255));
MSG_WriteByte(&sv.datagram, bound(0, (int) (PRVM_G_VECTOR(OFS_PARM1)[1] * 255), 255));
MSG_WriteByte(&sv.datagram, bound(0, (int) (PRVM_G_VECTOR(OFS_PARM1)[2] * 255), 255));
+ SV_FlushBroadcastMessages();
}
static void VM_SV_te_particlecube (void)
MSG_WriteByte(&sv.datagram, ((int) PRVM_G_FLOAT(OFS_PARM5)) != 0);
// randomvel
MSG_WriteCoord(&sv.datagram, PRVM_G_FLOAT(OFS_PARM6), sv.protocol);
+ SV_FlushBroadcastMessages();
}
static void VM_SV_te_particlerain (void)
MSG_WriteShort(&sv.datagram, (int)bound(0, PRVM_G_FLOAT(OFS_PARM3), 65535));
// color
MSG_WriteByte(&sv.datagram, (int)PRVM_G_FLOAT(OFS_PARM4));
+ SV_FlushBroadcastMessages();
}
static void VM_SV_te_particlesnow (void)
MSG_WriteShort(&sv.datagram, (int)bound(0, PRVM_G_FLOAT(OFS_PARM3), 65535));
// color
MSG_WriteByte(&sv.datagram, (int)PRVM_G_FLOAT(OFS_PARM4));
+ SV_FlushBroadcastMessages();
}
static void VM_SV_te_spark (void)
MSG_WriteByte(&sv.datagram, bound(-128, (int) PRVM_G_VECTOR(OFS_PARM1)[2], 127));
// count
MSG_WriteByte(&sv.datagram, bound(0, (int) PRVM_G_FLOAT(OFS_PARM2), 255));
+ SV_FlushBroadcastMessages();
}
static void VM_SV_te_gunshotquad (void)
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM0)[0], sv.protocol);
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM0)[1], sv.protocol);
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM0)[2], sv.protocol);
+ SV_FlushBroadcastMessages();
}
static void VM_SV_te_spikequad (void)
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM0)[0], sv.protocol);
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM0)[1], sv.protocol);
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM0)[2], sv.protocol);
+ SV_FlushBroadcastMessages();
}
static void VM_SV_te_superspikequad (void)
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM0)[0], sv.protocol);
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM0)[1], sv.protocol);
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM0)[2], sv.protocol);
+ SV_FlushBroadcastMessages();
}
static void VM_SV_te_explosionquad (void)
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM0)[0], sv.protocol);
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM0)[1], sv.protocol);
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM0)[2], sv.protocol);
+ SV_FlushBroadcastMessages();
}
static void VM_SV_te_smallflash (void)
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM0)[0], sv.protocol);
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM0)[1], sv.protocol);
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM0)[2], sv.protocol);
+ SV_FlushBroadcastMessages();
}
static void VM_SV_te_customflash (void)
MSG_WriteByte(&sv.datagram, (int)bound(0, PRVM_G_VECTOR(OFS_PARM3)[0] * 255, 255));
MSG_WriteByte(&sv.datagram, (int)bound(0, PRVM_G_VECTOR(OFS_PARM3)[1] * 255, 255));
MSG_WriteByte(&sv.datagram, (int)bound(0, PRVM_G_VECTOR(OFS_PARM3)[2] * 255, 255));
+ SV_FlushBroadcastMessages();
}
static void VM_SV_te_gunshot (void)
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM0)[0], sv.protocol);
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM0)[1], sv.protocol);
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM0)[2], sv.protocol);
+ SV_FlushBroadcastMessages();
}
static void VM_SV_te_spike (void)
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM0)[0], sv.protocol);
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM0)[1], sv.protocol);
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM0)[2], sv.protocol);
+ SV_FlushBroadcastMessages();
}
static void VM_SV_te_superspike (void)
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM0)[0], sv.protocol);
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM0)[1], sv.protocol);
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM0)[2], sv.protocol);
+ SV_FlushBroadcastMessages();
}
static void VM_SV_te_explosion (void)
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM0)[0], sv.protocol);
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM0)[1], sv.protocol);
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM0)[2], sv.protocol);
+ SV_FlushBroadcastMessages();
}
static void VM_SV_te_tarexplosion (void)
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM0)[0], sv.protocol);
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM0)[1], sv.protocol);
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM0)[2], sv.protocol);
+ SV_FlushBroadcastMessages();
}
static void VM_SV_te_wizspike (void)
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM0)[0], sv.protocol);
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM0)[1], sv.protocol);
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM0)[2], sv.protocol);
+ SV_FlushBroadcastMessages();
}
static void VM_SV_te_knightspike (void)
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM0)[0], sv.protocol);
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM0)[1], sv.protocol);
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM0)[2], sv.protocol);
+ SV_FlushBroadcastMessages();
}
static void VM_SV_te_lavasplash (void)
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM0)[0], sv.protocol);
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM0)[1], sv.protocol);
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM0)[2], sv.protocol);
+ SV_FlushBroadcastMessages();
}
static void VM_SV_te_teleport (void)
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM0)[0], sv.protocol);
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM0)[1], sv.protocol);
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM0)[2], sv.protocol);
+ SV_FlushBroadcastMessages();
}
static void VM_SV_te_explosion2 (void)
// color
MSG_WriteByte(&sv.datagram, (int)PRVM_G_FLOAT(OFS_PARM1));
MSG_WriteByte(&sv.datagram, (int)PRVM_G_FLOAT(OFS_PARM2));
+ SV_FlushBroadcastMessages();
}
static void VM_SV_te_lightning1 (void)
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM2)[0], sv.protocol);
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM2)[1], sv.protocol);
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM2)[2], sv.protocol);
+ SV_FlushBroadcastMessages();
}
static void VM_SV_te_lightning2 (void)
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM2)[0], sv.protocol);
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM2)[1], sv.protocol);
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM2)[2], sv.protocol);
+ SV_FlushBroadcastMessages();
}
static void VM_SV_te_lightning3 (void)
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM2)[0], sv.protocol);
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM2)[1], sv.protocol);
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM2)[2], sv.protocol);
+ SV_FlushBroadcastMessages();
}
static void VM_SV_te_beam (void)
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM2)[0], sv.protocol);
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM2)[1], sv.protocol);
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM2)[2], sv.protocol);
+ SV_FlushBroadcastMessages();
}
static void VM_SV_te_plasmaburn (void)
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM0)[0], sv.protocol);
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM0)[1], sv.protocol);
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM0)[2], sv.protocol);
+ SV_FlushBroadcastMessages();
}
static void VM_SV_te_flamejet (void)
MSG_WriteCoord(&sv.datagram, PRVM_G_VECTOR(OFS_PARM1)[2], sv.protocol);
// count
MSG_WriteByte(&sv.datagram, (int)PRVM_G_FLOAT(OFS_PARM2));
+ SV_FlushBroadcastMessages();
}
void clippointtosurface(model_t *model, msurface_t *surface, vec3_t p, vec3_t out)
MSG_WriteShort(&sv.datagram, (int)PRVM_G_FLOAT(OFS_PARM1));
MSG_WriteVector(&sv.datagram, PRVM_G_VECTOR(OFS_PARM2), sv.protocol);
MSG_WriteVector(&sv.datagram, PRVM_G_VECTOR(OFS_PARM3), sv.protocol);
+ SV_FlushBroadcastMessages();
}
//#337 void(float effectnum, vector origin, vector dir, float count) pointparticles (EXT_CSQC)
MSG_WriteVector(&sv.datagram, PRVM_G_VECTOR(OFS_PARM1), sv.protocol);
MSG_WriteVector(&sv.datagram, PRVM_G_VECTOR(OFS_PARM2), sv.protocol);
MSG_WriteShort(&sv.datagram, bound(0, (int)PRVM_G_FLOAT(OFS_PARM3), 65535));
+ SV_FlushBroadcastMessages();
}
prvm_builtin_t vm_sv_builtins[] = {
VM_strlennocol, // #476 float(string s) : DRESK - String Length (not counting color codes) (DP_QC_STRINGCOLORFUNCTIONS)
VM_strdecolorize, // #477 string(string s) : DRESK - Decolorized String (DP_SV_STRINGCOLORFUNCTIONS)
VM_strftime, // #478 string(float uselocaltime, string format, ...) (DP_QC_STRFTIME)
-NULL, // #479
+VM_tokenizebyseparator, // #479 float(string s) tokenizebyseparator (DP_QC_TOKENIZEBYSEPARATOR)
NULL, // #480
NULL, // #481
NULL, // #482