changeset 15377:bee601f0754c draft

(svn r20020) -Codechange: _script_file is used in only one function.
author alberth <alberth@openttd.org>
date Sat, 26 Jun 2010 15:04:57 +0000
parents 9c8bdca196f7
children ee826a793259
files src/console_cmds.cpp
diffstat 1 files changed, 5 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/console_cmds.cpp
+++ b/src/console_cmds.cpp
@@ -42,7 +42,6 @@
 #endif /* ENABLE_NETWORK */
 
 /* scriptfile handling */
-static FILE *_script_file;
 static bool _script_running;
 
 /* console command defines */
@@ -871,16 +870,16 @@
 
 	if (argc < 2) return false;
 
-	_script_file = FioFOpenFile(argv[1], "r", BASE_DIR);
+	FILE *script_file = FioFOpenFile(argv[1], "r", BASE_DIR);
 
-	if (_script_file == NULL) {
+	if (script_file == NULL) {
 		if (argc == 2 || atoi(argv[2]) != 0) IConsoleError("script file not found");
 		return true;
 	}
 
 	_script_running = true;
 
-	while (_script_running && fgets(cmdline, sizeof(cmdline), _script_file) != NULL) {
+	while (_script_running && fgets(cmdline, sizeof(cmdline), script_file) != NULL) {
 		/* Remove newline characters from the executing script */
 		for (cmdptr = cmdline; *cmdptr != '\0'; cmdptr++) {
 			if (*cmdptr == '\n' || *cmdptr == '\r') {
@@ -891,11 +890,11 @@
 		IConsoleCmdExec(cmdline);
 	}
 
-	if (ferror(_script_file))
+	if (ferror(script_file))
 		IConsoleError("Encountered errror while trying to read from script file");
 
 	_script_running = false;
-	FioFCloseFile(_script_file);
+	FioFCloseFile(script_file);
 	return true;
 }