[quake3-commits] r1805 - trunk/code/client

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Sun Dec 19 12:35:01 EST 2010


Author: tma
Date: 2010-12-19 12:35:01 -0500 (Sun, 19 Dec 2010)
New Revision: 1805

Modified:
   trunk/code/client/cl_keys.c
Log:
* (bug #4800) Don't prepend a slash to console commands if they're empty
* (bug #4800) Limit console input length such that there is always room for a
  leading slash


Modified: trunk/code/client/cl_keys.c
===================================================================
--- trunk/code/client/cl_keys.c	2010-12-19 16:34:35 UTC (rev 1804)
+++ trunk/code/client/cl_keys.c	2010-12-19 17:35:01 UTC (rev 1805)
@@ -535,12 +535,14 @@
 	}
 
 	if ( key_overstrikeMode ) {	
-		if ( edit->cursor == MAX_EDIT_LINE - 1 )
+		// - 2 to leave room for the leading slash and trailing \0
+		if ( edit->cursor == MAX_EDIT_LINE - 2 )
 			return;
 		edit->buffer[edit->cursor] = ch;
 		edit->cursor++;
 	} else {	// insert mode
-		if ( len == MAX_EDIT_LINE - 1 ) {
+		// - 2 to leave room for the leading slash and trailing \0
+		if ( len == MAX_EDIT_LINE - 2 ) {
 			return; // all full
 		}
 		memmove( edit->buffer + edit->cursor + 1, 
@@ -584,8 +586,10 @@
 	// enter finishes the line
 	if ( key == K_ENTER || key == K_KP_ENTER ) {
 		// if not in the game explicitly prepend a slash if needed
-		if ( cls.state != CA_ACTIVE && g_consoleField.buffer[0] != '\\' 
-			&& g_consoleField.buffer[0] != '/' ) {
+		if ( cls.state != CA_ACTIVE &&
+				g_consoleField.buffer[0] &&
+				g_consoleField.buffer[0] != '\\' &&
+				g_consoleField.buffer[0] != '/' ) {
 			char	temp[MAX_EDIT_LINE-1];
 
 			Q_strncpyz( temp, g_consoleField.buffer, sizeof( temp ) );



More information about the quake3-commits mailing list