From 13a5e5812af635477626de6a13f54ed8b8e4afa5 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 15 Jul 2012 02:14:37 +0300 Subject: TEENAGENT: Unpack teenagent.dat and remove the engine's zlib dependency This addresses bug #3539822 - "TEENAGENT: Not working without zlib" --- engines/teenagent/resources.cpp | 46 ++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 17 deletions(-) (limited to 'engines/teenagent/resources.cpp') diff --git a/engines/teenagent/resources.cpp b/engines/teenagent/resources.cpp index 597ca670c0..74ebae9c9b 100644 --- a/engines/teenagent/resources.cpp +++ b/engines/teenagent/resources.cpp @@ -22,7 +22,6 @@ #include "teenagent/resources.h" #include "teenagent/teenagent.h" #include "common/textconsole.h" -#include "common/zlib.h" namespace TeenAgent { @@ -69,24 +68,37 @@ bool Resources::loadArchives(const ADGameDescription *gd) { warning("%s", errorMessage.c_str()); return false; } - Common::SeekableReadStream *dat = Common::wrapCompressedReadStream(dat_file); - cseg.read(dat, 0xb3b0); - dseg.read(dat, 0xe790); - eseg.read(dat, 0x8be2); - - delete dat; - - { - FilePack varia; - varia.open("varia.res"); - font7.load(varia, 7); - font7.width_pack = 1; - font7.height = 11; - font8.load(varia, 8); - font8.height = 31; - varia.close(); + + // Check if teenagent.dat is compressed (older versions of the file) + uint16 header = dat_file->readUint16BE(); + bool isCompressed = (header == 0x1F8B || + ((header & 0x0F00) == 0x0800 && + header % 31 == 0)); + dat_file->seek(-2, SEEK_CUR); + + if (isCompressed) { + delete dat_file; + Common::String errorMessage = "The teenagent.dat file is compressed. Please decompress it"; + GUIErrorMessage(errorMessage); + warning("%s", errorMessage.c_str()); + return false; } + cseg.read(dat_file, 0xb3b0); + dseg.read(dat_file, 0xe790); + eseg.read(dat_file, 0x8be2); + + delete dat_file; + + FilePack varia; + varia.open("varia.res"); + font7.load(varia, 7); + font7.width_pack = 1; + font7.height = 11; + font8.load(varia, 8); + font8.height = 31; + varia.close(); + off.open("off.res"); on.open("on.res"); ons.open("ons.res"); -- cgit v1.2.3 From c54f95ee86b001676fbdc44aa5e1c74191fae459 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 15 Jul 2012 02:27:51 +0300 Subject: TEENAGENT: Readd the zlib code, to maintain backwards compatibility --- engines/teenagent/resources.cpp | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) (limited to 'engines/teenagent/resources.cpp') diff --git a/engines/teenagent/resources.cpp b/engines/teenagent/resources.cpp index 74ebae9c9b..49a429d5b7 100644 --- a/engines/teenagent/resources.cpp +++ b/engines/teenagent/resources.cpp @@ -22,6 +22,7 @@ #include "teenagent/resources.h" #include "teenagent/teenagent.h" #include "common/textconsole.h" +#include "common/zlib.h" namespace TeenAgent { @@ -69,26 +70,15 @@ bool Resources::loadArchives(const ADGameDescription *gd) { return false; } - // Check if teenagent.dat is compressed (older versions of the file) - uint16 header = dat_file->readUint16BE(); - bool isCompressed = (header == 0x1F8B || - ((header & 0x0F00) == 0x0800 && - header % 31 == 0)); - dat_file->seek(-2, SEEK_CUR); - - if (isCompressed) { - delete dat_file; - Common::String errorMessage = "The teenagent.dat file is compressed. Please decompress it"; - GUIErrorMessage(errorMessage); - warning("%s", errorMessage.c_str()); - return false; - } - - cseg.read(dat_file, 0xb3b0); - dseg.read(dat_file, 0xe790); - eseg.read(dat_file, 0x8be2); + // teenagent.dat used to be compressed with zlib compression. The usage of + // zlib here is no longer needed, and it's maintained only for backwards + // compatibility. + Common::SeekableReadStream *dat = Common::wrapCompressedReadStream(dat_file); + cseg.read(dat, 0xb3b0); + dseg.read(dat, 0xe790); + eseg.read(dat, 0x8be2); - delete dat_file; + delete dat; FilePack varia; varia.open("varia.res"); -- cgit v1.2.3 From f4e395b4a185ac4aabd4e0a19c7e00682365d893 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 15 Jul 2012 02:47:06 +0300 Subject: TEENAGENT: Show a verbose warning when a compressed data file is used and zlib hasn't been included in the executable --- engines/teenagent/resources.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'engines/teenagent/resources.cpp') diff --git a/engines/teenagent/resources.cpp b/engines/teenagent/resources.cpp index 49a429d5b7..0dc6ea2f3c 100644 --- a/engines/teenagent/resources.cpp +++ b/engines/teenagent/resources.cpp @@ -74,10 +74,27 @@ bool Resources::loadArchives(const ADGameDescription *gd) { // zlib here is no longer needed, and it's maintained only for backwards // compatibility. Common::SeekableReadStream *dat = Common::wrapCompressedReadStream(dat_file); + +#if !defined(USE_ZLIB) + uint16 header = dat->readUint16BE(); + bool isCompressed = (header == 0x1F8B || + ((header & 0x0F00) == 0x0800 && + header % 31 == 0)); + dat->seek(-2, SEEK_CUR); + + if (isCompressed) { + // teenagent.dat is compressed, but zlib hasn't been compiled in + delete dat; + Common::String errorMessage = "The teenagent.dat file is compressed and zlib hasn't been included in this executable. Please decompress it"; + GUIErrorMessage(errorMessage); + warning("%s", errorMessage.c_str()); + return false; + } +#endif + cseg.read(dat, 0xb3b0); dseg.read(dat, 0xe790); eseg.read(dat, 0x8be2); - delete dat; FilePack varia; -- cgit v1.2.3 From a97f4466fdf7320cf184d0d4974670b4b4e4bee4 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 15 Jul 2012 03:07:01 +0300 Subject: TEENAGENT: Add translatable strings in resources.cpp --- engines/teenagent/resources.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'engines/teenagent/resources.cpp') diff --git a/engines/teenagent/resources.cpp b/engines/teenagent/resources.cpp index 0dc6ea2f3c..dff58f98e2 100644 --- a/engines/teenagent/resources.cpp +++ b/engines/teenagent/resources.cpp @@ -22,6 +22,7 @@ #include "teenagent/resources.h" #include "teenagent/teenagent.h" #include "common/textconsole.h" +#include "common/translation.h" #include "common/zlib.h" namespace TeenAgent { @@ -64,9 +65,9 @@ bool Resources::loadArchives(const ADGameDescription *gd) { Common::File *dat_file = new Common::File(); if (!dat_file->open("teenagent.dat")) { delete dat_file; - Common::String errorMessage = "You're missing the 'teenagent.dat' file. Get it from the ScummVM website"; - GUIErrorMessage(errorMessage); + Common::String errorMessage = _("You're missing the 'teenagent.dat' file. Get it from the ScummVM website"); warning("%s", errorMessage.c_str()); + GUIErrorMessage(errorMessage); return false; } @@ -85,9 +86,9 @@ bool Resources::loadArchives(const ADGameDescription *gd) { if (isCompressed) { // teenagent.dat is compressed, but zlib hasn't been compiled in delete dat; - Common::String errorMessage = "The teenagent.dat file is compressed and zlib hasn't been included in this executable. Please decompress it"; - GUIErrorMessage(errorMessage); + Common::String errorMessage = _("The teenagent.dat file is compressed and zlib hasn't been included in this executable. Please decompress it"); warning("%s", errorMessage.c_str()); + GUIErrorMessage(errorMessage); return false; } #endif -- cgit v1.2.3