2003-10-24 21:43:32 +00:00
|
|
|
#include "common.qh"
|
|
|
|
|
|
|
|
#include "server.qh"
|
|
|
|
#include "protocol.qh"
|
|
|
|
#include "misc.qh"
|
|
|
|
|
2003-10-28 21:20:34 +00:00
|
|
|
float sv_spawning;
|
|
|
|
|
2003-10-24 21:43:32 +00:00
|
|
|
/*
|
|
|
|
All this crap is to make sure we don't overflow the signon
|
|
|
|
buffer or message buffer, since Quake doesn't bother to
|
|
|
|
just split the messages for us.
|
|
|
|
|
|
|
|
And since, at best, it will crash with an error if the buffer
|
|
|
|
gets overflowed.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// ========================================================================
|
|
|
|
// Don't change these unless you know what you're doing.
|
|
|
|
|
|
|
|
#define SV_SIGNON_BUFFERS 8
|
|
|
|
#define SV_SIGNON_BUFFER_SWAP 512
|
|
|
|
|
2004-02-09 04:25:00 +00:00
|
|
|
#define SV_FLUSHSIGNON_BREAKS 1 // QF == 1, twilight/stock == 0
|
2003-10-24 21:43:32 +00:00
|
|
|
|
|
|
|
#define SV_MAX_DATAGRAM 1450
|
2004-02-09 04:25:00 +00:00
|
|
|
#define SV_FRAME_OVERHEAD 725 // Wild guess.
|
2003-10-24 21:43:32 +00:00
|
|
|
|
|
|
|
#define SIZEOF_BASELINE 22
|
|
|
|
#define SIZEOF_AMBIENTSOUND 16
|
|
|
|
#define SIZEOF_MAKESTATIC 20
|
|
|
|
|
|
|
|
// ========================================================================
|
|
|
|
|
|
|
|
float sv_signon_buf_remaining;
|
|
|
|
float sv_signon_remaining;
|
|
|
|
float sv_frame_remaining;
|
|
|
|
|
|
|
|
// =================
|
|
|
|
|
2004-02-09 04:25:00 +00:00
|
|
|
float (float space)
|
|
|
|
SZ_GetSpace_frame =
|
|
|
|
{
|
2003-10-24 21:43:32 +00:00
|
|
|
if (sv_frame_remaining < space)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
sv_frame_remaining -= space;
|
|
|
|
return TRUE;
|
|
|
|
};
|
|
|
|
|
|
|
|
entity SZ_self;
|
2004-02-09 04:25:00 +00:00
|
|
|
|
|
|
|
float (float space)
|
|
|
|
SZ_GetSpace_signon =
|
|
|
|
{
|
2003-10-24 21:43:32 +00:00
|
|
|
if (sv_spawning || !SV_FLUSHSIGNON_BREAKS) {
|
|
|
|
if (self != SZ_self) {
|
|
|
|
SZ_self = self;
|
|
|
|
|
|
|
|
if (sv_signon_remaining < (SV_MAX_DATAGRAM - 512)) {
|
|
|
|
if (--sv_signon_buf_remaining <= 0)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
sv_signon_remaining = SV_MAX_DATAGRAM;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sv_signon_remaining < space)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
sv_signon_remaining -= space;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
};
|
|
|
|
|
|
|
|
// =================
|
|
|
|
|
2004-02-09 04:25:00 +00:00
|
|
|
void ()
|
|
|
|
SZ_init =
|
|
|
|
{
|
2003-10-24 21:43:32 +00:00
|
|
|
sv_signon_buf_remaining = SV_SIGNON_BUFFERS;
|
|
|
|
sv_signon_remaining = SV_MAX_DATAGRAM;
|
|
|
|
|
2004-02-09 04:25:00 +00:00
|
|
|
while ((self = nextent (self)))
|
|
|
|
SZ_GetSpace_signon (SIZEOF_BASELINE);
|
2003-10-24 21:43:32 +00:00
|
|
|
self = world;
|
|
|
|
};
|
|
|
|
|
2004-02-09 04:25:00 +00:00
|
|
|
void ()
|
|
|
|
SZ_frame =
|
|
|
|
{
|
2003-10-24 21:43:32 +00:00
|
|
|
sv_frame_remaining = SV_MAX_DATAGRAM - SV_FRAME_OVERHEAD;
|
|
|
|
};
|
|
|
|
|
|
|
|
// =================
|
|
|
|
|
2004-02-09 04:25:00 +00:00
|
|
|
void (entity e)
|
|
|
|
makestatic =
|
|
|
|
{
|
2003-10-24 21:43:32 +00:00
|
|
|
e.solid = SOLID_NOT;
|
|
|
|
e.movetype = MOVETYPE_NONE;
|
|
|
|
e.velocity = '0 0 0';
|
|
|
|
e.avelocity = '0 0 0';
|
|
|
|
e.nextthink = -1;
|
|
|
|
|
2004-02-09 04:25:00 +00:00
|
|
|
// No more space? Just let it be...
|
|
|
|
if (!SZ_GetSpace_signon (SIZEOF_MAKESTATIC))
|
2003-10-24 21:43:32 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (!sv_spawning) {
|
2004-02-09 04:25:00 +00:00
|
|
|
if (!SZ_GetSpace_frame (SIZEOF_MAKESTATIC)) {
|
2003-10-24 21:43:32 +00:00
|
|
|
self.think = SUB_makestatic;
|
|
|
|
self.nextthink = time + sv_mintic;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-02-09 04:25:00 +00:00
|
|
|
WriteBytes (MSG_ALL, SVC_MAKESTATIC, e.modelindex, e.frame,
|
|
|
|
e.colormap, e.skin);
|
|
|
|
WriteCoordV (MSG_ALL, e.origin);
|
|
|
|
WriteAngleV (MSG_ALL, e.angles);
|
2003-10-24 21:43:32 +00:00
|
|
|
}
|
|
|
|
|
2004-02-09 04:25:00 +00:00
|
|
|
BUILTIN_makestatic (e);
|
2003-10-24 21:43:32 +00:00
|
|
|
};
|
|
|
|
|
2004-02-09 04:25:00 +00:00
|
|
|
void (vector pos, string samp, float vol, float atten)
|
|
|
|
ambientsound =
|
|
|
|
{
|
2003-10-24 21:43:32 +00:00
|
|
|
if (!sv_spawning)
|
2004-02-09 04:25:00 +00:00
|
|
|
error ("ambientsound after spawn functions\n");
|
2003-10-24 21:43:32 +00:00
|
|
|
|
2004-02-09 04:25:00 +00:00
|
|
|
SZ_GetSpace_signon (SIZEOF_AMBIENTSOUND);
|
2003-10-24 21:43:32 +00:00
|
|
|
|
2004-02-09 04:25:00 +00:00
|
|
|
// Do it anyway
|
|
|
|
BUILTIN_ambientsound (pos, samp, vol, atten);
|
2003-10-24 21:43:32 +00:00
|
|
|
};
|