2001-02-19 21:15:25 +00:00
|
|
|
/*
|
|
|
|
sv_main.c
|
|
|
|
|
|
|
|
@description@
|
|
|
|
|
|
|
|
Copyright (C) 1996-1997 Id Software, Inc.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
2001-09-28 06:26:31 +00:00
|
|
|
static const char rcsid[] =
|
|
|
|
"$Id$";
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
#include "QF/console.h"
|
|
|
|
#include "QF/cmd.h"
|
2001-05-31 03:41:35 +00:00
|
|
|
#include "QF/cvar.h"
|
2001-03-27 20:33:07 +00:00
|
|
|
#include "QF/msg.h"
|
|
|
|
#include "QF/sys.h"
|
2001-08-27 07:13:32 +00:00
|
|
|
|
|
|
|
#include "compat.h"
|
2001-02-19 21:15:25 +00:00
|
|
|
#include "host.h"
|
2001-05-31 03:41:35 +00:00
|
|
|
#include "server.h"
|
2001-03-03 08:31:58 +00:00
|
|
|
#include "sv_progs.h"
|
2001-05-31 03:41:35 +00:00
|
|
|
#include "world.h"
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
server_t sv;
|
|
|
|
server_static_t svs;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
char localmodels[MAX_MODELS][5]; // inline model names for precache
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-03-04 05:27:29 +00:00
|
|
|
entity_state_t baselines[MAX_EDICTS];
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
SV_Init (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
int i;
|
|
|
|
|
2001-04-10 23:39:30 +00:00
|
|
|
sv_maxvelocity = Cvar_Get ("sv_maxvelocity", "2000", CVAR_NONE, NULL,
|
2001-08-27 07:13:32 +00:00
|
|
|
"None");
|
2001-04-10 23:39:30 +00:00
|
|
|
sv_gravity = Cvar_Get ("sv_gravity", "800", CVAR_SERVERINFO, Cvar_Info,
|
2001-08-27 07:13:32 +00:00
|
|
|
"None");
|
2001-04-10 23:39:30 +00:00
|
|
|
sv_friction = Cvar_Get ("sv_friction", "4", CVAR_SERVERINFO, Cvar_Info,
|
2001-08-27 07:13:32 +00:00
|
|
|
"None");
|
2001-04-10 23:39:30 +00:00
|
|
|
sv_edgefriction = Cvar_Get ("edgefriction", "2", CVAR_NONE, NULL, "None");
|
|
|
|
sv_stopspeed = Cvar_Get ("sv_stopspeed", "100", CVAR_NONE, NULL, "None");
|
|
|
|
sv_maxspeed = Cvar_Get ("sv_maxspeed", "320", CVAR_SERVERINFO, Cvar_Info,
|
2001-08-27 07:13:32 +00:00
|
|
|
"None");
|
2001-04-10 23:39:30 +00:00
|
|
|
sv_accelerate = Cvar_Get ("sv_accelerate", "10", CVAR_NONE, NULL, "None");
|
2001-08-27 07:13:32 +00:00
|
|
|
sv_idealpitchscale = Cvar_Get ("sv_idealpitchscale", "0.8", CVAR_NONE,
|
|
|
|
NULL, "None");
|
2001-04-10 23:39:30 +00:00
|
|
|
sv_aim = Cvar_Get ("sv_aim", "0.93", CVAR_NONE, NULL, "None");
|
|
|
|
sv_nostep = Cvar_Get ("sv_nostep", "0", CVAR_NONE, NULL, "None");
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
for (i = 0; i < MAX_MODELS; i++)
|
|
|
|
snprintf (localmodels[i], sizeof (localmodels[i]), "*%i", i);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
// EVENT MESSAGES =============================================================
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
/*
|
2001-08-27 07:13:32 +00:00
|
|
|
SV_StartParticle
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
Make sure the event gets sent to all clients
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2002-01-03 05:29:38 +00:00
|
|
|
SV_StartParticle (const vec3_t org, const vec3_t dir, int color, int count)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
int i, v;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
if (sv.datagram.cursize > MAX_DATAGRAM - 16)
|
|
|
|
return;
|
2001-02-19 21:15:25 +00:00
|
|
|
MSG_WriteByte (&sv.datagram, svc_particle);
|
2001-12-12 21:56:09 +00:00
|
|
|
MSG_WriteCoordV (&sv.datagram, org);
|
2001-02-26 06:48:02 +00:00
|
|
|
for (i = 0; i < 3; i++) {
|
|
|
|
v = dir[i] * 16;
|
2001-02-19 21:15:25 +00:00
|
|
|
if (v > 127)
|
|
|
|
v = 127;
|
|
|
|
else if (v < -128)
|
|
|
|
v = -128;
|
|
|
|
MSG_WriteChar (&sv.datagram, v);
|
|
|
|
}
|
|
|
|
MSG_WriteByte (&sv.datagram, count);
|
|
|
|
MSG_WriteByte (&sv.datagram, color);
|
2001-02-26 06:48:02 +00:00
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
/*
|
2001-08-27 07:13:32 +00:00
|
|
|
SV_StartSound
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
Each entity can have eight independant sound sources, like voice,
|
|
|
|
weapon, feet, etc.
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
Channel 0 is an auto-allocate channel, the others override anything
|
|
|
|
already running on that entity/channel pair.
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
An attenuation of 0 will play full volume everywhere in the level.
|
|
|
|
Larger attenuations will drop off. (max 4 attenuation)
|
2001-02-26 06:48:02 +00:00
|
|
|
*/
|
|
|
|
void
|
2001-07-15 07:04:17 +00:00
|
|
|
SV_StartSound (edict_t *entity, int channel, const char *sample, int volume,
|
2001-02-26 06:48:02 +00:00
|
|
|
float attenuation)
|
|
|
|
{
|
2001-08-27 07:13:32 +00:00
|
|
|
int ent, field_mask, sound_num, i;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
if (volume < 0 || volume > 255)
|
|
|
|
Sys_Error ("SV_StartSound: volume = %i", volume);
|
|
|
|
|
|
|
|
if (attenuation < 0 || attenuation > 4)
|
|
|
|
Sys_Error ("SV_StartSound: attenuation = %f", attenuation);
|
|
|
|
|
|
|
|
if (channel < 0 || channel > 7)
|
|
|
|
Sys_Error ("SV_StartSound: channel = %i", channel);
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
if (sv.datagram.cursize > MAX_DATAGRAM - 16)
|
|
|
|
return;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
// find precache number for sound
|
2001-02-26 06:48:02 +00:00
|
|
|
for (sound_num = 1; sound_num < MAX_SOUNDS
|
|
|
|
&& sv.sound_precache[sound_num]; sound_num++)
|
|
|
|
if (!strcmp (sample, sv.sound_precache[sound_num]))
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (sound_num == MAX_SOUNDS || !sv.sound_precache[sound_num]) {
|
|
|
|
Con_Printf ("SV_StartSound: %s not precacheed\n", sample);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-02-26 20:52:14 +00:00
|
|
|
ent = NUM_FOR_EDICT (&sv_pr_state, entity);
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
channel = (ent << 3) | channel;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
field_mask = 0;
|
|
|
|
if (volume != DEFAULT_SOUND_PACKET_VOLUME)
|
|
|
|
field_mask |= SND_VOLUME;
|
|
|
|
if (attenuation != DEFAULT_SOUND_PACKET_ATTENUATION)
|
|
|
|
field_mask |= SND_ATTENUATION;
|
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
// directed messages go only to the entity the are targeted on
|
2001-02-19 21:15:25 +00:00
|
|
|
MSG_WriteByte (&sv.datagram, svc_sound);
|
|
|
|
MSG_WriteByte (&sv.datagram, field_mask);
|
|
|
|
if (field_mask & SND_VOLUME)
|
|
|
|
MSG_WriteByte (&sv.datagram, volume);
|
|
|
|
if (field_mask & SND_ATTENUATION)
|
2001-02-26 06:48:02 +00:00
|
|
|
MSG_WriteByte (&sv.datagram, attenuation * 64);
|
2001-02-19 21:15:25 +00:00
|
|
|
MSG_WriteShort (&sv.datagram, channel);
|
|
|
|
MSG_WriteByte (&sv.datagram, sound_num);
|
2001-12-12 21:56:09 +00:00
|
|
|
for (i=0; i < 3; i++)
|
2001-08-27 07:13:32 +00:00
|
|
|
MSG_WriteCoord (&sv.datagram, SVvector (entity, origin)[i] + 0.5 *
|
|
|
|
(SVvector (entity, mins)[i] +
|
|
|
|
SVvector (entity, maxs)[i]));
|
2001-02-26 06:48:02 +00:00
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
// CLIENT SPAWNING ============================================================
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
/*
|
2001-08-27 07:13:32 +00:00
|
|
|
SV_SendServerinfo
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
Sends the first message from the server to a connected client.
|
|
|
|
This will be sent on the initial connection and upon each server load.
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
SV_SendServerinfo (client_t *client)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-07-15 07:04:17 +00:00
|
|
|
const char **s;
|
2001-02-26 06:48:02 +00:00
|
|
|
char message[2048];
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
MSG_WriteByte (&client->message, svc_print);
|
2001-02-26 06:48:02 +00:00
|
|
|
snprintf (message, sizeof (message), "%c\nVersion %s server (%i CRC)", 2,
|
2001-02-26 20:52:14 +00:00
|
|
|
NQ_VERSION, sv_pr_state.crc);
|
2001-02-26 06:48:02 +00:00
|
|
|
MSG_WriteString (&client->message, message);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
MSG_WriteByte (&client->message, svc_serverinfo);
|
|
|
|
MSG_WriteLong (&client->message, PROTOCOL_VERSION);
|
|
|
|
MSG_WriteByte (&client->message, svs.maxclients);
|
|
|
|
|
|
|
|
if (!coop->int_val && deathmatch->int_val)
|
|
|
|
MSG_WriteByte (&client->message, GAME_DEATHMATCH);
|
|
|
|
else
|
|
|
|
MSG_WriteByte (&client->message, GAME_COOP);
|
|
|
|
|
2001-02-26 20:52:14 +00:00
|
|
|
snprintf (message, sizeof (message),
|
2001-08-08 20:28:53 +00:00
|
|
|
PR_GetString (&sv_pr_state, SVstring (sv.edicts, message)));
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
MSG_WriteString (&client->message, message);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
for (s = sv.model_precache + 1; *s; s++)
|
2001-02-19 21:15:25 +00:00
|
|
|
MSG_WriteString (&client->message, *s);
|
|
|
|
MSG_WriteByte (&client->message, 0);
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
for (s = sv.sound_precache + 1; *s; s++)
|
2001-02-19 21:15:25 +00:00
|
|
|
MSG_WriteString (&client->message, *s);
|
|
|
|
MSG_WriteByte (&client->message, 0);
|
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
// send music
|
2001-02-19 21:15:25 +00:00
|
|
|
MSG_WriteByte (&client->message, svc_cdtrack);
|
2001-08-08 20:28:53 +00:00
|
|
|
MSG_WriteByte (&client->message, SVfloat (sv.edicts, sounds));
|
|
|
|
MSG_WriteByte (&client->message, SVfloat (sv.edicts, sounds));
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
// set view
|
2001-02-19 21:15:25 +00:00
|
|
|
MSG_WriteByte (&client->message, svc_setview);
|
2001-02-26 20:52:14 +00:00
|
|
|
MSG_WriteShort (&client->message,
|
|
|
|
NUM_FOR_EDICT (&sv_pr_state, client->edict));
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
MSG_WriteByte (&client->message, svc_signonnum);
|
|
|
|
MSG_WriteByte (&client->message, 1);
|
|
|
|
|
|
|
|
client->sendsignon = true;
|
2001-02-26 06:48:02 +00:00
|
|
|
client->spawned = false; // need prespawn, spawn, etc
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2001-08-27 07:13:32 +00:00
|
|
|
SV_ConnectClient
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
Initializes a client_t for a new net connection. This will only be called
|
|
|
|
once for a player each game, not once for each level change.
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
SV_ConnectClient (int clientnum)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
edict_t *ent;
|
|
|
|
client_t *client;
|
|
|
|
int edictnum;
|
2001-02-19 21:15:25 +00:00
|
|
|
struct qsocket_s *netconnection;
|
2001-02-26 06:48:02 +00:00
|
|
|
int i;
|
|
|
|
float spawn_parms[NUM_SPAWN_PARMS];
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
client = svs.clients + clientnum;
|
|
|
|
|
|
|
|
Con_DPrintf ("Client %s connected\n", client->netconnection->address);
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
edictnum = clientnum + 1;
|
|
|
|
|
2001-02-26 20:52:14 +00:00
|
|
|
ent = EDICT_NUM (&sv_pr_state, edictnum);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
// set up the client_t
|
2001-02-19 21:15:25 +00:00
|
|
|
netconnection = client->netconnection;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
if (sv.loadgame)
|
2001-02-26 06:48:02 +00:00
|
|
|
memcpy (spawn_parms, client->spawn_parms, sizeof (spawn_parms));
|
|
|
|
memset (client, 0, sizeof (*client));
|
2001-02-19 21:15:25 +00:00
|
|
|
client->netconnection = netconnection;
|
|
|
|
|
|
|
|
strcpy (client->name, "unconnected");
|
|
|
|
client->active = true;
|
|
|
|
client->spawned = false;
|
|
|
|
client->edict = ent;
|
|
|
|
client->message.data = client->msgbuf;
|
2001-02-26 06:48:02 +00:00
|
|
|
client->message.maxsize = sizeof (client->msgbuf);
|
|
|
|
client->message.allowoverflow = true; // we can catch it
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
client->privileged = false;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (sv.loadgame)
|
2001-02-26 06:48:02 +00:00
|
|
|
memcpy (client->spawn_parms, spawn_parms, sizeof (spawn_parms));
|
|
|
|
else {
|
|
|
|
// call the progs to get default spawn parms for the new client
|
2002-05-31 21:05:58 +00:00
|
|
|
PR_ExecuteProgram (&sv_pr_state, sv_funcs.SetNewParms);
|
2001-02-26 06:48:02 +00:00
|
|
|
for (i = 0; i < NUM_SPAWN_PARMS; i++)
|
2001-03-03 08:31:58 +00:00
|
|
|
client->spawn_parms[i] = sv_globals.parms[i];
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SV_SendServerinfo (client);
|
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
SV_CheckForNewClients (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
int i;
|
2001-08-27 07:13:32 +00:00
|
|
|
struct qsocket_s *ret;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
// check for new connections
|
2001-02-26 06:48:02 +00:00
|
|
|
while (1) {
|
2001-02-19 21:15:25 +00:00
|
|
|
ret = NET_CheckNewConnections ();
|
|
|
|
if (!ret)
|
|
|
|
break;
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
// init a new client structure
|
|
|
|
for (i = 0; i < svs.maxclients; i++)
|
2001-02-19 21:15:25 +00:00
|
|
|
if (!svs.clients[i].active)
|
|
|
|
break;
|
|
|
|
if (i == svs.maxclients)
|
|
|
|
Sys_Error ("Host_CheckForNewClients: no free clients");
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
svs.clients[i].netconnection = ret;
|
2001-02-26 06:48:02 +00:00
|
|
|
SV_ConnectClient (i);
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
net_activeconnections++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
// FRAME UPDATES ==============================================================
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
SV_ClearDatagram (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
|
|
|
SZ_Clear (&sv.datagram);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2001-08-27 07:13:32 +00:00
|
|
|
The PVS must include a small area around the client to allow head bobbing
|
|
|
|
or other small motion on the client side. Otherwise, a bob might cause an
|
|
|
|
entity that should be visible to not show up, especially when the bob
|
|
|
|
crosses a waterline.
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
int fatbytes;
|
|
|
|
byte fatpvs[MAX_MAP_LEAFS / 8];
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
SV_AddToFatPVS (vec3_t org, mnode_t *node)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
int i;
|
2001-08-27 07:13:32 +00:00
|
|
|
float d;
|
2001-02-26 06:48:02 +00:00
|
|
|
byte *pvs;
|
|
|
|
mplane_t *plane;
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
// if this is a leaf, accumulate the pvs bits
|
|
|
|
if (node->contents < 0) {
|
|
|
|
if (node->contents != CONTENTS_SOLID) {
|
|
|
|
pvs = Mod_LeafPVS ((mleaf_t *) node, sv.worldmodel);
|
|
|
|
for (i = 0; i < fatbytes; i++)
|
2001-02-19 21:15:25 +00:00
|
|
|
fatpvs[i] |= pvs[i];
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
plane = node->plane;
|
|
|
|
d = DotProduct (org, plane->normal) - plane->dist;
|
|
|
|
if (d > 8)
|
|
|
|
node = node->children[0];
|
|
|
|
else if (d < -8)
|
|
|
|
node = node->children[1];
|
2001-02-26 06:48:02 +00:00
|
|
|
else { // go down both
|
2001-02-19 21:15:25 +00:00
|
|
|
SV_AddToFatPVS (org, node->children[0]);
|
|
|
|
node = node->children[1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2001-08-27 07:13:32 +00:00
|
|
|
SV_FatPVS
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
Calculates a PVS that is the inclusive or of all leafs within 8 pixels of the
|
|
|
|
given point.
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
byte *
|
|
|
|
SV_FatPVS (vec3_t org)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
fatbytes = (sv.worldmodel->numleafs + 31) >> 3;
|
2001-02-19 21:15:25 +00:00
|
|
|
memset (fatpvs, 0, fatbytes);
|
|
|
|
SV_AddToFatPVS (org, sv.worldmodel->nodes);
|
|
|
|
return fatpvs;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
SV_WriteEntitiesToClient (edict_t *clent, sizebuf_t *msg)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-08-27 07:13:32 +00:00
|
|
|
int bits, e, i;
|
2001-02-26 06:48:02 +00:00
|
|
|
byte *pvs;
|
|
|
|
float miss;
|
2001-08-27 07:13:32 +00:00
|
|
|
vec3_t org;
|
2001-02-26 06:48:02 +00:00
|
|
|
edict_t *ent;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
// find the client's PVS
|
2001-08-08 20:28:53 +00:00
|
|
|
VectorAdd (SVvector (clent, origin), SVvector (clent, view_ofs), org);
|
2001-02-19 21:15:25 +00:00
|
|
|
pvs = SV_FatPVS (org);
|
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
// send over all entities (excpet the client) that touch the pvs
|
2001-02-26 20:52:14 +00:00
|
|
|
ent = NEXT_EDICT (&sv_pr_state, sv.edicts);
|
|
|
|
for (e = 1; e < sv.num_edicts; e++, ent = NEXT_EDICT (&sv_pr_state, ent)) {
|
2001-08-27 07:13:32 +00:00
|
|
|
// ignore if not touching a PV leaf
|
2001-02-26 06:48:02 +00:00
|
|
|
if (ent != clent) // clent is ALLWAYS sent
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-08-27 07:13:32 +00:00
|
|
|
// ignore ents without visible models
|
|
|
|
if (!SVfloat (ent, modelindex) ||
|
|
|
|
!*PR_GetString (&sv_pr_state, SVstring (ent, model)))
|
2001-02-19 21:15:25 +00:00
|
|
|
continue;
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
for (i = 0; i < ent->num_leafs; i++)
|
|
|
|
if (pvs[ent->leafnums[i] >> 3] & (1 << (ent->leafnums[i] & 7)))
|
2001-02-19 21:15:25 +00:00
|
|
|
break;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
if (i == ent->num_leafs)
|
2001-02-26 06:48:02 +00:00
|
|
|
continue; // not visible
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
if (msg->maxsize - msg->cursize < 16) {
|
2001-02-19 21:15:25 +00:00
|
|
|
Con_Printf ("packet overflow\n");
|
|
|
|
return;
|
|
|
|
}
|
2001-08-27 07:13:32 +00:00
|
|
|
// send an update
|
2001-02-19 21:15:25 +00:00
|
|
|
bits = 0;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
for (i = 0; i < 3; i++) {
|
2001-08-27 07:13:32 +00:00
|
|
|
miss = SVvector (ent, origin)[i] -
|
|
|
|
((entity_state_t*)ent->data)->origin[i];
|
2001-02-26 06:48:02 +00:00
|
|
|
if (miss < -0.1 || miss > 0.1)
|
|
|
|
bits |= U_ORIGIN1 << i;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
if (SVvector (ent, angles)[0] !=
|
|
|
|
((entity_state_t*)ent->data)->angles[0])
|
2001-02-19 21:15:25 +00:00
|
|
|
bits |= U_ANGLE1;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
if (SVvector (ent, angles)[1] !=
|
|
|
|
((entity_state_t*)ent->data)->angles[1])
|
2001-02-19 21:15:25 +00:00
|
|
|
bits |= U_ANGLE2;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
if (SVvector (ent, angles)[2] !=
|
|
|
|
((entity_state_t*)ent->data)->angles[2])
|
2001-02-19 21:15:25 +00:00
|
|
|
bits |= U_ANGLE3;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-08-08 20:28:53 +00:00
|
|
|
if (SVfloat (ent, movetype) == MOVETYPE_STEP)
|
2001-02-26 06:48:02 +00:00
|
|
|
bits |= U_NOLERP; // don't mess up the step animation
|
|
|
|
|
2001-08-08 20:28:53 +00:00
|
|
|
if (((entity_state_t*)ent->data)->colormap != SVfloat (ent, colormap))
|
2001-02-19 21:15:25 +00:00
|
|
|
bits |= U_COLORMAP;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-08-08 20:28:53 +00:00
|
|
|
if (((entity_state_t*)ent->data)->skin != SVfloat (ent, skin))
|
2001-02-19 21:15:25 +00:00
|
|
|
bits |= U_SKIN;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-08-08 20:28:53 +00:00
|
|
|
if (((entity_state_t*)ent->data)->frame != SVfloat (ent, frame))
|
2001-02-19 21:15:25 +00:00
|
|
|
bits |= U_FRAME;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-08-08 20:28:53 +00:00
|
|
|
if (((entity_state_t*)ent->data)->effects != SVfloat (ent, effects))
|
2001-02-19 21:15:25 +00:00
|
|
|
bits |= U_EFFECTS;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
if (((entity_state_t*)ent->data)->modelindex != SVfloat (ent,
|
|
|
|
modelindex))
|
2001-02-19 21:15:25 +00:00
|
|
|
bits |= U_MODEL;
|
|
|
|
|
|
|
|
if (e >= 256)
|
|
|
|
bits |= U_LONGENTITY;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
if (bits >= 256)
|
|
|
|
bits |= U_MOREBITS;
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
// write the message
|
|
|
|
MSG_WriteByte (msg, bits | U_SIGNAL);
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
if (bits & U_MOREBITS)
|
2001-02-26 06:48:02 +00:00
|
|
|
MSG_WriteByte (msg, bits >> 8);
|
2001-02-19 21:15:25 +00:00
|
|
|
if (bits & U_LONGENTITY)
|
2001-02-26 06:48:02 +00:00
|
|
|
MSG_WriteShort (msg, e);
|
2001-02-19 21:15:25 +00:00
|
|
|
else
|
2001-02-26 06:48:02 +00:00
|
|
|
MSG_WriteByte (msg, e);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (bits & U_MODEL)
|
2001-08-08 20:28:53 +00:00
|
|
|
MSG_WriteByte (msg, SVfloat (ent, modelindex));
|
2001-02-19 21:15:25 +00:00
|
|
|
if (bits & U_FRAME)
|
2001-08-08 20:28:53 +00:00
|
|
|
MSG_WriteByte (msg, SVfloat (ent, frame));
|
2001-02-19 21:15:25 +00:00
|
|
|
if (bits & U_COLORMAP)
|
2001-08-08 20:28:53 +00:00
|
|
|
MSG_WriteByte (msg, SVfloat (ent, colormap));
|
2001-02-19 21:15:25 +00:00
|
|
|
if (bits & U_SKIN)
|
2001-08-08 20:28:53 +00:00
|
|
|
MSG_WriteByte (msg, SVfloat (ent, skin));
|
2001-02-19 21:15:25 +00:00
|
|
|
if (bits & U_EFFECTS)
|
2001-08-08 20:28:53 +00:00
|
|
|
MSG_WriteByte (msg, SVfloat (ent, effects));
|
2001-02-19 21:15:25 +00:00
|
|
|
if (bits & U_ORIGIN1)
|
2001-08-08 20:28:53 +00:00
|
|
|
MSG_WriteCoord (msg, SVvector (ent, origin)[0]);
|
2001-02-19 21:15:25 +00:00
|
|
|
if (bits & U_ANGLE1)
|
2001-08-08 20:28:53 +00:00
|
|
|
MSG_WriteAngle (msg, SVvector (ent, angles)[0]);
|
2001-02-19 21:15:25 +00:00
|
|
|
if (bits & U_ORIGIN2)
|
2001-08-08 20:28:53 +00:00
|
|
|
MSG_WriteCoord (msg, SVvector (ent, origin)[1]);
|
2001-02-19 21:15:25 +00:00
|
|
|
if (bits & U_ANGLE2)
|
2001-08-08 20:28:53 +00:00
|
|
|
MSG_WriteAngle (msg, SVvector (ent, angles)[1]);
|
2001-02-19 21:15:25 +00:00
|
|
|
if (bits & U_ORIGIN3)
|
2001-08-08 20:28:53 +00:00
|
|
|
MSG_WriteCoord (msg, SVvector (ent, origin)[2]);
|
2001-02-19 21:15:25 +00:00
|
|
|
if (bits & U_ANGLE3)
|
2001-08-08 20:28:53 +00:00
|
|
|
MSG_WriteAngle (msg, SVvector (ent, angles)[2]);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
SV_CleanupEnts (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
int e;
|
|
|
|
edict_t *ent;
|
|
|
|
|
2001-02-26 20:52:14 +00:00
|
|
|
ent = NEXT_EDICT (&sv_pr_state, sv.edicts);
|
|
|
|
for (e = 1; e < sv.num_edicts; e++, ent = NEXT_EDICT (&sv_pr_state, ent)) {
|
2001-08-27 07:13:32 +00:00
|
|
|
SVfloat (ent, effects) = (int) SVfloat (ent, effects) &
|
|
|
|
~EF_MUZZLEFLASH;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
SV_WriteClientdataToMessage (edict_t *ent, sizebuf_t *msg)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-08-27 07:13:32 +00:00
|
|
|
int bits, items, i;
|
2001-02-26 06:48:02 +00:00
|
|
|
edict_t *other;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
// send a damage message
|
2001-08-08 20:28:53 +00:00
|
|
|
if (SVfloat (ent, dmg_take) || SVfloat (ent, dmg_save)) {
|
|
|
|
other = PROG_TO_EDICT (&sv_pr_state, SVentity (ent, dmg_inflictor));
|
2001-02-19 21:15:25 +00:00
|
|
|
MSG_WriteByte (msg, svc_damage);
|
2001-08-08 20:28:53 +00:00
|
|
|
MSG_WriteByte (msg, SVfloat (ent, dmg_save));
|
|
|
|
MSG_WriteByte (msg, SVfloat (ent, dmg_take));
|
2001-12-12 21:56:09 +00:00
|
|
|
for (i=0; i < 3; i++)
|
2001-08-27 07:13:32 +00:00
|
|
|
MSG_WriteCoord (msg, SVvector (other, origin)[i] + 0.5 *
|
|
|
|
(SVvector (other, mins)[i] +
|
|
|
|
SVvector (other, maxs)[i]));
|
2001-08-08 20:28:53 +00:00
|
|
|
SVfloat (ent, dmg_take) = 0;
|
|
|
|
SVfloat (ent, dmg_save) = 0;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2001-08-27 07:13:32 +00:00
|
|
|
|
|
|
|
// send the current viewpos offset from the view entity
|
2001-02-26 06:48:02 +00:00
|
|
|
SV_SetIdealPitch (); // how much to look up / down ideally
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
// a fixangle might get lost in a dropped packet. Oh well.
|
2001-08-08 20:28:53 +00:00
|
|
|
if (SVfloat (ent, fixangle)) {
|
2001-02-19 21:15:25 +00:00
|
|
|
MSG_WriteByte (msg, svc_setangle);
|
2001-12-12 21:56:09 +00:00
|
|
|
MSG_WriteAngleV (msg, SVvector (ent, angles));
|
2001-08-08 20:28:53 +00:00
|
|
|
SVfloat (ent, fixangle) = 0;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bits = 0;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-08-08 20:28:53 +00:00
|
|
|
if (SVvector (ent, view_ofs)[2] != DEFAULT_VIEWHEIGHT)
|
2001-02-19 21:15:25 +00:00
|
|
|
bits |= SU_VIEWHEIGHT;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-08-08 20:28:53 +00:00
|
|
|
if (SVfloat (ent, idealpitch))
|
2001-02-19 21:15:25 +00:00
|
|
|
bits |= SU_IDEALPITCH;
|
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
// stuff the sigil bits into the high bits of items for sbar, or else
|
|
|
|
// mix in items2
|
2002-02-25 07:44:17 +00:00
|
|
|
if (sv_fields.items2 != -1)
|
|
|
|
items = (int) SVfloat (ent, items) | ((int) SVfloat (ent, items2)
|
|
|
|
<< 23);
|
2001-02-19 21:15:25 +00:00
|
|
|
else
|
2002-02-25 07:44:17 +00:00
|
|
|
items = (int) SVfloat (ent, items) | ((int) *sv_globals.serverflags
|
|
|
|
<< 28);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
bits |= SU_ITEMS;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-08-08 20:28:53 +00:00
|
|
|
if ((int) SVfloat (ent, flags) & FL_ONGROUND)
|
2001-02-19 21:15:25 +00:00
|
|
|
bits |= SU_ONGROUND;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-08-08 20:28:53 +00:00
|
|
|
if (SVfloat (ent, waterlevel) >= 2)
|
2001-02-19 21:15:25 +00:00
|
|
|
bits |= SU_INWATER;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
for (i = 0; i < 3; i++) {
|
2001-08-08 20:28:53 +00:00
|
|
|
if (SVvector (ent, punchangle)[i])
|
2001-02-26 06:48:02 +00:00
|
|
|
bits |= (SU_PUNCH1 << i);
|
2001-08-08 20:28:53 +00:00
|
|
|
if (SVvector (ent, velocity)[i])
|
2001-02-26 06:48:02 +00:00
|
|
|
bits |= (SU_VELOCITY1 << i);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-08-08 20:28:53 +00:00
|
|
|
if (SVfloat (ent, weaponframe))
|
2001-02-19 21:15:25 +00:00
|
|
|
bits |= SU_WEAPONFRAME;
|
|
|
|
|
2001-08-08 20:28:53 +00:00
|
|
|
if (SVfloat (ent, armorvalue))
|
2001-02-19 21:15:25 +00:00
|
|
|
bits |= SU_ARMOR;
|
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
// if (SVfloat (ent, weapon))
|
2001-02-26 06:48:02 +00:00
|
|
|
bits |= SU_WEAPON;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
// send the data
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
MSG_WriteByte (msg, svc_clientdata);
|
|
|
|
MSG_WriteShort (msg, bits);
|
|
|
|
|
|
|
|
if (bits & SU_VIEWHEIGHT)
|
2001-08-08 20:28:53 +00:00
|
|
|
MSG_WriteChar (msg, SVvector (ent, view_ofs)[2]);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (bits & SU_IDEALPITCH)
|
2001-08-08 20:28:53 +00:00
|
|
|
MSG_WriteChar (msg, SVfloat (ent, idealpitch));
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
for (i = 0; i < 3; i++) {
|
|
|
|
if (bits & (SU_PUNCH1 << i))
|
2001-08-08 20:28:53 +00:00
|
|
|
MSG_WriteChar (msg, SVvector (ent, punchangle)[i]);
|
2001-02-26 06:48:02 +00:00
|
|
|
if (bits & (SU_VELOCITY1 << i))
|
2001-08-08 20:28:53 +00:00
|
|
|
MSG_WriteChar (msg, SVvector (ent, velocity)[i] / 16);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
// [always sent] if (bits & SU_ITEMS)
|
2001-02-19 21:15:25 +00:00
|
|
|
MSG_WriteLong (msg, items);
|
|
|
|
|
|
|
|
if (bits & SU_WEAPONFRAME)
|
2001-08-08 20:28:53 +00:00
|
|
|
MSG_WriteByte (msg, SVfloat (ent, weaponframe));
|
2001-02-19 21:15:25 +00:00
|
|
|
if (bits & SU_ARMOR)
|
2001-08-08 20:28:53 +00:00
|
|
|
MSG_WriteByte (msg, SVfloat (ent, armorvalue));
|
2001-02-19 21:15:25 +00:00
|
|
|
if (bits & SU_WEAPON)
|
2001-02-26 20:52:14 +00:00
|
|
|
MSG_WriteByte (msg,
|
2001-08-27 07:13:32 +00:00
|
|
|
SV_ModelIndex (PR_GetString (&sv_pr_state, SVstring
|
|
|
|
(ent, weaponmodel))));
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-08-08 20:28:53 +00:00
|
|
|
MSG_WriteShort (msg, SVfloat (ent, health));
|
|
|
|
MSG_WriteByte (msg, SVfloat (ent, currentammo));
|
|
|
|
MSG_WriteByte (msg, SVfloat (ent, ammo_shells));
|
|
|
|
MSG_WriteByte (msg, SVfloat (ent, ammo_nails));
|
|
|
|
MSG_WriteByte (msg, SVfloat (ent, ammo_rockets));
|
|
|
|
MSG_WriteByte (msg, SVfloat (ent, ammo_cells));
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
if (standard_quake) {
|
2001-08-08 20:28:53 +00:00
|
|
|
MSG_WriteByte (msg, SVfloat (ent, weapon));
|
2001-02-26 06:48:02 +00:00
|
|
|
} else {
|
|
|
|
for (i = 0; i < 32; i++) {
|
2001-08-08 20:28:53 +00:00
|
|
|
if (((int) SVfloat (ent, weapon)) & (1 << i)) {
|
2001-02-19 21:15:25 +00:00
|
|
|
MSG_WriteByte (msg, i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
qboolean
|
|
|
|
SV_SendClientDatagram (client_t *client)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
byte buf[MAX_DATAGRAM];
|
|
|
|
sizebuf_t msg;
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
msg.data = buf;
|
2001-02-26 06:48:02 +00:00
|
|
|
msg.maxsize = sizeof (buf);
|
2001-02-19 21:15:25 +00:00
|
|
|
msg.cursize = 0;
|
|
|
|
|
|
|
|
MSG_WriteByte (&msg, svc_time);
|
|
|
|
MSG_WriteFloat (&msg, sv.time);
|
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
// add the client specific data to the datagram
|
2001-02-19 21:15:25 +00:00
|
|
|
SV_WriteClientdataToMessage (client->edict, &msg);
|
|
|
|
|
|
|
|
SV_WriteEntitiesToClient (client->edict, &msg);
|
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
// copy the server datagram if there is space
|
2001-02-19 21:15:25 +00:00
|
|
|
if (msg.cursize + sv.datagram.cursize < msg.maxsize)
|
|
|
|
SZ_Write (&msg, sv.datagram.data, sv.datagram.cursize);
|
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
// send the datagram
|
2001-02-26 06:48:02 +00:00
|
|
|
if (NET_SendUnreliableMessage (client->netconnection, &msg) == -1) {
|
2001-08-27 07:13:32 +00:00
|
|
|
SV_DropClient (true); // if the message couldn't send, kick off
|
2001-02-19 21:15:25 +00:00
|
|
|
return false;
|
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
SV_UpdateToReliableMessages (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
int i, j;
|
|
|
|
client_t *client;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
// check for changes to be sent over the reliable streams
|
2001-02-26 06:48:02 +00:00
|
|
|
for (i = 0, host_client = svs.clients; i < svs.maxclients;
|
|
|
|
i++, host_client++) {
|
2001-09-24 19:41:42 +00:00
|
|
|
if (host_client->old_frags != (int) SVfloat (host_client->edict, frags)) {
|
2001-08-27 07:13:32 +00:00
|
|
|
for (j = 0, client = svs.clients; j < svs.maxclients; j++,
|
|
|
|
client++) {
|
2001-02-19 21:15:25 +00:00
|
|
|
if (!client->active)
|
|
|
|
continue;
|
|
|
|
MSG_WriteByte (&client->message, svc_updatefrags);
|
|
|
|
MSG_WriteByte (&client->message, i);
|
2001-02-26 20:52:14 +00:00
|
|
|
MSG_WriteShort (&client->message,
|
2001-08-08 20:28:53 +00:00
|
|
|
SVfloat (host_client->edict, frags));
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-08-08 20:28:53 +00:00
|
|
|
host_client->old_frags = SVfloat (host_client->edict, frags);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
for (j = 0, client = svs.clients; j < svs.maxclients; j++, client++) {
|
2001-02-19 21:15:25 +00:00
|
|
|
if (!client->active)
|
|
|
|
continue;
|
2001-02-26 06:48:02 +00:00
|
|
|
SZ_Write (&client->message, sv.reliable_datagram.data,
|
|
|
|
sv.reliable_datagram.cursize);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SZ_Clear (&sv.reliable_datagram);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2001-08-27 07:13:32 +00:00
|
|
|
SV_SendNop
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
Send a nop message without trashing or sending the accumulated client
|
|
|
|
message buffer
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
SV_SendNop (client_t *client)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
sizebuf_t msg;
|
|
|
|
byte buf[4];
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
msg.data = buf;
|
2001-02-26 06:48:02 +00:00
|
|
|
msg.maxsize = sizeof (buf);
|
2001-02-19 21:15:25 +00:00
|
|
|
msg.cursize = 0;
|
|
|
|
|
|
|
|
MSG_WriteChar (&msg, svc_nop);
|
|
|
|
|
|
|
|
if (NET_SendUnreliableMessage (client->netconnection, &msg) == -1)
|
2001-08-27 07:13:32 +00:00
|
|
|
SV_DropClient (true); // if the message couldn't send, kick off
|
2001-02-19 21:15:25 +00:00
|
|
|
client->last_message = realtime;
|
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
SV_SendClientMessages (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
int i;
|
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
// update frags, names, etc
|
2001-02-19 21:15:25 +00:00
|
|
|
SV_UpdateToReliableMessages ();
|
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
// build individual updates
|
2001-02-26 06:48:02 +00:00
|
|
|
for (i = 0, host_client = svs.clients; i < svs.maxclients;
|
|
|
|
i++, host_client++) {
|
2001-02-19 21:15:25 +00:00
|
|
|
if (!host_client->active)
|
|
|
|
continue;
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
if (host_client->spawned) {
|
2001-02-19 21:15:25 +00:00
|
|
|
if (!SV_SendClientDatagram (host_client))
|
|
|
|
continue;
|
2001-02-26 06:48:02 +00:00
|
|
|
} else {
|
|
|
|
// the player isn't totally in the game yet
|
|
|
|
// send small keepalive messages if too much time has passed
|
|
|
|
// send a full message when the next signon stage has been
|
|
|
|
// requested
|
|
|
|
// some other message data (name changes, etc) may accumulate
|
|
|
|
// between signon stages
|
|
|
|
if (!host_client->sendsignon) {
|
2001-02-19 21:15:25 +00:00
|
|
|
if (realtime - host_client->last_message > 5)
|
|
|
|
SV_SendNop (host_client);
|
2001-02-26 06:48:02 +00:00
|
|
|
continue; // don't send out non-signon messages
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// check for an overflowed message. Should only happen
|
|
|
|
// on a very fucked up connection that backs up a lot, then
|
|
|
|
// changes level
|
2001-02-26 06:48:02 +00:00
|
|
|
if (host_client->message.overflowed) {
|
2001-02-19 21:15:25 +00:00
|
|
|
SV_DropClient (true);
|
|
|
|
host_client->message.overflowed = false;
|
|
|
|
continue;
|
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
if (host_client->message.cursize || host_client->dropasap) {
|
|
|
|
if (!NET_CanSendMessage (host_client->netconnection)) {
|
2001-08-27 07:13:32 +00:00
|
|
|
// I_Printf ("can't write\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (host_client->dropasap)
|
|
|
|
SV_DropClient (false); // went to another level
|
2001-02-26 06:48:02 +00:00
|
|
|
else {
|
|
|
|
if (NET_SendMessage
|
|
|
|
(host_client->netconnection, &host_client->message) == -1)
|
|
|
|
SV_DropClient (true); // if the message couldn't send,
|
2001-08-27 07:13:32 +00:00
|
|
|
// kick off
|
2001-02-19 21:15:25 +00:00
|
|
|
SZ_Clear (&host_client->message);
|
|
|
|
host_client->last_message = realtime;
|
|
|
|
host_client->sendsignon = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
// clear muzzle flashes
|
2001-02-19 21:15:25 +00:00
|
|
|
SV_CleanupEnts ();
|
|
|
|
}
|
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
// SERVER SPAWNING ============================================================
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
int
|
2001-07-15 07:04:17 +00:00
|
|
|
SV_ModelIndex (const char *name)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
int i;
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
if (!name || !name[0])
|
|
|
|
return 0;
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
for (i = 0; i < MAX_MODELS && sv.model_precache[i]; i++)
|
|
|
|
if (!strcmp (sv.model_precache[i], name))
|
2001-02-19 21:15:25 +00:00
|
|
|
return i;
|
2001-02-26 06:48:02 +00:00
|
|
|
if (i == MAX_MODELS || !sv.model_precache[i])
|
2001-02-19 21:15:25 +00:00
|
|
|
Sys_Error ("SV_ModelIndex: model %s not precached", name);
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
SV_CreateBaseline (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-12-12 21:56:09 +00:00
|
|
|
int entnum;
|
2001-02-26 06:48:02 +00:00
|
|
|
edict_t *svent;
|
|
|
|
|
|
|
|
for (entnum = 0; entnum < sv.num_edicts; entnum++) {
|
|
|
|
// get the current server version
|
2001-02-26 20:52:14 +00:00
|
|
|
svent = EDICT_NUM (&sv_pr_state, entnum);
|
2001-02-19 21:15:25 +00:00
|
|
|
if (svent->free)
|
|
|
|
continue;
|
2001-08-08 20:28:53 +00:00
|
|
|
if (entnum > svs.maxclients && !SVfloat (svent, modelindex))
|
2001-02-19 21:15:25 +00:00
|
|
|
continue;
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
// create entity baseline
|
2001-08-27 07:13:32 +00:00
|
|
|
VectorCopy (SVvector (svent, origin),
|
|
|
|
((entity_state_t*)svent->data)->origin);
|
|
|
|
VectorCopy (SVvector (svent, angles),
|
|
|
|
((entity_state_t*)svent->data)->angles);
|
2001-08-08 20:28:53 +00:00
|
|
|
((entity_state_t*)svent->data)->frame = SVfloat (svent, frame);
|
|
|
|
((entity_state_t*)svent->data)->skin = SVfloat (svent, skin);
|
2001-02-26 06:48:02 +00:00
|
|
|
if (entnum > 0 && entnum <= svs.maxclients) {
|
2001-03-03 08:31:58 +00:00
|
|
|
((entity_state_t*)svent->data)->colormap = entnum;
|
2001-08-27 07:13:32 +00:00
|
|
|
((entity_state_t*)svent->data)->modelindex = SV_ModelIndex
|
|
|
|
("progs/player.mdl");
|
2001-02-26 06:48:02 +00:00
|
|
|
} else {
|
2001-03-03 08:31:58 +00:00
|
|
|
((entity_state_t*)svent->data)->colormap = 0;
|
|
|
|
((entity_state_t*)svent->data)->modelindex =
|
2001-08-27 07:13:32 +00:00
|
|
|
SV_ModelIndex (PR_GetString (&sv_pr_state,SVstring (svent,
|
|
|
|
model)));
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
// add to the message
|
|
|
|
MSG_WriteByte (&sv.signon, svc_spawnbaseline);
|
|
|
|
MSG_WriteShort (&sv.signon, entnum);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-03-03 08:31:58 +00:00
|
|
|
MSG_WriteByte (&sv.signon, ((entity_state_t*)svent->data)->modelindex);
|
|
|
|
MSG_WriteByte (&sv.signon, ((entity_state_t*)svent->data)->frame);
|
|
|
|
MSG_WriteByte (&sv.signon, ((entity_state_t*)svent->data)->colormap);
|
|
|
|
MSG_WriteByte (&sv.signon, ((entity_state_t*)svent->data)->skin);
|
2001-12-12 21:56:09 +00:00
|
|
|
|
|
|
|
MSG_WriteCoordAngleV (&sv.signon,
|
|
|
|
((entity_state_t*)svent->data)->origin,
|
|
|
|
((entity_state_t*)svent->data)->angles);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2001-08-27 07:13:32 +00:00
|
|
|
SV_SendReconnect
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
Tell all the clients that the server is changing levels
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
SV_SendReconnect (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
char data[128];
|
|
|
|
sizebuf_t msg;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
msg.data = data;
|
|
|
|
msg.cursize = 0;
|
2001-02-26 06:48:02 +00:00
|
|
|
msg.maxsize = sizeof (data);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
MSG_WriteChar (&msg, svc_stufftext);
|
|
|
|
MSG_WriteString (&msg, "reconnect\n");
|
|
|
|
NET_SendToAll (&msg, 5);
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
if (cls.state != ca_dedicated)
|
2001-02-22 04:46:59 +00:00
|
|
|
Cmd_ExecuteString ("reconnect\n", src_command);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2001-08-27 07:13:32 +00:00
|
|
|
SV_SaveSpawnparms
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
Grabs the current state of each client for saving across the
|
|
|
|
transition to another level
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
SV_SaveSpawnparms (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
int i, j;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-03-03 08:31:58 +00:00
|
|
|
svs.serverflags = *sv_globals.serverflags;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
for (i = 0, host_client = svs.clients; i < svs.maxclients;
|
|
|
|
i++, host_client++) {
|
2001-02-19 21:15:25 +00:00
|
|
|
if (!host_client->active)
|
|
|
|
continue;
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
// call the progs to get default spawn parms for the new client
|
2001-03-03 08:31:58 +00:00
|
|
|
*sv_globals.self =
|
2001-02-26 20:52:14 +00:00
|
|
|
EDICT_TO_PROG (&sv_pr_state, host_client->edict);
|
2002-05-31 21:05:58 +00:00
|
|
|
PR_ExecuteProgram (&sv_pr_state, sv_funcs.SetChangeParms);
|
2001-02-26 06:48:02 +00:00
|
|
|
for (j = 0; j < NUM_SPAWN_PARMS; j++)
|
2001-02-26 20:52:14 +00:00
|
|
|
host_client->spawn_parms[j] =
|
2001-03-03 08:31:58 +00:00
|
|
|
sv_globals.parms[j];
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2001-08-27 07:13:32 +00:00
|
|
|
SV_SpawnServer
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
This is called at the start of each level
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-07-15 07:04:17 +00:00
|
|
|
SV_SpawnServer (const char *server)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
int i;
|
2001-08-27 07:13:32 +00:00
|
|
|
edict_t *ent;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// let's not have any servers with no name
|
|
|
|
if (hostname->string[0] == 0)
|
2001-02-26 06:48:02 +00:00
|
|
|
Cvar_Set (hostname, "UNNAMED");
|
2001-02-19 21:15:25 +00:00
|
|
|
scr_centertime_off = 0;
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
Con_DPrintf ("SpawnServer: %s\n", server);
|
2001-02-19 21:15:25 +00:00
|
|
|
svs.changelevel_issued = false; // now safe to issue another
|
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
// tell all connected clients that we are going to a new level
|
2001-02-26 06:48:02 +00:00
|
|
|
if (sv.active) {
|
2001-02-19 21:15:25 +00:00
|
|
|
SV_SendReconnect ();
|
|
|
|
}
|
2001-08-27 07:13:32 +00:00
|
|
|
|
|
|
|
// make cvars consistant
|
2001-02-19 21:15:25 +00:00
|
|
|
if (coop->int_val)
|
2001-02-26 06:48:02 +00:00
|
|
|
Cvar_SetValue (deathmatch, 0);
|
2001-02-19 21:15:25 +00:00
|
|
|
current_skill = skill->int_val;
|
|
|
|
if (current_skill < 0)
|
|
|
|
current_skill = 0;
|
|
|
|
if (current_skill > 3)
|
|
|
|
current_skill = 3;
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
Cvar_SetValue (skill, (float) current_skill);
|
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
// set up the new server
|
2001-02-19 21:15:25 +00:00
|
|
|
Host_ClearMemory ();
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
memset (&sv, 0, sizeof (sv));
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
strcpy (sv.name, server);
|
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
// load progs to get entity field count
|
2001-02-19 21:15:25 +00:00
|
|
|
sv.max_edicts = MAX_EDICTS;
|
2002-01-29 20:53:44 +00:00
|
|
|
SV_LoadProgs ();
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-03-04 05:27:29 +00:00
|
|
|
// init the data field of the edicts
|
|
|
|
for (i = 0; i < MAX_EDICTS; i++) {
|
|
|
|
ent = EDICT_NUM (&sv_pr_state, i);
|
|
|
|
ent->data = &baselines[i];
|
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
sv.datagram.maxsize = sizeof (sv.datagram_buf);
|
2001-02-19 21:15:25 +00:00
|
|
|
sv.datagram.cursize = 0;
|
|
|
|
sv.datagram.data = sv.datagram_buf;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
sv.reliable_datagram.maxsize = sizeof (sv.reliable_datagram_buf);
|
2001-02-19 21:15:25 +00:00
|
|
|
sv.reliable_datagram.cursize = 0;
|
|
|
|
sv.reliable_datagram.data = sv.reliable_datagram_buf;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
sv.signon.maxsize = sizeof (sv.signon_buf);
|
2001-02-19 21:15:25 +00:00
|
|
|
sv.signon.cursize = 0;
|
|
|
|
sv.signon.data = sv.signon_buf;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
// leave slots at start for clients only
|
2001-02-26 06:48:02 +00:00
|
|
|
sv.num_edicts = svs.maxclients + 1;
|
|
|
|
for (i = 0; i < svs.maxclients; i++) {
|
2001-02-26 20:52:14 +00:00
|
|
|
ent = EDICT_NUM (&sv_pr_state, i + 1);
|
2001-02-19 21:15:25 +00:00
|
|
|
svs.clients[i].edict = ent;
|
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
sv.state = ss_loading;
|
|
|
|
sv.paused = false;
|
|
|
|
|
|
|
|
sv.time = 1.0;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
strcpy (sv.name, server);
|
2001-02-26 06:48:02 +00:00
|
|
|
snprintf (sv.modelname, sizeof (sv.modelname), "maps/%s.bsp", server);
|
2001-02-19 21:15:25 +00:00
|
|
|
sv.worldmodel = Mod_ForName (sv.modelname, false);
|
2001-02-26 06:48:02 +00:00
|
|
|
if (!sv.worldmodel) {
|
2001-02-19 21:15:25 +00:00
|
|
|
Con_Printf ("Couldn't spawn server %s\n", sv.modelname);
|
|
|
|
sv.active = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
sv.models[1] = sv.worldmodel;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
// clear world interaction links
|
2001-02-19 21:15:25 +00:00
|
|
|
SV_ClearWorld ();
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-26 20:52:14 +00:00
|
|
|
sv.sound_precache[0] = sv_pr_state.pr_strings;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 20:52:14 +00:00
|
|
|
sv.model_precache[0] = sv_pr_state.pr_strings;
|
2001-02-19 21:15:25 +00:00
|
|
|
sv.model_precache[1] = sv.modelname;
|
2001-02-26 06:48:02 +00:00
|
|
|
for (i = 1; i < sv.worldmodel->numsubmodels; i++) {
|
|
|
|
sv.model_precache[1 + i] = localmodels[i];
|
|
|
|
sv.models[i + 1] = Mod_ForName (localmodels[i], false);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
// load the rest of the entities
|
2001-02-26 20:52:14 +00:00
|
|
|
ent = EDICT_NUM (&sv_pr_state, 0);
|
|
|
|
memset (&ent->v, 0, sv_pr_state.progs->entityfields * 4);
|
2001-02-19 21:15:25 +00:00
|
|
|
ent->free = false;
|
2001-08-08 20:28:53 +00:00
|
|
|
SVstring (ent, model) = PR_SetString (&sv_pr_state, sv.worldmodel->name);
|
|
|
|
SVfloat (ent, modelindex) = 1; // world model
|
|
|
|
SVfloat (ent, solid) = SOLID_BSP;
|
|
|
|
SVfloat (ent, movetype) = MOVETYPE_PUSH;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (coop->int_val)
|
2001-03-03 08:31:58 +00:00
|
|
|
*sv_globals.coop = coop->int_val;
|
2001-02-19 21:15:25 +00:00
|
|
|
else
|
2001-03-03 08:31:58 +00:00
|
|
|
*sv_globals.deathmatch = deathmatch->int_val;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-03-04 05:27:29 +00:00
|
|
|
*sv_globals.mapname = PR_SetString (&sv_pr_state, sv.name);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
// serverflags are for cross level information (sigils)
|
2001-03-03 08:31:58 +00:00
|
|
|
*sv_globals.serverflags = svs.serverflags;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-26 20:52:14 +00:00
|
|
|
ED_LoadFromFile (&sv_pr_state, sv.worldmodel->entities);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
sv.active = true;
|
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
// all setup is completed, any further precache statements are errors
|
2001-02-19 21:15:25 +00:00
|
|
|
sv.state = ss_active;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
// run two frames to allow everything to settle
|
2001-02-19 21:15:25 +00:00
|
|
|
host_frametime = 0.1;
|
|
|
|
SV_Physics ();
|
2002-02-25 22:57:17 +00:00
|
|
|
sv.time += host_frametime;
|
2001-02-19 21:15:25 +00:00
|
|
|
SV_Physics ();
|
2002-02-25 22:57:17 +00:00
|
|
|
sv.time += host_frametime;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
// create a baseline for more efficient communications
|
2001-02-19 21:15:25 +00:00
|
|
|
SV_CreateBaseline ();
|
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
// send serverinfo to all connected clients
|
2001-02-26 06:48:02 +00:00
|
|
|
for (i = 0, host_client = svs.clients; i < svs.maxclients;
|
|
|
|
i++, host_client++)
|
2001-02-19 21:15:25 +00:00
|
|
|
if (host_client->active)
|
|
|
|
SV_SendServerinfo (host_client);
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
Con_DPrintf ("Server spawned.\n");
|
|
|
|
}
|