Changeset - r25596:7bf7822e5659
src/saveload/ai_sl.cpp
Show inline comments
 
@@ -117,9 +117,11 @@ static void Save_AIPL()
 
	for (int i = COMPANY_FIRST; i < MAX_COMPANIES; i++) {
 
		SlSetArrayIndex(i);
 
		SlAutolength((AutolengthProc *)SaveReal_AIPL, &i);
 
	}
 
}
 

	
 
extern const ChunkHandler _ai_chunk_handlers[] = {
 
	{ 'AIPL', Save_AIPL, Load_AIPL, nullptr, nullptr, CH_ARRAY | CH_LAST},
 
static const ChunkHandler ai_chunk_handlers[] = {
 
	{ 'AIPL', Save_AIPL, Load_AIPL, nullptr, nullptr, CH_ARRAY },
 
};
 

	
 
extern const ChunkHandlerTable _ai_chunk_handlers(ai_chunk_handlers);
src/saveload/airport_sl.cpp
Show inline comments
 
@@ -31,10 +31,12 @@ static void Save_ATID()
 

	
 
static void Load_ATID()
 
{
 
	Load_NewGRFMapping(_airporttile_mngr);
 
}
 

	
 
extern const ChunkHandler _airport_chunk_handlers[] = {
 
static const ChunkHandler airport_chunk_handlers[] = {
 
	{ 'ATID', Save_ATID, Load_ATID, nullptr, nullptr, CH_ARRAY },
 
	{ 'APID', Save_APID, Load_APID, nullptr, nullptr, CH_ARRAY | CH_LAST },
 
	{ 'APID', Save_APID, Load_APID, nullptr, nullptr, CH_ARRAY },
 
};
 

	
 
extern const ChunkHandlerTable _airport_chunk_handlers(airport_chunk_handlers);
src/saveload/animated_tile_sl.cpp
Show inline comments
 
@@ -52,9 +52,11 @@ static void Load_ANIT()
 
}
 

	
 
/**
 
 * "Definition" imported by the saveload code to be able to load and save
 
 * the animated tile table.
 
 */
 
extern const ChunkHandler _animated_tile_chunk_handlers[] = {
 
	{ 'ANIT', Save_ANIT, Load_ANIT, nullptr, nullptr, CH_RIFF | CH_LAST},
 
static const ChunkHandler animated_tile_chunk_handlers[] = {
 
	{ 'ANIT', Save_ANIT, Load_ANIT, nullptr, nullptr, CH_RIFF },
 
};
 

	
 
extern const ChunkHandlerTable _animated_tile_chunk_handlers(animated_tile_chunk_handlers);
src/saveload/autoreplace_sl.cpp
Show inline comments
 
@@ -52,9 +52,11 @@ static void Ptrs_ERNW()
 
{
 
	for (EngineRenew *er : EngineRenew::Iterate()) {
 
		SlObject(er, _engine_renew_desc);
 
	}
 
}
 

	
 
extern const ChunkHandler _autoreplace_chunk_handlers[] = {
 
	{ 'ERNW', Save_ERNW, Load_ERNW, Ptrs_ERNW, nullptr, CH_ARRAY | CH_LAST},
 
static const ChunkHandler autoreplace_chunk_handlers[] = {
 
	{ 'ERNW', Save_ERNW, Load_ERNW, Ptrs_ERNW, nullptr, CH_ARRAY },
 
};
 

	
 
extern const ChunkHandlerTable _autoreplace_chunk_handlers(autoreplace_chunk_handlers);
src/saveload/cargomonitor_sl.cpp
Show inline comments
 
@@ -114,10 +114,12 @@ static void LoadPickup()
 
		std::pair<CargoMonitorID, uint32> p(storage.number, storage.amount);
 
		_cargo_pickups.insert(p);
 
	}
 
}
 

	
 
/** Chunk definition of the cargomonitoring maps. */
 
extern const ChunkHandler _cargomonitor_chunk_handlers[] = {
 
	{ 'CMDL', SaveDelivery, LoadDelivery, nullptr, nullptr, CH_ARRAY},
 
	{ 'CMPU', SavePickup,   LoadPickup,   nullptr, nullptr, CH_ARRAY | CH_LAST},
 
static const ChunkHandler cargomonitor_chunk_handlers[] = {
 
	{ 'CMDL', SaveDelivery, LoadDelivery, nullptr, nullptr, CH_ARRAY },
 
	{ 'CMPU', SavePickup,   LoadPickup,   nullptr, nullptr, CH_ARRAY },
 
};
 

	
 
extern const ChunkHandlerTable _cargomonitor_chunk_handlers(cargomonitor_chunk_handlers);
src/saveload/cargopacket_sl.cpp
Show inline comments
 
@@ -123,9 +123,11 @@ static void Load_CAPA()
 
		CargoPacket *cp = new (index) CargoPacket();
 
		SlObject(cp, GetCargoPacketDesc());
 
	}
 
}
 

	
 
/** Chunk handlers related to cargo packets. */
 
extern const ChunkHandler _cargopacket_chunk_handlers[] = {
 
	{ 'CAPA', Save_CAPA, Load_CAPA, nullptr, nullptr, CH_ARRAY | CH_LAST},
 
static const ChunkHandler cargopacket_chunk_handlers[] = {
 
	{ 'CAPA', Save_CAPA, Load_CAPA, nullptr, nullptr, CH_ARRAY },
 
};
 

	
 
extern const ChunkHandlerTable _cargopacket_chunk_handlers(cargopacket_chunk_handlers);
src/saveload/cheat_sl.cpp
Show inline comments
 
@@ -45,9 +45,11 @@ static void Load_CHTS()
 
		cht[i].been_used = (SlReadByte() != 0);
 
		cht[i].value     = (SlReadByte() != 0);
 
	}
 
}
 

	
 
/** Chunk handlers related to cheats. */
 
extern const ChunkHandler _cheat_chunk_handlers[] = {
 
	{ 'CHTS', Save_CHTS, Load_CHTS, nullptr, nullptr, CH_RIFF | CH_LAST},
 
static const ChunkHandler cheat_chunk_handlers[] = {
 
	{ 'CHTS', Save_CHTS, Load_CHTS, nullptr, nullptr, CH_RIFF },
 
};
 

	
 
extern const ChunkHandlerTable _cheat_chunk_handlers(cheat_chunk_handlers);
src/saveload/company_sl.cpp
Show inline comments
 
@@ -524,9 +524,11 @@ static void Ptrs_PLYR()
 
	for (Company *c : Company::Iterate()) {
 
		SlObject(c, _company_settings_desc);
 
	}
 
}
 

	
 

	
 
