Begin phase 2 :)

- link net_svc.c to the server
- add a NET_SVC_Print_Emit function
- make the server use the above instead of svc_print manually

It's actually kind of ugly, because of how backbuffers are
implimented.  Hopefully I'll be able to clean that up later.
This commit is contained in:
Adam Olsen 2001-11-02 07:32:19 +00:00
parent 7b4e5e69af
commit 56f1d6f49b
5 changed files with 35 additions and 8 deletions

View file

@ -199,6 +199,7 @@ typedef struct net_svc_deltapacketentities_s
entity_state_t deltas[MAX_PACKET_ENTITIES];
} net_svc_deltapacketentities_t;
net_status_t NET_SVC_Print_Emit (net_svc_print_t *block, sizebuf_t *buf);
net_status_t NET_SVC_Print_Parse (net_svc_print_t *block, msg_t *msg);
net_status_t NET_SVC_Damage_Parse (net_svc_damage_t *block, msg_t *msg);
net_status_t NET_SVC_ServerData_Parse (net_svc_serverdata_t *block, msg_t *msg);

View file

@ -52,7 +52,7 @@ libasm_la_SOURCES= $(asm_src)
noinst_LTLIBRARIES= libqfnet.la $(asm)
common_sources= buildnum.c com.c game.c msg_ucmd.c pmove.c pmovetst.c \
net_packetlog.c
net_packetlog.c net_svc.c
common_ldflags= -export-dynamic
@ -112,7 +112,7 @@ client_LIB_DEPS= libqfnet.la libasm.la $(qf_client_LIBS)
client_sources= cl_cam.c cl_cmd.c cl_cvar.c cl_demo.c cl_ents.c cl_input.c \
cl_main.c cl_misc.c cl_ngraph.c cl_parse.c cl_pred.c \
cl_screen.c cl_skin.c cl_slist.c cl_tent.c cl_view.c \
console.c locs.c net_svc.c sbar.c skin.c teamplay.c
console.c locs.c sbar.c skin.c teamplay.c
# Software-rendering clients

View file

@ -51,6 +51,15 @@ static const char rcsid[] =
#include "msg_ucmd.h" // FIXME
#include "net_svc.h"
net_status_t
NET_SVC_Print_Emit (net_svc_print_t *block, sizebuf_t *buf)
{
MSG_WriteByte (buf, block->level);
MSG_WriteString (buf, block->message);
return buf->overflowed;
}
net_status_t
NET_SVC_Print_Parse (net_svc_print_t *block, msg_t *msg)
{

View file

@ -76,6 +76,7 @@ static const char rcsid[] =
#include "crudefile.h"
#include "game.h"
#include "net.h"
#include "net_svc.h"
#include "pmove.h"
#include "server.h"
#include "sv_progs.h"
@ -260,11 +261,14 @@ SV_FinalMessage (const char *message)
{
client_t *cl;
int i;
net_svc_print_t block;
block.level = PRINT_HIGH;
block.message = message;
SZ_Clear (net_message->message);
MSG_WriteByte (net_message->message, svc_print);
MSG_WriteByte (net_message->message, PRINT_HIGH);
MSG_WriteString (net_message->message, message);
NET_SVC_Print_Emit (&block, net_message->message);
MSG_WriteByte (net_message->message, svc_disconnect);
for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++)

View file

@ -49,6 +49,7 @@ static const char rcsid[] =
#include "bothdefs.h"
#include "compat.h"
#include "net_svc.h"
#include "server.h"
#include "sv_progs.h"
@ -69,6 +70,7 @@ void
SV_FlushRedirect (void)
{
char send[8000 + 6];
net_svc_print_t block;
if (sv_redirected == RD_PACKET) {
send[0] = 0xff;
@ -80,10 +82,15 @@ SV_FlushRedirect (void)
NET_SendPacket (strlen (send) + 1, send, net_from);
} else if (sv_redirected == RD_CLIENT) {
block.level = PRINT_HIGH;
block.message = outputbuf;
ClientReliableWrite_Begin (host_client, svc_print,
strlen (outputbuf) + 3);
ClientReliableWrite_Byte (host_client, PRINT_HIGH);
ClientReliableWrite_String (host_client, outputbuf);
if (host_client->num_backbuf) {
NET_SVC_Print_Emit (&block, &host_client->backbuf);
ClientReliable_FinishWrite (host_client);
} else
NET_SVC_Print_Emit (&block, &host_client->netchan.message);
}
// clear it
outputbuf[0] = 0;
@ -220,6 +227,7 @@ SV_PrintToClient (client_t *cl, int level, const char *string)
unsigned char *b;
int size;
static int buffer_size;
net_svc_print_t block;
size = strlen (string) + 1;
if (size > buffer_size) {
@ -239,9 +247,14 @@ SV_PrintToClient (client_t *cl, int level, const char *string)
if (*b != 0xFF)
b++;
block.level = level;
block.message = buffer;
ClientReliableWrite_Begin (cl, svc_print, strlen (buffer) + 3);
ClientReliableWrite_Byte (cl, level);
ClientReliableWrite_String (cl, buffer);
if (cl->num_backbuf) {
NET_SVC_Print_Emit (&block, &cl->backbuf);
ClientReliable_FinishWrite (cl);
} else
NET_SVC_Print_Emit (&block, &cl->netchan.message);
}
/*