OpenTTD Source
12.0-beta2
|
Go to the documentation of this file.
10 #include "../stdafx.h"
15 #include "../company_func.h"
16 #include "../company_manager_face.h"
18 #include "../tunnelbridge_map.h"
19 #include "../tunnelbridge.h"
20 #include "../station_base.h"
21 #include "../strings_func.h"
23 #include "table/strings.h"
25 #include "../safeguards.h"
63 uint lips =
GB(face, 10, 4);
69 lips = lips * 15 / 16;
77 uint nose =
GB(face, 13, 3);
79 nose = (nose * 3 >> 3) * 3 >> 2;
86 uint tie_earring =
GB(face, 24, 4);
133 for (RoadTramType rtt : _roadtramtypes) {
134 RoadType rt = GetRoadType(tile, rtt);
149 case STATION_WAYPOINT:
154 case STATION_TRUCK: {
156 for (RoadTramType rtt : _roadtramtypes) {
157 RoadType rt = GetRoadType(tile, rtt);
201 if (tile < other_end) {
214 for (RoadTramType rtt : _roadtramtypes) {
215 RoadType rt = GetRoadType(tile, rtt);
248 inline static const SaveLoad description[] = {{}};
255 for (
int i = 0; i != old_ai->num_build_rec; i++) {
260 void LoadCheck(
CompanyOldAI *old_ai)
const override { this->Load(old_ai); }
265 inline static const SaveLoad description[] = {
273 if (!c->
is_ai)
return;
284 inline static const SaveLoad description[] = {
321 inline static const SaveLoad description[] = {
381 inline static const SaveLoad description[] = {
404 for (
int i = 0; i < LS_END; i++) {
405 SlObject(&c->livery[i], this->GetDescription());
414 for (
size_t i = 0; i < num_liveries; i++) {
415 SlObject(&c->livery[i], this->GetLoadDescription());
416 if (update_in_use && i != LS_DEFAULT) {
417 if (c->livery[i].
in_use == 0) {
428 memmove(&c->livery[LS_FREIGHT_WAGON], &c->livery[LS_PASSENGER_WAGON_MONORAIL], (LS_END - LS_FREIGHT_WAGON) *
sizeof(c->livery[0]));
429 c->livery[LS_PASSENGER_WAGON_MONORAIL] = c->livery[LS_MONORAIL];
430 c->livery[LS_PASSENGER_WAGON_MAGLEV] = c->livery[LS_MAGLEV];
435 c->livery[LS_PASSENGER_TRAM] = c->livery[LS_BUS];
436 c->livery[LS_FREIGHT_TRAM] = c->livery[LS_TRUCK];
444 static const SaveLoad _company_desc[] = {
508 SlSetArrayIndex(c->index);
538 cprops->
name_1 = STR_GAME_SAVELOAD_NOT_AVAILABLE;
546 if (cprops->
name.empty() && !
IsInsideMM(cprops->
name_1, SPECSTR_COMPANY_NAME_START, SPECSTR_COMPANY_NAME_LAST + 1) &&
547 cprops->
name_1 != STR_GAME_SAVELOAD_NOT_AVAILABLE && cprops->
name_1 != STR_SV_UNNAMED &&
548 cprops->
name_1 != SPECSTR_ANDCO_NAME && cprops->
name_1 != SPECSTR_PRESIDENT_NAME &&
549 cprops->
name_1 != SPECSTR_SILLY_NAME) {
550 cprops->
name_1 = STR_GAME_SAVELOAD_NOT_AVAILABLE;
#define SLEG_CONDSTRUCTLIST(name, handler, from, to)
Storage of a list of structs in some savegame versions.
bool is_ai
If true, the company is (also) controlled by the computer (a NoAI program).
uint32 TileIndex
The index/ID of a Tile.
static StringTab GetStringTab(StringID str)
Extract the StringTab from a StringID.
Default handler for saving/loading an object to/from disk.
static Titem * Get(size_t index)
Returns Titem with given index.
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
@ SL_MIN_VERSION
First savegame version.
uint32 CompanyManagerFace
Company manager face bits, info see in company_manager_face.h.
void FixPointers() const override
Fix the pointers.
@ TRANSPORT_RAIL
Transport by train.
#define SLE_CONDSSTR(base, variable, type, from, to)
Storage of a std::string in some savegame versions.
std::reference_wrapper< const ChunkHandler > ChunkHandlerRef
A reference to ChunkHandler.
static const uint LEVELCROSSING_TRACKBIT_FACTOR
Multiplier for how many regular track bits a level crossing counts.
#define SLE_CONDARR(base, variable, type, length, from, to)
Storage of a fixed-size array of SL_VAR elements in some savegame versions.
@ INVALID_ROADTYPE
flag for invalid roadtype
void Save() const override
Save the chunk.
LoadCheckData _load_check_data
Data loaded from save during SL_LOAD_CHECK.
GenderEthnicity
The gender/race combinations that we have faces for.
uint32 water
Count of company owned track bits for canals.
#define SLE_CONDVAR(base, variable, type, from, to)
Storage of a variable in some savegame versions.
static uint ClampU(const uint a, const uint min, const uint max)
Clamp an unsigned integer between an interval.
#define SLE_STR(base, variable, type, length)
Storage of a string in every savegame version.
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
uint32 station
Count of company owned station tiles.
static bool TracksOverlap(TrackBits bits)
Checks if the given tracks overlap, ie form a crossing.
SaveLoadTable GetLoadDescription() const
Get the description for how to load the chunk.
std::string name
Name of the company if the user changed it.
static TrackBits GetTrackBits(TileIndex tile)
Gets the track bits of the given tile.
static bool HasSignals(TileIndex t)
Checks if a rail tile has signals.
CompanyInfrastructure infrastructure
NOSAVE: Counts of company owned infrastructure.
Handlers and description of chunk.
bool Insert(const T &key, const U &data)
Adds new item to this map.
@ SLV_GROUP_LIVERIES
205 PR#7108 Livery storage change and group liveries.
@ MP_ROAD
A tile with road (or tram tracks)
static bool IsLevelCrossing(TileIndex t)
Return whether a tile is a level crossing.
Statistics about the economy.
#define SLE_ARR(base, variable, type, length)
Storage of fixed-size array of SL_VAR elements in every version of a savegame.
static byte GetLockPart(TileIndex t)
Get the part of a lock.
static uint CountBits(T value)
Counts the number of set bits in a variable.
static Pool::IterateWrapper< Station > Iterate(size_t from=0)
Returns an iterable ensemble of all valid stations of type T.
static uint GetPresentSignals(TileIndex tile)
Get whether the given signals are present (Along/AgainstTrackDir)
@ GENDER_FEMALE
This bit set means a female, otherwise male.
static bool IsInsideMM(const T x, const size_t min, const size_t max)
Checks if a value is in an interval.
const SaveLoadCompat _company_liveries_compat[]
Original field order for SlCompanyLiveries.
@ TRANSPORT_ROAD
Transport by road vehicle.
static RoadBits GetRoadBits(TileIndex t, RoadTramType rtt)
Get the present road bits for a specific road type.
Colours _company_colours[MAX_COMPANIES]
NOSAVE: can be determined from company structs.
@ SLF_ALLOW_CONTROL
Allow control codes in the strings.
static uint MapSize()
Get the size of the map.
byte colour
Company colour.
byte num_valid_stat_ent
Number of valid statistical entries in old_economy.
A trimmed down version of what std::span will be in C++20.
static bool IsNormalRoad(TileIndex t)
Return whether a tile is a normal road.
@ MP_OBJECT
Contains objects such as transmitters and owned land.
static bool IsBuoy(TileIndex t)
Is tile t a buoy tile?
static StationType GetStationType(TileIndex t)
Get the station type of this tile.
const SaveLoadCompat _company_old_ai_buildrec_compat[]
Original field order for SlCompanyOldAIBuildRec.
void AfterLoadCompanyStats()
Rebuilding of company statistics after loading a savegame.
static bool IsShipDepot(TileIndex t)
Is it a water tile with a ship depot on it?
static const uint TUNNELBRIDGE_TRACKBIT_FACTOR
Multiplier for how many regular track bits a tunnel/bridge counts.
@ LOCK_PART_MIDDLE
Middle part of a lock.
byte in_use
Bit 0 set if this livery should override the default livery first colour, Bit 1 for the second colour...
@ SLV_EXTEND_CARGOTYPES
199 PR#6802 Extend cargotypes to 64
#define SLE_CONDREF(base, variable, type, from, to)
Storage of a reference in some savegame versions.
fluid_settings_t * settings
FluidSynth settings handle.
static bool IsSavegameVersionBefore(SaveLoadVersion major, byte minor=0)
Checks whether the savegame is below major.
@ MP_TUNNELBRIDGE
Tunnel entry/exit and bridge heads.
@ REF_ENGINE_RENEWS
Load/save a reference to an engine renewal (autoreplace).
uint32 road[ROADTYPE_END]
Count of company owned track bits for each road type.
uint32 signal
Count of company owned signals.
static bool IsRoadDepot(TileIndex t)
Return whether a tile is a road depot.
@ WATER_CLASS_CANAL
Canal.
RoadType
The different roadtypes we support.
size_t SlGetStructListLength(size_t limit)
Get the length of this list; if it exceeds the limit, error out.
@ SLV_2
2.0 0.3.0 2.1 0.3.1, 0.3.2
static Owner GetTileOwner(TileIndex tile)
Returns the owner of a tile.
@ SL_MAX_VERSION
Highest possible saveload version.
const SaveLoadCompat _company_old_ai_compat[]
Original field order for SlCompanyOldAI.
CompanyPropertiesMap companies
Company information.
bool IsStationTileBlocked(TileIndex tile)
Check whether a rail station tile is NOT traversable.
@ SLV_16
16.0 2817 16.1 3155
#define SLE_VAR(base, variable, type)
Storage of a variable in every version of a savegame.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
static WaterClass GetWaterClass(TileIndex t)
Get the water class at a tile.
const SaveLoadCompat _company_sl_compat[]
Original field order for company_desc.
CompanyEconomyEntry cur_economy
Economic data of the company of this quarter.
static bool IsPlainRail(TileIndex t)
Returns whether this is plain rails, with or without signals.
void NORETURN SlErrorCorrupt(const char *msg)
Error handler for corrupt savegames.
SaveLoadTable GetDescription() const override
@ TRANSPORT_WATER
Transport over water.
uint32 rail[RAILTYPE_END]
Count of company owned track bits for each rail type.
static RailType GetRailType(TileIndex t)
Gets the rail type of the given tile.
@ MP_STATION
A tile of a station.
SaveLoadTable GetDescription() const override
Get the description of the fields in the savegame.
@ NUM_CARGO
Maximal number of cargo types in a game.
static bool IsLock(TileIndex t)
Is there a lock on a given water tile?
const SaveLoadCompat _company_settings_compat[]
Original field order for SlCompanySettings.
static const uint LOCK_DEPOT_TILE_FACTOR
Multiplier for how many regular tiles a lock counts.
StringID president_name_1
Name of the president if the user did not change it.
TrackBits
Bitfield corresponding to Track.
static uint GetTunnelBridgeLength(TileIndex begin, TileIndex end)
Calculates the length of a tunnel or a bridge (without end tiles)
static T SetBit(T &x, const uint8 y)
Set a bit in a variable.
#define lengthof(x)
Return the length of an fixed size array.
@ SLV_SAVELOAD_LIST_LENGTH
293 PR#9374 Consistency in list length with SL_STRUCT / SL_STRUCTLIST / SL_DEQUE / SL_REFLIST.
static void MemSetT(T *ptr, byte value, size_t num=1)
Type-safe version of memset().
std::vector< SaveLoad > SlCompatTableHeader(const SaveLoadTable &slt, const SaveLoadCompatTable &slct)
Load a table header in a savegame compatible way.
static Owner GetRoadOwner(TileIndex t, RoadTramType rtt)
Get the owner of a specific road type.
static TileIndex GetOtherTunnelBridgeEnd(TileIndex t)
Determines type of the wormhole and returns its other end.
static void SetCompanyManagerFaceBits(CompanyManagerFace &cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge, uint val)
Sets the company manager's face bits for the given company manager's face variable.
static TileType GetTileType(TileIndex tile)
Get the tiletype of a given tile.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
@ GE_WM
A male of Caucasian origin (white)
@ FACIL_AIRPORT
Station with an airport.
void SlObject(void *object, const SaveLoadTable &slt)
Main SaveLoad function.
CompanyManagerFace ConvertFromOldCompanyManagerFace(uint32 face)
Converts an old company manager's face format to the new company manager's face format.
std::vector< SaveLoad > SlTableHeader(const SaveLoadTable &slt)
Save or Load a table header.
static uint ScaleCompanyManagerFaceValue(CompanyManagerFaceVariable cmfv, GenderEthnicity ge, uint val)
Scales a company manager's face bits variable to the correct scope.
#define SLEG_CONDSTRUCT(name, handler, from, to)
Storage of a structs in some savegame versions.
void SlSetStructListLength(size_t length)
Set the length of this list.
static TransportType GetTunnelBridgeTransportType(TileIndex t)
Tunnel: Get the transport type of the tunnel (road or rail) Bridge: Get the transport type of the bri...
const SaveLoadCompat _company_economy_compat[]
Original field order for SlCompanyEconomy.
CompanyEconomyEntry old_economy[MAX_HISTORY_QUARTERS]
Economic data of the company of the last MAX_HISTORY_QUARTERS quarters.
@ ETHNICITY_BLACK
This bit set means black, otherwise white.
Information about a particular livery.
void Load() const override
Load the chunk.
Statically loadable part of Company pool item.
size_t GetNumLiveries() const
Get the number of liveries used by this savegame version.
void LoadCheck(size_t) const override
Load the chunk for game preview.
int SlIterateArray()
Iterate through the elements of an array and read the whole thing.
@ GE_WF
A female of Caucasian origin (white)
StringID name_1
Name of the company if the user did not change it.
#define SLEG_STRUCTLIST(name, handler)
Storage of a list of structs in every savegame version.
#define SLEG_STRUCT(name, handler)
Storage of a structs in every savegame version.
byte colour2
Second colour, for vehicles with 2CC support.
byte colour1
First colour, for all vehicles.