spawn code complete

This commit is contained in:
Bill Currie 2005-05-08 08:04:50 +00:00
parent e8680d792e
commit a409ea4a74
19 changed files with 83 additions and 18 deletions

View file

@ -12,7 +12,7 @@ EXTRA_DIST = asm_i386.h alsa_funcs_list.h adivtab.h anorm_dots.h anorms.h \
r_local.h r_screen.h r_shared.h rua_internal.h sbar.h skin_stencil.h \
snd_render.h varrays.h vgamodes.h view.h vregset.h winquake.h world.h \
\
qw/msg_backbuf.h qw/msg_ucmd.h qw/pmove.h qw/protocol.h \
qw/bothdefs.h qw/msg_backbuf.h qw/msg_ucmd.h qw/pmove.h qw/protocol.h \
\
win32/fnmatch.h \
\

View file

@ -80,6 +80,7 @@ typedef struct server_s {
struct info_s *info;
char *soundlist[MAX_SOUNDS + 1];
char *modellist[MAX_MODELS + 1];
char *lightstyles[MAX_LIGHTSTYLES];
int playermodel;
struct client_s *clients;

View file

@ -54,6 +54,7 @@ static __attribute__ ((unused)) const char rcsid[] =
#include "QF/info.h"
#include "QF/va.h"
#include "qw/bothdefs.h"
#include "qw/msg_ucmd.h"
#include "qw/protocol.h"
@ -159,7 +160,11 @@ static void
cl_prespawn_f (client_t *cl, void *unused)
{
const char *cmd;
const char *info;
server_t *sv = cl->server;
player_t *pl;
int i;
sizebuf_t *msg;
if (!cl->server)
return;
@ -168,6 +173,51 @@ cl_prespawn_f (client_t *cl, void *unused)
Client_New (cl);
return;
}
for (i = 0, pl = sv->players; i < MAX_SV_PLAYERS; i++, pl++) {
if (!pl->info)
continue;
msg = MSG_ReliableCheckBlock (&cl->backbuf, 24 + pl->info->cursize);
MSG_WriteByte (msg, svc_updatefrags);
MSG_WriteByte (msg, i);
MSG_WriteShort (msg, pl->frags);
MSG_WriteByte (msg, svc_updateping);
MSG_WriteByte (msg, i);
MSG_WriteShort (msg, 333/*XXX*/);
MSG_WriteByte (msg, svc_updatepl);
MSG_WriteByte (msg, i);
MSG_WriteByte (msg, 0/*XXX*/);
MSG_WriteByte (msg, svc_updateentertime);
MSG_WriteByte (msg, i);
MSG_WriteFloat (msg, 0/*XXX*/);
info = pl->info ? Info_MakeString (pl->info, 0) : "";
MSG_WriteByte (msg, svc_updateuserinfo);
MSG_WriteByte (msg, i);
MSG_WriteLong (msg, pl->uid);
MSG_WriteString (msg, info);
if (cl->backbuf.num_backbuf)
MSG_Reliable_FinishWrite (&cl->backbuf);
}
for (i = 0; i < MAX_LIGHTSTYLES; i++) {
MSG_ReliableWrite_Begin (&cl->backbuf, svc_lightstyle,
3 + (sv->lightstyles[i] ?
strlen (sv->lightstyles[i]) : 1));
MSG_ReliableWrite_Byte (&cl->backbuf, i);
MSG_ReliableWrite_String (&cl->backbuf, sv->lightstyles[i]);
}
MSG_ReliableWrite_Begin (&cl->backbuf, svc_updatestatlong, 6);
MSG_ReliableWrite_Byte (&cl->backbuf, STAT_TOTALSECRETS);
MSG_ReliableWrite_Long (&cl->backbuf,
sv->players[0].stats[STAT_TOTALSECRETS]);
MSG_ReliableWrite_Begin (&cl->backbuf, svc_updatestatlong, 6);
MSG_ReliableWrite_Byte (&cl->backbuf, STAT_TOTALMONSTERS);
MSG_ReliableWrite_Long (&cl->backbuf,
sv->players[0].stats[STAT_TOTALMONSTERS]);
MSG_ReliableWrite_Begin (&cl->backbuf, svc_updatestatlong, 6);
MSG_ReliableWrite_Byte (&cl->backbuf, STAT_SECRETS);
MSG_ReliableWrite_Long (&cl->backbuf, sv->players[0].stats[STAT_SECRETS]);
MSG_ReliableWrite_Begin (&cl->backbuf, svc_updatestatlong, 6);
MSG_ReliableWrite_Byte (&cl->backbuf, STAT_SECRETS);
MSG_ReliableWrite_Long (&cl->backbuf, sv->players[0].stats[STAT_SECRETS]);
cmd = va ("cmd spawn %i 0\n", cl->server->spawncount);
MSG_ReliableWrite_Begin (&cl->backbuf, svc_stufftext, strlen (cmd) + 2);
MSG_ReliableWrite_String (&cl->backbuf, cmd);
@ -247,6 +297,9 @@ cl_serverinfo_f (client_t *cl, void *unused)
static void
cl_download_f (client_t *cl, void *unused)
{
MSG_ReliableWrite_Begin (&cl->backbuf, svc_download, 4);
MSG_ReliableWrite_Short (&cl->backbuf, -1);
MSG_ReliableWrite_Byte (&cl->backbuf, 0);
}
static void

View file

@ -784,6 +784,19 @@ sv_print (server_t *sv, qmsg_t *msg)
Server_Broadcast (sv, 1, data, len);
}
static void
sv_lightstyle (server_t *sv, qmsg_t *msg)
{
int ind = MSG_ReadByte (msg);
const char *style = MSG_ReadString (msg);
if (ind > MAX_LIGHTSTYLES)
return;
if (sv->lightstyles[ind])
free (sv->lightstyles[ind]);
sv->lightstyles[ind] = strdup (style);
}
void
sv_parse (server_t *sv, qmsg_t *msg, int reliable)
{
@ -950,9 +963,7 @@ sv_parse (server_t *sv, qmsg_t *msg, int reliable)
sv_spawnstatic (sv, msg);
break;
case svc_lightstyle:
//XXX
MSG_ReadByte (msg);
MSG_ReadString (msg);
sv_lightstyle (sv, msg);
break;
}
}

