cvar_t gamecfg = {0, "gamecfg", "0", "unused cvar in quake, can be used by mods"};
cvar_t noexit = {CVAR_NOTIFY, "noexit","0", "kills anyone attempting to use an exit"};
cvar_t nomonsters = {0, "nomonsters", "0", "unused cvar in quake, can be used by mods"};
-cvar_t pausable = {0, "pausable","1", "allow players to pause or not"};
+cvar_t pausable = {0, "pausable","1", "allow players to pause or not (otherwise, only the server admin can)"};
cvar_t pr_checkextension = {CVAR_READONLY, "pr_checkextension", "1", "indicates to QuakeC that the standard quakec extensions system is available (if 0, quakec should not attempt to use extensions)"};
cvar_t samelevel = {CVAR_NOTIFY, "samelevel","0", "repeats same level if level ends (due to timelimit or someone hitting an exit)"};
cvar_t skill = {0, "skill","1", "difficulty level of game, affects monster layouts in levels, 0 = easy, 1 = normal, 2 = hard, 3 = nightmare (same layout as hard but monsters fire twice)"};
cvar_t sv_cullentities_trace_delay = {0, "sv_cullentities_trace_delay", "1", "number of seconds until the entity gets actually culled"};
cvar_t sv_cullentities_trace_delay_players = {0, "sv_cullentities_trace_delay_players", "0.2", "number of seconds until the entity gets actually culled if it is a player entity"};
cvar_t sv_cullentities_trace_enlarge = {0, "sv_cullentities_trace_enlarge", "0", "box enlargement for entity culling"};
+cvar_t sv_cullentities_trace_eyejitter = {0, "sv_cullentities_trace_eyejitter", "16", "jitter the eye by this much for each trace"};
cvar_t sv_cullentities_trace_prediction = {0, "sv_cullentities_trace_prediction", "1", "also trace from the predicted player position"};
cvar_t sv_cullentities_trace_prediction_time = {0, "sv_cullentities_trace_prediction_time", "0.2", "how many seconds of prediction to use"};
cvar_t sv_cullentities_trace_entityocclusion = {0, "sv_cullentities_trace_entityocclusion", "0", "also check if doors and other bsp models are in the way"};
cvar_t sv_gameplayfix_setmodelrealbox = {0, "sv_gameplayfix_setmodelrealbox", "1", "fixes a bug in Quake that made setmodel always set the entity box to ('-16 -16 -16', '16 16 16') rather than properly checking the model box, breaks some poorly coded mods"};
cvar_t sv_gameplayfix_slidemoveprojectiles = {0, "sv_gameplayfix_slidemoveprojectiles", "1", "allows MOVETYPE_FLY/FLYMISSILE/TOSS/BOUNCE/BOUNCEMISSILE entities to finish their move in a frame even if they hit something, fixes 'gravity accumulation' bug for grenades on steep slopes"};
cvar_t sv_gameplayfix_stepdown = {0, "sv_gameplayfix_stepdown", "0", "attempts to step down stairs, not just up them (prevents the familiar thud..thud..thud.. when running down stairs and slopes)"};
-cvar_t sv_gameplayfix_stepwhilejumping = {0, "sv_gameplayfix_stepwhilejumping", "1", "applies step-up onto a ledge even while airborn, useful if you would otherwise just-miss the floor when running across small areas with gaps (for instance running across the moving platforms in dm2, or jumping to the megahealth and red armor in dm2 rather than using the bridge)"};
cvar_t sv_gameplayfix_stepmultipletimes = {0, "sv_gameplayfix_stepmultipletimes", "0", "applies step-up onto a ledge more than once in a single frame, when running quickly up stairs"};
-cvar_t sv_gameplayfix_nostepmoveonsteepslopes = {0, "sv_gameplayfix_nostepmoveonsteepslopes", "0", "grude fix which prevents MOVETYPE_STEP (not swimming or flying) to move on slopes whose angle is bigger than 45 degree"};
+cvar_t sv_gameplayfix_nostepmoveonsteepslopes = {0, "sv_gameplayfix_nostepmoveonsteepslopes", "0", "crude fix which prevents MOVETYPE_STEP (not swimming or flying) to move on slopes whose angle is bigger than 45 degree"};
cvar_t sv_gameplayfix_swiminbmodels = {0, "sv_gameplayfix_swiminbmodels", "1", "causes pointcontents (used to determine if you are in a liquid) to check bmodel entities as well as the world model, so you can swim around in (possibly moving) water bmodel entities"};
cvar_t sv_gameplayfix_upwardvelocityclearsongroundflag = {0, "sv_gameplayfix_upwardvelocityclearsongroundflag", "1", "prevents monsters, items, and most other objects from being stuck to the floor when pushed around by damage, and other situations in mods"};
cvar_t sv_gameplayfix_downtracesupportsongroundflag = {0, "sv_gameplayfix_downtracesupportsongroundflag", "1", "prevents very short moves from clearing onground (which may make the player stick to the floor at high netfps)"};
cvar_t sv_gameplayfix_unstickentities = {0, "sv_gameplayfix_unstickentities", "1", "hack to check if entities are crossing world collision hull and try to move them to the right position"};
cvar_t sv_gameplayfix_fixedcheckwatertransition = {0, "sv_gameplayfix_fixedcheckwatertransition", "1", "fix two very stupid bugs in SV_CheckWaterTransition when watertype is CONTENTS_EMPTY (the bugs causes waterlevel to be 1 on first frame, -1 on second frame - the fix makes it 0 on both frames)"};
cvar_t sv_gravity = {CVAR_NOTIFY, "sv_gravity","800", "how fast you fall (512 = roughly earth gravity)"};
+cvar_t sv_init_frame_count = {0, "sv_init_frame_count", "2", "number of frames to run to allow everything to settle before letting clients connect"};
cvar_t sv_idealpitchscale = {0, "sv_idealpitchscale","0.8", "how much to look up/down slopes and stairs when not using freelook"};
-cvar_t sv_jumpstep = {CVAR_NOTIFY, "sv_jumpstep", "0", "whether you can step up while jumping (sv_gameplayfix_stepwhilejumping must also be 1)"};
+cvar_t sv_jumpstep = {CVAR_NOTIFY, "sv_jumpstep", "0", "whether you can step up while jumping"};
cvar_t sv_jumpvelocity = {0, "sv_jumpvelocity", "270", "cvar that can be used by QuakeC code for jump velocity"};
cvar_t sv_maxairspeed = {0, "sv_maxairspeed", "30", "maximum speed a player can accelerate to when airborn (note that it is possible to completely stop by moving the opposite direction)"};
cvar_t sv_maxrate = {CVAR_SAVE | CVAR_NOTIFY, "sv_maxrate", "1000000", "upper limit on client rate cvar, should reflect your network connection quality"};
cvar_t sv_autodemo_perclient_discardable = {CVAR_SAVE, "sv_autodemo_perclient_discardable", "0", "Allow game code to decide whether a demo should be kept or discarded."};
cvar_t halflifebsp = {0, "halflifebsp", "0", "indicates the current map is hlbsp format (useful to know because of different bounding box sizes)"};
+cvar_t sv_mapformat_is_quake2 = {0, "sv_mapformat_is_quake2", "0", "indicates the current map is q2bsp format (useful to know because of different entity behaviors, .frame on submodels and other things)"};
+cvar_t sv_mapformat_is_quake3 = {0, "sv_mapformat_is_quake3", "0", "indicates the current map is q2bsp format (useful to know because of different entity behaviors)"};
server_t sv;
server_static_t svs;
Cvar_RegisterVariable (&sv_cullentities_trace_delay);
Cvar_RegisterVariable (&sv_cullentities_trace_delay_players);
Cvar_RegisterVariable (&sv_cullentities_trace_enlarge);
+ Cvar_RegisterVariable (&sv_cullentities_trace_eyejitter);
Cvar_RegisterVariable (&sv_cullentities_trace_entityocclusion);
Cvar_RegisterVariable (&sv_cullentities_trace_prediction);
Cvar_RegisterVariable (&sv_cullentities_trace_prediction_time);
Cvar_RegisterVariable (&sv_gameplayfix_setmodelrealbox);
Cvar_RegisterVariable (&sv_gameplayfix_slidemoveprojectiles);
Cvar_RegisterVariable (&sv_gameplayfix_stepdown);
- Cvar_RegisterVariable (&sv_gameplayfix_stepwhilejumping);
Cvar_RegisterVariable (&sv_gameplayfix_stepmultipletimes);
Cvar_RegisterVariable (&sv_gameplayfix_nostepmoveonsteepslopes);
Cvar_RegisterVariable (&sv_gameplayfix_swiminbmodels);
Cvar_RegisterVariable (&sv_gameplayfix_unstickentities);
Cvar_RegisterVariable (&sv_gameplayfix_fixedcheckwatertransition);
Cvar_RegisterVariable (&sv_gravity);
+ Cvar_RegisterVariable (&sv_init_frame_count);
Cvar_RegisterVariable (&sv_idealpitchscale);
Cvar_RegisterVariable (&sv_jumpstep);
Cvar_RegisterVariable (&sv_jumpvelocity);
Cvar_RegisterVariable (&sv_autodemo_perclient_discardable);
Cvar_RegisterVariable (&halflifebsp);
+ Cvar_RegisterVariable (&sv_mapformat_is_quake2);
+ Cvar_RegisterVariable (&sv_mapformat_is_quake3);
sv_mempool = Mem_AllocPool("server", 0, NULL);
}
==================
*/
-void SV_StartSound (prvm_edict_t *entity, int channel, const char *sample, int volume, float attenuation, qboolean reliable, float speed)
+void SV_StartSound (prvm_edict_t *entity, int channel, const char *sample, int nvolume, float attenuation, qboolean reliable, float speed)
{
prvm_prog_t *prog = SVVM_prog;
sizebuf_t *dest;
dest = (reliable ? &sv.reliable_datagram : &sv.datagram);
- if (volume < 0 || volume > 255)
+ if (nvolume < 0 || nvolume > 255)
{
- Con_Printf ("SV_StartSound: volume = %i\n", volume);
+ Con_Printf ("SV_StartSound: volume = %i\n", nvolume);
return;
}
speed4000 = (int)floor(speed * 4000.0f + 0.5f);
field_mask = 0;
- if (volume != DEFAULT_SOUND_PACKET_VOLUME)
+ if (nvolume != DEFAULT_SOUND_PACKET_VOLUME)
field_mask |= SND_VOLUME;
if (attenuation != DEFAULT_SOUND_PACKET_ATTENUATION)
field_mask |= SND_ATTENUATION;
MSG_WriteByte (dest, svc_sound);
MSG_WriteByte (dest, field_mask);
if (field_mask & SND_VOLUME)
- MSG_WriteByte (dest, volume);
+ MSG_WriteByte (dest, nvolume);
if (field_mask & SND_ATTENUATION)
MSG_WriteByte (dest, (int)(attenuation*64));
if (field_mask & SND_SPEEDUSHORT4000)
==================
*/
-void SV_StartPointSound (vec3_t origin, const char *sample, int volume, float attenuation, float speed)
+void SV_StartPointSound (vec3_t origin, const char *sample, int nvolume, float attenuation, float speed)
{
int sound_num, field_mask, i, speed4000;
- if (volume < 0 || volume > 255)
+ if (nvolume < 0 || nvolume > 255)
{
- Con_Printf ("SV_StartPointSound: volume = %i\n", volume);
+ Con_Printf ("SV_StartPointSound: volume = %i\n", nvolume);
return;
}
speed4000 = (int)(speed * 40.0f);
field_mask = 0;
- if (volume != DEFAULT_SOUND_PACKET_VOLUME)
+ if (nvolume != DEFAULT_SOUND_PACKET_VOLUME)
field_mask |= SND_VOLUME;
if (attenuation != DEFAULT_SOUND_PACKET_ATTENUATION)
field_mask |= SND_ATTENUATION;
MSG_WriteByte (&sv.datagram, svc_sound);
MSG_WriteByte (&sv.datagram, field_mask);
if (field_mask & SND_VOLUME)
- MSG_WriteByte (&sv.datagram, volume);
+ MSG_WriteByte (&sv.datagram, nvolume);
if (field_mask & SND_ATTENUATION)
MSG_WriteByte (&sv.datagram, (int)(attenuation*64));
if (field_mask & SND_SPEEDUSHORT4000)
{
client->csqcentityscope[i] = 0;
client->csqcentitysendflags[i] = 0xFFFFFF;
- client->csqcentityglobalhistory[i] = 0;
}
for (i = 0;i < NUM_CSQCENTITYDB_FRAMES;i++)
{
MSG_WriteString (&client->netconnection->message,message);
SV_StopDemoRecording(client); // to split up demos into different files
- if(sv_autodemo_perclient.integer && client->netconnection)
+ if(sv_autodemo_perclient.integer)
{
char demofile[MAX_OSPATH];
char ipaddress[MAX_QPATH];
- size_t i;
+ size_t j;
// start a new demo file
LHNETADDRESS_ToString(&(client->netconnection->peeraddress), ipaddress, sizeof(ipaddress), true);
- for(i = 0; ipaddress[i]; ++i)
- if(!isalnum(ipaddress[i]))
- ipaddress[i] = '-';
+ for(j = 0; ipaddress[j]; ++j)
+ if(!isalnum(ipaddress[j]))
+ ipaddress[j] = '-';
dpsnprintf (demofile, sizeof(demofile), "%s_%s_%d_%s.dem", Sys_TimeString (sv_autodemo_perclient_nameformat.string), sv.worldbasename, PRVM_NUM_FOR_EDICT(client->edict), ipaddress);
SV_StartDemoRecording(client, demofile, -1);
if(client->sv_demo_file != NULL)
{
- int i;
+ int k;
static char buf[NET_MAXMESSAGE];
sizebuf_t sb;
sb.data = (unsigned char *) buf;
sb.maxsize = sizeof(buf);
- i = 0;
- while(MakeDownloadPacket(sv.csqc_progname, svs.csqc_progdata, sv.csqc_progsize, sv.csqc_progcrc, i++, &sb, sv.protocol))
+ k = 0;
+ while(MakeDownloadPacket(sv.csqc_progname, svs.csqc_progdata, sv.csqc_progsize, sv.csqc_progcrc, k++, &sb, sv.protocol))
SV_WriteDemoMessage(client, &sb, false);
}
MSG_WriteByte (&client->netconnection->message, svc_signonnum);
MSG_WriteByte (&client->netconnection->message, 1);
+ client->prespawned = false; // need prespawn, spawn, etc
client->spawned = false; // need prespawn, spawn, etc
+ client->begun = false; // need prespawn, spawn, etc
client->sendsignon = 1; // send this message, and increment to 2, 2 will be set to 0 by the prespawn command
// clear movement info until client enters the new level properly
if(client->netconnection && client->netconnection->crypto.authenticated)
{
- Con_Printf("%s connection to %s has been established: client is %s@%.*s, I am %.*s@%.*s\n",
+ Con_Printf("%s connection to %s has been established: client is %s@%s%.*s, I am %.*s@%s%.*s\n",
client->netconnection->crypto.use_aes ? "Encrypted" : "Authenticated",
client->netconnection->address,
client->netconnection->crypto.client_idfp[0] ? client->netconnection->crypto.client_idfp : "-",
+ (client->netconnection->crypto.client_issigned || !client->netconnection->crypto.client_keyfp[0]) ? "" : "~",
crypto_keyfp_recommended_length, client->netconnection->crypto.client_keyfp[0] ? client->netconnection->crypto.client_keyfp : "-",
crypto_keyfp_recommended_length, client->netconnection->crypto.server_idfp[0] ? client->netconnection->crypto.server_idfp : "-",
+ (client->netconnection->crypto.server_issigned || !client->netconnection->crypto.server_keyfp[0]) ? "" : "~",
crypto_keyfp_recommended_length, client->netconnection->crypto.server_keyfp[0] ? client->netconnection->crypto.server_keyfp : "-"
);
}
strlcpy(client->name, "unconnected", sizeof(client->name));
strlcpy(client->old_name, "unconnected", sizeof(client->old_name));
+ client->prespawned = false;
client->spawned = false;
+ client->begun = false;
client->edict = PRVM_EDICT_NUM(clientnum+1);
if (client->netconnection)
client->netconnection->message.allowoverflow = true; // we can catch it
client->unreliablemsg.maxsize = sizeof(client->unreliablemsg_data);
// updated by receiving "rate" command from client, this is also the default if not using a DP client
client->rate = 1000000000;
- // no limits for local player
- if (client->netconnection && LHNETADDRESS_GetAddressType(&client->netconnection->peeraddress) == LHNETADDRESSTYPE_LOOP)
- client->rate = 1000000000;
client->connecttime = realtime;
if (!sv.loadgame)
if (client->netconnection)
SV_SendServerinfo (client);
else
- client->spawned = true;
+ client->prespawned = client->spawned = client->begun = true;
}
unsigned int customizeentityforclient;
unsigned int sendentity;
float f;
- float *v;
+ prvm_vec_t *v;
vec3_t cullmins, cullmaxs;
dp_model_t *model;
cs->framegroupblend[2].lerp = PRVM_serveredictfloat(ent, lerpfrac3);
cs->framegroupblend[3].lerp = PRVM_serveredictfloat(ent, lerpfrac4);
cs->framegroupblend[0].lerp = 1.0f - cs->framegroupblend[1].lerp - cs->framegroupblend[2].lerp - cs->framegroupblend[3].lerp;
+ cs->frame = 0; // don't need the legacy frame
}
cs->light[0] = light[0];
#define MAX_LINEOFSIGHTTRACES 64
-qboolean SV_CanSeeBox(int numtraces, vec_t enlarge, vec3_t eye, vec3_t entboxmins, vec3_t entboxmaxs)
+qboolean SV_CanSeeBox(int numtraces, vec_t eyejitter, vec_t enlarge, vec3_t eye, vec3_t entboxmins, vec3_t entboxmaxs)
{
prvm_prog_t *prog = SVVM_prog;
float pitchsign;
float alpha;
float starttransformed[3], endtransformed[3];
+ float boxminstransformed[3], boxmaxstransformed[3];
+ float localboxcenter[3], localboxextents[3], localboxmins[3], localboxmaxs[3];
int blocked = 0;
int traceindex;
int originalnumtouchedicts;
dp_model_t *model;
prvm_edict_t *touch;
static prvm_edict_t *touchedicts[MAX_EDICTS];
+ vec3_t eyemins, eyemaxs, start;
vec3_t boxmins, boxmaxs;
vec3_t clipboxmins, clipboxmaxs;
vec3_t endpoints[MAX_LINEOFSIGHTTRACES];
numtraces = min(numtraces, MAX_LINEOFSIGHTTRACES);
+ // jitter the eye location within this box
+ eyemins[0] = eye[0] - eyejitter;
+ eyemaxs[0] = eye[0] + eyejitter;
+ eyemins[1] = eye[1] - eyejitter;
+ eyemaxs[1] = eye[1] + eyejitter;
+ eyemins[2] = eye[2] - eyejitter;
+ eyemaxs[2] = eye[2] + eyejitter;
// expand the box a little
boxmins[0] = (enlarge+1) * entboxmins[0] - enlarge * entboxmaxs[0];
boxmaxs[0] = (enlarge+1) * entboxmaxs[0] - enlarge * entboxmins[0];
VectorSet(endpoints[traceindex], lhrandom(boxmins[0], boxmaxs[0]), lhrandom(boxmins[1], boxmaxs[1]), lhrandom(boxmins[2], boxmaxs[2]));
// calculate sweep box for the entire swarm of traces
- VectorCopy(eye, clipboxmins);
- VectorCopy(eye, clipboxmaxs);
+ VectorCopy(eyemins, clipboxmins);
+ VectorCopy(eyemaxs, clipboxmaxs);
for (traceindex = 0;traceindex < numtraces;traceindex++)
{
clipboxmins[0] = min(clipboxmins[0], endpoints[traceindex][0]);
for (traceindex = 0;traceindex < numtraces;traceindex++)
{
+ VectorSet(start, lhrandom(eyemins[0], eyemaxs[0]), lhrandom(eyemins[1], eyemaxs[1]), lhrandom(eyemins[2], eyemaxs[2]));
// check world occlusion
if (sv.worldmodel && sv.worldmodel->brush.TraceLineOfSight)
- if (!sv.worldmodel->brush.TraceLineOfSight(sv.worldmodel, eye, endpoints[traceindex]))
+ if (!sv.worldmodel->brush.TraceLineOfSight(sv.worldmodel, start, endpoints[traceindex], boxmins, boxmaxs))
continue;
for (touchindex = 0;touchindex < numtouchedicts;touchindex++)
{
Matrix4x4_CreateFromQuakeEntity(&matrix, PRVM_serveredictvector(touch, origin)[0], PRVM_serveredictvector(touch, origin)[1], PRVM_serveredictvector(touch, origin)[2], pitchsign * PRVM_serveredictvector(touch, angles)[0], PRVM_serveredictvector(touch, angles)[1], PRVM_serveredictvector(touch, angles)[2], 1);
Matrix4x4_Invert_Simple(&imatrix, &matrix);
// see if the ray hits this entity
- Matrix4x4_Transform(&imatrix, eye, starttransformed);
+ Matrix4x4_Transform(&imatrix, start, starttransformed);
Matrix4x4_Transform(&imatrix, endpoints[traceindex], endtransformed);
- if (!model->brush.TraceLineOfSight(model, starttransformed, endtransformed))
+ Matrix4x4_Transform(&imatrix, boxmins, boxminstransformed);
+ Matrix4x4_Transform(&imatrix, boxmaxs, boxmaxstransformed);
+ // transform the AABB to local space
+ VectorMAM(0.5f, boxminstransformed, 0.5f, boxmaxstransformed, localboxcenter);
+ localboxextents[0] = fabs(boxmaxstransformed[0] - localboxcenter[0]);
+ localboxextents[1] = fabs(boxmaxstransformed[1] - localboxcenter[1]);
+ localboxextents[2] = fabs(boxmaxstransformed[2] - localboxcenter[2]);
+ localboxmins[0] = localboxcenter[0] - localboxextents[0];
+ localboxmins[1] = localboxcenter[1] - localboxextents[1];
+ localboxmins[2] = localboxcenter[2] - localboxextents[2];
+ localboxmaxs[0] = localboxcenter[0] + localboxextents[0];
+ localboxmaxs[1] = localboxcenter[1] + localboxextents[1];
+ localboxmaxs[2] = localboxcenter[2] + localboxextents[2];
+ if (!model->brush.TraceLineOfSight(model, starttransformed, endtransformed, localboxmins, localboxmaxs))
{
blocked++;
break;
}
// or not seen by random tracelines
- if (sv_cullentities_trace.integer && !isbmodel && sv.worldmodel->brush.TraceLineOfSight && !r_trippy.integer)
+ if (sv_cullentities_trace.integer && !isbmodel && sv.worldmodel && sv.worldmodel->brush.TraceLineOfSight && !r_trippy.integer)
{
int samples =
s->number <= svs.maxclients
{
int eyeindex;
for (eyeindex = 0;eyeindex < sv.writeentitiestoclient_numeyes;eyeindex++)
- if(SV_CanSeeBox(samples, enlarge, sv.writeentitiestoclient_eyes[eyeindex], ed->priv.server->cullmins, ed->priv.server->cullmaxs))
+ if(SV_CanSeeBox(samples, sv_cullentities_trace_eyejitter.value, enlarge, sv.writeentitiestoclient_eyes[eyeindex], ed->priv.server->cullmins, ed->priv.server->cullmaxs))
break;
if(eyeindex < sv.writeentitiestoclient_numeyes)
svs.clients[sv.writeentitiestoclient_clientnumber].visibletime[s->number] =
for(k = 0; k < sv.writeentitiestoclient_numeyes; ++k)
if(eye_levels[k] <= MAX_EYE_RECURSION)
{
- if(SV_CanSeeBox(sv_cullentities_trace_samples.integer, sv_cullentities_trace_enlarge.value, sv.writeentitiestoclient_eyes[k], mi, ma))
+ if(SV_CanSeeBox(sv_cullentities_trace_samples.integer, sv_cullentities_trace_eyejitter.value, sv_cullentities_trace_enlarge.value, sv.writeentitiestoclient_eyes[k], mi, ma))
{
eye_levels[sv.writeentitiestoclient_numeyes] = eye_levels[k] + 1;
VectorCopy(camera_origins[j], sv.writeentitiestoclient_eyes[sv.writeentitiestoclient_numeyes]);
vec_t predtime = bound(0, host_client->ping, sv_cullentities_trace_prediction_time.value);
vec3_t predeye;
VectorMA(eye, predtime, PRVM_serveredictvector(camera, velocity), predeye);
- if (SV_CanSeeBox(1, 0, eye, predeye, predeye))
+ if (SV_CanSeeBox(1, 0, 0, eye, predeye, predeye))
{
VectorCopy(predeye, sv.writeentitiestoclient_eyes[sv.writeentitiestoclient_numeyes]);
sv.writeentitiestoclient_numeyes++;
else
EntityFrameCSQC_WriteFrame(msg, maxsize, numcsqcsendstates, sv.writeentitiestoclient_csqcsendstates, 0);
- if(client->num_skippedentityframes >= 10)
- need_empty = true; // force every 10th frame to be not empty (or cl_movement replay takes too long)
+ // force every 16th frame to be not empty (or cl_movement replay takes
+ // too long)
+ // BTW, this should normally not kick in any more due to the check
+ // below, except if the client stopped sending movement frames
+ if(client->num_skippedentityframes >= 16)
+ need_empty = true;
+
+ // help cl_movement a bit more
+ if(client->movesequence != client->lastmovesequence)
+ need_empty = true;
+ client->lastmovesequence = client->movesequence;
if (client->entitydatabase5)
success = EntityFrame5_WriteFrame(msg, maxsize, client->entitydatabase5, numsendstates, sv.writeentitiestoclient_sendstates, client - svs.clients + 1, client->movesequence, need_empty);
{
// angle fixing was requested by global thinking code...
// so store the current angles for later use
- memcpy(host_client->fixangle_angles, PRVM_serveredictvector(ent, angles), sizeof(host_client->fixangle_angles));
+ VectorCopy(PRVM_serveredictvector(ent, angles), host_client->fixangle_angles);
host_client->fixangle_angles_set = TRUE;
// and clear fixangle for the next frame
host_client->fixangle_angles_set = FALSE;
}
- // stuff the sigil bits into the high bits of items for sbar, or else
- // mix in items2
- // LordHavoc: detecting items2 turned out to be tricky, check if the field
- // was forcefully declared, we want to override serverflags if it was
- // declared by the qc intentionally, but not if we added it in the engine.
- if (prog->fieldoffsets.items2 < (int)(prog->numfielddefs - SV_REQGLOBALS))
- items = (int)PRVM_serveredictfloat(ent, items) | ((int)PRVM_serveredictfloat(ent, items2) << 23);
- else
- items = (int)PRVM_serveredictfloat(ent, items) | ((int)PRVM_serverglobalfloat(serverflags) << 28);
+ // the runes are in serverflags, pack them into the items value, also pack
+ // in the items2 value for mission pack huds
+ // (used only in the mission packs, which do not use serverflags)
+ items = (int)PRVM_serveredictfloat(ent, items) | ((int)PRVM_serveredictfloat(ent, items2) << 23) | ((int)PRVM_serverglobalfloat(serverflags) << 28);
VectorCopy(PRVM_serveredictvector(ent, punchvector), punchvector);
MSG_WriteByte (msg, stats[STAT_NAILS]);
MSG_WriteByte (msg, stats[STAT_ROCKETS]);
MSG_WriteByte (msg, stats[STAT_CELLS]);
- if (gamemode == GAME_HIPNOTIC || gamemode == GAME_ROGUE || gamemode == GAME_NEXUIZ)
+ if (gamemode == GAME_HIPNOTIC || gamemode == GAME_ROGUE || gamemode == GAME_QUOTH || IS_OLDNEXUIZ_DERIVED(gamemode))
{
for (i = 0;i < 32;i++)
if (stats[STAT_ACTIVEWEAPON] & (1<<i))
return;
for (i = 0, client = svs.clients;i < svs.maxclients;i++, client++)
{
- if (!client->spawned || !client->netconnection || client->unreliablemsg.cursize + sv.datagram.cursize > client->unreliablemsg.maxsize || client->unreliablemsg_splitpoints >= (int)(sizeof(client->unreliablemsg_splitpoint)/sizeof(client->unreliablemsg_splitpoint[0])))
+ if (!client->begun || !client->netconnection || client->unreliablemsg.cursize + sv.datagram.cursize > client->unreliablemsg.maxsize || client->unreliablemsg_splitpoints >= (int)(sizeof(client->unreliablemsg_splitpoint)/sizeof(client->unreliablemsg_splitpoint[0])))
continue;
SZ_Write(&client->unreliablemsg, sv.datagram.data, sv.datagram.cursize);
client->unreliablemsg_splitpoint[client->unreliablemsg_splitpoints++] = client->unreliablemsg.cursize;
sizebuf_t msg;
int stats[MAX_CL_STATS];
static unsigned char sv_sendclientdatagram_buf[NET_MAXMESSAGE];
+ double timedelta;
// obey rate limit by limiting packet frequency if the packet size
// limiting fails
//
// at very low rates (or very small sys_ticrate) the packet size is
// not reduced below 128, but packets may be sent less often
- maxsize = (int)(clientrate * sys_ticrate.value);
+
+ // how long are bursts?
+ timedelta = host_client->rate_burstsize / (double)client->rate;
+
+ // how much of the burst do we keep reserved?
+ timedelta *= 1 - net_burstreserve.value;
+
+ // only try to use excess time
+ timedelta = bound(0, realtime - host_client->netconnection->cleartime, timedelta);
+
+ // but we know next packet will be in sys_ticrate, so we can use up THAT bandwidth
+ timedelta += sys_ticrate.value;
+
+ // note: packet overhead (not counted in maxsize) is 28 bytes
+ maxsize = (int)(clientrate * timedelta) - 28;
+
+ // put it in sound bounds
maxsize = bound(128, maxsize, 1400);
maxsize2 = 1400;
+
// csqc entities can easily exceed 128 bytes, so disable throttling in
// mods that use csqc (they are likely to use less bandwidth anyway)
- if (sv.csqc_progsize > 0)
+ if((net_usesizelimit.integer == 1) ? (sv.csqc_progsize > 0) : (net_usesizelimit.integer < 1))
maxsize = maxsize2;
+
break;
}
msg.cursize = 0;
msg.allowoverflow = false;
- if (host_client->spawned)
+ if (host_client->begun)
{
// the player is in the game
MSG_WriteByte (&msg, svc_time);
SV_WriteDemoMessage(client, &msg, false);
// send the datagram
- NetConn_SendUnreliableMessage (client->netconnection, &msg, sv.protocol, clientrate, client->sendsignon == 2);
+ NetConn_SendUnreliableMessage (client->netconnection, &msg, sv.protocol, clientrate, client->rate_burstsize, client->sendsignon == 2);
if (client->sendsignon == 1 && !client->netconnection->message.cursize)
client->sendsignon = 2; // prevent reliable until client sends prespawn (this is the keepalive phase)
}
if (name == NULL)
name = "";
// always point the string back at host_client->name to keep it safe
- strlcpy (host_client->name, name, sizeof (host_client->name));
+ //strlcpy (host_client->name, name, sizeof (host_client->name));
+ if (name != host_client->name) // prevent buffer overlap SIGABRT on Mac OSX
+ strlcpy (host_client->name, name, sizeof (host_client->name));
PRVM_serveredictstring(host_client->edict, netname) = PRVM_SetEngineString(prog, host_client->name);
if (strcmp(host_client->old_name, host_client->name))
{
- if (host_client->spawned)
+ if (host_client->begun)
SV_BroadcastPrintf("%s ^7changed name to %s\n", host_client->old_name, host_client->name);
strlcpy(host_client->old_name, host_client->name, sizeof(host_client->old_name));
// send notification to all clients
if (model == NULL)
model = "";
// always point the string back at host_client->name to keep it safe
- strlcpy (host_client->playermodel, model, sizeof (host_client->playermodel));
+ //strlcpy (host_client->playermodel, model, sizeof (host_client->playermodel));
+ if (model != host_client->playermodel) // prevent buffer overlap SIGABRT on Mac OSX
+ strlcpy (host_client->playermodel, model, sizeof (host_client->playermodel));
PRVM_serveredictstring(host_client->edict, playermodel) = PRVM_SetEngineString(prog, host_client->playermodel);
// NEXUIZ_PLAYERSKIN
if (skin == NULL)
skin = "";
// always point the string back at host_client->name to keep it safe
- strlcpy (host_client->playerskin, skin, sizeof (host_client->playerskin));
+ //strlcpy (host_client->playerskin, skin, sizeof (host_client->playerskin));
+ if (skin != host_client->playerskin) // prevent buffer overlap SIGABRT on Mac OSX
+ strlcpy (host_client->playerskin, skin, sizeof (host_client->playerskin));
PRVM_serveredictstring(host_client->edict, playerskin) = PRVM_SetEngineString(prog, host_client->playerskin);
// TODO: add an extension name for this [1/17/2008 Black]
// frags
host_client->frags = (int)PRVM_serveredictfloat(host_client->edict, frags);
- if(gamemode == GAME_NEXUIZ || gamemode == GAME_XONOTIC)
- if(!host_client->spawned && host_client->netconnection)
+ if(IS_OLDNEXUIZ_DERIVED(gamemode))
+ if(!host_client->begun && host_client->netconnection)
host_client->frags = -666;
if (host_client->old_frags != host_client->frags)
{
}
for (j = 0, client = svs.clients;j < svs.maxclients;j++, client++)
- if (client->netconnection && (client->spawned || client->clientconnectcalled)) // also send MSG_ALL to people who are past ClientConnect, but not spawned yet
+ if (client->netconnection && (client->begun || client->clientconnectcalled)) // also send MSG_ALL to people who are past ClientConnect, but not spawned yet
SZ_Write (&client->netconnection->message, sv.reliable_datagram.data, sv.reliable_datagram.cursize);
SZ_Clear (&sv.reliable_datagram);
argc = 0;
for (;;)
{
- if (!COM_ParseToken_Simple(&text, true, false) || !strcmp(com_token, "\n"))
+ if (!COM_ParseToken_Simple(&text, true, false, true) || !strcmp(com_token, "\n"))
break;
if (argc < 16)
{
{
if (argc == 2)
{
- for (effectnameindex = 1;effectnameindex < SV_MAX_PARTICLEEFFECTNAME;effectnameindex++)
+ for (effectnameindex = 1;effectnameindex < MAX_PARTICLEEFFECTNAME;effectnameindex++)
{
if (sv.particleeffectname[effectnameindex][0])
{
}
}
// if we run out of names, abort
- if (effectnameindex == SV_MAX_PARTICLEEFFECTNAME)
+ if (effectnameindex == MAX_PARTICLEEFFECTNAME)
{
Con_Printf("%s:%i: too many effects!\n", filename, linenumber);
break;
}
}
// search for the name
- for (effectnameindex = 1;effectnameindex < SV_MAX_PARTICLEEFFECTNAME && sv.particleeffectname[effectnameindex][0];effectnameindex++)
+ for (effectnameindex = 1;effectnameindex < MAX_PARTICLEEFFECTNAME && sv.particleeffectname[effectnameindex][0];effectnameindex++)
if (!strcmp(sv.particleeffectname[effectnameindex], name))
return effectnameindex;
// return 0 if we couldn't find it
int i, entnum, large;
prvm_edict_t *svent;
- // LordHavoc: clear *all* states (note just active ones)
+ // LordHavoc: clear *all* baselines (not just active ones)
for (entnum = 0;entnum < prog->max_edicts;entnum++)
{
// get the current server version
// SV_LockThreadMutex();
+ if(cls.state == ca_dedicated)
+ Sys_MakeProcessNice();
+
if (cls.state != ca_dedicated)
{
- SCR_BeginLoadingPlaque();
+ SCR_BeginLoadingPlaque(false);
S_StopAllSounds();
}
if (!worldmodel || !worldmodel->TraceBox)
{
Con_Printf("Couldn't load map %s\n", modelname);
+
+ if(cls.state == ca_dedicated)
+ Sys_MakeProcessMean();
+
// SV_UnlockThreadMutex();
+
return;
}
cls.signon = 0;
Cvar_SetValue("halflifebsp", worldmodel->brush.ishlbsp);
+ Cvar_SetValue("sv_mapformat_is_quake2", worldmodel->brush.isq2bsp);
+ Cvar_SetValue("sv_mapformat_is_quake3", worldmodel->brush.isq3bsp);
if(*sv_random_seed.string)
{
//
// AK possible hack since num_edicts is still 0
ent = PRVM_EDICT_NUM(0);
- memset (ent->fields.vp, 0, prog->entityfields * 4);
+ memset (ent->fields.fp, 0, prog->entityfields * sizeof(prvm_vec_t));
ent->priv.server->free = false;
PRVM_serveredictstring(ent, model) = PRVM_SetEngineString(prog, sv.worldname);
PRVM_serveredictfloat(ent, modelindex) = 1; // world model
// and we need to set the ->edict pointers to point into the progs edicts
for (i = 0, host_client = svs.clients;i < svs.maxclients;i++, host_client++)
{
- host_client->spawned = false;
+ host_client->begun = false;
host_client->edict = PRVM_EDICT_NUM(i + 1);
PRVM_ED_ClearEdict(prog, host_client->edict);
}
// run two frames to allow everything to settle
sv.time = 1.0001;
- for (i = 0;i < 2;i++)
+ for (i = 0;i < sv_init_frame_count.integer;i++)
{
sv.frametime = 0.1;
SV_Physics ();
}
+ // Once all init frames have been run, we consider svqc code fully initialized.
+ prog->inittime = realtime;
+
if (cls.state == ca_dedicated)
Mod_PurgeUnused();
PRVM_serverglobaledict(self) = PRVM_EDICT_TO_PROG(host_client->edict);
prog->ExecuteProgram(prog, PRVM_serverfunction(ClientConnect), "QC function ClientConnect is missing");
prog->ExecuteProgram(prog, PRVM_serverfunction(PutClientInServer), "QC function PutClientInServer is missing");
- host_client->spawned = true;
+ host_client->begun = true;
}
}
Con_DPrint("Server spawned.\n");
NetConn_Heartbeat (2);
+ if(cls.state == ca_dedicated)
+ Sys_MakeProcessMean();
+
// SV_UnlockThreadMutex();
}
PRVM_serveredictstring(e, crypto_idfp) = PRVM_SetEngineString(prog, svs.clients[num].netconnection->crypto.client_idfp);
else
PRVM_serveredictstring(e, crypto_idfp) = 0;
+ PRVM_serveredictfloat(e, crypto_idfp_signed) = (svs.clients[num].netconnection != NULL && svs.clients[num].netconnection->crypto.authenticated && svs.clients[num].netconnection->crypto.client_issigned);
if(svs.clients[num].netconnection != NULL && svs.clients[num].netconnection->crypto.authenticated && svs.clients[num].netconnection->crypto.client_keyfp[0])
PRVM_serveredictstring(e, crypto_keyfp) = PRVM_SetEngineString(prog, svs.clients[num].netconnection->crypto.client_keyfp);
else
e = PRVM_NUM_FOR_EDICT(ed);
sv.csqcentityversion[e] = 0;
for (i = 0;i < svs.maxclients;i++)
- {
- if (svs.clients[i].csqcentityscope[e])
- svs.clients[i].csqcentityscope[e] = 1; // removed, awaiting send
svs.clients[i].csqcentitysendflags[e] = 0xFFFFFF;
- }
}
static void SVVM_count_edicts(prvm_prog_t *prog)
prog->error_cmd = Host_Error;
prog->ExecuteProgram = SVVM_ExecuteProgram;
- PRVM_Prog_Load(prog, sv_progs.string, SV_REQFUNCS, sv_reqfuncs, SV_REQFIELDS, sv_reqfields, SV_REQGLOBALS, sv_reqglobals);
+ PRVM_Prog_Load(prog, sv_progs.string, NULL, 0, SV_REQFUNCS, sv_reqfuncs, SV_REQFIELDS, sv_reqfields, SV_REQGLOBALS, sv_reqglobals);
// some mods compiled with scrambling compilers lack certain critical
// global names and field names such as "self" and "time" and "nextthink"
playing = false;
if (sv.active)
for (i = 0, host_client = svs.clients;i < svs.maxclients;i++, host_client++)
- if(host_client->spawned)
+ if(host_client->begun)
if(host_client->netconnection)
playing = true;
- if(!playing)
+ if(sv.time < 10)
{
- // Nobody is looking? Then we won't do timing...
- // Instead, reset it to zero
+ // don't accumulate time for the first 10 seconds of a match
+ // so things can settle
svs.perf_acc_realtime = svs.perf_acc_sleeptime = svs.perf_acc_lost = svs.perf_acc_offset = svs.perf_acc_offset_squared = svs.perf_acc_offset_max = svs.perf_acc_offset_samples = 0;
}
else if(svs.perf_acc_realtime > 5)
svs.perf_offset_sdev = sqrt(svs.perf_acc_offset_squared / svs.perf_acc_offset_samples - svs.perf_offset_avg * svs.perf_offset_avg);
}
if(svs.perf_lost > 0 && developer_extra.integer)
- Con_DPrintf("Server can't keep up: %s\n", Host_TimingReport(vabuf, sizeof(vabuf)));
+ if(playing)
+ Con_DPrintf("Server can't keep up: %s\n", Host_TimingReport(vabuf, sizeof(vabuf)));
svs.perf_acc_realtime = svs.perf_acc_sleeptime = svs.perf_acc_lost = svs.perf_acc_offset = svs.perf_acc_offset_squared = svs.perf_acc_offset_max = svs.perf_acc_offset_samples = 0;
}
if (sv.paused == 1 && sv_realtime > sv.pausedstart && sv.pausedstart > 0)
{
PRVM_serverglobalfloat(time) = sv.time;
- prog->globals.generic[OFS_PARM0] = sv_realtime - sv.pausedstart;
+ prog->globals.fp[OFS_PARM0] = sv_realtime - sv.pausedstart;
prog->ExecuteProgram(prog, PRVM_serverfunction(SV_PausedTic), "QC function SV_PausedTic is missing");
}
Thread_DestroyMutex(svs.threadmutex);
svs.threaded = false;
}
-
-void SV_LockThreadMutex(void)
-{
- if (svs.threaded)
- Thread_LockMutex(svs.threadmutex);
-}
-
-void SV_UnlockThreadMutex(void)
-{
- if (svs.threaded)
- Thread_UnlockMutex(svs.threadmutex);
-}