(svn r12867) [0.6] -Backport from trunk r12706, r12642, r12622, r12572, r12542:

- Fix: Do not crash very hard on unrecognised savegames, just go back to the intro menu instead (r12706)
- Fix: Remove buggy buoys at tile 0 from old TTDP savegames (r12642)
- Fix: Infinite loop in case your compiler decides that enums are unsigned by default (r12622)
- Fix: min() has 32bit arguments, clamping of 64bit values did not work (r12572)
- Fix: Do not install scenarios into the current user's homedir when running 'make install', that is silly. Simply always install scenarios system wide instead (r12542)
This commit is contained in:
rubidium 2008-04-24 12:15:24 +00:00
parent 7bf1737a66
commit 4cb6a89e81
5 changed files with 24 additions and 23 deletions

View File

@ -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

View File

@ -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);
}
/**

View File

@ -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;

View File

@ -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);

View File

@ -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);