I think I finally got the protocol side of map changes right

"pause" qtv recorders while changing maps
send changing/reconnect via the qtv extensions
This commit is contained in:
Bill Currie 2010-01-13 06:50:44 +00:00 committed by Jeff Teunissen
parent d53190f345
commit 70cc48826c
10 changed files with 82 additions and 18 deletions

View file

@ -519,9 +519,9 @@ server_run (server_t *sv)
static byte delta_msg[2] = {qtv_delta};
static byte nop_msg[1] = {qtv_nop};
sv->next_run = realtime + 0.03;
if (sv->connected > 1) {
int frame = (sv->netchan.outgoing_sequence) & UPDATE_MASK;
sv->next_run = realtime + 0.03;
sv->frames[frame].delta_sequence = sv->delta;
if (sv->validsequence && sv->delta != -1) {
delta_msg[1] = sv->delta;
@ -532,7 +532,8 @@ server_run (server_t *sv)
return;
}
}
Netchan_Transmit (&sv->netchan, 0, 0);
if (sv->netchan.message.cursize)
Netchan_Transmit (&sv->netchan, 0, 0);
}
void

View file

@ -219,6 +219,8 @@ sv_changing_f (server_t *sv)
sv->connected = 1;
sv->num_signon_buffers = 0;
qtv_printf ("Changing map...\n");
MSG_WriteByte (&sv->netchan.message, qtv_nop);
sv->next_run = realtime;
}
static void
@ -229,6 +231,7 @@ sv_reconnect_f (server_t *sv)
qtv_printf ("Reconnecting...\n");
MSG_WriteByte (msg, qtv_stringcmd);
MSG_WriteString (msg, "new");
sv->next_run = realtime;
}
typedef struct {

View file

@ -38,5 +38,7 @@ int SV_qtvPacket (int qport);
void SV_qtvCheckTimeouts (void);
void SV_qtvSendMessages (void);
void SV_qtvFinalMessage (const char *message);
void SV_qtvChanging (void);
void SV_qtvReconnect (void);
#endif//__sv_qtv_h

View file

@ -45,6 +45,8 @@ void SVR_RemoveUser (recorder_t *r);
struct sizebuf_s *SVR_WriteBegin (byte type, int to, int size);
struct sizebuf_s *SVR_Datagram (void);
void SVR_ForceFrame (void);
void SVR_Pause (recorder_t *r);
void SVR_Continue (recorder_t *r);
void SVR_SetDelta (recorder_t *r, int delta, int in_frame);
void SVR_SendMessages (void);
int SVR_NumRecorders (void);

View file

@ -797,7 +797,7 @@ CL_NextDemo (void)
/*
CL_Changing_f
Just sent as a hint to the client that they should
Sent as just a hint to the client that they should
drop to full console
*/
static void

View file

@ -57,6 +57,7 @@ static __attribute__ ((used)) const char rcsid[] =
#include "server.h"
#include "sv_demo.h"
#include "sv_progs.h"
#include "sv_qtv.h"
#include "sv_recorder.h"
qboolean sv_allow_cheats;
@ -465,12 +466,14 @@ SV_Map_f (void)
if (sv.recording_demo)
SV_Stop (0);
SV_qtvChanging ();
SV_BroadcastCommand ("changing\n");
SV_SendMessagesToAll ();
dstring_copystr (curlevel, level);
SV_SpawnServer (level);
SV_qtvReconnect ();
SV_BroadcastCommand ("reconnect\n");
}

View file

@ -1774,7 +1774,8 @@ SV_ReadPackets (void)
}
if (net_message->message->cursize < 11) {
SV_Printf ("%s: Runt packet\n", NET_AdrToString (net_from));
SV_Printf ("%s: Runt packet: %d\n", NET_AdrToString (net_from),
net_message->message->cursize);
continue;
}
// read the qport out of the message so we can fix up

View file

