From a63c1534cc8d8eb5d343a80a2805a2e9e6cd5358 Mon Sep 17 00:00:00 2001 From: /dev/humancontroller Date: Sun, 13 Jul 2014 18:57:22 +0200 Subject: prep for size_t change from int to unsigned int --- src/cgame/cg_main.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c index 4b7b1758..6699fa1f 100644 --- a/src/cgame/cg_main.c +++ b/src/cgame/cg_main.c @@ -599,10 +599,9 @@ void CG_RemoveNotifyLine( void ) cg.consoleText[ i ] = cg.consoleText[ i + offset ]; //pop up the first consoleLine + cg.numConsoleLines--; for( i = 0; i < cg.numConsoleLines; i++ ) cg.consoleLines[ i ] = cg.consoleLines[ i + 1 ]; - - cg.numConsoleLines--; } /* @@ -626,18 +625,22 @@ void CG_AddNotifyText( void ) bufferLen = strlen( buffer ); textLen = strlen( cg.consoleText ); - + // Ignore console messages that were just printed if( cg_noPrintDuplicate.integer && textLen >= bufferLen && !strcmp( cg.consoleText + textLen - bufferLen, buffer ) ) return; - + if( cg.numConsoleLines == MAX_CONSOLE_LINES ) + { CG_RemoveNotifyLine( ); + textLen = strlen( cg.consoleText ); + } - Q_strcat( cg.consoleText, MAX_CONSOLE_TEXT, buffer ); + Q_strncpyz( cg.consoleText + textLen, buffer, MAX_CONSOLE_TEXT - textLen ); cg.consoleLines[ cg.numConsoleLines ].time = cg.time; - cg.consoleLines[ cg.numConsoleLines ].length = bufferLen; + cg.consoleLines[ cg.numConsoleLines ].length = + MIN( bufferLen, MAX_CONSOLE_TEXT - textLen - 1 ); cg.numConsoleLines++; } -- cgit