Merge branch 'master' into save_ext

# Conflicts:
#	src/saveload/company_sl.cpp
#	src/saveload/saveload.cpp
This commit is contained in:
Jonathan G Rennison
2017-03-19 12:12:52 +00:00
136 changed files with 1000 additions and 858 deletions

View File

@@ -718,12 +718,14 @@ bool AfterLoadGame()
if (IsSavegameVersionBefore(95)) _settings_game.vehicle.dynamic_engines = 0;
if (IsSavegameVersionBefore(96)) _settings_game.economy.station_noise_level = false;
if (IsSavegameVersionBefore(133)) {
_settings_game.vehicle.roadveh_acceleration_model = 0;
_settings_game.vehicle.train_slope_steepness = 3;
}
if (IsSavegameVersionBefore(134)) _settings_game.economy.feeder_payment_share = 75;
if (IsSavegameVersionBefore(138)) _settings_game.vehicle.plane_crashes = 2;
if (IsSavegameVersionBefore(139)) _settings_game.vehicle.roadveh_slope_steepness = 7;
if (IsSavegameVersionBefore(139)) {
_settings_game.vehicle.roadveh_acceleration_model = 0;
_settings_game.vehicle.roadveh_slope_steepness = 7;
}
if (IsSavegameVersionBefore(143)) _settings_game.economy.allow_town_level_crossings = true;
if (IsSavegameVersionBefore(159)) {
_settings_game.vehicle.max_train_length = 50;

View File

@@ -16,6 +16,7 @@
#include "../tunnelbridge_map.h"
#include "../tunnelbridge.h"
#include "../station_base.h"
#include "../strings_func.h"
#include "../settings_func.h"
#include "saveload.h"
@@ -244,7 +245,7 @@ static const SaveLoad _company_desc[] = {
SLE_VAR(CompanyProperties, name_1, SLE_STRINGID),
SLE_CONDSTR(CompanyProperties, name, SLE_STR | SLF_ALLOW_CONTROL, 0, 84, SL_MAX_VERSION),
SLE_VAR(CompanyProperties, president_name_1, SLE_UINT16),
SLE_VAR(CompanyProperties, president_name_1, SLE_STRINGID),
SLE_VAR(CompanyProperties, president_name_2, SLE_UINT32),
SLE_CONDSTR(CompanyProperties, president_name, SLE_STR | SLF_ALLOW_CONTROL, 0, 84, SL_MAX_VERSION),
@@ -503,11 +504,11 @@ static void Check_PLYR()
/* We do not load old custom names */
if (IsSavegameVersionBefore(84)) {
if (GB(cprops->name_1, 11, 5) == 15) {
if (GetStringTab(cprops->name_1) == TEXT_TAB_OLD_CUSTOM) {
cprops->name_1 = STR_GAME_SAVELOAD_NOT_AVAILABLE;
}
if (GB(cprops->president_name_1, 11, 5) == 15) {
if (GetStringTab(cprops->president_name_1) == TEXT_TAB_OLD_CUSTOM) {
cprops->president_name_1 = STR_GAME_SAVELOAD_NOT_AVAILABLE;
}
}

View File

@@ -96,8 +96,16 @@ static void Load_NGRF()
{
Load_NGRF_common(_grfconfig);
/* Append static NewGRF configuration, but only if there are some NewGRFs. */
if (_game_mode != GM_MENU || _all_grfs != NULL) AppendStaticGRFConfigs(&_grfconfig);
if (_game_mode == GM_MENU) {
/* Intro game must not have NewGRF. */
if (_grfconfig != NULL) SlErrorCorrupt("The intro game must not use NewGRF");
/* Activate intro NewGRFs (townnames) */
ResetGRFConfig(false);
} else {
/* Append static NewGRF configuration */
AppendStaticGRFConfigs(&_grfconfig);
}
}
static void Check_NGRF()

View File

@@ -267,8 +267,9 @@
* 193 26802
* 194 26881 1.5.x, 1.6.0
* 195 27572 1.6.x
* 196 27778 1.7.x
*/
extern const uint16 SAVEGAME_VERSION = 195; ///< Current savegame version of OpenTTD.
extern const uint16 SAVEGAME_VERSION = 196; ///< Current savegame version of OpenTTD.
const uint16 SAVEGAME_VERSION_EXT = 0x8000; ///< Savegame extension indicator mask
SavegameType _savegame_type; ///< type of savegame we are loading
@@ -2081,7 +2082,7 @@ struct LZOLoadFilter : LoadFilter {
byte out[LZO_BUFFER_SIZE + LZO_BUFFER_SIZE / 16 + 64 + 3 + sizeof(uint32) * 2];
uint32 tmp[2];
uint32 size;
lzo_uint len;
lzo_uint len = ssize;
/* Read header*/
if (this->chain->Read((byte*)tmp, sizeof(tmp)) != sizeof(tmp)) SlError(STR_GAME_SAVELOAD_ERROR_FILE_NOT_READABLE, "File read failed");
@@ -2103,7 +2104,8 @@ struct LZOLoadFilter : LoadFilter {
if (tmp[0] != lzo_adler32(0, out, size + sizeof(uint32))) SlErrorCorrupt("Bad checksum");
/* Decompress */
lzo1x_decompress_safe(out + sizeof(uint32) * 1, size, buf, &len, NULL);
int ret = lzo1x_decompress_safe(out + sizeof(uint32) * 1, size, buf, &len, NULL);
if (ret != LZO_E_OK) SlError(STR_GAME_SAVELOAD_ERROR_FILE_NOT_READABLE);
return len;
}
};

View File

@@ -52,7 +52,7 @@ enum SavegameType {
extern FileToSaveLoad _file_to_saveload;
void GenerateDefaultSaveName(char *buf, const char *last);
void SetSaveLoadError(uint16 str);
void SetSaveLoadError(StringID str);
const char *GetSaveLoadErrorString();
SaveOrLoadResult SaveOrLoad(const char *filename, SaveLoadOperation fop, DetailedFileType dft, Subdirectory sb, bool threaded = true);
void WaitTillSaved();
@@ -171,7 +171,7 @@ enum VarTypes {
SLE_INT64 = SLE_FILE_I64 | SLE_VAR_I64,
SLE_UINT64 = SLE_FILE_U64 | SLE_VAR_U64,
SLE_CHAR = SLE_FILE_I8 | SLE_VAR_CHAR,
SLE_STRINGID = SLE_FILE_STRINGID | SLE_VAR_U16,
SLE_STRINGID = SLE_FILE_STRINGID | SLE_VAR_U32,
SLE_STRINGBUF = SLE_FILE_STRING | SLE_VAR_STRB,
SLE_STRINGBQUOTE = SLE_FILE_STRING | SLE_VAR_STRBQ,
SLE_STRING = SLE_FILE_STRING | SLE_VAR_STR,

View File

@@ -325,6 +325,10 @@ static void SwapPackets(GoodsEntry *ge)
static void Load_STNS()
{
_cargo_source_xy = 0;
_cargo_days = 0;
_cargo_feeder_share = 0;
int index;
while ((index = SlIterateArray()) != -1) {
Station *st = new (index) Station();
@@ -514,8 +518,9 @@ static void Save_STNN()
static void Load_STNN()
{
int index;
_num_flows = 0;
int index;
while ((index = SlIterateArray()) != -1) {
bool waypoint = (SlReadByte() & FACIL_WAYPOINT) != 0;

View File

@@ -11,6 +11,7 @@
#include "../stdafx.h"
#include "../string_func.h"
#include "../strings_func.h"
#include "saveload_internal.h"
#include "table/strings.h"
@@ -60,7 +61,7 @@ char *_old_name_array = NULL;
char *CopyFromOldName(StringID id)
{
/* Is this name an (old) custom name? */
if (GB(id, 11, 5) != 15) return NULL;
if (GetStringTab(id) != TEXT_TAB_OLD_CUSTOM) return NULL;
if (IsSavegameVersionBefore(37)) {
/* Allow for expansion when converted to UTF-8. */

View File

@@ -14,6 +14,7 @@
#include "../town.h"
#include "../landscape.h"
#include "../subsidy_func.h"
#include "../strings_func.h"
#include "saveload.h"
#include "newgrf_sl.h"
@@ -285,7 +286,7 @@ static void Load_TOWN()
SlObject(&t->received[i], _town_received_desc);
}
if (t->townnamegrfid == 0 && !IsInsideMM(t->townnametype, SPECSTR_TOWNNAME_START, SPECSTR_TOWNNAME_LAST + 1) && GB(t->townnametype, 11, 5) != 15) {
if (t->townnamegrfid == 0 && !IsInsideMM(t->townnametype, SPECSTR_TOWNNAME_START, SPECSTR_TOWNNAME_LAST + 1) && GetStringTab(t->townnametype) != TEXT_TAB_OLD_CUSTOM) {
SlErrorCorrupt("Invalid town name generator");
}