From e10e412bba99090b67a99cd7fddd5405172452f1 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 21 May 2012 21:21:48 +0300 Subject: COMMON: Allow the savefile manager to create uncompressed saves These are useful in cases where the files can be used in the original interpreters (such as the exported characters from QFG), in order to avoid confusion in cases where the users are unaware that these saves are compressed and are trying to load them in the original interpreters. --- common/savefile.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common') diff --git a/common/savefile.h b/common/savefile.h index 03a7b52add..3aa0f423e3 100644 --- a/common/savefile.h +++ b/common/savefile.h @@ -108,7 +108,7 @@ public: * @param name the name of the savefile * @return pointer to an OutSaveFile, or NULL if an error occurred. */ - virtual OutSaveFile *openForSaving(const String &name) = 0; + virtual OutSaveFile *openForSaving(const String &name, bool compress = true) = 0; /** * Open the file with the specified name in the given directory for loading. -- cgit v1.2.3 From 4c4a127ca23ca55ec4f3348b40553ac5f72a3892 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 21 May 2012 23:17:28 +0300 Subject: COMMON: Add documentation regarding the new parameter in openForSaving() --- common/savefile.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'common') diff --git a/common/savefile.h b/common/savefile.h index 3aa0f423e3..2f4b8a2d5b 100644 --- a/common/savefile.h +++ b/common/savefile.h @@ -105,7 +105,8 @@ public: /** * Open the savefile with the specified name in the given directory for saving. - * @param name the name of the savefile + * @param name the name of the savefile + * @param compress toggles whether to compress the resulting save file (default) or not. * @return pointer to an OutSaveFile, or NULL if an error occurred. */ virtual OutSaveFile *openForSaving(const String &name, bool compress = true) = 0; -- cgit v1.2.3 From c9ace6426ebd4cac2777f199848dcfa5770b65ca Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 21 Jun 2012 10:35:27 +0300 Subject: COMMON: Add a detailed explanation on when to create uncompressed saves --- common/savefile.h | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/savefile.h b/common/savefile.h index 2f4b8a2d5b..abe0df2758 100644 --- a/common/savefile.h +++ b/common/savefile.h @@ -104,9 +104,32 @@ public: virtual String popErrorDesc(); /** - * Open the savefile with the specified name in the given directory for saving. + * Open the savefile with the specified name in the given directory for + * saving. + * + * Saved games are always compressed using ZIP compression on platforms + * where the zlib library is included (i.e. almost all platforms except the + * NDS). Engines are expected to always create compressed saved games. + * A notable exception is when the created saved games are compatible with + * the ones that the original interpreters create, and they are then used + * with later game versions in a game series which are not supported by + * ScummVM. An example is the characters exported in the Quest for Glory + * games: these saved states actually contain simple text strings with + * character attributes, which can then be used with later games in the + * Quest for Glory Series. Currently, ScummVM supports Quest for Glory + * 1, 2 and 3. These exported heroes can also be read by the AGS VGA fan + * made version of Quest for Glory 2 and the SCI32 game Quest for Glory IV, + * none of which is supported by ScummVM yet. Moreover, these heroes can + * also be imported into Quest for Glory V, which is a 3D game and thus + * outside of ScummVM's scope. For these reasons, in such cases engines can + * create uncompressed saved games to help users import them in other games + * not supported by ScummVM. Users only need to know that such saved games + * exported by ScummVM are compatible with later unsupported games, without + * needing to explain how to uncompress them. + * * @param name the name of the savefile - * @param compress toggles whether to compress the resulting save file (default) or not. + * @param compress toggles whether to compress the resulting save file + * (default) or not. * @return pointer to an OutSaveFile, or NULL if an error occurred. */ virtual OutSaveFile *openForSaving(const String &name, bool compress = true) = 0; -- cgit v1.2.3 From 16adcb5145ce293af120b7cc828a08166da310e2 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 25 Jun 2012 22:32:00 +0300 Subject: COMMON: Simplify the documentation in openForSaving() The new more concise description is courtesy of wjp. --- common/savefile.h | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) (limited to 'common') diff --git a/common/savefile.h b/common/savefile.h index abe0df2758..da787289ee 100644 --- a/common/savefile.h +++ b/common/savefile.h @@ -107,25 +107,13 @@ public: * Open the savefile with the specified name in the given directory for * saving. * - * Saved games are always compressed using ZIP compression on platforms - * where the zlib library is included (i.e. almost all platforms except the - * NDS). Engines are expected to always create compressed saved games. - * A notable exception is when the created saved games are compatible with - * the ones that the original interpreters create, and they are then used - * with later game versions in a game series which are not supported by - * ScummVM. An example is the characters exported in the Quest for Glory - * games: these saved states actually contain simple text strings with - * character attributes, which can then be used with later games in the - * Quest for Glory Series. Currently, ScummVM supports Quest for Glory - * 1, 2 and 3. These exported heroes can also be read by the AGS VGA fan - * made version of Quest for Glory 2 and the SCI32 game Quest for Glory IV, - * none of which is supported by ScummVM yet. Moreover, these heroes can - * also be imported into Quest for Glory V, which is a 3D game and thus - * outside of ScummVM's scope. For these reasons, in such cases engines can - * create uncompressed saved games to help users import them in other games - * not supported by ScummVM. Users only need to know that such saved games - * exported by ScummVM are compatible with later unsupported games, without - * needing to explain how to uncompress them. + * Saved games are compressed by default, and engines are expected to + * always write compressed saves. + * + * A notable exception is if uncompressed files are needed for + * compatibility with games not supported by ScummVM, such as character + * exports from the Quest for Glory series. QfG5 is a 3D game and won't be + * supported by ScummVM. * * @param name the name of the savefile * @param compress toggles whether to compress the resulting save file -- cgit v1.2.3 From 50136f43c7de4889444d9de19ff5d99f2cc04bf7 Mon Sep 17 00:00:00 2001 From: Thierry Crozat Date: Sun, 1 Jul 2012 01:03:49 +0100 Subject: COMMON: Expand a bit the KeyState documentation This follows a bug that was found in the Lure engine where keycode was used in a place where it should have used ascii. --- common/keyboard.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'common') diff --git a/common/keyboard.h b/common/keyboard.h index e6db086598..f9e94e6656 100644 --- a/common/keyboard.h +++ b/common/keyboard.h @@ -248,7 +248,10 @@ struct KeyState { * ASCII-value of the pressed key (if any). * This depends on modifiers, i.e. pressing the 'A' key results in * different values here depending on the status of shift, alt and - * caps lock. + * caps lock. This should be used rather than keycode for text input + * to avoid keyboard layout issues. For example you cannot assume that + * KEYCODE_0 without a modifier will be '0' (on AZERTY keyboards it is + * not). */ uint16 ascii; -- cgit v1.2.3 From b398dcabaffbbc53d24d296fed3f64b0b8ecd519 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 18 Jul 2012 13:54:15 +0200 Subject: COMMON: Add an optional argument to wrapCompressedReadStream, to simplify using streams that can't tell their size() --- common/zlib.cpp | 9 +++++---- common/zlib.h | 10 +++++++++- 2 files changed, 14 insertions(+), 5 deletions(-) (limited to 'common') diff --git a/common/zlib.cpp b/common/zlib.cpp index 7d765fc539..76e34485da 100644 --- a/common/zlib.cpp +++ b/common/zlib.cpp @@ -107,7 +107,7 @@ protected: public: - GZipReadStream(SeekableReadStream *w) : _wrapped(w), _stream() { + GZipReadStream(SeekableReadStream *w, uint32 knownSize = 0) : _wrapped(w), _stream() { assert(w != 0); // Verify file header is correct @@ -122,7 +122,8 @@ public: _origSize = w->readUint32LE(); } else { // Original size not available in zlib format - _origSize = 0; + // use an otherwise known size if supplied. + _origSize = knownSize; } _pos = 0; w->seek(0, SEEK_SET); @@ -336,7 +337,7 @@ public: #endif // USE_ZLIB -SeekableReadStream *wrapCompressedReadStream(SeekableReadStream *toBeWrapped) { +SeekableReadStream *wrapCompressedReadStream(SeekableReadStream *toBeWrapped, uint32 knownSize) { #if defined(USE_ZLIB) if (toBeWrapped) { uint16 header = toBeWrapped->readUint16BE(); @@ -345,7 +346,7 @@ SeekableReadStream *wrapCompressedReadStream(SeekableReadStream *toBeWrapped) { header % 31 == 0)); toBeWrapped->seek(-2, SEEK_CUR); if (isCompressed) - return new GZipReadStream(toBeWrapped); + return new GZipReadStream(toBeWrapped, knownSize); } #endif return toBeWrapped; diff --git a/common/zlib.h b/common/zlib.h index 61322c286a..8372499922 100644 --- a/common/zlib.h +++ b/common/zlib.h @@ -86,10 +86,18 @@ bool inflateZlibHeaderless(byte *dst, uint dstLen, const byte *src, uint srcLen, * format. In the former case, the original stream is returned unmodified * (and in particular, not wrapped). * + * Certain GZip-formats don't supply an easily readable length, if you + * still need the length carried along with the stream, and you know + * the decompressed length at wrap-time, then it can be supplied as knownSize + * here. knownSize will be ignored if the GZip-stream DOES include a length. + * * It is safe to call this with a NULL parameter (in this case, NULL is * returned). + * + * @param toBeWrapped the stream to be wrapped (if it is in gzip-format) + * @param knownSize a supplied length of the compressed data (if not available directly) */ -SeekableReadStream *wrapCompressedReadStream(SeekableReadStream *toBeWrapped); +SeekableReadStream *wrapCompressedReadStream(SeekableReadStream *toBeWrapped, uint32 knownSize = 0); /** * Take an arbitrary WriteStream and wrap it in a custom stream which provides -- cgit v1.2.3 From 991710d0a158bfce4e54bd240482a4e3044271d3 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Fri, 27 Jul 2012 11:32:51 -0400 Subject: VIDEO: Adapt QuickTimeDecoder to the AdvancedVideoDecoder API --- common/quicktime.h | 1 + 1 file changed, 1 insertion(+) (limited to 'common') diff --git a/common/quicktime.h b/common/quicktime.h index 974502d075..08ca35ad51 100644 --- a/common/quicktime.h +++ b/common/quicktime.h @@ -35,6 +35,7 @@ #include "common/scummsys.h" #include "common/stream.h" #include "common/rational.h" +#include "common/types.h" namespace Common { class MacResManager; -- cgit v1.2.3 From b5a63d6709e87005c9b02fa02d4ae8802b7ce915 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Wed, 15 Aug 2012 00:15:29 +0200 Subject: COMMON: Remove fprintf/stderr usage from xmlparser. --- common/xmlparser.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'common') diff --git a/common/xmlparser.cpp b/common/xmlparser.cpp index ea3d44cf87..f0b7f1cc81 100644 --- a/common/xmlparser.cpp +++ b/common/xmlparser.cpp @@ -20,15 +20,11 @@ * */ -// FIXME: Avoid using fprintf -#define FORBIDDEN_SYMBOL_EXCEPTION_fprintf -#define FORBIDDEN_SYMBOL_EXCEPTION_stderr - - #include "common/xmlparser.h" #include "common/archive.h" #include "common/fs.h" #include "common/memstream.h" +#include "common/system.h" namespace Common { @@ -123,17 +119,19 @@ bool XMLParser::parserError(const String &errStr) { keyClosing = currentPosition; } - fprintf(stderr, "\n File <%s>, line %d:\n", _fileName.c_str(), lineCount); + Common::String errorMessage = Common::String::format("\n File <%s>, line %d:\n", _fileName.c_str(), lineCount); currentPosition = (keyClosing - keyOpening); _stream->seek(keyOpening, SEEK_SET); while (currentPosition--) - fprintf(stderr, "%c", _stream->readByte()); + errorMessage += (char)_stream->readByte(); + + errorMessage += "\n\nParser error: "; + errorMessage += errStr; + errorMessage += "\n\n"; - fprintf(stderr, "\n\nParser error: "); - fprintf(stderr, "%s", errStr.c_str()); - fprintf(stderr, "\n\n"); + g_system->logMessage(LogMessageType::kError, errorMessage.c_str()); return false; } -- cgit v1.2.3 From 6f9d84665fd090ae55386b1373a69e080b34e089 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Sun, 26 Aug 2012 12:38:35 -0400 Subject: COMMON: Add MKTAG16 for 16-bit multi-character constants --- common/endian.h | 6 ++++++ common/winexe_pe.cpp | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'common') diff --git a/common/endian.h b/common/endian.h index 394437ec67..759513efef 100644 --- a/common/endian.h +++ b/common/endian.h @@ -146,6 +146,12 @@ */ #define MKTAG(a0,a1,a2,a3) ((uint32)((a3) | ((a2) << 8) | ((a1) << 16) | ((a0) << 24))) +/** + * A wrapper macro used around two character constants, like 'wb', to + * ensure portability. Typical usage: MKTAG16('w','b'). + */ +#define MKTAG16(a0,a1) ((uint16)((a1) | ((a0) << 8))) + // Functions for reading/writing native integers. // They also transparently handle the need for alignment. diff --git a/common/winexe_pe.cpp b/common/winexe_pe.cpp index 6c0f9c9962..b3c45ffe73 100644 --- a/common/winexe_pe.cpp +++ b/common/winexe_pe.cpp @@ -64,7 +64,7 @@ bool PEResources::loadFromEXE(SeekableReadStream *stream) { if (!stream) return false; - if (stream->readUint16BE() != 'MZ') + if (stream->readUint16BE() != MKTAG16('M', 'Z')) return false; stream->skip(58); -- cgit v1.2.3