diff --git a/Makefile.in b/Makefile.in index 73e500ac5a..97cfd8b475 100644 --- a/Makefile.in +++ b/Makefile.in @@ -22,7 +22,6 @@ INSTALL_DIR = !!INSTALL_DIR!! INSTALL_BINARY_DIR = "$(INSTALL_DIR)/"!!BINARY_DIR!! INSTALL_ICON_DIR = "$(INSTALL_DIR)/"!!ICON_DIR!! INSTALL_DATA_DIR = "$(INSTALL_DIR)/"!!DATA_DIR!! -INSTALL_PERSONAL_DIR = !!PERSONAL_DIR!! TTD = !!TTD!! TTDS = $(SRC_DIRS:%=%/$(TTD)) OS = !!OS!! @@ -271,10 +270,5 @@ install: bundle $(Q)install -m 644 "$(BUNDLE_DIR)/data/"* "$(INSTALL_DATA_DIR)/data" $(Q)install -m 644 "$(BUNDLE_DIR)/docs/"* "$(INSTALL_DATA_DIR)/docs" $(Q)install -m 644 "$(BUNDLE_DIR)/media/"* "$(INSTALL_ICON_DIR)" -ifdef INSTALL_PERSONAL_DIR - $(Q)mkdir -p ~/"$(INSTALL_PERSONAL_DIR)" - $(Q)cp -R "$(BUNDLE_DIR)/scenario" ~/"$(INSTALL_PERSONAL_DIR)" -else $(Q)cp -R "$(BUNDLE_DIR)/scenario" "$(INSTALL_DATA_DIR)" -endif # INSTALL_PERSONAL_DIR endif # OSXAPP diff --git a/src/core/math_func.hpp b/src/core/math_func.hpp index e68573a811..355b6ebe7e 100644 --- a/src/core/math_func.hpp +++ b/src/core/math_func.hpp @@ -177,7 +177,7 @@ static inline int32 ClampToI32(const int64 a) */ static inline uint16 ClampToU16(const uint64 a) { - return min(a, 0xFFFF); + return (uint16)(a <= 0xFFFFU ? a : 0xFFFFU); } /** diff --git a/src/oldloader.cpp b/src/oldloader.cpp index 0c985c375e..4aca9a75cf 100644 --- a/src/oldloader.cpp +++ b/src/oldloader.cpp @@ -1694,6 +1694,12 @@ bool LoadOldSaveGame(const char *file) fclose(ls.file); + /* Some old TTDP savegames could have buoys at tile 0 + * (without assigned station struct) + * MakeWater() can be used as long as sea has the same + * format as old savegames (eg. everything is zeroed) */ + MakeWater(0); + _pause_game = 2; return true; diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp index 33a53f9e08..11ff5b9468 100644 --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -865,13 +865,14 @@ static CommandCost ClearTile_Road(TileIndex tile, byte flags) /* Must iterate over the roadtypes in a reverse manner because * tram tracks must be removed before the road bits. */ - for (RoadType rt = ROADTYPE_HWAY; rt >= ROADTYPE_ROAD; rt--) { + RoadType rt = ROADTYPE_HWAY; + do { if (HasBit(rts, rt)) { CommandCost tmp_ret = RemoveRoad(tile, flags, GetCrossingRoadBits(tile), rt, false); if (CmdFailed(tmp_ret)) return tmp_ret; ret.AddCost(tmp_ret); } - } + } while (rt-- != ROADTYPE_ROAD); if (flags & DC_EXEC) { DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); diff --git a/src/saveload.cpp b/src/saveload.cpp index bf3ed3a234..3634c82245 100644 --- a/src/saveload.cpp +++ b/src/saveload.cpp @@ -76,13 +76,24 @@ static struct { enum NeedLengthValues {NL_NONE = 0, NL_WANTLENGTH = 1, NL_CALCLENGTH = 2}; +/** Error handler, calls longjmp to simulate an exception. + * @todo this was used to have a central place to handle errors, but it is + * pretty ugly, and seriously interferes with any multithreaded approaches */ +static void NORETURN SlError(StringID string, const char *extra_msg = NULL) +{ + _sl.error_str = string; + free(_sl.extra_msg); + _sl.extra_msg = (extra_msg == NULL) ? NULL : strdup(extra_msg); + throw std::exception(); +} + /** * Fill the input buffer by reading from the file with the given reader */ static void SlReadFill() { uint len = _sl.read_bytes(); - assert(len != 0); + if (len == 0) SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_SAVEGAME, "Unexpected end of chunk"); _sl.bufp = _sl.buf; _sl.bufe = _sl.buf + len; @@ -137,17 +148,6 @@ static void SlWriteFill() _sl.bufe = _sl.buf + _sl.bufsize; } -/** Error handler, calls longjmp to simulate an exception. - * @todo this was used to have a central place to handle errors, but it is - * pretty ugly, and seriously interferes with any multithreaded approaches */ -static void NORETURN SlError(StringID string, const char *extra_msg = NULL) -{ - _sl.error_str = string; - free(_sl.extra_msg); - _sl.extra_msg = (extra_msg == NULL) ? NULL : strdup(extra_msg); - throw std::exception(); -} - /** Read in a single byte from file. If the temporary buffer is full, * flush it to its final destination * @return return the read byte from file @@ -1524,7 +1524,7 @@ static SaveOrLoadResult SaveFileToDisk(bool threaded) uint i; uint count = 1 << Savegame_POOL_BLOCK_SIZE_BITS; - assert(_ts.count == _sl.offs_base); + if (_ts.count != _sl.offs_base) SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_SAVEGAME, "Unexpected size of chunk"); for (i = 0; i != _Savegame_pool.GetBlockCount() - 1; i++) { _sl.buf = _Savegame_pool.blocks[i]; fmt->writer(count); @@ -1537,7 +1537,7 @@ static SaveOrLoadResult SaveFileToDisk(bool threaded) } fmt->uninit_write(); - assert(_ts.count == _sl.offs_base); + if (_ts.count != _sl.offs_base) SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_SAVEGAME, "Unexpected size of chunk"); GetSavegameFormat("memory")->uninit_write(); // clean the memorypool fclose(_sl.fh);