extern const ChunkHandler _company_chunk_handlers[] = {
 
	{ 'PLYR', Save_PLYR, Load_PLYR, Ptrs_PLYR, Check_PLYR, CH_ARRAY | CH_LAST},
 
static const ChunkHandler company_chunk_handlers[] = {
 
	{ 'PLYR', Save_PLYR, Load_PLYR, Ptrs_PLYR, Check_PLYR, CH_ARRAY },
 
};
 

	
 
extern const ChunkHandlerTable _company_chunk_handlers(company_chunk_handlers);
src/saveload/depot_sl.cpp
Show inline comments
 
@@ -53,9 +53,11 @@ static void Ptrs_DEPT()
 
	for (Depot *depot : Depot::Iterate()) {
 
		SlObject(depot, _depot_desc);
 
		if (IsSavegameVersionBefore(SLV_141)) depot->town = Town::Get((size_t)depot->town);
 
	}
 
}
 

	
 
extern const ChunkHandler _depot_chunk_handlers[] = {
 
	{ 'DEPT', Save_DEPT, Load_DEPT, Ptrs_DEPT, nullptr, CH_ARRAY | CH_LAST},
 
static const ChunkHandler depot_chunk_handlers[] = {
 
	{ 'DEPT', Save_DEPT, Load_DEPT, Ptrs_DEPT, nullptr, CH_ARRAY },
 
};
 

	
 
extern const ChunkHandlerTable _depot_chunk_handlers(depot_chunk_handlers);
src/saveload/economy_sl.cpp
Show inline comments
 
@@ -91,12 +91,14 @@ static void Ptrs_CAPY()
 
	for (CargoPayment *cp : CargoPayment::Iterate()) {
 
		SlObject(cp, _cargopayment_desc);
 
	}
 
}
 

	
 

	
 
extern const ChunkHandler _economy_chunk_handlers[] = {
 
	{ 'CAPY', Save_CAPY,     Load_CAPY,     Ptrs_CAPY, nullptr, CH_ARRAY},
 
	{ 'PRIC', nullptr,       Load_PRIC,     nullptr,   nullptr, CH_RIFF },
 
	{ 'CAPR', nullptr,       Load_CAPR,     nullptr,   nullptr, CH_RIFF },
 
	{ 'ECMY', Save_ECMY,     Load_ECMY,     nullptr,   nullptr, CH_RIFF | CH_LAST},
 
static const ChunkHandler economy_chunk_handlers[] = {
 
	{ 'CAPY', Save_CAPY, Load_CAPY, Ptrs_CAPY, nullptr, CH_ARRAY },
 
	{ 'PRIC', nullptr,   Load_PRIC, nullptr,   nullptr, CH_RIFF  },
 
	{ 'CAPR', nullptr,   Load_CAPR, nullptr,   nullptr, CH_RIFF  },
 
	{ 'ECMY', Save_ECMY, Load_ECMY, nullptr,   nullptr, CH_RIFF  },
 
};
 

	
 
extern const ChunkHandlerTable _economy_chunk_handlers(economy_chunk_handlers);
src/saveload/engine_sl.cpp
Show inline comments
 
@@ -190,11 +190,13 @@ static void Load_EIDS()
 
	while (SlIterateArray() != -1) {
 
		EngineIDMapping *eid = &_engine_mngr.emplace_back();
 
		SlObject(eid, _engine_id_mapping_desc);
 
	}
 
}
 

	
 
extern const ChunkHandler _engine_chunk_handlers[] = {
 
	{ 'EIDS', Save_EIDS, Load_EIDS, nullptr, nullptr, CH_ARRAY          },
 
	{ 'ENGN', Save_ENGN, Load_ENGN, nullptr, nullptr, CH_ARRAY          },
 
	{ 'ENGS', nullptr,   Load_ENGS, nullptr, nullptr, CH_RIFF | CH_LAST },
 
static const ChunkHandler engine_chunk_handlers[] = {
 
	{ 'EIDS', Save_EIDS, Load_EIDS, nullptr, nullptr, CH_ARRAY },
 
	{ 'ENGN', Save_ENGN, Load_ENGN, nullptr, nullptr, CH_ARRAY },
 
	{ 'ENGS', nullptr,   Load_ENGS, nullptr, nullptr, CH_RIFF  },
 
};
 

	
 
extern const ChunkHandlerTable _engine_chunk_handlers(engine_chunk_handlers);
src/saveload/game_sl.cpp
Show inline comments
 
@@ -170,10 +170,12 @@ static void Save_GSTR()
 
	for (uint i = 0; i < _current_data->raw_strings.size(); i++) {
 
		SlSetArrayIndex(i);
 
		SlAutolength((AutolengthProc *)SaveReal_GSTR, &_current_data->raw_strings[i]);
 
	}
 
}
 

	
 
extern const ChunkHandler _game_chunk_handlers[] = {
 
static const ChunkHandler game_chunk_handlers[] = {
 
	{ 'GSTR', Save_GSTR, Load_GSTR, nullptr, nullptr, CH_ARRAY },
 
	{ 'GSDT', Save_GSDT, Load_GSDT, nullptr, nullptr, CH_ARRAY | CH_LAST},
 
	{ 'GSDT', Save_GSDT, Load_GSDT, nullptr, nullptr, CH_ARRAY },
 
};
 

	
 
extern const ChunkHandlerTable _game_chunk_handlers(game_chunk_handlers);
src/saveload/gamelog_sl.cpp
Show inline comments
 
@@ -165,9 +165,11 @@ static void Load_GLOG()
 

	
 
static void Check_GLOG()
 
{
 
	Load_GLOG_common(_load_check_data.gamelog_action, _load_check_data.gamelog_actions);
 
}
 

	
 
extern const ChunkHandler _gamelog_chunk_handlers[] = {
 
	{ 'GLOG', Save_GLOG, Load_GLOG, nullptr, Check_GLOG, CH_RIFF | CH_LAST }
 
static const ChunkHandler gamelog_chunk_handlers[] = {
 
	{ 'GLOG', Save_GLOG, Load_GLOG, nullptr, Check_GLOG, CH_RIFF }
 
};
 

	
 
extern const ChunkHandlerTable _gamelog_chunk_handlers(gamelog_chunk_handlers);
src/saveload/goal_sl.cpp
Show inline comments
 
@@ -37,9 +37,11 @@ static void Load_GOAL()
 
	while ((index = SlIterateArray()) != -1) {
 
		Goal *s = new (index) Goal();
 
		SlObject(s, _goals_desc);
 
	}
 
}
 

	
 
extern const ChunkHandler _goal_chunk_handlers[] = {
 
	{ 'GOAL', Save_GOAL, Load_GOAL, nullptr, nullptr, CH_ARRAY | CH_LAST},
 
static const ChunkHandler goal_chunk_handlers[] = {
 
	{ 'GOAL', Save_GOAL, Load_GOAL, nullptr, nullptr, CH_ARRAY },
 
};
 

	
 
extern const ChunkHandlerTable _goal_chunk_handlers(goal_chunk_handlers);
src/saveload/group_sl.cpp
Show inline comments
 
@@ -52,9 +52,11 @@ static void Load_GRPS()
 
	                g->livery.colour1 = c->livery[LS_DEFAULT].colour1;
 
	                g->livery.colour2 = c->livery[LS_DEFAULT].colour2;
 
		}
 
	}
 
}
 

	
 
