From 533a9cec8f70f8fd81d5c7dc9d5221533c24c8b0 Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Mon, 1 Jun 2009 22:39:54 +0100 Subject: [PATCH] Use 32 bit integers in binary map data --- maps/figure8.bin | Bin 4372 -> 4364 bytes src/Map.cpp | 15 ++++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/maps/figure8.bin b/maps/figure8.bin index 423917226d27afbba72987d2e151a568b15c3cc9..f2b6d3e68d3e04e5331214b75695402fcb5ff64a 100644 GIT binary patch delta 14 VcmbQD)T6|zz`($uu#uNt5C9h90)PMj delta 22 VcmeBCnxe$3zyJYYdLt{lAOIv90)PMj diff --git a/src/Map.cpp b/src/Map.cpp index 70dc734..3e6d0cb 100644 --- a/src/Map.cpp +++ b/src/Map.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -915,10 +916,10 @@ void Map::writeHeightMap(const string& aFileName) const if (!of.good()) throw runtime_error("Failed to open " + aFileName + " for writing"); - const long wl = static_cast(myWidth); - const long dl = static_cast(myDepth); - of.write(reinterpret_cast(&wl), sizeof(long)); - of.write(reinterpret_cast(&dl), sizeof(long)); + const int32_t wl = static_cast(myWidth); + const int32_t dl = static_cast(myDepth); + of.write(reinterpret_cast(&wl), sizeof(int32_t)); + of.write(reinterpret_cast(&dl), sizeof(int32_t)); for (int i = 0; i < (myWidth + 1) * (myDepth + 1); i++) of.write(reinterpret_cast(&myHeightMap[i].pos.y), @@ -935,9 +936,9 @@ void Map::readHeightMap(const string& aFileName) throw runtime_error("Failed to open " + aFileName + " for reading"); // Check the dimensions of the binary file match the XML file - long wl, dl; - is.read(reinterpret_cast(&wl), sizeof(long)); - is.read(reinterpret_cast(&dl), sizeof(long)); + int32_t wl, dl; + is.read(reinterpret_cast(&wl), sizeof(int32_t)); + is.read(reinterpret_cast(&dl), sizeof(int32_t)); if (wl != myWidth || dl != myDepth) { error() << "Expected width " << myWidth << " got " << wl; -- 2.39.2