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
|
|
|
|
|
|
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
#include "QF/cmd.h"
|
2022-05-26 08:10:23 +00:00
|
|
|
#include "QF/console.h"
|
2001-05-31 03:41:35 +00:00
|
|
|
#include "QF/cvar.h"
|
2022-05-26 08:10:23 +00:00
|
|
|
#include "QF/gib.h"
|
2001-03-27 20:33:07 +00:00
|
|
|
#include "QF/msg.h"
|
2004-11-06 02:21:00 +00:00
|
|
|
#include "QF/mathlib.h"
|
2022-06-03 06:43:53 +00:00
|
|
|
#include "QF/quakefs.h"
|
2021-07-26 02:15:51 +00:00
|
|
|
#include "QF/set.h"
|
2001-03-27 20:33:07 +00:00
|
|
|
#include "QF/sys.h"
|
2003-03-25 17:49:27 +00:00
|
|
|
#include "QF/va.h"
|
2001-08-27 07:13:32 +00:00
|
|
|
|
2022-06-03 06:43:53 +00:00
|
|
|
#include "QF/simd/vec4f.h"
|
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
#include "compat.h"
|
2001-05-31 03:41:35 +00:00
|
|
|
#include "world.h"
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2020-06-21 14:15:17 +00:00
|
|
|
#include "nq/include/host.h"
|
|
|
|
#include "nq/include/server.h"
|
|
|
|
#include "nq/include/sv_progs.h"
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
server_t sv;
|
|
|
|
server_static_t svs;
|
2011-12-22 04:42:39 +00:00
|
|
|
double sv_frametime;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2018-06-08 04:21:30 +00:00
|
|
|
char localmodels[MAX_MODELS][6]; // inline model names for precache
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2010-08-24 00:53:54 +00:00
|
|
|
int sv_protocol = PROTOCOL_FITZQUAKE;
|
|
|
|
|
|
|
|
static void
|
|
|
|
SV_Protocol_f (void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
switch (Cmd_Argc ()) {
|
|
|
|
case 1:
|
|
|
|
Sys_Printf ("\"sv_protocol\" is \"%i\"\n", sv_protocol);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
i = atoi (Cmd_Argv (1));
|
|
|
|
if (i != PROTOCOL_NETQUAKE && i != PROTOCOL_FITZQUAKE) {
|
|
|
|
Sys_Printf ("sv_protocol must be %i or %i\n",
|
|
|
|
PROTOCOL_NETQUAKE, PROTOCOL_FITZQUAKE);
|
|
|
|
} else {
|
|
|
|
sv_protocol = i;
|
|
|
|
if (sv.active)
|
|
|
|
Sys_Printf ("changes will not take effect until the next "
|
|
|
|
"level load.\n");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
Sys_Printf ("usage: sv_protocol <protocol>\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
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;
|
|
|
|
|
2012-02-01 12:52:47 +00:00
|
|
|
SV_Progs_Init ();
|
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
SV_Physics_Init_Cvars ();
|
|
|
|
SV_User_Init_Cvars ();
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2010-08-24 00:53:54 +00:00
|
|
|
Cmd_AddCommand ("sv_protocol", SV_Protocol_f, "set the protocol to be "
|
|
|
|
"used after the next map load");
|
|
|
|
|
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
|
|
|
|
2012-05-21 23:23:22 +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;
|
2002-07-02 19:13:53 +00:00
|
|
|
MSG_WriteByte (&sv.datagram, v);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
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
|
|
|
|
2012-05-21 23:23:22 +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)
|
|
|
|
{
|
2004-11-06 02:21:00 +00:00
|
|
|
int ent, field_mask, sound_num;
|
|
|
|
vec3_t v;
|
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]) {
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("SV_StartSound: %s not precacheed\n", sample);
|
2001-02-26 06:48:02 +00:00
|
|
|
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
|
|
|
|
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;
|
|
|
|
|
2010-08-24 00:53:54 +00:00
|
|
|
if (ent >= 8192) {
|
|
|
|
if (sv.protocol == PROTOCOL_NETQUAKE)
|
|
|
|
return; //don't send any info protocol can't support
|
|
|
|
else
|
|
|
|
field_mask |= SND_LARGEENTITY;
|
|
|
|
}
|
|
|
|
if (sound_num >= 256 || channel >= 8) {
|
|
|
|
if (sv.protocol == PROTOCOL_NETQUAKE)
|
|
|
|
return; //don't send any info protocol can't support
|
|
|
|
else
|
|
|
|
field_mask |= SND_LARGESOUND;
|
|
|
|
}
|
|
|
|
|
2010-01-13 06:42:26 +00:00
|
|
|
// directed messages go to only the entity on which they are targeted
|
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);
|
2010-08-24 00:53:54 +00:00
|
|
|
|
|
|
|
if (field_mask & SND_LARGEENTITY) {
|
|
|
|
MSG_WriteShort (&sv.datagram, ent);
|
|
|
|
MSG_WriteByte (&sv.datagram, channel);
|
|
|
|
} else {
|
|
|
|
MSG_WriteShort (&sv.datagram, (ent << 3 | channel));
|
|
|
|
}
|
|
|
|
if (field_mask & SND_LARGESOUND)
|
|
|
|
MSG_WriteShort (&sv.datagram, sound_num);
|
|
|
|
else
|
|
|
|
MSG_WriteByte (&sv.datagram, sound_num);
|
|
|
|
|
2004-11-06 02:21:00 +00:00
|
|
|
VectorBlend (SVvector (entity, mins), SVvector (entity, maxs), 0.5, v);
|
|
|
|
VectorAdd (v, SVvector (entity, origin), v);
|
|
|
|
MSG_WriteCoordV (&sv.datagram, v);
|
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
|
|
|
*/
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-26 06:48:02 +00:00
|
|
|
SV_SendServerinfo (client_t *client)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-07-15 07:04:17 +00:00
|
|
|
const char **s;
|
2003-08-05 01:45:52 +00:00
|
|
|
char message[2048];
|
2010-08-24 00:53:54 +00:00
|
|
|
int i;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
MSG_WriteByte (&client->message, svc_print);
|
2010-11-26 22:25:47 +00:00
|
|
|
snprintf (message, sizeof (message), "%c\nVersion %s server (%i CRC)\n", 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);
|
2010-08-24 00:53:54 +00:00
|
|
|
MSG_WriteLong (&client->message, sv.protocol);
|
2001-02-19 21:15:25 +00:00
|
|
|
MSG_WriteByte (&client->message, svs.maxclients);
|
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if (!coop && deathmatch)
|
2001-02-19 21:15:25 +00:00
|
|
|
MSG_WriteByte (&client->message, GAME_DEATHMATCH);
|
|
|
|
else
|
|
|
|
MSG_WriteByte (&client->message, GAME_COOP);
|
|
|
|
|
2012-05-21 23:23:22 +00:00
|
|
|
snprintf (message, sizeof (message), "%s",
|
2001-08-08 20:28:53 +00:00
|
|
|
PR_GetString (&sv_pr_state, SVstring (sv.edicts, message)));
|
2010-08-24 00:53:54 +00:00
|
|
|
message[sizeof (message) - 1] = 0;
|
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
|
|
|
|
2010-08-24 00:53:54 +00:00
|
|
|
// send only the first 256 model and sound precaches if protocol 15
|
|
|
|
for (i = 0, s = sv.model_precache + 1; *s; s++, i++)
|
|
|
|
if (sv.protocol != PROTOCOL_NETQUAKE || i < 256)
|
|
|
|
MSG_WriteString (&client->message, *s);
|
2001-02-19 21:15:25 +00:00
|
|
|
MSG_WriteByte (&client->message, 0);
|
|
|
|
|
2010-08-24 00:53:54 +00:00
|
|
|
for (i = 0, s = sv.sound_precache + 1; *s; s++, i++)
|
|
|
|
if (sv.protocol != PROTOCOL_NETQUAKE || i < 256)
|
|
|
|
MSG_WriteString (&client->message, *s);
|
2001-02-19 21:15:25 +00:00
|
|
|
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
|
|
|
|
2012-05-21 23:23:22 +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
|
|
|
|
2010-01-13 06:42:26 +00:00
|
|
|
Initializes a client_t for a new net connection. This will be called only
|
2001-08-27 07:13:32 +00:00
|
|
|
once for a player each game, not once for each level change.
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-26 06:48:02 +00:00
|
|
|
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;
|
|
|
|
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_dev, "Client %s connected\n",
|
2010-11-23 05:09:30 +00:00
|
|
|
client->netconnection->address);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
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
|
|
|
{
|
2022-01-16 13:15:18 +00:00
|
|
|
unsigned 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
|
|
|
*/
|
|
|
|
|
2021-07-26 02:15:51 +00:00
|
|
|
static set_t *fatpvs;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2022-05-22 02:18:32 +00:00
|
|
|
SV_AddToFatPVS (vec4f_t org, int node_id)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-08-27 07:13:32 +00:00
|
|
|
float d;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
while (1) {
|
|
|
|
// if this is a leaf, accumulate the pvs bits
|
2022-05-22 02:18:32 +00:00
|
|
|
if (node_id < 0) {
|
|
|
|
mleaf_t *leaf = sv.worldmodel->brush.leafs + ~node_id;
|
|
|
|
if (leaf->contents != CONTENTS_SOLID) {
|
2023-06-28 12:45:41 +00:00
|
|
|
set_union (fatpvs, Mod_LeafPVS (leaf, &sv.worldmodel->brush));
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2022-05-22 02:18:32 +00:00
|
|
|
mnode_t *node = sv.worldmodel->brush.nodes + node_id;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2022-05-22 02:18:32 +00:00
|
|
|
d = dotf (node->plane, org)[0];
|
2001-02-19 21:15:25 +00:00
|
|
|
if (d > 8)
|
2022-05-22 02:18:32 +00:00
|
|
|
node_id = node->children[0];
|
2001-02-19 21:15:25 +00:00
|
|
|
else if (d < -8)
|
2022-05-22 02:18:32 +00:00
|
|
|
node_id = 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]);
|
2022-05-22 02:18:32 +00:00
|
|
|
node_id = node->children[1];
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
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
|
|
|
*/
|
2021-07-26 02:15:51 +00:00
|
|
|
static set_t *
|
2022-05-22 02:18:32 +00:00
|
|
|
SV_FatPVS (vec4f_t org)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2021-07-26 02:15:51 +00:00
|
|
|
if (!fatpvs) {
|
2021-07-27 03:32:40 +00:00
|
|
|
fatpvs = set_new_size (sv.worldmodel->brush.visleafs);
|
2021-07-26 02:15:51 +00:00
|
|
|
}
|
2021-07-27 03:32:40 +00:00
|
|
|
set_expand (fatpvs, sv.worldmodel->brush.visleafs);
|
2021-07-26 02:15:51 +00:00
|
|
|
set_empty (fatpvs);
|
2022-05-22 02:18:32 +00:00
|
|
|
SV_AddToFatPVS (org, 0);
|
2001-02-19 21:15:25 +00:00
|
|
|
return fatpvs;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-26 06:48:02 +00:00
|
|
|
SV_WriteEntitiesToClient (edict_t *clent, sizebuf_t *msg)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2022-01-16 13:15:18 +00:00
|
|
|
pr_uint_t bits, e;
|
2021-07-26 02:15:51 +00:00
|
|
|
set_t *pvs;
|
2001-02-26 06:48:02 +00:00
|
|
|
float miss;
|
2022-05-22 02:18:32 +00:00
|
|
|
vec4f_t org;
|
2001-02-26 06:48:02 +00:00
|
|
|
edict_t *ent;
|
2010-08-24 00:53:54 +00:00
|
|
|
entity_state_t *baseline;
|
2010-12-07 23:44:52 +00:00
|
|
|
edict_leaf_t *el;
|
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);
|
2022-05-22 02:18:32 +00:00
|
|
|
org[3] = 1;
|
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)) {
|
2010-12-09 05:27:36 +00:00
|
|
|
baseline = &SVdata (ent)->state;
|
2010-08-24 00:53:54 +00:00
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
// ignore if not touching a PV leaf
|
2004-03-11 04:13:12 +00:00
|
|
|
if (ent != clent) { // clent is ALWAYS sent
|
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;
|
|
|
|
|
2010-08-24 00:53:54 +00:00
|
|
|
// don't send model > 255 for protocol 15
|
|
|
|
if (sv.protocol == PROTOCOL_NETQUAKE
|
|
|
|
&& (int) SVfloat (ent, modelindex) & 0xFF00)
|
|
|
|
continue;
|
|
|
|
|
2010-12-09 05:27:36 +00:00
|
|
|
for (el = SVdata (ent)->leafs; el; el = el->next) {
|
2021-07-26 02:15:51 +00:00
|
|
|
if (set_is_member (pvs, el->leafnum))
|
2001-02-19 21:15:25 +00:00
|
|
|
break;
|
2010-12-07 23:44:52 +00:00
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2010-12-07 23:44:52 +00:00
|
|
|
if (!el)
|
2001-02-26 06:48:02 +00:00
|
|
|
continue; // not visible
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2010-08-24 00:53:54 +00:00
|
|
|
if (msg->cursize + 24 > msg->maxsize) {
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("packet overflow\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
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
|
|
|
|
2010-08-24 00:53:54 +00:00
|
|
|
|
2022-01-16 13:15:18 +00:00
|
|
|
for (int i = 0; i < 3; i++) {
|
2010-08-24 00:53:54 +00:00
|
|
|
miss = SVvector (ent, origin)[i] - baseline->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
|
|
|
}
|
|
|
|
|
2010-08-24 00:53:54 +00:00
|
|
|
if (SVvector (ent, angles)[0] != baseline->angles[0])
|
2001-02-19 21:15:25 +00:00
|
|
|
bits |= U_ANGLE1;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2010-08-24 00:53:54 +00:00
|
|
|
if (SVvector (ent, angles)[1] != baseline->angles[1])
|
2001-02-19 21:15:25 +00:00
|
|
|
bits |= U_ANGLE2;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2010-08-24 00:53:54 +00:00
|
|
|
if (SVvector (ent, angles)[2] != baseline->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)
|
2010-08-24 00:53:54 +00:00
|
|
|
bits |= U_STEP; // don't mess up the step animation
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2010-08-24 00:53:54 +00:00
|
|
|
if (baseline->colormap != SVfloat (ent, colormap))
|
2001-02-19 21:15:25 +00:00
|
|
|
bits |= U_COLORMAP;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2012-05-24 12:13:33 +00:00
|
|
|
if (baseline->skinnum != SVfloat (ent, skin))
|
2001-02-19 21:15:25 +00:00
|
|
|
bits |= U_SKIN;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2010-08-24 00:53:54 +00:00
|
|
|
if (baseline->frame != SVfloat (ent, frame))
|
2001-02-19 21:15:25 +00:00
|
|
|
bits |= U_FRAME;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2010-08-24 00:53:54 +00:00
|
|
|
if (baseline->effects != SVfloat (ent, effects))
|
2001-02-19 21:15:25 +00:00
|
|
|
bits |= U_EFFECTS;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2010-08-24 00:53:54 +00:00
|
|
|
if (baseline->modelindex != SVfloat (ent, modelindex))
|
2001-02-19 21:15:25 +00:00
|
|
|
bits |= U_MODEL;
|
|
|
|
|
2010-12-16 00:34:29 +00:00
|
|
|
if (sv_fields.alpha != -1)
|
|
|
|
SVdata (ent)->alpha = ENTALPHA_ENCODE(SVfloat (ent, alpha));
|
2010-08-24 00:53:54 +00:00
|
|
|
|
|
|
|
//don't send invisible entities unless they have effects
|
2010-12-16 00:34:29 +00:00
|
|
|
if (SVdata (ent)->alpha == ENTALPHA_ZERO && !SVfloat (ent, effects))
|
2010-08-24 00:53:54 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
if (sv.protocol != PROTOCOL_NETQUAKE) {
|
2010-12-16 00:34:29 +00:00
|
|
|
if (SVdata (ent)->state.alpha != SVdata (ent)->alpha)
|
|
|
|
bits |= U_ALPHA;
|
2010-08-24 00:53:54 +00:00
|
|
|
if (bits & U_FRAME && (int) SVfloat (ent, frame) & 0xFF00)
|
|
|
|
bits |= U_FRAME2;
|
|
|
|
if (bits & U_MODEL && (int) SVfloat (ent, modelindex) & 0xFF00)
|
|
|
|
bits |= U_MODEL2;
|
2010-12-16 00:34:29 +00:00
|
|
|
if (SVdata (ent)->sendinterval)
|
|
|
|
bits |= U_LERPFINISH;
|
2010-08-24 00:53:54 +00:00
|
|
|
if (bits >= 65536)
|
|
|
|
bits |= U_EXTEND1;
|
|
|
|
if (bits >= 16777216)
|
|
|
|
bits |= U_EXTEND2;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
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);
|
2010-08-24 00:53:54 +00:00
|
|
|
if (bits & U_EXTEND1)
|
|
|
|
MSG_WriteByte (msg, bits >> 16);
|
|
|
|
if (bits & U_EXTEND2)
|
|
|
|
MSG_WriteByte (msg, bits >> 24);
|
|
|
|
|
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]);
|
2010-08-24 00:53:54 +00:00
|
|
|
|
2010-12-16 00:34:29 +00:00
|
|
|
if (bits & U_ALPHA)
|
|
|
|
MSG_WriteByte(msg, SVdata (ent)->alpha);
|
2010-08-24 00:53:54 +00:00
|
|
|
if (bits & U_FRAME2)
|
|
|
|
MSG_WriteByte(msg, (int) SVfloat (ent, frame) >> 8);
|
|
|
|
if (bits & U_MODEL2)
|
|
|
|
MSG_WriteByte(msg, (int) SVfloat (ent, modelindex) >> 8);
|
|
|
|
if (bits & U_LERPFINISH)
|
|
|
|
MSG_WriteByte(msg, rint ((SVfloat (ent, nextthink) - sv.time) * 255));
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-26 06:48:02 +00:00
|
|
|
SV_CleanupEnts (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2022-01-16 13:15:18 +00:00
|
|
|
pr_uint_t e;
|
2001-02-26 06:48:02 +00:00
|
|
|
edict_t *ent;
|
|
|
|
|
2001-02-26 20:52:14 +00:00
|
|
|
ent = NEXT_EDICT (&sv_pr_state, sv.edicts);
|
2002-09-28 02:33:39 +00:00
|
|
|
for (e = 1; e < sv.num_edicts; e++, ent = NEXT_EDICT (&sv_pr_state, ent))
|
|
|
|
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;
|
2004-11-06 02:21:00 +00:00
|
|
|
vec3_t v;
|
2001-02-26 06:48:02 +00:00
|
|
|
edict_t *other;
|
2010-08-24 00:53:54 +00:00
|
|
|
const char *weaponmodel;
|
|
|
|
|
|
|
|
weaponmodel = PR_GetString (&sv_pr_state, SVstring (ent, weaponmodel));
|
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));
|
2004-11-06 02:21:00 +00:00
|
|
|
VectorBlend (SVvector (other, mins), SVvector (other, maxs), 0.5, v);
|
|
|
|
VectorAdd (v, SVvector (other, origin), v);
|
|
|
|
MSG_WriteCoordV (msg, v);
|
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
|
|
|
|
2010-08-24 00:53:54 +00:00
|
|
|
if (sv.protocol != PROTOCOL_NETQUAKE) {
|
|
|
|
if (bits & SU_WEAPON && SV_ModelIndex(weaponmodel) & 0xFF00)
|
|
|
|
bits |= SU_WEAPON2;
|
|
|
|
if ((int) SVfloat (ent, armorvalue) & 0xFF00)
|
|
|
|
bits |= SU_ARMOR2;
|
|
|
|
if ((int) SVfloat (ent, currentammo) & 0xFF00)
|
|
|
|
bits |= SU_AMMO2;
|
|
|
|
if ((int) SVfloat (ent, ammo_shells) & 0xFF00)
|
|
|
|
bits |= SU_SHELLS2;
|
|
|
|
if ((int) SVfloat (ent, ammo_nails) & 0xFF00)
|
|
|
|
bits |= SU_NAILS2;
|
|
|
|
if ((int) SVfloat (ent, ammo_rockets) & 0xFF00)
|
|
|
|
bits |= SU_ROCKETS2;
|
|
|
|
if ((int) SVfloat (ent, ammo_cells) & 0xFF00)
|
|
|
|
bits |= SU_CELLS2;
|
|
|
|
if (bits & SU_WEAPONFRAME && (int) SVfloat (ent, weaponframe) & 0xFF00)
|
|
|
|
bits |= SU_WEAPONFRAME2;
|
2010-12-16 00:34:29 +00:00
|
|
|
if (bits & SU_WEAPON && SVdata (ent)->alpha != ENTALPHA_DEFAULT)
|
|
|
|
bits |= SU_WEAPONALPHA; //for now, weaponalpha = client entity alpha
|
2010-08-24 00:53:54 +00:00
|
|
|
if (bits >= 65536)
|
|
|
|
bits |= SU_EXTEND1;
|
|
|
|
if (bits >= 16777216)
|
|
|
|
bits |= SU_EXTEND2;
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
2010-08-24 00:53:54 +00:00
|
|
|
if (bits & SU_EXTEND1)
|
|
|
|
MSG_WriteByte(msg, bits>>16);
|
|
|
|
if (bits & SU_EXTEND2)
|
|
|
|
MSG_WriteByte(msg, bits>>24);
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
if (bits & SU_VIEWHEIGHT)
|
2002-07-02 19:13:53 +00:00
|
|
|
MSG_WriteByte (msg, SVvector (ent, view_ofs)[2]);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (bits & SU_IDEALPITCH)
|
2002-07-02 19:13:53 +00:00
|
|
|
MSG_WriteByte (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))
|
2002-07-02 19:13:53 +00:00
|
|
|
MSG_WriteByte (msg, SVvector (ent, punchangle)[i]);
|
2001-02-26 06:48:02 +00:00
|
|
|
if (bits & (SU_VELOCITY1 << i))
|
2002-07-02 19:13:53 +00:00
|
|
|
MSG_WriteByte (msg, SVvector (ent, velocity)[i] / 16);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2002-09-28 02:33:39 +00:00
|
|
|
// if (bits & SU_ITEMS) // [always sent]
|
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)
|
2010-08-24 00:53:54 +00:00
|
|
|
MSG_WriteByte (msg, SV_ModelIndex (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 {
|
2011-12-11 23:57:17 +00:00
|
|
|
// NOTE: this is abysmally stupid. weapon is being treated as a
|
|
|
|
// radio button style bit mask, limiting the available weapons to
|
|
|
|
// 32. Sure, that's a lot of weapons, but still...
|
|
|
|
//
|
|
|
|
// Send the index of the lowest order set bit.
|
|
|
|
unsigned weapon;
|
|
|
|
weapon = (unsigned) SVfloat (ent, weapon);
|
2001-02-26 06:48:02 +00:00
|
|
|
for (i = 0; i < 32; i++) {
|
2011-12-11 23:57:17 +00:00
|
|
|
if (weapon & (1 << i)) {
|
2001-02-19 21:15:25 +00:00
|
|
|
MSG_WriteByte (msg, i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-08-24 00:53:54 +00:00
|
|
|
|
|
|
|
if (bits & SU_WEAPON2)
|
|
|
|
MSG_WriteByte (msg, SV_ModelIndex(weaponmodel) >> 8);
|
|
|
|
if (bits & SU_ARMOR2)
|
|
|
|
MSG_WriteByte (msg, (int) SVfloat (ent, armorvalue) >> 8);
|
|
|
|
if (bits & SU_AMMO2)
|
|
|
|
MSG_WriteByte (msg, (int) SVfloat (ent, currentammo) >> 8);
|
|
|
|
if (bits & SU_SHELLS2)
|
|
|
|
MSG_WriteByte (msg, (int) SVfloat (ent, ammo_shells) >> 8);
|
|
|
|
if (bits & SU_NAILS2)
|
|
|
|
MSG_WriteByte (msg, (int) SVfloat (ent, ammo_nails) >> 8);
|
|
|
|
if (bits & SU_ROCKETS2)
|
|
|
|
MSG_WriteByte (msg, (int) SVfloat (ent, ammo_rockets) >> 8);
|
|
|
|
if (bits & SU_CELLS2)
|
|
|
|
MSG_WriteByte (msg, (int) SVfloat (ent, ammo_cells) >> 8);
|
|
|
|
if (bits & SU_WEAPONFRAME2)
|
|
|
|
MSG_WriteByte (msg, (int) SVfloat (ent, weaponframe) >> 8);
|
2010-12-16 00:34:29 +00:00
|
|
|
if (bits & SU_WEAPONALPHA)
|
|
|
|
MSG_WriteByte (msg, SVdata (ent)->alpha); //for now, weaponalpha = client entity alpha
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2023-06-13 09:06:11 +00:00
|
|
|
static bool
|
2001-02-26 06:48:02 +00:00
|
|
|
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;
|
|
|
|
|
2010-08-24 00:53:54 +00:00
|
|
|
if (strcmp (client->netconnection->address, "LOCAL") != 0)
|
|
|
|
msg.maxsize = DATAGRAM_MTU;
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-26 06:48:02 +00:00
|
|
|
SV_UpdateToReliableMessages (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2022-01-16 13:15:18 +00:00
|
|
|
unsigned i, j;
|
2001-02-26 06:48:02 +00:00
|
|
|
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++) {
|
2002-09-28 02:33:39 +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
|
|
|
*/
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-26 06:48:02 +00:00
|
|
|
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;
|
|
|
|
|
2002-07-02 19:13:53 +00:00
|
|
|
MSG_WriteByte (&msg, svc_nop);
|
2001-02-19 21:15:25 +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
|
2010-12-15 09:47:17 +00:00
|
|
|
client->last_message = sv.time;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
SV_SendClientMessages (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2022-01-16 13:15:18 +00:00
|
|
|
unsigned i;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
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 {
|
2002-09-28 02:33:39 +00:00
|
|
|
// 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
|
2001-02-26 06:48:02 +00:00
|
|
|
if (!host_client->sendsignon) {
|
2010-12-15 09:47:17 +00:00
|
|
|
if (sv.time - host_client->last_message > 5)
|
2001-02-19 21:15:25 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-13 06:42:26 +00:00
|
|
|
// check for an overflowed message. Should happen only on a very
|
|
|
|
// bad 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);
|
2010-12-15 09:47:17 +00:00
|
|
|
host_client->last_message = sv.time;
|
2001-02-19 21:15:25 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-26 06:48:02 +00:00
|
|
|
SV_CreateBaseline (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2022-01-16 13:15:18 +00:00
|
|
|
pr_uint_t entnum;
|
2001-02-26 06:48:02 +00:00
|
|
|
edict_t *svent;
|
2010-08-24 00:53:54 +00:00
|
|
|
entity_state_t *baseline;
|
|
|
|
int bits;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
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);
|
2010-12-09 05:27:36 +00:00
|
|
|
baseline = &SVdata (svent)->state;
|
2010-08-24 00:53:54 +00:00
|
|
|
|
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
|
2010-08-24 00:53:54 +00:00
|
|
|
VectorCopy (SVvector (svent, origin), baseline->origin);
|
|
|
|
VectorCopy (SVvector (svent, angles), baseline->angles);
|
|
|
|
baseline->frame = SVfloat (svent, frame);
|
2012-05-24 12:13:33 +00:00
|
|
|
baseline->skinnum = SVfloat (svent, skin);
|
2001-02-26 06:48:02 +00:00
|
|
|
if (entnum > 0 && entnum <= svs.maxclients) {
|
2010-08-24 00:53:54 +00:00
|
|
|
baseline->colormap = entnum;
|
|
|
|
baseline->modelindex = SV_ModelIndex ("progs/player.mdl");
|
|
|
|
baseline->alpha = ENTALPHA_DEFAULT;
|
2001-02-26 06:48:02 +00:00
|
|
|
} else {
|
2010-08-24 00:53:54 +00:00
|
|
|
const char *model;
|
|
|
|
model = PR_GetString (&sv_pr_state, SVstring (svent, model));
|
|
|
|
baseline->colormap = 0;
|
|
|
|
baseline->modelindex = SV_ModelIndex (model);
|
|
|
|
baseline->alpha = ENTALPHA_DEFAULT;
|
|
|
|
}
|
|
|
|
|
|
|
|
bits = 0;
|
|
|
|
if (sv.protocol == PROTOCOL_NETQUAKE) {
|
|
|
|
//still want to send baseline in PROTOCOL_NETQUAKE, so reset
|
|
|
|
//these values
|
|
|
|
if (baseline->modelindex & 0xFF00)
|
|
|
|
baseline->modelindex = 0;
|
|
|
|
if (baseline->frame & 0xFF00)
|
|
|
|
baseline->frame = 0;
|
|
|
|
baseline->alpha = ENTALPHA_DEFAULT;
|
|
|
|
} else {
|
|
|
|
if (baseline->modelindex & 0xFF00)
|
|
|
|
bits |= B_LARGEMODEL;
|
|
|
|
if (baseline->frame & 0xFF00)
|
|
|
|
bits |= B_LARGEFRAME;
|
|
|
|
if (baseline->alpha != ENTALPHA_DEFAULT)
|
|
|
|
bits |= B_ALPHA;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
// add to the message
|
2010-08-24 00:53:54 +00:00
|
|
|
if (bits)
|
|
|
|
MSG_WriteByte (&sv.signon, svc_spawnbaseline2);
|
|
|
|
else
|
|
|
|
MSG_WriteByte (&sv.signon, svc_spawnbaseline);
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
MSG_WriteShort (&sv.signon, entnum);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2010-08-24 00:53:54 +00:00
|
|
|
if (bits)
|
|
|
|
MSG_WriteByte (&sv.signon, bits);
|
2001-12-12 21:56:09 +00:00
|
|
|
|
2010-08-24 00:53:54 +00:00
|
|
|
if (bits & B_LARGEMODEL)
|
|
|
|
MSG_WriteShort (&sv.signon, baseline->modelindex);
|
|
|
|
else
|
|
|
|
MSG_WriteByte (&sv.signon, baseline->modelindex);
|
|
|
|
|
|
|
|
if (bits & B_LARGEFRAME)
|
|
|
|
MSG_WriteShort (&sv.signon, baseline->frame);
|
|
|
|
else
|
|
|
|
MSG_WriteByte (&sv.signon, baseline->frame);
|
|
|
|
MSG_WriteByte (&sv.signon, baseline->colormap);
|
2012-05-24 12:13:33 +00:00
|
|
|
MSG_WriteByte (&sv.signon, baseline->skinnum);
|
2010-08-24 00:53:54 +00:00
|
|
|
|
2022-03-30 15:07:20 +00:00
|
|
|
MSG_WriteCoordAngleV (&sv.signon, (vec_t*)&baseline->origin,//FIXME
|
2021-03-11 07:19:49 +00:00
|
|
|
baseline->angles);
|
2010-08-24 00:53:54 +00:00
|
|
|
|
|
|
|
if (bits & B_ALPHA)
|
|
|
|
MSG_WriteByte (&sv.signon, baseline->alpha);
|
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
|
|
|
*/
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-26 06:48:02 +00:00
|
|
|
SV_SendReconnect (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2005-06-08 06:35:48 +00:00
|
|
|
byte data[128];
|
2001-02-26 06:48:02 +00:00
|
|
|
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
|
|
|
|
2002-07-02 19:13:53 +00:00
|
|
|
MSG_WriteByte (&msg, svc_stufftext);
|
2001-02-19 21:15:25 +00:00
|
|
|
MSG_WriteString (&msg, "reconnect\n");
|
2010-11-21 05:27:43 +00:00
|
|
|
NET_SendToAll (&msg, 5.0);
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2022-04-06 10:32:55 +00:00
|
|
|
if (!net_is_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
|
|
|
{
|
2022-01-16 13:15:18 +00:00
|
|
|
unsigned 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
|
2022-01-22 07:00:04 +00:00
|
|
|
*sv_globals.self = 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++)
|
2002-09-28 02:33:39 +00:00
|
|
|
host_client->spawn_parms[j] = 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
|
|
|
{
|
2014-01-23 02:57:57 +00:00
|
|
|
byte *buf;
|
2014-01-23 04:13:00 +00:00
|
|
|
QFile *ent_file;
|
2001-08-27 07:13:32 +00:00
|
|
|
edict_t *ent;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2014-01-23 04:13:00 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
// let's not have any servers with no name
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if (hostname[0] == 0)
|
|
|
|
Cvar_Set ("hostname", "UNNAMED");
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_dev, "SpawnServer: %s\n", server);
|
2001-02-19 21:15:25 +00:00
|
|
|
svs.changelevel_issued = false; // now safe to issue another
|
2011-12-22 04:42:39 +00:00
|
|
|
svs.phys_client = SV_Physics_Client;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
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
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if (coop)
|
|
|
|
deathmatch = 0;
|
|
|
|
current_skill = skill;
|
2001-02-19 21:15:25 +00:00
|
|
|
if (current_skill < 0)
|
|
|
|
current_skill = 0;
|
|
|
|
if (current_skill > 3)
|
|
|
|
current_skill = 3;
|
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
skill = current_skill;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
// set up the new server
|
2022-05-16 11:51:37 +00:00
|
|
|
Host_SpawnServer ();
|
2001-02-19 21:15:25 +00:00
|
|
|
|
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);
|
|
|
|
|
2010-08-24 00:53:54 +00:00
|
|
|
sv.protocol = sv_protocol;
|
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
// load progs to get entity field count
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
sv.max_edicts = bound (MIN_EDICTS, max_edicts, MAX_EDICTS);
|
2002-01-29 20:53:44 +00:00
|
|
|
SV_LoadProgs ();
|
2010-12-08 00:20:43 +00:00
|
|
|
SV_FreeAllEdictLeafs ();
|
2001-02-19 21:15:25 +00:00
|
|
|
|
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
|
|
|
|
2010-01-13 06:42:26 +00:00
|
|
|
// leave slots at start for only clients
|
2001-02-26 06:48:02 +00:00
|
|
|
sv.num_edicts = svs.maxclients + 1;
|
2022-01-16 13:15:18 +00:00
|
|
|
for (unsigned 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) {
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("Couldn't spawn server %s\n", sv.modelname);
|
2001-02-19 21:15:25 +00:00
|
|
|
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;
|
2021-08-01 12:54:05 +00:00
|
|
|
for (unsigned i = 1; i < sv.worldmodel->brush.numsubmodels; i++) {
|
2001-02-26 06:48:02 +00:00
|
|
|
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);
|
2013-01-17 05:11:54 +00:00
|
|
|
memset (&E_fld (ent, 0), 0, sv_pr_state.progs->entityfields * 4);
|
2001-02-19 21:15:25 +00:00
|
|
|
ent->free = false;
|
2021-02-01 05:39:00 +00:00
|
|
|
SVstring (ent, model) = PR_SetString (&sv_pr_state, sv.worldmodel->path);
|
2001-08-08 20:28:53 +00:00
|
|
|
SVfloat (ent, modelindex) = 1; // world model
|
|
|
|
SVfloat (ent, solid) = SOLID_BSP;
|
|
|
|
SVfloat (ent, movetype) = MOVETYPE_PUSH;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if (coop)
|
|
|
|
*sv_globals.coop = coop;
|
2001-02-19 21:15:25 +00:00
|
|
|
else
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
*sv_globals.deathmatch = deathmatch;
|
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
|
|
|
|
2004-11-09 22:32:00 +00:00
|
|
|
*sv_globals.time = sv.time;
|
2021-01-31 07:01:20 +00:00
|
|
|
ent_file = QFS_VOpenFile (va (0, "maps/%s.ent", server), 0,
|
2014-01-23 04:13:00 +00:00
|
|
|
sv.worldmodel->vpath);
|
|
|
|
if ((buf = QFS_LoadFile (ent_file, 0))) {
|
2014-01-23 02:57:57 +00:00
|
|
|
ED_LoadFromFile (&sv_pr_state, (char *) buf);
|
2003-03-25 17:49:27 +00:00
|
|
|
free (buf);
|
|
|
|
} else {
|
2021-02-01 10:31:11 +00:00
|
|
|
ED_LoadFromFile (&sv_pr_state, sv.worldmodel->brush.entities);
|
2003-03-25 17:49:27 +00:00
|
|
|
}
|
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
|
2011-12-22 04:42:39 +00:00
|
|
|
sv_frametime = host_frametime = 0.1;
|
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
|
|
|
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 ();
|
|
|
|
|
2010-08-24 00:53:54 +00:00
|
|
|
if (sv.signon.cursize > 8000-2)
|
|
|
|
Sys_Printf ("%i byte signon buffer exceeds standard limit of 7998.\n",
|
|
|
|
sv.signon.cursize);
|
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
// send serverinfo to all connected clients
|
2022-01-16 13:15:18 +00:00
|
|
|
for (unsigned i = 0; i < svs.maxclients; i++) {
|
2021-08-01 12:54:05 +00:00
|
|
|
host_client = svs.clients + i;
|
|
|
|
if (host_client->active) {
|
2001-02-19 21:15:25 +00:00
|
|
|
SV_SendServerinfo (host_client);
|
2021-08-01 12:54:05 +00:00
|
|
|
}
|
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_dev, "Server spawned.\n");
|
2022-05-26 08:10:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SV_Frame (void)
|
|
|
|
{
|
|
|
|
if (net_is_dedicated) {
|
|
|
|
Con_ProcessInput ();
|
|
|
|
|
|
|
|
GIB_Thread_Execute ();
|
|
|
|
cmd_source = src_command;
|
|
|
|
Cbuf_Execute_Stack (host_cbuf);
|
|
|
|
}
|
|
|
|
|
|
|
|
*sv_globals.frametime = sv_frametime = host_frametime;
|
|
|
|
|
|
|
|
// set the time and clear the general datagram
|
|
|
|
SV_ClearDatagram ();
|
|
|
|
|
|
|
|
SV_CheckForNewClients ();
|
|
|
|
|
|
|
|
// read client messages
|
|
|
|
SV_RunClients ();
|
|
|
|
|
|
|
|
// move things around and think
|
|
|
|
// always pause in single player if in console or menus
|
|
|
|
if (!sv.paused && (svs.maxclients > 1 || host_in_game)) {
|
|
|
|
SV_Physics ();
|
|
|
|
sv.time += host_frametime;
|
|
|
|
}
|
|
|
|
|
|
|
|
// send all messages to the clients
|
|
|
|
SV_SendClientMessages ();
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|