extern const ChunkHandler _group_chunk_handlers[] = {
 
	{ 'GRPS', Save_GRPS, Load_GRPS, nullptr, nullptr, CH_ARRAY | CH_LAST},
 
static const ChunkHandler group_chunk_handlers[] = {
 
	{ 'GRPS', Save_GRPS, Load_GRPS, nullptr, nullptr, CH_ARRAY },
 
};
 

	
 
extern const ChunkHandlerTable _group_chunk_handlers(group_chunk_handlers);
src/saveload/industry_sl.cpp
Show inline comments
 
@@ -173,13 +173,15 @@ static void Load_ITBL()
 
	while ((index = SlIterateArray()) != -1) {
 
		if ((uint)index >= NUM_INDUSTRYTYPES) SlErrorCorrupt("Too many industry builder datas");
 
		SlObject(_industry_builder.builddata + index, _industrytype_builder_desc);
 
	}
 
}
 

	
 
extern const ChunkHandler _industry_chunk_handlers[] = {
 
	{ 'INDY', Save_INDY,     Load_INDY,     Ptrs_INDY, nullptr, CH_ARRAY},
 
	{ 'IIDS', Save_IIDS,     Load_IIDS,     nullptr,   nullptr, CH_ARRAY},
 
	{ 'TIDS', Save_TIDS,     Load_TIDS,     nullptr,   nullptr, CH_ARRAY},
 
	{ 'IBLD', LoadSave_IBLD, LoadSave_IBLD, nullptr,   nullptr, CH_RIFF},
 
	{ 'ITBL', Save_ITBL,     Load_ITBL,     nullptr,   nullptr, CH_ARRAY | CH_LAST},
 
static const ChunkHandler industry_chunk_handlers[] = {
 
	{ 'INDY', Save_INDY,     Load_INDY,     Ptrs_INDY, nullptr, CH_ARRAY },
 
	{ 'IIDS', Save_IIDS,     Load_IIDS,     nullptr,   nullptr, CH_ARRAY },
 
	{ 'TIDS', Save_TIDS,     Load_TIDS,     nullptr,   nullptr, CH_ARRAY },
 
	{ 'IBLD', LoadSave_IBLD, LoadSave_IBLD, nullptr,   nullptr, CH_RIFF  },
 
	{ 'ITBL', Save_ITBL,     Load_ITBL,     nullptr,   nullptr, CH_ARRAY },
 
};
 

	
 
extern const ChunkHandlerTable _industry_chunk_handlers(industry_chunk_handlers);
src/saveload/labelmaps_sl.cpp
Show inline comments
 
@@ -118,10 +118,12 @@ static void Load_RAIL()
 
	while (SlIterateArray() != -1) {
 
		SlObject(&lo, _label_object_desc);
 
		_railtype_list.push_back((RailTypeLabel)lo.label);
 
	}
 
}
 

	
 
extern const ChunkHandler _labelmaps_chunk_handlers[] = {
 
	{ 'RAIL', Save_RAIL, Load_RAIL, nullptr, nullptr, CH_ARRAY | CH_LAST},
 
static const ChunkHandler labelmaps_chunk_handlers[] = {
 
	{ 'RAIL', Save_RAIL, Load_RAIL, nullptr, nullptr, CH_ARRAY },
 
};
 

	
 
extern const ChunkHandlerTable _labelmaps_chunk_handlers(labelmaps_chunk_handlers);
 

	
src/saveload/linkgraph_sl.cpp
Show inline comments
 
@@ -277,11 +277,13 @@ static void Save_LGRS()
 
 */
 
static void Ptrs_LGRS()
 
{
 
	SlObject(&LinkGraphSchedule::instance, GetLinkGraphScheduleDesc());
 
}
 

	
 
extern const ChunkHandler _linkgraph_chunk_handlers[] = {
 
static const ChunkHandler linkgraph_chunk_handlers[] = {
 
	{ 'LGRP', Save_LGRP, Load_LGRP, nullptr,   nullptr, CH_ARRAY },
 
	{ 'LGRJ', Save_LGRJ, Load_LGRJ, nullptr,   nullptr, CH_ARRAY },
 
	{ 'LGRS', Save_LGRS, Load_LGRS, Ptrs_LGRS, nullptr, CH_LAST  }
 
	{ 'LGRS', Save_LGRS, Load_LGRS, Ptrs_LGRS, nullptr, CH_RIFF  }
 
};
 

	
 
extern const ChunkHandlerTable _linkgraph_chunk_handlers(linkgraph_chunk_handlers);
src/saveload/map_sl.cpp
Show inline comments
 
@@ -291,19 +291,21 @@ static void Save_MAP8()
 
		for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] = _me[i++].m8;
 
		SlArray(buf.data(), MAP_SL_BUF_SIZE, SLE_UINT16);
 
	}
 
}
 

	
 

	
 
