From 5fbb2830369df5b910d7ba7d00a37bfe8504b1c8 Mon Sep 17 00:00:00 2001 From: havoc Date: Thu, 4 Dec 2003 11:13:57 +0000 Subject: [PATCH] eradicated SZ_Print, thanks to Fuh for pointing out the sheer evil of this function found in nq, qw and q2... SZ_Print is a strcat onto a sizebuf - note that it could OVERWRITE THE SIZEBUF STRUCT if it is empty (but it was never empty where quake used it). git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@3688 d7cf8633-e32d-0410-b094-e92efae38249 --- cmd.c | 16 ++++++++-------- common.c | 14 +++----------- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/cmd.c b/cmd.c index d2b0b115..24c4c635 100644 --- a/cmd.c +++ b/cmd.c @@ -848,6 +848,7 @@ Sends the entire command line over to the server */ void Cmd_ForwardToServer (void) { + char *s; if (cls.state != ca_connected) { Con_Printf ("Can't \"%s\", not connected\n", Cmd_Argv(0)); @@ -857,16 +858,15 @@ void Cmd_ForwardToServer (void) if (cls.demoplayback) return; // not really connected - MSG_WriteByte (&cls.message, clc_stringcmd); + // LordHavoc: thanks to Fuh for bringing the pure evil of SZ_Print to my + // attention, it has been eradicated from here, its only (former) use in + // all of darkplaces. if (strcasecmp(Cmd_Argv(0), "cmd") != 0) - { - SZ_Print (&cls.message, Cmd_Argv(0)); - SZ_Print (&cls.message, " "); - } - if (Cmd_Argc() > 1) - SZ_Print (&cls.message, Cmd_Args()); + s = va("%s %s", Cmd_Argv(0), Cmd_Argc() > 1 ? Cmd_Args() : "\n"); else - SZ_Print (&cls.message, "\n"); + s = va("%s", Cmd_Argc() > 1 ? Cmd_Args() : "\n"); + MSG_WriteByte(&cls.message, clc_stringcmd); + SZ_Write(&cls.message, s, strlen(s) + 1); } diff --git a/common.c b/common.c index 518ad5b9..557f83e7 100644 --- a/common.c +++ b/common.c @@ -425,17 +425,9 @@ void SZ_Write (sizebuf_t *buf, const void *data, int length) memcpy (SZ_GetSpace(buf,length),data,length); } -void SZ_Print (sizebuf_t *buf, const char *data) -{ - int len; - len = strlen(data)+1; - -// byte * cast to keep VC++ happy - if (buf->data[buf->cursize-1]) - memcpy ((qbyte *)SZ_GetSpace(buf, len),data,len); // no trailing 0 - else - memcpy ((qbyte *)SZ_GetSpace(buf, len-1)-1,data,len); // write over trailing 0 -} +// LordHavoc: thanks to Fuh for bringing the pure evil of SZ_Print to my +// attention, it has been eradicated from here, its only (former) use in +// all of darkplaces. static char *hexchar = "0123456789ABCDEF"; void Com_HexDumpToConsole(const qbyte *data, int size) -- 2.39.2