aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorMatthew Hoops2012-08-26 15:49:45 -0400
committerMatthew Hoops2012-08-26 16:12:25 -0400
commitbb1e60e8b2f3bba06ae3b089097f94ea82a70c8a (patch)
treea434233367725fbb6dc7072776c312f52254d57f /common
parent7a49b3669a0e18210a2f5409cb35da735f549b11 (diff)
parent857b92f8ffececa9c1f990d21a6a8d1630199a62 (diff)
downloadscummvm-rg350-bb1e60e8b2f3bba06ae3b089097f94ea82a70c8a.tar.gz
scummvm-rg350-bb1e60e8b2f3bba06ae3b089097f94ea82a70c8a.tar.bz2
scummvm-rg350-bb1e60e8b2f3bba06ae3b089097f94ea82a70c8a.zip
Merge remote branch 'upstream/master' into pegasus
Conflicts: AUTHORS devtools/credits.pl gui/credits.h
Diffstat (limited to 'common')
-rw-r--r--common/endian.h6
-rw-r--r--common/keyboard.h5
-rw-r--r--common/quicktime.h1
-rw-r--r--common/savefile.h18
-rw-r--r--common/winexe_pe.cpp2
-rw-r--r--common/xmlparser.cpp18
-rw-r--r--common/zlib.cpp9
-rw-r--r--common/zlib.h10
8 files changed, 49 insertions, 20 deletions
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/keyboard.h b/common/keyboard.h
index 64c6cc4d01..3262a15c3f 100644
--- a/common/keyboard.h
+++ b/common/keyboard.h
@@ -249,7 +249,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;
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;
diff --git a/common/savefile.h b/common/savefile.h
index 03a7b52add..da787289ee 100644
--- a/common/savefile.h
+++ b/common/savefile.h
@@ -104,11 +104,23 @@ public:
virtual String popErrorDesc();
/**
- * Open the savefile with the specified name in the given directory for saving.
- * @param name the name of the savefile
+ * Open the savefile with the specified name in the given directory for
+ * saving.
+ *
+ * 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
+ * (default) or not.
* @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.
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);
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;
}
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