Merge branch 'master' into enhanced_viewport_overlay

Notes on conflict resolution:
* MarkTileDirtyByTile gained an extra param on both sides of the merge
  Move bridge level offset to be after zoom level param, as it's used less.
* Add zoom level params to MarkBridgeDirty functions
* Fix undefined behaviour in colour_index cycling in ViewportMapDraw

Conflicts:
	src/clear_cmd.cpp
	src/pbs.cpp
	src/rail_cmd.cpp
	src/toolbar_gui.cpp
	src/train_cmd.cpp
	src/vehicle.cpp
	src/viewport.cpp
	src/viewport_func.h
This commit is contained in:
Jonathan G Rennison
2015-08-05 21:25:13 +01:00
220 changed files with 5428 additions and 4324 deletions

View File

@@ -16,6 +16,7 @@
#include "../fios.h"
#include "../gamelog_internal.h"
#include "../network/network.h"
#include "../network/network_func.h"
#include "../gfxinit.h"
#include "../viewport_func.h"
#include "../industry.h"
@@ -2951,18 +2952,20 @@ bool AfterLoadGame()
}
/*
* Only keep order-backups for network clients.
* Only keep order-backups for network clients (and when replaying).
* If we are a network server or not networking, then we just loaded a previously
* saved-by-server savegame. There are no clients with a backup, so clear it.
* Furthermore before savegame version 192 the actual content was always corrupt.
*/
if (!_networking || _network_server || IsSavegameVersionBefore(192)) {
#ifndef DEBUG_DUMP_COMMANDS
/* Note: We cannot use CleanPool since that skips part of the destructor
* and then leaks un-reachable Orders in the order pool. */
OrderBackup *ob;
FOR_ALL_ORDER_BACKUPS(ob) {
delete ob;
}
#endif
}

View File

@@ -48,21 +48,39 @@ static const SaveLoad _engine_desc[] = {
SLE_END()
};
static std::vector<Engine> _temp_engine;
static std::vector<Engine*> _temp_engine;
/**
* Allocate an Engine structure, but not using the pools.
* The allocated Engine must be freed using FreeEngine;
* @return Allocated engine.
*/
static Engine* CallocEngine()
{
uint8 *zero = CallocT<uint8>(sizeof(Engine));
Engine *engine = new (zero) Engine();
return engine;
}
/**
* Deallocate an Engine constructed by CallocEngine.
* @param e Engine to free.
*/
static void FreeEngine(Engine *e)
{
if (e != NULL) {
e->~Engine();
free(e);
}
}
Engine *GetTempDataEngine(EngineID index)
{
if (index < _temp_engine.size()) {
return &_temp_engine[index];
return _temp_engine[index];
} else if (index == _temp_engine.size()) {
uint8 zero[sizeof(Engine)];
memset(zero, 0, sizeof(zero));
Engine *engine = new (zero) Engine();
/* Adding 'engine' to the vector makes a shallow copy, so we do not want to destruct 'engine' */
_temp_engine.push_back(*engine);
return &_temp_engine[index];
_temp_engine.push_back(CallocEngine());
return _temp_engine[index];
} else {
NOT_REACHED();
}
@@ -127,6 +145,9 @@ void CopyTempEngineData()
}
/* Get rid of temporary data */
for (std::vector<Engine*>::iterator it = _temp_engine.begin(); it != _temp_engine.end(); ++it) {
FreeEngine(*it);
}
_temp_engine.clear();
}

View File

@@ -160,14 +160,14 @@ static void Save_ITBL()
/** Load industry-type build data. */
static void Load_ITBL()
{
int index;
for (int i = 0; i < NUM_INDUSTRYTYPES; i++) {
index = SlIterateArray();
assert(index == i);
SlObject(_industry_builder.builddata + i, _industrytype_builder_desc);
for (IndustryType it = 0; it < NUM_INDUSTRYTYPES; it++) {
_industry_builder.builddata[it].Reset();
}
int index;
while ((index = SlIterateArray()) != -1) {
if ((uint)index >= NUM_INDUSTRYTYPES) SlErrorCorrupt("Too many industry builder datas");
SlObject(_industry_builder.builddata + index, _industrytype_builder_desc);
}
index = SlIterateArray();
assert(index == -1);
}
extern const ChunkHandler _industry_chunk_handlers[] = {

View File

@@ -220,7 +220,7 @@ static void Load_LGRJ()
*/
static void Load_LGRS()
{
SlObject(LinkGraphSchedule::Instance(), GetLinkGraphScheduleDesc());
SlObject(&LinkGraphSchedule::instance, GetLinkGraphScheduleDesc());
}
/**
@@ -246,7 +246,7 @@ void AfterLoadLinkGraphs()
}
}
LinkGraphSchedule::Instance()->SpawnAll();
LinkGraphSchedule::instance.SpawnAll();
}
/**
@@ -278,7 +278,7 @@ static void Save_LGRJ()
*/
static void Save_LGRS()
{
SlObject(LinkGraphSchedule::Instance(), GetLinkGraphScheduleDesc());
SlObject(&LinkGraphSchedule::instance, GetLinkGraphScheduleDesc());
}
/**
@@ -286,7 +286,7 @@ static void Save_LGRS()
*/
static void Ptrs_LGRS()
{
SlObject(LinkGraphSchedule::Instance(), GetLinkGraphScheduleDesc());
SlObject(&LinkGraphSchedule::instance, GetLinkGraphScheduleDesc());
}
extern const ChunkHandler _linkgraph_chunk_handlers[] = {

View File

@@ -51,7 +51,7 @@ void Load_NewGRFMapping(OverrideManagerBase &mapping)
int index;
while ((index = SlIterateArray()) != -1) {
if ((uint)index >= max_id) break;
if ((uint)index >= max_id) SlErrorCorrupt("Too many NewGRF entity mappings");
SlObject(&mapping.mapping_ID[index], _newgrf_mapping_desc);
}
}

View File

@@ -261,7 +261,7 @@
* 191 26646
* 192 26700
* 193 26802
* 194 26881
* 194 26881 1.5.x
*/
extern const uint16 SAVEGAME_VERSION = 195; ///< Current savegame version of OpenTTD.
@@ -1669,9 +1669,11 @@ static void SlLoadChunk(const ChunkHandler *ch)
case CH_ARRAY:
_sl.array_index = 0;
ch->load_proc();
if (_next_offs != 0) SlErrorCorrupt("Invalid array length");
break;
case CH_SPARSE_ARRAY:
ch->load_proc();
if (_next_offs != 0) SlErrorCorrupt("Invalid array length");
break;
default:
if ((m & 0xF) == CH_RIFF) {