Changeset - r4891:548da56c10b9
[Not reviewed]
master
0 1 0
peter1138 - 18 years ago 2006-10-19 09:39:29
peter1138@openttd.org
(svn r6835) - Fix: Pressing ^D (EOF) at a dedicated console caused it to repeat the last command, instead of doing nothing.
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
video/dedicated_v.c
Show inline comments
 
@@ -174,49 +174,49 @@ static uint32 GetTime(void)
 

	
 
#else
 

	
 
static bool InputWaiting(void)
 
{
 
	return WaitForSingleObject(_hInputReady, 1) == WAIT_OBJECT_0;
 
}
 

	
 
static uint32 GetTime(void)
 
{
 
	return GetTickCount();
 
}
 

	
 
#endif
 

	
 
static void DedicatedHandleKeyInput(void)
 
{
 
	static char input_line[200] = "";
 

	
 
	if (!InputWaiting()) return;
 

	
 
	if (_exit_game) return;
 

	
 
#if defined(UNIX) || defined(__OS2__)
 
	fgets(input_line, lengthof(input_line), stdin);
 
	if (fgets(input_line, lengthof(input_line), stdin) == NULL) return;
 
#else
 
	/* Handle console input, and singal console thread, it can accept input again */
 
	strncpy(input_line, _win_console_thread_buffer, lengthof(input_line));
 
	SetEvent(_hWaitForInputHandling);
 
#endif
 

	
 
	/* XXX - strtok() does not 'forget' \n\r if it is the first character! */
 
	strtok(input_line, "\r\n"); // Forget about the final \n (or \r)
 
	{ /* Remove any special control characters */
 
		uint i;
 
		for (i = 0; i < lengthof(input_line); i++) {
 
			if (input_line[i] == '\n' || input_line[i] == '\r') // cut missed beginning '\0'
 
				input_line[i] = '\0';
 

	
 
			if (input_line[i] == '\0')
 
				break;
 

	
 
			if (!IS_INT_INSIDE(input_line[i], ' ', 256))
 
				input_line[i] = ' ';
 
		}
 
	}
 

	
 
	IConsoleCmdExec(input_line); // execute command
 
}
0 comments (0 inline, 0 general)