mirror of
https://github.com/UberGames/ioef.git
synced 2025-02-17 17:31:08 +00:00
* (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
This commit is contained in:
parent
c314f29290
commit
c081b9c1fd
1 changed files with 8 additions and 4 deletions
|
@ -535,12 +535,14 @@ void Field_CharEvent( field_t *edit, int ch ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( key_overstrikeMode ) {
|
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;
|
return;
|
||||||
edit->buffer[edit->cursor] = ch;
|
edit->buffer[edit->cursor] = ch;
|
||||||
edit->cursor++;
|
edit->cursor++;
|
||||||
} else { // insert mode
|
} 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
|
return; // all full
|
||||||
}
|
}
|
||||||
memmove( edit->buffer + edit->cursor + 1,
|
memmove( edit->buffer + edit->cursor + 1,
|
||||||
|
@ -584,8 +586,10 @@ void Console_Key (int key) {
|
||||||
// enter finishes the line
|
// enter finishes the line
|
||||||
if ( key == K_ENTER || key == K_KP_ENTER ) {
|
if ( key == K_ENTER || key == K_KP_ENTER ) {
|
||||||
// if not in the game explicitly prepend a slash if needed
|
// if not in the game explicitly prepend a slash if needed
|
||||||
if ( cls.state != CA_ACTIVE && g_consoleField.buffer[0] != '\\'
|
if ( cls.state != CA_ACTIVE &&
|
||||||
&& g_consoleField.buffer[0] != '/' ) {
|
g_consoleField.buffer[0] &&
|
||||||
|
g_consoleField.buffer[0] != '\\' &&
|
||||||
|
g_consoleField.buffer[0] != '/' ) {
|
||||||
char temp[MAX_EDIT_LINE-1];
|
char temp[MAX_EDIT_LINE-1];
|
||||||
|
|
||||||
Q_strncpyz( temp, g_consoleField.buffer, sizeof( temp ) );
|
Q_strncpyz( temp, g_consoleField.buffer, sizeof( temp ) );
|
||||||
|
|
Loading…
Reference in a new issue