Merge branch 'enhanced_viewport_overlay-sx' into jgrpp
town_gui.cpp updated due to struct CommandContainer change. Conflicts: src/command.cpp src/command_type.h src/gfxinit.cpp src/openttd.cpp src/pbs.cpp src/saveload/extended_ver_sl.cpp src/saveload/extended_ver_sl.h src/saveload/saveload.cpp src/stdafx.h src/train_cmd.cpp src/viewport_type.h src/window_type.h
This commit is contained in:
@@ -57,6 +57,7 @@ const SlxiSubChunkInfo _sl_xv_sub_chunk_infos[] = {
|
||||
{ XSLFI_TT_WAIT_IN_DEPOT, XSCF_NULL, 1, 1, "tt_wait_in_depot", NULL, NULL, NULL },
|
||||
{ XSLFI_AUTO_TIMETABLE, XSCF_NULL, 1, 1, "auto_timetables", NULL, NULL, NULL },
|
||||
{ XSLFI_VEHICLE_REPAIR_COST, XSCF_NULL, 1, 1, "vehicle_repair_cost", NULL, NULL, NULL },
|
||||
{ XSLFI_ENH_VIEWPORT_PLANS, XSCF_IGNORABLE_ALL, 1, 1, "enh_viewport_plans", NULL, NULL, "PLAN,PLLN" },
|
||||
{ XSLFI_NULL, XSCF_NULL, 0, 0, NULL, NULL, NULL, NULL },// This is the end marker
|
||||
};
|
||||
|
||||
|
@@ -32,6 +32,7 @@ enum SlXvFeatureIndex {
|
||||
XSLFI_TT_WAIT_IN_DEPOT, ///< Timetabling waiting time in depot patch
|
||||
XSLFI_AUTO_TIMETABLE, ///< Auto timetables and separation patch
|
||||
XSLFI_VEHICLE_REPAIR_COST, ///< Vehicle repair costs patch
|
||||
XSLFI_ENH_VIEWPORT_PLANS, ///< Enhanced viewport patch: plans
|
||||
|
||||
XSLFI_SIZE, ///< Total count of features, including null feature
|
||||
};
|
||||
@@ -86,6 +87,8 @@ enum SlxiSubChunkFlags {
|
||||
XSCF_IGNORABLE_VERSION = 1 << 1, ///< the loader is free to ignore this without aborting the load if the version is greater than the maximum that can be loaded
|
||||
XSCF_EXTRA_DATA_PRESENT = 1 << 2, ///< extra data field is present, extra data in some sub-chunk/feature specific format, not used for anything yet
|
||||
XSCF_CHUNK_ID_LIST_PRESENT = 1 << 3, ///< chunk ID list field is present, list of chunks which this sub-chunk/feature adds to the save game, this can be used to discard the chunks if the feature is unknown
|
||||
|
||||
XSCF_IGNORABLE_ALL = XSCF_IGNORABLE_UNKNOWN | XSCF_IGNORABLE_VERSION, ///< all "ignorable" flags
|
||||
};
|
||||
DECLARE_ENUM_AS_BIT_SET(SlxiSubChunkFlags)
|
||||
|
||||
|
87
src/saveload/plans_sl.cpp
Normal file
87
src/saveload/plans_sl.cpp
Normal file
@@ -0,0 +1,87 @@
|
||||
/* $Id$ */
|
||||
|
||||
/*
|
||||
* This file is part of OpenTTD.
|
||||
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
||||
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** @file plans_sl.cpp Code handling saving and loading of plans data. */
|
||||
|
||||
#include "../stdafx.h"
|
||||
#include "../plans_base.h"
|
||||
#include "../fios.h"
|
||||
|
||||
#include "saveload.h"
|
||||
|
||||
/** Description of a plan within the savegame. */
|
||||
static const SaveLoad _plan_desc[] = {
|
||||
SLE_VAR(Plan, owner, SLE_UINT8),
|
||||
SLE_VAR(Plan, visible, SLE_BOOL),
|
||||
SLE_VAR(Plan, visible_by_all, SLE_BOOL),
|
||||
SLE_VAR(Plan, creation_date, SLE_INT32),
|
||||
SLE_END()
|
||||
};
|
||||
|
||||
/** Save all plans. */
|
||||
static void Save_PLAN()
|
||||
{
|
||||
Plan *p;
|
||||
FOR_ALL_PLANS(p) {
|
||||
SlSetArrayIndex(p->index);
|
||||
SlObject(p, _plan_desc);
|
||||
}
|
||||
}
|
||||
|
||||
/** Load all plans. */
|
||||
static void Load_PLAN()
|
||||
{
|
||||
int index;
|
||||
while ((index = SlIterateArray()) != -1) {
|
||||
Plan *p = new (index) Plan();
|
||||
SlObject(p, _plan_desc);
|
||||
}
|
||||
}
|
||||
|
||||
/** Save all plan lines. */
|
||||
static void Save_PLANLINE()
|
||||
{
|
||||
Plan *p;
|
||||
FOR_ALL_PLANS(p) {
|
||||
for (size_t i = 0; i < p->lines.size(); i++) {
|
||||
SlSetArrayIndex((uint) p->index << 16 | (uint) i);
|
||||
PlanLine *pl = p->lines[i];
|
||||
size_t plsz = pl->tiles.size();
|
||||
SlSetLength(plsz * sizeof(TileIndex));
|
||||
SlArray(&pl->tiles[0], plsz, SLE_UINT32);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Load all plan lines. */
|
||||
static void Load_PLANLINE()
|
||||
{
|
||||
int index;
|
||||
while ((index = SlIterateArray()) != -1) {
|
||||
Plan *p = Plan::Get((uint) index >> 16);
|
||||
uint line_index = index & 0xFFFF;
|
||||
if (p->lines.size() <= line_index) p->lines.resize(line_index + 1);
|
||||
PlanLine *pl = new PlanLine();
|
||||
p->lines[line_index] = pl;
|
||||
size_t plsz = SlGetFieldLength() / sizeof(TileIndex);
|
||||
pl->tiles.resize(plsz);
|
||||
SlArray(&pl->tiles[0], plsz, SLE_UINT32);
|
||||
}
|
||||
|
||||
Plan *p;
|
||||
FOR_ALL_PLANS(p) {
|
||||
p->SetVisibility(false);
|
||||
}
|
||||
}
|
||||
|
||||
/** Chunk handlers related to plans. */
|
||||
extern const ChunkHandler _plan_chunk_handlers[] = {
|
||||
{ 'PLAN', Save_PLAN, Load_PLAN, NULL, NULL, CH_ARRAY},
|
||||
{ 'PLLN', Save_PLANLINE, Load_PLANLINE, NULL, NULL, CH_ARRAY | CH_LAST},
|
||||
};
|
@@ -456,6 +456,7 @@ extern const ChunkHandler _object_chunk_handlers[];
|
||||
extern const ChunkHandler _persistent_storage_chunk_handlers[];
|
||||
extern const ChunkHandler _trace_restrict_chunk_handlers[];
|
||||
extern const ChunkHandler _signal_chunk_handlers[];
|
||||
extern const ChunkHandler _plan_chunk_handlers[];
|
||||
|
||||
/** Array of all chunks in a savegame, \c NULL terminated. */
|
||||
static const ChunkHandler * const _chunk_handlers[] = {
|
||||
@@ -495,6 +496,7 @@ static const ChunkHandler * const _chunk_handlers[] = {
|
||||
_persistent_storage_chunk_handlers,
|
||||
_trace_restrict_chunk_handlers,
|
||||
_signal_chunk_handlers,
|
||||
_plan_chunk_handlers,
|
||||
NULL,
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user