From c5954fd1bdc5dcb63884b838533c45caf17fdd28 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Mon, 11 Jun 2018 00:54:29 +0100 Subject: [PATCH 1/2] Fix syntax errors in saveload_buffer.h on strict pointer alignment platforms Fixes #57 --- src/saveload/saveload_buffer.h | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/saveload/saveload_buffer.h b/src/saveload/saveload_buffer.h index a289e50f0c..5e21cf5b02 100644 --- a/src/saveload/saveload_buffer.h +++ b/src/saveload/saveload_buffer.h @@ -221,8 +221,8 @@ struct MemoryDumper { #if OTTD_ALIGNMENT == 0 *((unaligned_uint16 *) this->buf) = TO_BE16(v); #else - this->buf[0] = GB(v, 8, 8)); - this->buf[1] = GB(v, 0, 8)); + this->buf[0] = GB(v, 8, 8); + this->buf[1] = GB(v, 0, 8); #endif this->buf += 2; } @@ -232,10 +232,10 @@ struct MemoryDumper { #if OTTD_ALIGNMENT == 0 *((unaligned_uint32 *) this->buf) = TO_BE32(v); #else - this->buf[0] = GB(v, 24, 8)); - this->buf[1] = GB(v, 16, 8)); - this->buf[2] = GB(v, 8, 8)); - this->buf[3] = GB(v, 0, 8)); + this->buf[0] = GB(v, 24, 8); + this->buf[1] = GB(v, 16, 8); + this->buf[2] = GB(v, 8, 8); + this->buf[3] = GB(v, 0, 8); #endif this->buf += 4; } @@ -245,14 +245,14 @@ struct MemoryDumper { #if OTTD_ALIGNMENT == 0 *((unaligned_uint64 *) this->buf) = TO_BE64(v); #else - this->buf[0] = GB(v, 56, 8)); - this->buf[1] = GB(v, 48, 8)); - this->buf[2] = GB(v, 40, 8)); - this->buf[3] = GB(v, 32, 8)); - this->buf[4] = GB(v, 24, 8)); - this->buf[5] = GB(v, 16, 8)); - this->buf[6] = GB(v, 8, 8)); - this->buf[7] = GB(v, 0, 8)); + this->buf[0] = GB(v, 56, 8); + this->buf[1] = GB(v, 48, 8); + this->buf[2] = GB(v, 40, 8); + this->buf[3] = GB(v, 32, 8); + this->buf[4] = GB(v, 24, 8); + this->buf[5] = GB(v, 16, 8); + this->buf[6] = GB(v, 8, 8); + this->buf[7] = GB(v, 0, 8); #endif this->buf += 8; } From a3156804c5af5245b1cf1314b4b2891f1ae40e92 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Mon, 11 Jun 2018 00:55:49 +0100 Subject: [PATCH 2/2] Fix narrowing/type conversion warning on big endian platforms --- src/saveload/saveload.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp index dd34a7dea1..a0e0c76123 100644 --- a/src/saveload/saveload.cpp +++ b/src/saveload/saveload.cpp @@ -2772,7 +2772,7 @@ static SaveOrLoadResult SaveFileToDisk(bool threaded) const SaveLoadFormat *fmt = GetSavegameFormat(_savegame_format, &compression); /* We have written our stuff to memory, now write it to file! */ - uint32 hdr[2] = { fmt->tag, TO_BE32((SAVEGAME_VERSION | SAVEGAME_VERSION_EXT) << 16) }; + uint32 hdr[2] = { fmt->tag, TO_BE32((uint32) (SAVEGAME_VERSION | SAVEGAME_VERSION_EXT) << 16) }; _sl.sf->Write((byte*)hdr, sizeof(hdr)); _sl.sf = fmt->init_write(_sl.sf, compression);