Merge branch 'master' into jgrpp
# Conflicts: # cmake/CompileFlags.cmake # src/crashlog.cpp # src/fileio.cpp # src/fileio_func.h # src/fios_gui.cpp # src/ini_load.cpp # src/ini_type.h # src/lang/english.txt # src/lang/german.txt # src/lang/korean.txt # src/network/network_client.cpp # src/order_base.h # src/order_cmd.cpp # src/os/windows/win32.cpp # src/road_cmd.cpp # src/saveload/saveload.cpp # src/saveload/saveload.h # src/settings.cpp # src/station_cmd.cpp # src/stdafx.h # src/table/settings.ini # src/tree_cmd.cpp # src/tree_gui.cpp # src/vehicle_base.h # src/video/cocoa/cocoa_v.mm # src/video/cocoa/event.mm # src/video/cocoa/wnd_quartz.mm # src/viewport.cpp # src/widgets/tree_widget.h
This commit is contained in:
@@ -1983,8 +1983,7 @@ bool AfterLoadGame()
|
||||
|
||||
v->current_order.ConvertFromOldSavegame();
|
||||
if (v->type == VEH_ROAD && v->IsPrimaryVehicle() && v->FirstShared() == v) {
|
||||
Order* order;
|
||||
FOR_VEHICLE_ORDERS(v, order) order->SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
|
||||
for (Order *order : v->Orders()) order->SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
|
||||
}
|
||||
}
|
||||
} else if (IsSavegameVersionBefore(SLV_94)) {
|
||||
@@ -2463,7 +2462,7 @@ bool AfterLoadGame()
|
||||
for (Vehicle *v : st->loading_vehicles) {
|
||||
/* There are always as many CargoPayments as Vehicles. We need to make the
|
||||
* assert() in Pool::GetNew() happy by calling CanAllocateItem(). */
|
||||
assert_compile(CargoPaymentPool::MAX_SIZE == VehiclePool::MAX_SIZE);
|
||||
static_assert(CargoPaymentPool::MAX_SIZE == VehiclePool::MAX_SIZE);
|
||||
assert(CargoPayment::CanAllocateItem());
|
||||
if (v->cargo_payment == nullptr) v->cargo_payment = new CargoPayment(v);
|
||||
}
|
||||
|
@@ -103,7 +103,7 @@ static const SaveLoad * const _glog_desc[] = {
|
||||
_glog_emergency_desc,
|
||||
};
|
||||
|
||||
assert_compile(lengthof(_glog_desc) == GLCT_END);
|
||||
static_assert(lengthof(_glog_desc) == GLCT_END);
|
||||
|
||||
static void Load_GLOG_common(LoggedAction *&gamelog_action, uint &gamelog_actions)
|
||||
{
|
||||
|
@@ -214,8 +214,8 @@ static void Load_MAP8()
|
||||
|
||||
static void Load_WMAP()
|
||||
{
|
||||
assert_compile(sizeof(Tile) == 8);
|
||||
assert_compile(sizeof(TileExtended) == 4);
|
||||
static_assert(sizeof(Tile) == 8);
|
||||
static_assert(sizeof(TileExtended) == 4);
|
||||
assert(_sl_xv_feature_versions[XSLFI_WHOLE_MAP_CHUNK] == 1 || _sl_xv_feature_versions[XSLFI_WHOLE_MAP_CHUNK] == 2);
|
||||
|
||||
ReadBuffer *reader = ReadBuffer::GetCurrent();
|
||||
@@ -264,8 +264,8 @@ static void Load_WMAP()
|
||||
|
||||
static void Save_WMAP()
|
||||
{
|
||||
assert_compile(sizeof(Tile) == 8);
|
||||
assert_compile(sizeof(TileExtended) == 4);
|
||||
static_assert(sizeof(Tile) == 8);
|
||||
static_assert(sizeof(TileExtended) == 4);
|
||||
assert(_sl_xv_feature_versions[XSLFI_WHOLE_MAP_CHUNK] == 2);
|
||||
|
||||
MemoryDumper *dumper = MemoryDumper::GetCurrent();
|
||||
|
@@ -243,7 +243,7 @@ static inline bool CheckOldSavegameType(FILE *f, char *temp, const char *last, u
|
||||
|
||||
static SavegameType DetermineOldSavegameType(FILE *f, char *title, const char *last)
|
||||
{
|
||||
assert_compile(TTD_HEADER_SIZE >= TTO_HEADER_SIZE);
|
||||
static_assert(TTD_HEADER_SIZE >= TTO_HEADER_SIZE);
|
||||
char temp[TTD_HEADER_SIZE] = "Unknown";
|
||||
|
||||
SavegameType type = SGT_TTO;
|
||||
@@ -271,7 +271,7 @@ static SavegameType DetermineOldSavegameType(FILE *f, char *title, const char *l
|
||||
|
||||
typedef bool LoadOldMainProc(LoadgameState *ls);
|
||||
|
||||
bool LoadOldSaveGame(const char *file)
|
||||
bool LoadOldSaveGame(const std::string &file)
|
||||
{
|
||||
LoadgameState ls;
|
||||
|
||||
@@ -283,7 +283,7 @@ bool LoadOldSaveGame(const char *file)
|
||||
ls.file = FioFOpenFile(file, "rb", NO_DIRECTORY);
|
||||
|
||||
if (ls.file == nullptr) {
|
||||
DEBUG(oldloader, 0, "Cannot open file '%s'", file);
|
||||
DEBUG(oldloader, 0, "Cannot open file '%s'", file.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -318,7 +318,7 @@ bool LoadOldSaveGame(const char *file)
|
||||
return true;
|
||||
}
|
||||
|
||||
void GetOldSaveGameName(const char *file, char *title, const char *last)
|
||||
void GetOldSaveGameName(const std::string &file, char *title, const char *last)
|
||||
{
|
||||
FILE *f = FioFOpenFile(file, "rb", NO_DIRECTORY);
|
||||
|
||||
|
@@ -93,7 +93,7 @@ struct OldChunks {
|
||||
};
|
||||
|
||||
/* If it fails, check lines above.. */
|
||||
assert_compile(sizeof(TileIndex) == 4);
|
||||
static_assert(sizeof(TileIndex) == 4);
|
||||
|
||||
extern uint _bump_assert_value;
|
||||
byte ReadByte(LoadgameState *ls);
|
||||
|
@@ -355,17 +355,13 @@ static void SlNullPointers()
|
||||
_sl_version = SAVEGAME_VERSION;
|
||||
SlXvSetCurrentState();
|
||||
|
||||
DEBUG(sl, 1, "Nulling pointers");
|
||||
|
||||
FOR_ALL_CHUNK_HANDLERS(ch) {
|
||||
if (ch->ptrs_proc != nullptr) {
|
||||
DEBUG(sl, 2, "Nulling pointers for %c%c%c%c", ch->id >> 24, ch->id >> 16, ch->id >> 8, ch->id);
|
||||
DEBUG(sl, 3, "Nulling pointers for %c%c%c%c", ch->id >> 24, ch->id >> 16, ch->id >> 8, ch->id);
|
||||
ch->ptrs_proc();
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG(sl, 1, "All pointers nulled");
|
||||
|
||||
assert(_sl.action == SLA_NULL);
|
||||
}
|
||||
|
||||
@@ -1270,7 +1266,7 @@ static size_t ReferenceToInt(const void *obj, SLRefType rt)
|
||||
*/
|
||||
static void *IntToReference(size_t index, SLRefType rt)
|
||||
{
|
||||
assert_compile(sizeof(size_t) <= sizeof(void *));
|
||||
static_assert(sizeof(size_t) <= sizeof(void *));
|
||||
|
||||
assert(_sl.action == SLA_PTRS);
|
||||
|
||||
@@ -2307,17 +2303,13 @@ static void SlFixPointers()
|
||||
{
|
||||
_sl.action = SLA_PTRS;
|
||||
|
||||
DEBUG(sl, 1, "Fixing pointers");
|
||||
|
||||
FOR_ALL_CHUNK_HANDLERS(ch) {
|
||||
if (ch->ptrs_proc != nullptr) {
|
||||
DEBUG(sl, 2, "Fixing pointers for %c%c%c%c", ch->id >> 24, ch->id >> 16, ch->id >> 8, ch->id);
|
||||
DEBUG(sl, 3, "Fixing pointers for %c%c%c%c", ch->id >> 24, ch->id >> 16, ch->id >> 8, ch->id);
|
||||
ch->ptrs_proc();
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG(sl, 1, "All pointers fixed");
|
||||
|
||||
assert(_sl.action == SLA_PTRS);
|
||||
}
|
||||
|
||||
@@ -2874,7 +2866,7 @@ static const SaveLoadFormat *GetSavegameFormat(char *s, byte *compression_level)
|
||||
/* actual loader/saver function */
|
||||
void InitializeGame(uint size_x, uint size_y, bool reset_date, bool reset_settings);
|
||||
extern bool AfterLoadGame();
|
||||
extern bool LoadOldSaveGame(const char *file);
|
||||
extern bool LoadOldSaveGame(const std::string &file);
|
||||
|
||||
/**
|
||||
* Clear temporary data that is passed between various saveload phases.
|
||||
@@ -3368,7 +3360,7 @@ SaveOrLoadResult LoadWithFilter(LoadFilter *reader)
|
||||
* @param threaded True when threaded saving is allowed
|
||||
* @return Return the result of the action. #SL_OK, #SL_ERROR, or #SL_REINIT ("unload" the game)
|
||||
*/
|
||||
SaveOrLoadResult SaveOrLoad(const char *filename, SaveLoadOperation fop, DetailedFileType dft, Subdirectory sb, bool threaded)
|
||||
SaveOrLoadResult SaveOrLoad(const std::string &filename, SaveLoadOperation fop, DetailedFileType dft, Subdirectory sb, bool threaded)
|
||||
{
|
||||
/* An instance of saving is already active, so don't go saving again */
|
||||
if (_sl.saveinprogress && fop == SLO_SAVE && dft == DFT_GAME_FILE && threaded) {
|
||||
@@ -3435,7 +3427,7 @@ SaveOrLoadResult SaveOrLoad(const char *filename, SaveLoadOperation fop, Detaile
|
||||
}
|
||||
|
||||
if (fop == SLO_SAVE) { // SAVE game
|
||||
DEBUG(desync, 1, "save: date{%08x; %02x; %02x}; %s", _date, _date_fract, _tick_skip_counter, filename);
|
||||
DEBUG(desync, 1, "save: date{%08x; %02x; %02x}; %s", _date, _date_fract, _tick_skip_counter, filename.c_str());
|
||||
if (_network_server || !_settings_client.gui.threaded_saves) threaded = false;
|
||||
|
||||
return DoSave(new FileWriter(fh), threaded);
|
||||
@@ -3443,7 +3435,7 @@ SaveOrLoadResult SaveOrLoad(const char *filename, SaveLoadOperation fop, Detaile
|
||||
|
||||
/* LOAD game */
|
||||
assert(fop == SLO_LOAD || fop == SLO_CHECK);
|
||||
DEBUG(desync, 1, "load: %s", filename);
|
||||
DEBUG(desync, 1, "load: %s", filename.c_str());
|
||||
return DoLoad(new FileReader(fh), fop == SLO_CHECK);
|
||||
} catch (...) {
|
||||
/* This code may be executed both for old and new save games. */
|
||||
@@ -3532,7 +3524,7 @@ void FileToSaveLoad::SetMode(SaveLoadOperation fop, AbstractFileType aft, Detail
|
||||
*/
|
||||
void FileToSaveLoad::SetName(const char *name)
|
||||
{
|
||||
strecpy(this->name, name, lastof(this->name));
|
||||
this->name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -16,6 +16,7 @@
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
/** SaveLoad versions
|
||||
* Previous savegame versions, the trunk revision where they were
|
||||
@@ -366,7 +367,7 @@ struct FileToSaveLoad {
|
||||
SaveLoadOperation file_op; ///< File operation to perform.
|
||||
DetailedFileType detail_ftype; ///< Concrete file type (PNG, BMP, old save, etc).
|
||||
AbstractFileType abstract_ftype; ///< Abstract type of file (scenario, heightmap, etc).
|
||||
char name[MAX_PATH]; ///< Name of the file.
|
||||
std::string name; ///< Name of the file.
|
||||
char title[255]; ///< Internal name of the game.
|
||||
|
||||
void SetMode(FiosType ft);
|
||||
@@ -390,7 +391,7 @@ extern FileToSaveLoad _file_to_saveload;
|
||||
void GenerateDefaultSaveName(char *buf, const char *last);
|
||||
void SetSaveLoadError(StringID str);
|
||||
const char *GetSaveLoadErrorString();
|
||||
SaveOrLoadResult SaveOrLoad(const char *filename, SaveLoadOperation fop, DetailedFileType dft, Subdirectory sb, bool threaded = true);
|
||||
SaveOrLoadResult SaveOrLoad(const std::string &filename, SaveLoadOperation fop, DetailedFileType dft, Subdirectory sb, bool threaded = true);
|
||||
void WaitTillSaved();
|
||||
void ProcessAsyncSaveFinish();
|
||||
void DoExitSave();
|
||||
|
Reference in New Issue
Block a user