summaryrefslogtreecommitdiff
path: root/src/saveload
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-12-04 10:08:32 +0000
committerrubidium <rubidium@openttd.org>2010-12-04 10:08:32 +0000
commita0fb4c8a134d609683bea556b54e9fc62133ba41 (patch)
treec23c19bbb5e176739c73b73f5b0a0ccfb01d0bce /src/saveload
parentb7d2d7958156e227c8d9ce736b3b3d207192353e (diff)
downloadopenttd-a0fb4c8a134d609683bea556b54e9fc62133ba41.tar.xz
(svn r21381) -Fix (r21377,r21375): some compilers have to spoil the fun...
Diffstat (limited to 'src/saveload')
-rw-r--r--src/saveload/saveload.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp
index 33d0733a4..0ba0e509c 100644
--- a/src/saveload/saveload.cpp
+++ b/src/saveload/saveload.cpp
@@ -2047,7 +2047,7 @@ struct ZlibLoadFilter : LoadFilter {
/* virtual */ size_t Read(byte *buf, size_t size)
{
this->z.next_out = buf;
- this->z.avail_out = size;
+ this->z.avail_out = (uint)size;
do {
/* read more bytes from the file? */
@@ -2139,6 +2139,14 @@ struct ZlibSaveFilter : SaveFilter {
#if defined(WITH_LZMA)
#include <lzma.h>
+/**
+ * Have a copy of an initialised LZMA stream. We need this as it's
+ * impossible to "re"-assign LZMA_STREAM_INIT to a variable in some
+ * compilers, i.e. LZMA_STREAM_INIT can't be used to set something.
+ * This var has to be used instead.
+ */
+static const lzma_stream _lzma_init = LZMA_STREAM_INIT;
+
/** Filter without any compression. */
struct LZMALoadFilter : LoadFilter {
lzma_stream lzma; ///< Stream state that we are reading from.
@@ -2148,9 +2156,8 @@ struct LZMALoadFilter : LoadFilter {
* Initialise this filter.
* @param chain The next filter in this chain.
*/
- LZMALoadFilter(LoadFilter *chain) : LoadFilter(chain)
+ LZMALoadFilter(LoadFilter *chain) : LoadFilter(chain), lzma(_lzma_init)
{
- this->lzma = LZMA_STREAM_INIT;
/* Allow saves up to 256 MB uncompressed */
if (lzma_auto_decoder(&this->lzma, 1 << 28, 0) != LZMA_OK) SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_INTERNAL_ERROR, "cannot initialize decompressor");
}
@@ -2192,9 +2199,8 @@ struct LZMASaveFilter : SaveFilter {
* @param chain The next filter in this chain.
* @param compression_level The requested level of compression.
*/
- LZMASaveFilter(SaveFilter *chain, byte compression_level) : SaveFilter(chain)
+ LZMASaveFilter(SaveFilter *chain, byte compression_level) : SaveFilter(chain), lzma(_lzma_init)
{
- this->lzma = LZMA_STREAM_INIT;
if (lzma_easy_encoder(&this->lzma, compression_level, LZMA_CHECK_CRC32) != LZMA_OK) SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_INTERNAL_ERROR, "cannot initialize compressor");
}