summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortron <tron@openttd.org>2005-02-18 08:36:11 +0000
committertron <tron@openttd.org>2005-02-18 08:36:11 +0000
commit1804109f4b622f9ac42ec0b3d956d7a475dc0000 (patch)
treec54e5e5cf2afb11a9b524ba116762c3a2c089ce5
parent4118a32cfff50e6a188a4ede34d2e2cbb2b5e493 (diff)
downloadopenttd-1804109f4b622f9ac42ec0b3d956d7a475dc0000.tar.xz
(svn r1886) Correctly process the last line of a script, even if it's not newline terminated. Also print an error message if something goes wrong while reading from the script file
-rw-r--r--console_cmds.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/console_cmds.c b/console_cmds.c
index ab0364bfd..aea87fa40 100644
--- a/console_cmds.c
+++ b/console_cmds.c
@@ -609,10 +609,12 @@ DEF_CONSOLE_CMD(ConExec)
_script_running = true;
- fgets(cmd, sizeof(cmd), _script_file);
- while (!feof(_script_file) && _script_running) {
+ while (_script_running && fgets(cmd, sizeof(cmd), _script_file) != NULL) {
IConsoleCmdExec(cmd);
- fgets(cmd, sizeof(cmd), _script_file);
+ }
+
+ if (ferror(_script_file)) {
+ IConsoleError("Encountered errror while trying to read from script file");
}
_script_running = false;