From d74e82fe7fdc467dbebab704a7ace2de57395147 Mon Sep 17 00:00:00 2001 From: Arnaud Boutonné Date: Thu, 2 Sep 2010 10:52:29 +0000 Subject: HUGO: Fix loading of config file during game init Add a check on CONFIG.DAT size in order to avoid loading crap into the _config structure during the initialization of the engine. The game no longer starts in turbo & mute mode svn-id: r52493 --- engines/hugo/file.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'engines/hugo/file.cpp') diff --git a/engines/hugo/file.cpp b/engines/hugo/file.cpp index 172b1687cb..150ad2d2b8 100644 --- a/engines/hugo/file.cpp +++ b/engines/hugo/file.cpp @@ -826,8 +826,12 @@ void FileManager::readConfig() { sprintf(path, "%s%s", _vm.getGameStatus().path, CONFIGFILE); if (f.open(path)) { // If config format changed, ignore it and use defaults - if (f.read(&_config, sizeof(_config)) != sizeof(_config)) - _config = tmpConfig; + if (f.size() != sizeof(_config)) { + warning("Incompatible %s: file size:%d expected size: %d. Skipping loading.", CONFIGFILE, f.size(), sizeof(_config)); + } else { + if (f.read(&_config, sizeof(_config)) != sizeof(_config)) + _config = tmpConfig; + } f.close(); } -- cgit v1.2.3