12 #include "../stdafx.h" 13 #include "../company_func.h" 14 #include "../company_manager_face.h" 16 #include "../tunnelbridge_map.h" 17 #include "../tunnelbridge.h" 18 #include "../station_base.h" 19 #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);
104 FOR_ALL_STATIONS(st) {
149 case STATION_WAYPOINT:
154 case STATION_TRUCK: {
200 if (tile < other_end) {
242 static const SaveLoad _company_desc[] = {
300 static const SaveLoad _company_settings_desc[] = {
321 static const SaveLoad _company_settings_skip_desc[] = {
343 static const SaveLoad _company_economy_desc[] = {
364 static const SaveLoad _company_ai_desc[] = {
395 static const SaveLoad _company_ai_build_rec_desc[] = {
404 static const SaveLoad _company_livery_desc[] = {
417 SlObject(c, _company_settings_desc);
420 SlObject(¬hing, _company_settings_skip_desc);
428 SlObject(&old_ai, _company_ai_desc);
429 for (i = 0; i != old_ai.num_build_rec; i++) {
430 SlObject(¬hing, _company_ai_build_rec_desc);
446 for (i = 0; i < num_liveries; i++) {
447 SlObject(&c->livery[i], _company_livery_desc);
450 if (num_liveries < LS_END) {
452 memmove(&c->livery[LS_FREIGHT_WAGON], &c->livery[LS_PASSENGER_WAGON_MONORAIL], (LS_END - LS_FREIGHT_WAGON) *
sizeof(c->livery[0]));
453 c->livery[LS_PASSENGER_WAGON_MONORAIL] = c->livery[LS_MONORAIL];
454 c->livery[LS_PASSENGER_WAGON_MAGLEV] = c->livery[LS_MAGLEV];
457 if (num_liveries == LS_END - 4) {
459 c->livery[LS_PASSENGER_TRAM] = c->livery[LS_BUS];
460 c->livery[LS_FREIGHT_TRAM] = c->livery[LS_TRUCK];
465 for (i = 0; i < num_liveries; i++) {
466 SlObject(&dummy_livery, _company_livery_desc);
471 static void SaveLoad_PLYR(
Company *c)
473 SaveLoad_PLYR_common(c, c);
476 static void Save_PLYR()
479 FOR_ALL_COMPANIES(c) {
480 SlSetArrayIndex(c->
index);
485 static void Load_PLYR()
495 static void Check_PLYR()
500 memset(cprops, 0,
sizeof(*cprops));
501 SaveLoad_PLYR_common(NULL, cprops);
506 cprops->
name_1 = STR_GAME_SAVELOAD_NOT_AVAILABLE;
514 if (cprops->
name == NULL && !
IsInsideMM(cprops->
name_1, SPECSTR_COMPANY_NAME_START, SPECSTR_COMPANY_NAME_LAST + 1) &&
515 cprops->
name_1 != STR_GAME_SAVELOAD_NOT_AVAILABLE && cprops->
name_1 != STR_SV_UNNAMED &&
516 cprops->
name_1 != SPECSTR_ANDCO_NAME && cprops->
name_1 != SPECSTR_PRESIDENT_NAME &&
517 cprops->
name_1 != SPECSTR_SILLY_NAME) {
518 cprops->
name_1 = STR_GAME_SAVELOAD_NOT_AVAILABLE;
525 static void Ptrs_PLYR()
528 FOR_ALL_COMPANIES(c) {
529 SlObject(c, _company_settings_desc);
535 {
'PLYR', Save_PLYR, Load_PLYR, Ptrs_PLYR, Check_PLYR, CH_ARRAY |
CH_LAST},
#define SLE_CONDNULL(length, from, to)
Empty space in some savegame versions.
static TileType GetTileType(TileIndex tile)
Get the tiletype of a given tile.
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
static TransportType GetTunnelBridgeTransportType(TileIndex t)
Tunnel: Get the transport type of the tunnel (road or rail) Bridge: Get the transport type of the bri...
static byte GetLockPart(TileIndex t)
Get the part of a lock.
char * name
Name of the company if the user changed it.
A female of Caucasian origin (white)
static const uint LEVELCROSSING_TRACKBIT_FACTOR
Multiplier for how many regular track bits a level crossing counts.
void AfterLoadCompanyStats()
Rebuilding of company statistics after loading a savegame.
#define SLE_CONDSTR(base, variable, type, length, from, to)
Storage of a string in some savegame versions.
#define SLE_CONDREF(base, variable, type, from, to)
Storage of a reference in some savegame versions.
void NORETURN SlErrorCorrupt(const char *msg)
Error handler for corrupt savegames.
static Titem * Get(size_t index)
Returns Titem with given index.
static bool IsInsideMM(const T x, const uint min, const uint max)
Checks if a value is in an interval.
static WaterClass GetWaterClass(TileIndex t)
Get the water class at a tile.
static T SetBit(T &x, const uint8 y)
Set a bit in a variable.
This bit set means a female, otherwise male.
A tile with road (or tram tracks)
#define SLE_ARR(base, variable, type, length)
Storage of an array in every version of a savegame.
Tindex index
Index of this pool item.
static RoadBits GetRoadBits(TileIndex t, RoadType rt)
Get the present road bits for a specific road type.
bool Insert(const T &key, const U &data)
Adds new item to this map.
#define FOR_EACH_SET_ROADTYPE(var, road_types)
Iterate through each set RoadType in a RoadTypes value.
static StringTab GetStringTab(StringID str)
Extract the StringTab from a StringID.
Contains objects such as transmitters and owned land.
A male of Caucasian origin (white)
uint32 station
Count of company owned station tiles.
static bool IsLevelCrossing(TileIndex t)
Return whether a tile is a level crossing.
RoadType
The different roadtypes we support.
static T max(const T a, const T b)
Returns the maximum of two values.
static StationType GetStationType(TileIndex t)
Get the station type of this tile.
static uint ClampU(const uint a, const uint min, const uint max)
Clamp an unsigned integer between an interval.
static bool IsLock(TileIndex t)
Is there a lock on a given water tile?
static uint GetPresentSignals(TileIndex tile)
Get whether the given signals are present (Along/AgainstTrackDir)
TrackBits
Bitfield corresponding to Track.
LoadCheckData _load_check_data
Data loaded from save during SL_LOAD_CHECK.
uint32 CompanyManagerFace
Company manager face bits, info see in company_manager_face.h.
Load/save a reference to an engine renewal (autoreplace).
Functions/types related to saving and loading games.
uint32 signal
Count of company owned signals.
#define SLE_CONDVAR(base, variable, type, from, to)
Storage of a variable in some savegame versions.
static bool IsBuoy(TileIndex t)
Is tile t a buoy tile?
byte num_valid_stat_ent
Number of valid statistical entries in old_economy.
static Owner GetRoadOwner(TileIndex t, RoadType rt)
Get the owner of a specific road type.
allow control codes in the strings
CompanyPropertiesMap companies
Company information.
Statically loadable part of Company pool item.
static Owner GetTileOwner(TileIndex tile)
Returns the owner of a tile.
static uint GetTunnelBridgeLength(TileIndex begin, TileIndex end)
Calculates the length of a tunnel or a bridge (without end tiles)
uint32 road[ROADTYPE_END]
Count of company owned track bits for each road type.
Information about a particular livery.
static const uint TUNNELBRIDGE_TRACKBIT_FACTOR
Multiplier for how many regular track bits a tunnel/bridge counts.
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.
CompanyManagerFace ConvertFromOldCompanyManagerFace(uint32 face)
Converts an old company manager's face format to the new company manager's face format.
bool is_ai
If true, the company is (also) controlled by the computer (a NoAI program).
StationFacilityByte facilities
The facilities that this station has.
#define SL_MAX_VERSION
Highest possible savegame version.
static bool IsSavegameVersionBefore(uint16 major, byte minor=0)
Checks whether the savegame is below major.
#define lengthof(x)
Return the length of an fixed size array.
static uint ScaleCompanyManagerFaceValue(CompanyManagerFaceVariable cmfv, GenderEthnicity ge, uint val)
Scales a company manager's face bits variable to the correct scope.
int SlIterateArray()
Iterate through the elements of an array and read the whole thing.
Handlers and description of chunk.
static bool HasSignals(TileIndex t)
Checks if a rail tile has signals.
Maximal number of cargo types in a game.
OwnerByte owner
The owner of this station.
static TrackBits GetTrackBits(TileIndex tile)
Gets the track bits of the given tile.
CompanyInfrastructure infrastructure
NOSAVE: Counts of company owned infrastructure.
uint32 rail[RAILTYPE_END]
Count of company owned track bits for each rail type.
#define SLE_END()
End marker of a struct/class save or load.
static TileIndex GetOtherTunnelBridgeEnd(TileIndex t)
Determines type of the wormhole and returns its other end.
static uint MapSize()
Get the size of the map.
bool IsStationTileBlocked(TileIndex tile)
Check whether a rail station tile is NOT traversable.
Tunnel entry/exit and bridge heads.
#define SLE_CONDARR(base, variable, type, length, from, to)
Storage of an array in some savegame versions.
static bool IsShipDepot(TileIndex t)
Is it a water tile with a ship depot on it?
uint32 TileIndex
The index/ID of a Tile.
StringID name_1
Name of the company if the user did not change it.
static const uint LOCK_DEPOT_TILE_FACTOR
Multiplier for how many regular tiles a lock counts.
byte colour
Company colour.
StringID president_name_1
Name of the president if the user did not change it.
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
CompanyEconomyEntry old_economy[MAX_HISTORY_QUARTERS]
Economic data of the company of the last MAX_HISTORY_QUARTERS quarters.
void SlObject(void *object, const SaveLoad *sld)
Main SaveLoad function.
Transport by road vehicle.
static uint CountBits(T value)
Counts the number of set bits in a variable.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-NULL) Titem.
This bit set means black, otherwise white.
Colours _company_colours[MAX_COMPANIES]
NOSAVE: can be determined from company structs.
void SlAutolength(AutolengthProc *proc, void *arg)
Do something of which I have no idea what it is :P.
static bool IsNormalRoad(TileIndex t)
Return whether a tile is a normal road.
static RoadTypes GetRoadTypes(TileIndex t)
Get the present road types of a tile.
GenderEthnicity
The gender/race combinations that we have faces for.
Statistics about the economy.
#define SLE_VAR(base, variable, type)
Storage of a variable in every version of a savegame.
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
#define SLE_STR(base, variable, type, length)
Storage of a string in every savegame version.
static bool IsPlainRail(TileIndex t)
Returns whether this is plain rails, with or without signals.
CompanyEconomyEntry cur_economy
Economic data of the company of this quarter.
static bool IsRoadDepot(TileIndex t)
Return whether a tile is a road depot.
static RailType GetRailType(TileIndex t)
Gets the rail type of the given tile.
static bool TracksOverlap(TrackBits bits)
Checks if the given tracks overlap, ie form a crossing.
Last chunk in this array.
static void MemSetT(T *ptr, byte value, size_t num=1)
Type-safe version of memset().
uint32 water
Count of company owned track bits for canals.