extern const ChunkHandler _map_chunk_handlers[] = {
 
static const ChunkHandler map_chunk_handlers[] = {
 
	{ 'MAPS', Save_MAPS, Load_MAPS, nullptr, Check_MAPS, CH_RIFF },
 
	{ 'MAPT', Save_MAPT, Load_MAPT, nullptr, nullptr,    CH_RIFF },
 
	{ 'MAPH', Save_MAPH, Load_MAPH, nullptr, nullptr,    CH_RIFF },
 
	{ 'MAPO', Save_MAP1, Load_MAP1, nullptr, nullptr,    CH_RIFF },
 
	{ 'MAP2', Save_MAP2, Load_MAP2, nullptr, nullptr,    CH_RIFF },
 
	{ 'M3LO', Save_MAP3, Load_MAP3, nullptr, nullptr,    CH_RIFF },
 
	{ 'M3HI', Save_MAP4, Load_MAP4, nullptr, nullptr,    CH_RIFF },
 
	{ 'MAP5', Save_MAP5, Load_MAP5, nullptr, nullptr,    CH_RIFF },
 
	{ 'MAPE', Save_MAP6, Load_MAP6, nullptr, nullptr,    CH_RIFF },
 
	{ 'MAP7', Save_MAP7, Load_MAP7, nullptr, nullptr,    CH_RIFF },
 
	{ 'MAP8', Save_MAP8, Load_MAP8, nullptr, nullptr,    CH_RIFF | CH_LAST },
 
	{ 'MAP8', Save_MAP8, Load_MAP8, nullptr, nullptr,    CH_RIFF },
 
};
 

	
 
extern const ChunkHandlerTable _map_chunk_handlers(map_chunk_handlers);
src/saveload/misc_sl.cpp
Show inline comments
 
@@ -142,10 +142,12 @@ static const SaveLoad _view_desc[] = {
 

	
 
static void SaveLoad_VIEW()
 
{
 
	SlGlobList(_view_desc);
 
}
 

	
 
extern const ChunkHandler _misc_chunk_handlers[] = {
 
	{ 'DATE', SaveLoad_DATE, SaveLoad_DATE, nullptr, Check_DATE, CH_RIFF},
 
	{ 'VIEW', SaveLoad_VIEW, SaveLoad_VIEW, nullptr, nullptr,    CH_RIFF | CH_LAST},
 
static const ChunkHandler misc_chunk_handlers[] = {
 
	{ 'DATE', SaveLoad_DATE, SaveLoad_DATE, nullptr, Check_DATE, CH_RIFF },
 
	{ 'VIEW', SaveLoad_VIEW, SaveLoad_VIEW, nullptr, nullptr,    CH_RIFF },
 
};
 

	
 
extern const ChunkHandlerTable _misc_chunk_handlers(misc_chunk_handlers);
src/saveload/newgrf_sl.cpp
Show inline comments
 
@@ -108,9 +108,11 @@ static void Load_NGRF()
 

	
 
static void Check_NGRF()
 
{
 
	Load_NGRF_common(_load_check_data.grfconfig);
 
}
 

	
 
extern const ChunkHandler _newgrf_chunk_handlers[] = {
 
	{ 'NGRF', Save_NGRF, Load_NGRF, nullptr, Check_NGRF, CH_ARRAY | CH_LAST }
 
static const ChunkHandler newgrf_chunk_handlers[] = {
 
	{ 'NGRF', Save_NGRF, Load_NGRF, nullptr, Check_NGRF, CH_ARRAY }
 
};
 

	
 
extern const ChunkHandlerTable _newgrf_chunk_handlers(newgrf_chunk_handlers);
src/saveload/object_sl.cpp
Show inline comments
 
@@ -63,10 +63,12 @@ static void Save_OBID()
 

	
 
static void Load_OBID()
 
{
 
	Load_NewGRFMapping(_object_mngr);
 
}
 

	
 
extern const ChunkHandler _object_chunk_handlers[] = {
 
static const ChunkHandler object_chunk_handlers[] = {
 
	{ 'OBID', Save_OBID, Load_OBID, nullptr,   nullptr, CH_ARRAY },
 
	{ 'OBJS', Save_OBJS, Load_OBJS, Ptrs_OBJS, nullptr, CH_ARRAY | CH_LAST},
 
	{ 'OBJS', Save_OBJS, Load_OBJS, Ptrs_OBJS, nullptr, CH_ARRAY },
 
};
 

	
 
extern const ChunkHandlerTable _object_chunk_handlers(object_chunk_handlers);
src/saveload/order_sl.cpp
Show inline comments
 
@@ -283,11 +283,13 @@ static void Ptrs_BKOR()
 
{
 
	for (OrderBackup *ob : OrderBackup::Iterate()) {
 
		SlObject(ob, GetOrderBackupDescription());
 
	}
 
}
 

	
 
extern const ChunkHandler _order_chunk_handlers[] = {
 
	{ 'BKOR', Save_BKOR, Load_BKOR, Ptrs_BKOR, nullptr, CH_ARRAY},
 
	{ 'ORDR', Save_ORDR, Load_ORDR, Ptrs_ORDR, nullptr, CH_ARRAY},
 
	{ 'ORDL', Save_ORDL, Load_ORDL, Ptrs_ORDL, nullptr, CH_ARRAY | CH_LAST},
 
static const ChunkHandler order_chunk_handlers[] = {
 
	{ 'BKOR', Save_BKOR, Load_BKOR, Ptrs_BKOR, nullptr, CH_ARRAY },
 
	{ 'ORDR', Save_ORDR, Load_ORDR, Ptrs_ORDR, nullptr, CH_ARRAY },
 
	{ 'ORDL', Save_ORDL, Load_ORDL, Ptrs_ORDL, nullptr, CH_ARRAY },
 
};
 

	
 
extern const ChunkHandlerTable _order_chunk_handlers(order_chunk_handlers);
src/saveload/saveload.cpp
Show inline comments
 
@@ -211,107 +211,113 @@ struct SaveLoadParams {
 
	uint16 game_speed;                   ///< The game speed when saving started.
 
	bool saveinprogress;                 ///< Whether there is currently a save in progress.
 
};
 

	
 
static SaveLoadParams _sl; ///< Parameters used for/at saveload.
 

	
 
/* these define the chunks */
 
extern const ChunkHandler _gamelog_chunk_handlers[];
 
extern const ChunkHandler _map_chunk_handlers[];
 
extern const ChunkHandler _misc_chunk_handlers[];
 
extern const ChunkHandler _name_chunk_handlers[];
 
extern const ChunkHandler _cheat_chunk_handlers[] ;
 
extern const ChunkHandler _setting_chunk_handlers[];
 
extern const ChunkHandler _company_chunk_handlers[];
 
extern const ChunkHandler _engine_chunk_handlers[];
 
extern const ChunkHandler _veh_chunk_handlers[];
 
extern const ChunkHandler _waypoint_chunk_handlers[];
 
extern const ChunkHandler _depot_chunk_handlers[];
 
extern const ChunkHandler _order_chunk_handlers[];
 
extern const ChunkHandler _town_chunk_handlers[];
 
extern const ChunkHandler _sign_chunk_handlers[];
 
extern const ChunkHandler _station_chunk_handlers[];
 
extern const ChunkHandler _industry_chunk_handlers[];
 
extern const ChunkHandler _economy_chunk_handlers[];
 
extern const ChunkHandler _subsidy_chunk_handlers[];
 
extern const ChunkHandler _cargomonitor_chunk_handlers[];
 
extern const ChunkHandler _goal_chunk_handlers[];
 
extern const ChunkHandler _story_page_chunk_handlers[];
 
extern const ChunkHandler _ai_chunk_handlers[];
 
extern const ChunkHandler _game_chunk_handlers[];
 
extern const ChunkHandler _animated_tile_chunk_handlers[];
 
extern const ChunkHandler _newgrf_chunk_handlers[];
 
extern const ChunkHandler _group_chunk_handlers[];
 
extern const ChunkHandler _cargopacket_chunk_handlers[];
 
extern const ChunkHandler _autoreplace_chunk_handlers[];
 
extern const ChunkHandler _labelmaps_chunk_handlers[];
 
extern const ChunkHandler _linkgraph_chunk_handlers[];
 
extern const ChunkHandler _airport_chunk_handlers[];
 
extern const ChunkHandler _object_chunk_handlers[];
 
extern const ChunkHandler _persistent_storage_chunk_handlers[];
 

	
 
/** Array of all chunks in a savegame, \c nullptr terminated. */
 
static const ChunkHandler * const _chunk_handlers[] = {
 
	_gamelog_chunk_handlers,
 
	_map_chunk_handlers,
 
	_misc_chunk_handlers,
 
	_name_chunk_handlers,
 
	_cheat_chunk_handlers,
 
	_setting_chunk_handlers,
 
	_veh_chunk_handlers,
 
	_waypoint_chunk_handlers,
 
	_depot_chunk_handlers,
 
	_order_chunk_handlers,
 
	_industry_chunk_handlers,
 
	_economy_chunk_handlers,
 
	_subsidy_chunk_handlers,
 
	_cargomonitor_chunk_handlers,
 
	_goal_chunk_handlers,
 
	_story_page_chunk_handlers,
 
	_engine_chunk_handlers,
 
	_town_chunk_handlers,
 
	_sign_chunk_handlers,
 
	_station_chunk_handlers,
 
	_company_chunk_handlers,
 
	_ai_chunk_handlers,
 
	_game_chunk_handlers,
 
	_animated_tile_chunk_handlers,
 
	_newgrf_chunk_handlers,
 
	_group_chunk_handlers,
 
	_cargopacket_chunk_handlers,
 
	_autoreplace_chunk_handlers,
 
	_labelmaps_chunk_handlers,
 
	_linkgraph_chunk_handlers,
 
	_airport_chunk_handlers,
 
	_object_chunk_handlers,
 
	_persistent_storage_chunk_handlers,
 
	nullptr,
 
};
 

	
 
/**
 
 * Iterate over all chunk handlers.
 
 * @param ch the chunk handler iterator
 
 */
 
#define FOR_ALL_CHUNK_HANDLERS(ch) \
 
	for (const ChunkHandler * const *chsc = _chunk_handlers; *chsc != nullptr; chsc++) \
 
		for (const ChunkHandler *ch = *chsc; ch != nullptr; ch = (ch->flags & CH_LAST) ? nullptr : ch + 1)
 
static const std::vector<ChunkHandler> &ChunkHandlers()
 
{
 
	/* These define the chunks */
 
	extern const ChunkHandlerTable _gamelog_chunk_handlers;
 
	extern const ChunkHandlerTable _map_chunk_handlers;
 
	extern const ChunkHandlerTable _misc_chunk_handlers;
 
	extern const ChunkHandlerTable _name_chunk_handlers;
 
	extern const ChunkHandlerTable _cheat_chunk_handlers;
 
	extern const ChunkHandlerTable _setting_chunk_handlers;
 
	extern const ChunkHandlerTable _company_chunk_handlers;
 
	extern const ChunkHandlerTable _engine_chunk_handlers;
 
	extern const ChunkHandlerTable _veh_chunk_handlers;
 
	extern const ChunkHandlerTable _waypoint_chunk_handlers;
 
	extern const ChunkHandlerTable _depot_chunk_handlers;
 
	extern const ChunkHandlerTable _order_chunk_handlers;
 
	extern const ChunkHandlerTable _town_chunk_handlers;
 
	extern const ChunkHandlerTable _sign_chunk_handlers;
 
	extern const ChunkHandlerTable _station_chunk_handlers;
 
	extern const ChunkHandlerTable _industry_chunk_handlers;
 
	extern const ChunkHandlerTable _economy_chunk_handlers;
 
	extern const ChunkHandlerTable _subsidy_chunk_handlers;
 
	extern const ChunkHandlerTable _cargomonitor_chunk_handlers;
 
	extern const ChunkHandlerTable _goal_chunk_handlers;
 
	extern const ChunkHandlerTable _story_page_chunk_handlers;
 
	extern const ChunkHandlerTable _ai_chunk_handlers;
 
	extern const ChunkHandlerTable _game_chunk_handlers;
 
	extern const ChunkHandlerTable _animated_tile_chunk_handlers;
 
	extern const ChunkHandlerTable _newgrf_chunk_handlers;
 
	extern const ChunkHandlerTable _group_chunk_handlers;
 
	extern const ChunkHandlerTable _cargopacket_chunk_handlers;
 
	extern const ChunkHandlerTable _autoreplace_chunk_handlers;
 
	extern const ChunkHandlerTable _labelmaps_chunk_handlers;
 
	extern const ChunkHandlerTable _linkgraph_chunk_handlers;
 
	extern const ChunkHandlerTable _airport_chunk_handlers;
 
	extern const ChunkHandlerTable _object_chunk_handlers;
 
	extern const ChunkHandlerTable _persistent_storage_chunk_handlers;
 

	
 
	/** List of all chunks in a savegame. */
 
	static const ChunkHandlerTable _chunk_handler_tables[] = {
 
		_gamelog_chunk_handlers,
 
		_map_chunk_handlers,
 
		_misc_chunk_handlers,
 
		_name_chunk_handlers,
 
		_cheat_chunk_handlers,
 
		_setting_chunk_handlers,
 
		_veh_chunk_handlers,
 
		_waypoint_chunk_handlers,
 
		_depot_chunk_handlers,
 
		_order_chunk_handlers,
 
		_industry_chunk_handlers,
 
		_economy_chunk_handlers,
 
		_subsidy_chunk_handlers,
 
		_cargomonitor_chunk_handlers,
 
		_goal_chunk_handlers,
 
		_story_page_chunk_handlers,
 
		_engine_chunk_handlers,
 
		_town_chunk_handlers,
 
		_sign_chunk_handlers,
 
		_station_chunk_handlers,
 
		_company_chunk_handlers,
 
		_ai_chunk_handlers,
 
		_game_chunk_handlers,
 
		_animated_tile_chunk_handlers,
 
		_newgrf_chunk_handlers,
 
		_group_chunk_handlers,
 
		_cargopacket_chunk_handlers,
 
		_autoreplace_chunk_handlers,
 
		_labelmaps_chunk_handlers,
 
		_linkgraph_chunk_handlers,
 
		_airport_chunk_handlers,
 
		_object_chunk_handlers,
 
		_persistent_storage_chunk_handlers,
 
	};
 

	
 
	static std::vector<ChunkHandler> _chunk_handlers;
 

	
 
	if (_chunk_handlers.empty()) {
 
		for (auto &chunk_handler_table : _chunk_handler_tables) {
 
			for (auto &chunk_handler : chunk_handler_table) {
 
				_chunk_handlers.push_back(chunk_handler);
 
			}
 
		}
 
	}
 

	
 
	return _chunk_handlers;
 
}
 

	
 
/** Null all pointers (convert index -> nullptr) */
 
static void SlNullPointers()
 
{
 
	_sl.action = SLA_NULL;
 

	
 
	/* We don't want any savegame conversion code to run
 
	 * during NULLing; especially those that try to get
 
	 * pointers from other pools. */
 
	_sl_version = SAVEGAME_VERSION;
 

	
 
	FOR_ALL_CHUNK_HANDLERS(ch) {
 
		if (ch->ptrs_proc != nullptr) {
 
			DEBUG(sl, 3, "Nulling pointers for %c%c%c%c", ch->id >> 24, ch->id >> 16, ch->id >> 8, ch->id);
 
			ch->ptrs_proc();
 
	for (auto &ch : ChunkHandlers()) {
 
		if (ch.ptrs_proc != nullptr) {
 
			DEBUG(sl, 3, "Nulling pointers for %c%c%c%c", ch.id >> 24, ch.id >> 16, ch.id >> 8, ch.id);
 
			ch.ptrs_proc();
 
		}
 
	}
 

	
 
	assert(_sl.action == SLA_NULL);
 
}
 

	
 
@@ -1651,39 +1657,39 @@ void SlAutolength(AutolengthProc *proc, 
 
}
 

	
 
/**
 
 * Load a chunk of data (eg vehicles, stations, etc.)
 
 * @param ch The chunkhandler that will be used for the operation
 
 */
 
static void SlLoadChunk(const ChunkHandler *ch)
 
static void SlLoadChunk(const ChunkHandler &ch)
 
{
 
	byte m = SlReadByte();
 
	size_t len;
 
	size_t endoffs;
 

	
 
	_sl.block_mode = m;
 
	_sl.obj_len = 0;
 

	
 
	switch (m) {
 
		case CH_ARRAY:
 
			_sl.array_index = 0;
 
			ch->load_proc();
 
			ch.load_proc();
 
			if (_next_offs != 0) SlErrorCorrupt("Invalid array length");
 
			break;
 
		case CH_SPARSE_ARRAY:
 
			ch->load_proc();
 
			ch.load_proc();
 
			if (_next_offs != 0) SlErrorCorrupt("Invalid array length");
 
			break;
 
		default:
 
			if ((m & 0xF) == CH_RIFF) {
 
				/* Read length */
 
				len = (SlReadByte() << 16) | ((m >> 4) << 24);
 
				len += SlReadUint16();
 
				_sl.obj_len = len;
 
				endoffs = _sl.reader->GetSize() + len;
 
				ch->load_proc();
 
				ch.load_proc();
 
				if (_sl.reader->GetSize() != endoffs) SlErrorCorrupt("Invalid chunk size");
 
			} else {
 
				SlErrorCorrupt("Invalid chunk type");
 
			}
 
			break;
 
	}
 
@@ -1691,46 +1697,46 @@ static void SlLoadChunk(const ChunkHandl
 

	
 
/**
 
 * Load a chunk of data for checking savegames.
 
 * If the chunkhandler is nullptr, the chunk is skipped.
 
 * @param ch The chunkhandler that will be used for the operation
 
 */
 
static void SlLoadCheckChunk(const ChunkHandler *ch)
 
static void SlLoadCheckChunk(const ChunkHandler &ch)
 
{
 
	byte m = SlReadByte();
 
	size_t len;
 
	size_t endoffs;
 

	
 
	_sl.block_mode = m;
 
	_sl.obj_len = 0;
 

	
 
	switch (m) {
 
		case CH_ARRAY:
 
			_sl.array_index = 0;
 
			if (ch->load_check_proc) {
 
				ch->load_check_proc();
 
			if (ch.load_check_proc) {
 
				ch.load_check_proc();
 
			} else {
 
				SlSkipArray();
 
			}
 
			break;
 
		case CH_SPARSE_ARRAY:
 
			if (ch->load_check_proc) {
 
				ch->load_check_proc();
 
			if (ch.load_check_proc) {
 
				ch.load_check_proc();
 
			} else {
 
				SlSkipArray();
 
			}
 
			break;
 
		default:
 
			if ((m & 0xF) == CH_RIFF) {
 
				/* Read length */
 
				len = (SlReadByte() << 16) | ((m >> 4) << 24);
 
				len += SlReadUint16();
 
				_sl.obj_len = len;
 
				endoffs = _sl.reader->GetSize() + len;
 
				if (ch->load_check_proc) {
 
					ch->load_check_proc();
 
				if (ch.load_check_proc) {
 
					ch.load_check_proc();
 
				} else {
 
					SlSkipBytes(len);
 
				}
 
				if (_sl.reader->GetSize() != endoffs) SlErrorCorrupt("Invalid chunk size");
 
			} else {
 
				SlErrorCorrupt("Invalid chunk type");
 
@@ -1741,24 +1747,24 @@ static void SlLoadCheckChunk(const Chunk
 

	
 
/**
 
 * Save a chunk of data (eg. vehicles, stations, etc.). Each chunk is
 
 * prefixed by an ID identifying it, followed by data, and terminator where appropriate
 
 * @param ch The chunkhandler that will be used for the operation
 
 */
 
static void SlSaveChunk(const ChunkHandler *ch)
 
static void SlSaveChunk(const ChunkHandler &ch)
 
{
 
	ChunkSaveLoadProc *proc = ch->save_proc;
 
	ChunkSaveLoadProc *proc = ch.save_proc;
 

	
 
	/* Don't save any chunk information if there is no save handler. */
 
	if (proc == nullptr) return;
 

	
 
	SlWriteUint32(ch->id);
 
	DEBUG(sl, 2, "Saving chunk %c%c%c%c", ch->id >> 24, ch->id >> 16, ch->id >> 8, ch->id);
 

	
 
	_sl.block_mode = ch->flags & CH_TYPE_MASK;
 
	switch (ch->flags & CH_TYPE_MASK) {
 
	SlWriteUint32(ch.id);
 
	DEBUG(sl, 2, "Saving chunk %c%c%c%c", ch.id >> 24, ch.id >> 16, ch.id >> 8, ch.id);
 

	
 
	_sl.block_mode = ch.type;
 
	switch (ch.type) {
 
		case CH_RIFF:
 
			_sl.need_length = NL_WANTLENGTH;
 
			proc();
 
			break;
 
		case CH_ARRAY:
 
			_sl.last_array_index = 0;
 
@@ -1775,13 +1781,13 @@ static void SlSaveChunk(const ChunkHandl
 
	}
 
}
 

	
 
/** Save all chunks */
 
static void SlSaveChunks()
 
{
 
	FOR_ALL_CHUNK_HANDLERS(ch) {
 
	for (auto &ch : ChunkHandlers()) {
 
		SlSaveChunk(ch);
 
	}
 

	
 
	/* Terminator */
 
	SlWriteUint32(0);
 
}
 
@@ -1791,13 +1797,13 @@ static void SlSaveChunks()
 
 * chunk in the savegame or in memory
 
 * @param id the chunk in question
 
 * @return returns the appropriate chunkhandler
 
 */
 
static const ChunkHandler *SlFindChunkHandler(uint32 id)
 
{
 
	FOR_ALL_CHUNK_HANDLERS(ch) if (ch->id == id) return ch;
 
	for (auto &ch : ChunkHandlers()) if (ch.id == id) return &ch;
 
	return nullptr;
 
}
 

	
 
/** Load all chunks */
 
static void SlLoadChunks()
 
{
 
@@ -1806,13 +1812,13 @@ static void SlLoadChunks()
 

	
 
	for (id = SlReadUint32(); id != 0; id = SlReadUint32()) {
 
		DEBUG(sl, 2, "Loading chunk %c%c%c%c", id >> 24, id >> 16, id >> 8, id);
 

	
 
		ch = SlFindChunkHandler(id);
 
		if (ch == nullptr) SlErrorCorrupt("Unknown chunk type");
 
		SlLoadChunk(ch);
 
		SlLoadChunk(*ch);
 
	}
 
}
 

	
 
/** Load all chunks for savegame checking */
 
static void SlLoadCheckChunks()
 
{
 
@@ -1821,25 +1827,25 @@ static void SlLoadCheckChunks()
 

	
 
	for (id = SlReadUint32(); id != 0; id = SlReadUint32()) {
 
		DEBUG(sl, 2, "Loading chunk %c%c%c%c", id >> 24, id >> 16, id >> 8, id);
 

	
 
		ch = SlFindChunkHandler(id);
 
		if (ch == nullptr) SlErrorCorrupt("Unknown chunk type");
 
		SlLoadCheckChunk(ch);
 
		SlLoadCheckChunk(*ch);
 
	}
 
}
 

	
 
/** Fix all pointers (convert index -> pointer) */
 
static void SlFixPointers()
 
{
 
	_sl.action = SLA_PTRS;
 

	
 
	FOR_ALL_CHUNK_HANDLERS(ch) {
 
		if (ch->ptrs_proc != nullptr) {
 
			DEBUG(sl, 3, "Fixing pointers for %c%c%c%c", ch->id >> 24, ch->id >> 16, ch->id >> 8, ch->id);
 
			ch->ptrs_proc();
 
	for (auto &ch : ChunkHandlers()) {
 
		if (ch.ptrs_proc != nullptr) {
 
			DEBUG(sl, 3, "Fixing pointers for %c%c%c%c", ch.id >> 24, ch.id >> 16, ch.id >> 8, ch.id);
 
			ch.ptrs_proc();
 
		}
 
	}
 

	
 
	assert(_sl.action == SLA_PTRS);
 
}
 

	
src/saveload/saveload.h
Show inline comments
 
@@ -11,12 +11,13 @@
 
#define SAVELOAD_H
 

	
 
#include "../fileio_type.h"
 
#include "../strings_type.h"
 
#include "../core/span_type.hpp"
 
#include <string>
 
#include <vector>
 

	
 
/** SaveLoad versions
 
 * Previous savegame versions, the trunk revision where they were
 
 * introduced and the released version that had that particular
 
 * savegame version.
 
 * Up to savegame version 18 there is a minor version as well.
 
@@ -375,22 +376,32 @@ void DoExitSave();
 
SaveOrLoadResult SaveWithFilter(struct SaveFilter *writer, bool threaded);
 
SaveOrLoadResult LoadWithFilter(struct LoadFilter *reader);
 

	
 
typedef void ChunkSaveLoadProc();
 
typedef void AutolengthProc(void *arg);
 

	
 
/** Type of a chunk. */
 
enum ChunkType {
 
	CH_RIFF = 0,
 
	CH_ARRAY = 1,
 
	CH_SPARSE_ARRAY = 2,
 
};
 

	
 
/** Handlers and description of chunk. */
 
struct ChunkHandler {
 
	uint32 id;                          ///< Unique ID (4 letters).
 
	ChunkSaveLoadProc *save_proc;       ///< Save procedure of the chunk.
 
	ChunkSaveLoadProc *load_proc;       ///< Load procedure of the chunk.
 
	ChunkSaveLoadProc *ptrs_proc;       ///< Manipulate pointers in the chunk.
 
	ChunkSaveLoadProc *load_check_proc; ///< Load procedure for game preview.
 
	uint32 flags;                       ///< Flags of the chunk. @see ChunkType
 
	ChunkType type;                     ///< Type of the chunk. @see ChunkType
 
};
 

	
 
/** A table of ChunkHandler entries. */
 
using ChunkHandlerTable = span<const ChunkHandler>;
 

	
 
/** Type of reference (#SLE_REF, #SLE_CONDREF). */
 
enum SLRefType {
 
	REF_ORDER          =  0, ///< Load/save a reference to an order.
 
	REF_VEHICLE        =  1, ///< Load/save a reference to a vehicle.
 
	REF_STATION        =  2, ///< Load/save a reference to a station.
 
	REF_TOWN           =  3, ///< Load/save a reference to a town.
 
@@ -401,21 +412,12 @@ enum SLRefType {
 
	REF_ORDERLIST      =  8, ///< Load/save a reference to an orderlist.
 
	REF_STORAGE        =  9, ///< Load/save a reference to a persistent storage.
 
	REF_LINK_GRAPH     = 10, ///< Load/save a reference to a link graph.
 
	REF_LINK_GRAPH_JOB = 11, ///< Load/save a reference to a link graph job.
 
};
 

	
 
/** Flags of a chunk. */
 
enum ChunkType {
 
	CH_RIFF         =  0,
 
	CH_ARRAY        =  1,
 
	CH_SPARSE_ARRAY =  2,
 
	CH_TYPE_MASK    =  3,
 
	CH_LAST         =  8, ///< Last chunk in this array.
 
};
 

	
 
/**
 
 * VarTypes is the general bitmasked magic type that tells us
 
 * certain characteristics about the variable it refers to. For example
 
 * SLE_FILE_* gives the size(type) as it would be in the savegame and
 
 * SLE_VAR_* the size(type) as it is in memory during runtime. These are
 
 * the first 8 bits (0-3 SLE_FILE, 4-7 SLE_VAR).
src/saveload/signs_sl.cpp
Show inline comments
 
@@ -59,9 +59,11 @@ static void Load_SIGN()
 
			si->owner = OWNER_DEITY;
 
		}
 
	}
 
}
 

	
 
/** Chunk handlers related to signs. */
 
extern const ChunkHandler _sign_chunk_handlers[] = {
 
	{ 'SIGN', Save_SIGN, Load_SIGN, nullptr, nullptr, CH_ARRAY | CH_LAST},
 
static const ChunkHandler sign_chunk_handlers[] = {
 
	{ 'SIGN', Save_SIGN, Load_SIGN, nullptr, nullptr, CH_ARRAY },
 
};
 

	
 
extern const ChunkHandlerTable _sign_chunk_handlers(sign_chunk_handlers);
src/saveload/station_sl.cpp
Show inline comments
 
@@ -610,11 +610,13 @@ static void Ptrs_ROADSTOP()
 
{
 
	for (RoadStop *rs : RoadStop::Iterate()) {
 
		SlObject(rs, _roadstop_desc);
 
	}
 
}
 

	
 
extern const ChunkHandler _station_chunk_handlers[] = {
 
static const ChunkHandler station_chunk_handlers[] = {
 
	{ 'STNS', nullptr,       Load_STNS,     Ptrs_STNS,     nullptr, CH_ARRAY },
 
	{ 'STNN', Save_STNN,     Load_STNN,     Ptrs_STNN,     nullptr, CH_ARRAY },
 
	{ 'ROAD', Save_ROADSTOP, Load_ROADSTOP, Ptrs_ROADSTOP, nullptr, CH_ARRAY | CH_LAST},
 
	{ 'ROAD', Save_ROADSTOP, Load_ROADSTOP, Ptrs_ROADSTOP, nullptr, CH_ARRAY },
 
};
 

	
 
extern const ChunkHandlerTable _station_chunk_handlers(station_chunk_handlers);
src/saveload/storage_sl.cpp
Show inline comments
 
@@ -41,9 +41,11 @@ static void Save_PSAC()
 
		SlSetArrayIndex(ps->index);
 
		SlObject(ps, _storage_desc);
 
	}
 
}
 

	
 
/** Chunk handler for persistent storages. */
 
extern const ChunkHandler _persistent_storage_chunk_handlers[] = {
 
	{ 'PSAC', Save_PSAC, Load_PSAC, nullptr, nullptr, CH_ARRAY | CH_LAST},
 
static const ChunkHandler persistent_storage_chunk_handlers[] = {
 
	{ 'PSAC', Save_PSAC, Load_PSAC, nullptr, nullptr, CH_ARRAY },
 
};
 

	
 
extern const ChunkHandlerTable _persistent_storage_chunk_handlers(persistent_storage_chunk_handlers);
src/saveload/story_sl.cpp
Show inline comments
 
@@ -92,10 +92,12 @@ static void Load_STORY_PAGE()
 
	/* Update the next sort value, so that the next
 
	 * created page is shown after all existing pages.
 
	 */
 
	_story_page_next_sort_value = max_sort_value + 1;
 
}
 

	
 
extern const ChunkHandler _story_page_chunk_handlers[] = {
 
	{ 'STPE', Save_STORY_PAGE_ELEMENT, Load_STORY_PAGE_ELEMENT, nullptr, nullptr, CH_ARRAY},
 
	{ 'STPA', Save_STORY_PAGE,         Load_STORY_PAGE,         nullptr, nullptr, CH_ARRAY | CH_LAST},
 
static const ChunkHandler story_page_chunk_handlers[] = {
 
	{ 'STPE', Save_STORY_PAGE_ELEMENT, Load_STORY_PAGE_ELEMENT, nullptr, nullptr, CH_ARRAY },
 
	{ 'STPA', Save_STORY_PAGE,         Load_STORY_PAGE,         nullptr, nullptr, CH_ARRAY },
 
};
 

	
 
extern const ChunkHandlerTable _story_page_chunk_handlers(story_page_chunk_handlers);
src/saveload/strings_sl.cpp
Show inline comments
 
@@ -128,9 +128,11 @@ static void Load_NAME()
 
		/* Make sure the old name is null terminated */
 
		_old_name_array[LEN_OLD_STRINGS * index + LEN_OLD_STRINGS - 1] = '\0';
 
	}
 
}
 

	
 
/** Chunk handlers related to strings. */
 
extern const ChunkHandler _name_chunk_handlers[] = {
 
	{ 'NAME', nullptr, Load_NAME, nullptr, nullptr, CH_ARRAY | CH_LAST},
 
static const ChunkHandler name_chunk_handlers[] = {
 
	{ 'NAME', nullptr, Load_NAME, nullptr, nullptr, CH_ARRAY },
 
};
 

	
 
extern const ChunkHandlerTable _name_chunk_handlers(name_chunk_handlers);
src/saveload/subsidy_sl.cpp
Show inline comments
 
@@ -40,9 +40,11 @@ static void Load_SUBS()
 
	while ((index = SlIterateArray()) != -1) {
 
		Subsidy *s = new (index) Subsidy();
 
		SlObject(s, _subsidies_desc);
 
	}
 
}
 

	
 
extern const ChunkHandler _subsidy_chunk_handlers[] = {
 
	{ 'SUBS', Save_SUBS, Load_SUBS, nullptr, nullptr, CH_ARRAY | CH_LAST},
 
static const ChunkHandler subsidy_chunk_handlers[] = {
 
	{ 'SUBS', Save_SUBS, Load_SUBS, nullptr, nullptr, CH_ARRAY },
 
};
 

	
 
extern const ChunkHandlerTable _subsidy_chunk_handlers(subsidy_chunk_handlers);
src/saveload/town_sl.cpp
Show inline comments
 
@@ -293,10 +293,12 @@ static void Ptrs_TOWN()
 
	for (Town *t : Town::Iterate()) {
 
		SlObject(t, _town_desc);
 
	}
 
}
 

	
 
/** Chunk handler for towns. */
 
extern const ChunkHandler _town_chunk_handlers[] = {
 
static const ChunkHandler town_chunk_handlers[] = {
 
	{ 'HIDS', Save_HIDS, Load_HIDS, nullptr,   nullptr, CH_ARRAY },
 
	{ 'CITY', Save_TOWN, Load_TOWN, Ptrs_TOWN, nullptr, CH_ARRAY | CH_LAST},
 
	{ 'CITY', Save_TOWN, Load_TOWN, Ptrs_TOWN, nullptr, CH_ARRAY },
 
};
 

	
 
extern const ChunkHandlerTable _town_chunk_handlers(town_chunk_handlers);
src/saveload/vehicle_sl.cpp
Show inline comments
 
@@ -928,9 +928,11 @@ static void Ptrs_VEHS()
 
{
 
	for (Vehicle *v : Vehicle::Iterate()) {
 
		SlObject(v, GetVehicleDescription(v->type));
 
	}
 
}
 

	
 
extern const ChunkHandler _veh_chunk_handlers[] = {
 
	{ 'VEHS', Save_VEHS, Load_VEHS, Ptrs_VEHS, nullptr, CH_SPARSE_ARRAY | CH_LAST},
 
static const ChunkHandler veh_chunk_handlers[] = {
 
	{ 'VEHS', Save_VEHS, Load_VEHS, Ptrs_VEHS, nullptr, CH_SPARSE_ARRAY },
 
};
 

	
 
extern const ChunkHandlerTable _veh_chunk_handlers(veh_chunk_handlers);
src/saveload/waypoint_sl.cpp
Show inline comments
 
@@ -221,9 +221,11 @@ static void Ptrs_WAYP()
 
		if (IsSavegameVersionBefore(SLV_84)) {
 
			wp.name = CopyFromOldName(wp.string_id);
 
		}
 
	}
 
}
 

	
 
extern const ChunkHandler _waypoint_chunk_handlers[] = {
 
	{ 'CHKP', nullptr, Load_WAYP, Ptrs_WAYP, nullptr, CH_ARRAY | CH_LAST},
 
static const ChunkHandler waypoint_chunk_handlers[] = {
 
	{ 'CHKP', nullptr, Load_WAYP, Ptrs_WAYP, nullptr, CH_ARRAY },
 
};
 

	
 
extern const ChunkHandlerTable _waypoint_chunk_handlers(waypoint_chunk_handlers);
src/settings.cpp
Show inline comments
 
@@ -2082,17 +2082,19 @@ static void Check_PATS()
 

	
 
static void Save_PATS()
 
{
 
	SaveSettings(_settings, &_settings_game);
 
}
 

	
 
extern const ChunkHandler _setting_chunk_handlers[] = {
 
	{ 'OPTS', nullptr,      Load_OPTS, nullptr, nullptr,       CH_RIFF},
 
	{ 'PATS', Save_PATS, Load_PATS, nullptr, Check_PATS, CH_RIFF | CH_LAST},
 
static const ChunkHandler setting_chunk_handlers[] = {
 
	{ 'OPTS', nullptr,   Load_OPTS, nullptr, nullptr,    CH_RIFF },
 
	{ 'PATS', Save_PATS, Load_PATS, nullptr, Check_PATS, CH_RIFF },
 
};
 

	
 
extern const ChunkHandlerTable _setting_chunk_handlers(setting_chunk_handlers);
 

	
 
static bool IsSignedVarMemType(VarType vt)
 
{
 
	switch (GetVarMemType(vt)) {
 
		case SLE_VAR_I8:
 
		case SLE_VAR_I16:
 
		case SLE_VAR_I32:
0 comments (0 inline, 0 general)