prespawn stuff seems to be done (evil hack for signon buffers, but hey:)

This commit is contained in:
Bill Currie 2005-05-08 09:10:43 +00:00
parent fc18658e86
commit 9683888e70
3 changed files with 49 additions and 7 deletions

View file

@ -58,6 +58,7 @@ typedef struct frame_s {
#define MAX_SV_PLAYERS 32 #define MAX_SV_PLAYERS 32
#define MAX_SV_ENTITIES 512 #define MAX_SV_ENTITIES 512
#define MAX_SIGNON_BUFFERS 8
typedef struct server_s { typedef struct server_s {
struct server_s *next; struct server_s *next;
@ -65,6 +66,7 @@ typedef struct server_s {
const char *address; const char *address;
int qport; int qport;
int connected; int connected;
int signon;
struct connection_s *con; struct connection_s *con;
netadr_t adr; netadr_t adr;
netchan_t netchan; netchan_t netchan;
@ -82,6 +84,9 @@ typedef struct server_s {
char *modellist[MAX_MODELS + 1]; char *modellist[MAX_MODELS + 1];
char *lightstyles[MAX_LIGHTSTYLES]; char *lightstyles[MAX_LIGHTSTYLES];
int playermodel; int playermodel;
int num_signon_buffers;
int signon_buffer_size[MAX_SIGNON_BUFFERS];
byte signon_buffers[MAX_SIGNON_BUFFERS][MAX_DATAGRAM];
struct client_s *clients; struct client_s *clients;

View file

@ -161,6 +161,8 @@ cl_prespawn_f (client_t *cl, void *unused)
{ {
const char *cmd; const char *cmd;
server_t *sv = cl->server; server_t *sv = cl->server;
int buf, size;
sizebuf_t *msg;
if (!cl->server) if (!cl->server)
return; return;
@ -169,9 +171,18 @@ cl_prespawn_f (client_t *cl, void *unused)
Client_New (cl); Client_New (cl);
return; return;
} }
buf = atoi (Cmd_Argv (2));
if (buf >= sv->num_signon_buffers)
buf = 0;
if (buf == sv->num_signon_buffers - 1)
cmd = va ("cmd spawn %i 0\n", cl->server->spawncount); cmd = va ("cmd spawn %i 0\n", cl->server->spawncount);
MSG_ReliableWrite_Begin (&cl->backbuf, svc_stufftext, strlen (cmd) + 2); else
MSG_ReliableWrite_String (&cl->backbuf, cmd); cmd = va ("cmd prespawn %i %i\n", cl->server->spawncount, buf + 1);
size = sv->signon_buffer_size[buf] + 1 + strlen (cmd) + 1;
msg = MSG_ReliableCheckBlock (&cl->backbuf, size);
SZ_Write (msg, sv->signon_buffers[buf], sv->signon_buffer_size[buf]);
MSG_WriteByte (msg, svc_stufftext);
MSG_WriteString (msg, cmd);
} }
static void static void
@ -728,11 +739,11 @@ cl_send_messages (client_t *cl)
write_player (31, &cl->state, cl->server, &msg); write_player (31, &cl->state, cl->server, &msg);
MSG_WriteByte (&msg, svc_packetentities); MSG_WriteByte (&msg, svc_packetentities);
MSG_WriteShort (&msg, 0); MSG_WriteShort (&msg, 0);
}
if (cl->datagram.cursize) { if (cl->datagram.cursize) {
SZ_Write (&msg, cl->datagram.data, cl->datagram.cursize); SZ_Write (&msg, cl->datagram.data, cl->datagram.cursize);
SZ_Clear (&cl->datagram); SZ_Clear (&cl->datagram);
} }
}
Netchan_Transmit (&cl->netchan, msg.cursize, msg.data); Netchan_Transmit (&cl->netchan, msg.cursize, msg.data);
} }

View file

@ -184,6 +184,9 @@ static void
sv_cmd_f (server_t *sv) sv_cmd_f (server_t *sv)
{ {
if (Cmd_Argc () > 1) { if (Cmd_Argc () > 1) {
sv->signon = 0;
if (strcmp (Cmd_Argv (1), "prespawn") == 0)
sv->signon = 1;
MSG_WriteByte (&sv->netchan.message, qtv_stringcmd); MSG_WriteByte (&sv->netchan.message, qtv_stringcmd);
SZ_Print (&sv->netchan.message, Cmd_Args (1)); SZ_Print (&sv->netchan.message, Cmd_Args (1));
} }
@ -797,12 +800,28 @@ sv_lightstyle (server_t *sv, qmsg_t *msg)
sv->lightstyles[ind] = strdup (style); sv->lightstyles[ind] = strdup (style);
} }
static void
save_signon (server_t *sv, qmsg_t *msg, int start)
{
int size = msg->readcount - start;
byte *buf = msg->message->data + start;
if (!size)
return;
sv->signon_buffer_size[sv->num_signon_buffers] = size;
memcpy (sv->signon_buffers[sv->num_signon_buffers], buf, size);
sv->num_signon_buffers++;
}
void void
sv_parse (server_t *sv, qmsg_t *msg, int reliable) sv_parse (server_t *sv, qmsg_t *msg, int reliable)
{ {
int svc; int svc;
vec3_t v; vec3_t v;
player_t *pl; player_t *pl;
int start = msg->readcount;
int signon_saved = 0;
while (1) { while (1) {
svc = MSG_ReadByte (msg); svc = MSG_ReadByte (msg);
@ -938,6 +957,10 @@ sv_parse (server_t *sv, qmsg_t *msg, int reliable)
sv_serverdata (sv, msg); sv_serverdata (sv, msg);
break; break;
case svc_stufftext: case svc_stufftext:
if (sv->signon && !signon_saved) {
save_signon (sv, msg, start);
signon_saved = 1;
}
sv_stringcmd (sv, msg); sv_stringcmd (sv, msg);
break; break;
@ -967,4 +990,7 @@ sv_parse (server_t *sv, qmsg_t *msg, int reliable)
break; break;
} }
} }
if (sv->signon && !signon_saved) {
save_signon (sv, msg, start);
}
} }