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
commit4a4b9d145d0a2a5fef2d563e736b21eb1fdaba3a (patch)
treec54e5e5cf2afb11a9b524ba116762c3a2c089ce5
parent9f4e45d333351d7cf5364b57aa0ffe29c618e035 (diff)
downloadopenttd-4a4b9d145d0a2a5fef2d563e736b21eb1fdaba3a.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;