This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
#include "quakedef.h"
+cvar_t sv_vischeckentities = {0, "sv_vischeckentities", "1"};
+cvar_t sv_reportvischeckentities = {0, "sv_reportvischeckentities", "0"};
+int sv_vischeckentitycullcount = 0;
+
server_t sv;
server_static_t svs;
char localmodels[MAX_MODELS][5]; // inline model names for precache
-extern cvar_t sv_deltacompress;
-
//============================================================================
/*
*/
void SV_Init (void)
{
- int i;
- extern cvar_t sv_maxvelocity;
- extern cvar_t sv_gravity;
- extern cvar_t sv_nostep;
- extern cvar_t sv_friction;
- extern cvar_t sv_edgefriction;
- extern cvar_t sv_stopspeed;
- extern cvar_t sv_maxspeed;
- extern cvar_t sv_accelerate;
- extern cvar_t sv_idealpitchscale;
- extern cvar_t sv_aim;
- extern cvar_t sv_predict;
+ int i;
Cvar_RegisterVariable (&sv_maxvelocity);
Cvar_RegisterVariable (&sv_gravity);
Cvar_RegisterVariable (&sv_nostep);
Cvar_RegisterVariable (&sv_predict);
Cvar_RegisterVariable (&sv_deltacompress);
+ Cvar_RegisterVariable (&sv_vischeckentities);
+ Cvar_RegisterVariable (&sv_reportvischeckentities);
- for (i=0 ; i<MAX_MODELS ; i++)
+ for (i = 0;i < MAX_MODELS;i++)
sprintf (localmodels[i], "*%i", i);
}
=============================================================================
*/
-/*
+/*
==================
SV_StartParticle
int i, v;
if (sv.datagram.cursize > MAX_DATAGRAM-16)
- return;
+ return;
MSG_WriteByte (&sv.datagram, svc_particle);
MSG_WriteFloatCoord (&sv.datagram, org[0]);
MSG_WriteFloatCoord (&sv.datagram, org[1]);
}
MSG_WriteByte (&sv.datagram, count);
MSG_WriteByte (&sv.datagram, color);
-}
+}
-/*
+/*
==================
SV_StartEffect
void SV_StartEffect (vec3_t org, int modelindex, int startframe, int framecount, int framerate)
{
if (sv.datagram.cursize > MAX_DATAGRAM-18)
- return;
+ return;
if (modelindex >= 256 || startframe >= 256)
{
MSG_WriteByte (&sv.datagram, svc_effect2);
MSG_WriteByte (&sv.datagram, framecount);
MSG_WriteByte (&sv.datagram, framerate);
}
-}
+}
-/*
+/*
==================
SV_StartSound
Larger attenuations will drop off. (max 4 attenuation)
==================
-*/
+*/
void SV_StartSound (edict_t *entity, int channel, char *sample, int volume,
float attenuation)
-{
+{
int sound_num;
int field_mask;
int i;
int ent;
-
+
if (volume < 0 || volume > 255)
Host_Error ("SV_StartSound: volume = %i", volume);
Host_Error ("SV_StartSound: channel = %i", channel);
if (sv.datagram.cursize > MAX_DATAGRAM-16)
- return;
+ return;
// find precache number for sound
for (sound_num=1 ; sound_num<MAX_SOUNDS
// set up the client_t
netconnection = client->netconnection;
-
+
if (sv.loadgame)
memcpy (spawn_parms, client->spawn_parms, sizeof(spawn_parms));
memset (client, 0, sizeof(*client));
//
// init a new client structure
- //
+ //
for (i=0 ; i<svs.maxclients ; i++)
if (!svs.clients[i].active)
break;
{
int e, i, clentnum, bits, alpha, glowcolor, glowsize, scale, colormod, effects;
byte *pvs;
- vec3_t org, origin, angles;
+ vec3_t org, origin, angles, entmins, entmaxs;
float movelerp, moveilerp, nextfullupdate;
edict_t *ent;
eval_t *val;
for (i = 0;i < ent->num_leafs;i++)
if (pvs[ent->leafnums[i] >> 3] & (1 << (ent->leafnums[i]&7) ))
break;
-
+
if (i == ent->num_leafs)
{
// not visible
continue;
}
+
+ VectorAdd(ent->v.mins, ent->v.origin, entmins);
+ VectorAdd(ent->v.maxs, ent->v.origin, entmaxs);
+ entmins[0] -= 1.0f;entmins[1] -= 1.0f;entmins[2] -= 1.0f;
+ entmaxs[0] += 1.0f;entmaxs[1] += 1.0f;entmaxs[2] += 1.0f;
+ if (!Portal_CheckBox(sv.worldmodel, org, entmins, entmaxs))
+ {
+ sv_vischeckentitycullcount++;
+ continue;
+ }
}
}
if (ent->v.movetype == MOVETYPE_STEP)
bits |= U_STEP;
-
+
if (ent->v.movetype == MOVETYPE_STEP && ((int) ent->v.flags & (FL_ONGROUND | FL_FLY | FL_SWIM))) // monsters have smoothed walking/flying/swimming movement
{
if (!ent->steplerptime || ent->steplerptime > sv.time) // when the level just started...
if (bits & U_FRAME2) MSG_WriteByte(msg, (int)ent->v.frame >> 8);
if (bits & U_MODEL2) MSG_WriteByte(msg, (int)ent->v.modelindex >> 8);
}
+
+ if (sv_reportvischeckentities.value)
+ Con_Printf("sv_vischeck culled entities: %d\n", sv_vischeckentitycullcount);
+ sv_vischeckentitycullcount = 0;
}
/*
{
int e;
edict_t *ent;
-
+
ent = NEXT_EDICT(sv.edicts);
for (e=1 ; e<sv.num_edicts ; e++, ent = NEXT_EDICT(ent))
{
MSG_WriteByte (msg, ent->v.dmg_take);
for (i=0 ; i<3 ; i++)
MSG_WriteFloatCoord (msg, other->v.origin[i] + 0.5*(other->v.mins[i] + other->v.maxs[i]));
-
+
ent->v.dmg_take = 0;
ent->v.dmg_save = 0;
}
}
bits = 0;
-
+
if (ent->v.view_ofs[2] != DEFAULT_VIEWHEIGHT)
bits |= SU_VIEWHEIGHT;
-
+
if (ent->v.idealpitch)
bits |= SU_IDEALPITCH;
if (ent->v.velocity[i])
bits |= (SU_VELOCITY1<<i);
}
-
+
if (ent->v.weaponframe)
bits |= SU_WEAPONFRAME;
SV_DropClient (true);// if the message couldn't send, kick off
return false;
}
-
+
return true;
}
sv.signon.maxsize = sizeof(sv.signon_buf);
sv.signon.cursize = 0;
sv.signon.data = sv.signon_buf;
-
+
// leave slots at start for clients only
sv.num_edicts = svs.maxclients+1;
for (i=0 ; i<svs.maxclients ; i++)
return;
}
sv.models[1] = sv.worldmodel;
-
+
//
// clear world interaction links
//
ent->v.modelindex = 1; // world model
ent->v.solid = SOLID_BSP;
ent->v.movetype = MOVETYPE_PUSH;
- ent->v.angles[0] = ent->v.angles[1] = ent->v.angles[2] = 0;
if (coop.value)
pr_global_struct->coop = coop.value;
ED_LoadFromFile (sv.worldmodel->entities);
// LordHavoc: clear world angles (to fix e3m3.bsp)
- sv.edicts->v.angles[0] = sv.edicts->v.angles[1] = sv.edicts->v.angles[2] = 0;
+ VectorClear(sv.edicts->v.angles);
sv.active = true;
// all setup is completed, any further precache statements are errors
sv.state = ss_active;
-
+
// run two frames to allow everything to settle
sv.frametime = pr_global_struct->frametime = host_frametime = 0.1;
SV_Physics ();
for (i=0,host_client = svs.clients ; i<svs.maxclients ; i++, host_client++)
if (host_client->active)
SV_SendServerinfo (host_client);
-
+
Con_DPrintf ("Server spawned.\n");
}