View file

@ -2,7 +2,7 @@
AUTOMAKE_OPTIONS= foreign
EXTRA_DIST = \
bothdefs.h cl_cam.h cl_chat.h cl_demo.h cl_ents.h cl_input.h \
cl_cam.h cl_chat.h cl_demo.h cl_ents.h cl_input.h \
cl_main.h cl_parse.h cl_pred.h cl_skin.h cl_slist.h cl_tent.h \
client.h crudefile.h game.h host.h server.h sv_gib.h sv_demo.h \
sv_pr_cmds.h sv_pr_qwe.h sv_progs.h sv_qtv.h

View file

@ -47,7 +47,7 @@ static __attribute__ ((unused)) const char rcsid[] =
#include "qw/msg_ucmd.h"
#include "bothdefs.h"
#include "qw/bothdefs.h"
#include "cl_cam.h"
#include "cl_ents.h"
#include "cl_main.h"

View file

@ -85,7 +85,7 @@ static __attribute__ ((unused)) const char rcsid[] =
#include "QF/vid.h"
#include "QF/gib.h"
#include "bothdefs.h"
#include "qw/bothdefs.h"
#include "buildnum.h"
#include "cl_cam.h"
#include "cl_chat.h"

View file

@ -61,7 +61,7 @@ static __attribute__ ((unused)) const char rcsid[] =
#include "QF/dstring.h"
#include "QF/gib.h"
#include "bothdefs.h"
#include "qw/bothdefs.h"
#include "cl_cam.h"
#include "cl_chat.h"
#include "cl_ents.h"

View file

@ -37,7 +37,7 @@ static __attribute__ ((unused)) const char rcsid[] =
#include "QF/cvar.h"
#include "QF/keys.h"
#include "bothdefs.h"
#include "qw/bothdefs.h"
#include "compat.h"
#include "cl_ents.h"
#include "cl_pred.h"

View file

@ -70,7 +70,7 @@ static __attribute__ ((unused)) const char rcsid[] =
#include "QF/sys.h"
#include "QF/va.h"
#include "bothdefs.h"
#include "qw/bothdefs.h"
#include "cl_main.h"
#include "cl_slist.h"
#include "client.h"

View file

@ -40,7 +40,7 @@ static __attribute__ ((unused)) const char rcsid[] =
#include "QF/screen.h"
#include "QF/vid.h"
#include "bothdefs.h"
#include "qw/bothdefs.h"
#include "cl_main.h"
#include "client.h"
#include "compat.h"

View file

@ -57,7 +57,7 @@ static __attribute__ ((unused)) const char rcsid[] =
#include "QF/vid.h"
#include "QF/view.h"
#include "bothdefs.h"
#include "qw/bothdefs.h"
#include "cl_cam.h"
#include "cl_parse.h"
#include "client.h"

View file

@ -52,7 +52,7 @@ static __attribute__ ((unused)) const char rcsid[] =
#include "QF/sys.h"
#include "QF/va.h"
#include "bothdefs.h"
#include "qw/bothdefs.h"
#include "compat.h"
#include "server.h"
#include "sv_demo.h"

View file

@ -79,7 +79,7 @@ static __attribute__ ((unused)) const char rcsid[] =
#include "QF/ver_check.h"
#include "QF/zone.h"
#include "bothdefs.h"
#include "qw/bothdefs.h"
#include "buildnum.h"
#include "compat.h"
#include "crudefile.h"

View file

@ -49,7 +49,7 @@ static __attribute__ ((unused)) const char rcsid[] =
#include "QF/sizebuf.h"
#include "bothdefs.h"
#include "qw/bothdefs.h"
#include "server.h"
#include "sv_demo.h"
#include "sv_progs.h"

View file

@ -49,7 +49,7 @@ static __attribute__ ((unused)) const char rcsid[] =
#include "QF/sound.h" // FIXME: DEFAULT_SOUND_PACKET_*
#include "QF/sys.h"
#include "bothdefs.h"
#include "qw/bothdefs.h"
#include "compat.h"
#include "server.h"
#include "sv_progs.h"

View file

@ -59,7 +59,7 @@ static __attribute__ ((unused)) const char rcsid[] =
#include "qw/msg_ucmd.h"
#include "qw/msg_ucmd.h"
#include "bothdefs.h"
#include "qw/bothdefs.h"
#include "compat.h"
#include "qw/pmove.h"
#include "server.h"

View file

@ -54,7 +54,7 @@ static __attribute__ ((unused)) const char rcsid[] =
#include "QF/skin.h"
#include "QF/gib.h"
#include "bothdefs.h"
#include "qw/bothdefs.h"
#include "cl_input.h"
#include "client.h"
#include "compat.h"