From 63c804310c413bd4e0898a01e6884f1b212a5d1b Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Wed, 7 May 2003 04:24:50 +0000 Subject: [PATCH] more inline avoidance --- qw/source/sv_send.c | 190 ++++++++++++++++++++++---------------------- qw/source/sv_user.c | 38 ++++----- 2 files changed, 115 insertions(+), 113 deletions(-) diff --git a/qw/source/sv_send.c b/qw/source/sv_send.c index 07eaf28d9..66d4f37b8 100644 --- a/qw/source/sv_send.c +++ b/qw/source/sv_send.c @@ -200,16 +200,6 @@ SV_Print (const char *fmt, va_list args) } } -void -SV_Printf (const char *fmt, ...) -{ - va_list argptr; - - va_start (argptr, fmt); - SV_Print (fmt, argptr); - va_end (argptr); -} - /* EVENT MESSAGES */ static void @@ -244,91 +234,6 @@ SV_PrintToClient (client_t *cl, int level, const char *string) ClientReliableWrite_String (cl, buffer); } -/* - SV_ClientPrintf - - Sends text across to be displayed if the level passes -*/ -void -SV_ClientPrintf (int recorder, client_t *cl, int level, const char *fmt, ...) -{ - char string[1024]; - va_list argptr; - - if (level < cl->messagelevel) - return; - - va_start (argptr, fmt); - vsnprintf (string, sizeof (string), fmt, argptr); - va_end (argptr); - - if (recorder && sv.demorecording) { - DemoWrite_Begin (dem_single, cl - svs.clients, strlen (string) + 3); - MSG_WriteByte (&demo.dbuf->sz, svc_print); - MSG_WriteByte (&demo.dbuf->sz, level); - MSG_WriteString (&demo.dbuf->sz, string); - } - - SV_PrintToClient (cl, level, string); -} - -/* - SV_BroadcastPrintf - - Sends text to all active clients -*/ -void -SV_BroadcastPrintf (int level, const char *fmt, ...) -{ - char string[1024]; - client_t *cl; - int i; - va_list argptr; - - va_start (argptr, fmt); - vsnprintf (string, sizeof (string), fmt, argptr); - va_end (argptr); - - SV_Printf ("%s", string); // print to the console - - for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) { - if (level < cl->messagelevel) - continue; - if (cl->state < cs_zombie) - continue; - - SV_PrintToClient (cl, level, string); - } - - if (sv.demorecording) { - DemoWrite_Begin (dem_all, cl - svs.clients, strlen (string) + 3); - MSG_WriteByte (&demo.dbuf->sz, svc_print); - MSG_WriteByte (&demo.dbuf->sz, level); - MSG_WriteString (&demo.dbuf->sz, string); - } -} - -/* - SV_BroadcastCommand - - Sends text to all active clients -*/ -void -SV_BroadcastCommand (const char *fmt, ...) -{ - char string[1024]; - va_list argptr; - - if (!sv.state) - return; - va_start (argptr, fmt); - vsnprintf (string, sizeof (string), fmt, argptr); - va_end (argptr); - - MSG_WriteByte (&sv.reliable_datagram, svc_stufftext); - MSG_WriteString (&sv.reliable_datagram, string); -} - /* SV_Multicast @@ -1013,3 +918,98 @@ SV_SendMessagesToAll (void) SV_SendClientMessages (); } + +void +SV_Printf (const char *fmt, ...) +{ + va_list argptr; + + va_start (argptr, fmt); + SV_Print (fmt, argptr); + va_end (argptr); +} + +/* + SV_ClientPrintf + + Sends text across to be displayed if the level passes +*/ +void +SV_ClientPrintf (int recorder, client_t *cl, int level, const char *fmt, ...) +{ + char string[1024]; + va_list argptr; + + if (level < cl->messagelevel) + return; + + va_start (argptr, fmt); + vsnprintf (string, sizeof (string), fmt, argptr); + va_end (argptr); + + if (recorder && sv.demorecording) { + DemoWrite_Begin (dem_single, cl - svs.clients, strlen (string) + 3); + MSG_WriteByte (&demo.dbuf->sz, svc_print); + MSG_WriteByte (&demo.dbuf->sz, level); + MSG_WriteString (&demo.dbuf->sz, string); + } + + SV_PrintToClient (cl, level, string); +} + +/* + SV_BroadcastPrintf + + Sends text to all active clients +*/ +void +SV_BroadcastPrintf (int level, const char *fmt, ...) +{ + char string[1024]; + client_t *cl; + int i; + va_list argptr; + + va_start (argptr, fmt); + vsnprintf (string, sizeof (string), fmt, argptr); + va_end (argptr); + + SV_Printf ("%s", string); // print to the console + + for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) { + if (level < cl->messagelevel) + continue; + if (cl->state < cs_zombie) + continue; + + SV_PrintToClient (cl, level, string); + } + + if (sv.demorecording) { + DemoWrite_Begin (dem_all, cl - svs.clients, strlen (string) + 3); + MSG_WriteByte (&demo.dbuf->sz, svc_print); + MSG_WriteByte (&demo.dbuf->sz, level); + MSG_WriteString (&demo.dbuf->sz, string); + } +} + +/* + SV_BroadcastCommand + + Sends text to all active clients +*/ +void +SV_BroadcastCommand (const char *fmt, ...) +{ + char string[1024]; + va_list argptr; + + if (!sv.state) + return; + va_start (argptr, fmt); + vsnprintf (string, sizeof (string), fmt, argptr); + va_end (argptr); + + MSG_WriteByte (&sv.reliable_datagram, svc_stufftext); + MSG_WriteString (&sv.reliable_datagram, string); +} diff --git a/qw/source/sv_user.c b/qw/source/sv_user.c index ef937ae59..9e6355bf2 100644 --- a/qw/source/sv_user.c +++ b/qw/source/sv_user.c @@ -95,6 +95,8 @@ cvar_t *sv_timekick_interval; cvar_t *sv_timecheck_fuzz; cvar_t *sv_timecheck_decay; +static void OutofBandPrintf (netadr_t where, const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); + // USER STRINGCMD EXECUTION host_client and sv_player will be valid. /* @@ -585,24 +587,6 @@ SV_NextDownload_f (void *unused) } -static void -OutofBandPrintf (netadr_t where, const char *fmt, ...) -{ - char send[1024]; - va_list argptr; - - send[0] = 0xff; - send[1] = 0xff; - send[2] = 0xff; - send[3] = 0xff; - send[4] = A2C_PRINT; - va_start (argptr, fmt); - vsnprintf (send + 5, sizeof (send - 5), fmt, argptr); - va_end (argptr); - - Netchan_SendPacket (strlen (send) + 1, send, where); -} - static void SV_NextUpload (void) { @@ -1878,3 +1862,21 @@ SV_UserInit (void) sv_kickfake = Cvar_Get ("sv_kickfake", "1", CVAR_NONE, NULL, "Kick users sending to send fake talk messages"); } + +static void +OutofBandPrintf (netadr_t where, const char *fmt, ...) +{ + char send[1024]; + va_list argptr; + + send[0] = 0xff; + send[1] = 0xff; + send[2] = 0xff; + send[3] = 0xff; + send[4] = A2C_PRINT; + va_start (argptr, fmt); + vsnprintf (send + 5, sizeof (send - 5), fmt, argptr); + va_end (argptr); + + Netchan_SendPacket (strlen (send) + 1, send, where); +}