@ -3,10 +3,10 @@
#DESCRIPTION#
Copyright (C) 2004 #AUTHOR#
Copyright (C) 2004 Bill Currie <bill@taniwha.org>
Author: #AUTHOR#
Date: #DATE#
Author: Bill Currie
Date: 2004/3/4
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
@ -281,6 +281,8 @@ qtv_begin_f (sv_qtv_t *proxy)
if (!proxy->recorder)
proxy->recorder = SVR_AddUser (qtv_write, qtv_frame, 0, qtv_finish, 0,
proxy);
else
SVR_Continue (proxy->recorder);
proxy->begun = 1;
}
@ -525,3 +527,45 @@ SV_qtvFinalMessage (const char *message)
net_message->message->data);
}
}
void
SV_qtvChanging (void)
{
sv_qtv_t *proxy;
int i, len;
sizebuf_t *buf;
const char *msg;
msg = va ("%cchanging", qtv_stringcmd);
len = strlen (msg) + 1;
for (i = 0; i < MAX_PROXIES; i++) {
proxy = proxies + i;
if (!proxy->info)
continue;
SVR_Pause (proxy->recorder);
buf = MSG_ReliableCheckBlock (&proxy->backbuf, len);
MSG_ReliableWrite_SZ (&proxy->backbuf, msg, len);
}
SV_qtvSendMessages ();
}
void
SV_qtvReconnect (void)
{
sv_qtv_t *proxy;
int i, len;
sizebuf_t *buf;
const char *msg;
msg = va ("%creconnect", qtv_stringcmd);
len = strlen (msg) + 1;
for (i = 0; i < MAX_PROXIES; i++) {
proxy = proxies + i;
if (!proxy->info)
continue;
buf = MSG_ReliableCheckBlock (&proxy->backbuf, len);
MSG_ReliableWrite_SZ (&proxy->backbuf, msg, len);
}
}

View file

@ -110,6 +110,7 @@ struct recorder_s {
void (*end_frame)(recorder_t *, void *);
void (*finish)(void *, sizebuf_t *);
void *user;
int paused;
delta_t delta;
entity_state_t entities[UPDATE_BACKUP][MAX_DEMO_PACKET_ENTITIES];
plent_state_t players[UPDATE_BACKUP][MAX_CLIENTS];
@ -458,8 +459,11 @@ write_packet (void)
write_to_msg (0, 0, time, &msg);
for (r = sv.recorders; r; r = r->next)
for (r = sv.recorders; r; r = r->next) {
if (r->paused)
continue;
r->write (r->user, &msg, 1);
}
rec.dbuf = &rec.frames[rec.parsecount & DEMO_FRAMES_MASK].buf;
rec.dbuf->sz.maxsize = MAXSIZE + rec.dbuf->bufsize;
@ -602,6 +606,8 @@ SVR_SendMessages (void)
// this will include clients, a packetentities, and
// possibly a nails update
for (r = sv.recorders; r; r = r->next) {
if (r->paused)
continue;
write_datagram (r);
if (r->end_frame)
r->end_frame (r, r->user);
@ -613,6 +619,18 @@ SVR_SendMessages (void)
rec.lastwritten++;
}
void
SVR_Pause (recorder_t *r)
{
r->paused = 1;
}
void
SVR_Continue (recorder_t *r)
{
r->paused = 0;
}
void
SVR_SetDelta (recorder_t *r, int delta, int in_frame)
{

View file

@ -53,7 +53,6 @@ static __attribute__ ((used)) const char rcsid[] =
#include "compat.h"
#include "server.h"
#include "sv_progs.h"
#include "sv_qtv.h"
#include "sv_recorder.h"
#define CHAN_AUTO 0
@ -822,21 +821,12 @@ SV_SendMessagesToAll (void)
{
client_t *c;
int i;
double demo_start, demo_end;
for (i = 0, c = svs.clients; i < MAX_CLIENTS; i++, c++)
if (c->state < cs_zombie) // FIXME: should this send to only active?
c->send_message = true;
SV_SendClientMessages ();
demo_start = Sys_DoubleTime ();
if (sv.recorders)
SVR_SendMessages ();
demo_end = Sys_DoubleTime ();
svs.stats.demo += demo_end - demo_start;
SV_qtvSendMessages ();
}
void