OpenTTD Source: src/saveload/company_sl.cpp File Reference

OpenTTD Source 1.11.0-RC1

Data Structures | Functions | Variables
company_sl.cpp File Reference
`#include "../stdafx.h"`
`#include "../company_func.h"`
`#include "../company_manager_face.h"`
`#include "../fios.h"`
`#include "../tunnelbridge_map.h"`
`#include "../tunnelbridge.h"`
`#include "../station_base.h"`
`#include "../strings_func.h"`
`#include "saveload.h"`
`#include "table/strings.h"`
`#include "../safeguards.h"`

Go to the source code of this file.

## Data Structures
struct | CompanyOldAI

## Functions
CompanyManagerFace | ConvertFromOldCompanyManagerFace (uint32 face)
| Converts an old company manager's face format to the new company manager's face format. More...
void | AfterLoadCompanyStats ()
| Rebuilding of company statistics after loading a savegame.
static void | SaveLoad_PLYR_common (Company *c, CompanyProperties *cprops)
static void | SaveLoad_PLYR (Company *c)
static void | Save_PLYR ()
static void | Load_PLYR ()
static void | Check_PLYR ()
static void | Ptrs_PLYR ()

## Variables
static const SaveLoad | _company_desc []
static const SaveLoad | _company_settings_desc []
static const SaveLoad | _company_settings_skip_desc []
static const SaveLoad | _company_economy_desc []
static const SaveLoad | _company_ai_desc []
static const SaveLoad | _company_ai_build_rec_desc []
static const SaveLoad | _company_livery_desc []
const ChunkHandler | _company_chunk_handlers []

## Detailed Description

Code handling saving and loading of company data

Definition in file company_sl.cpp.

## Function Documentation

## ◆ ConvertFromOldCompanyManagerFace()

CompanyManagerFace ConvertFromOldCompanyManagerFace | ( | uint32 | face | ) |

Converts an old company manager's face format to the new company manager's face format.

Meaning of the bits in the old face (some bits are used in several times):

- 4 and 5: chin
- 6 to 9: eyebrows
- 10 to 13: nose
- 13 to 15: lips (also moustache for males)
- 16 to 19: hair
- 20 to 22: eye colour
- 20 to 27: tie, ear rings etc.
- 28 to 30: glasses
- 19, 26 and 27: race (bit 27 set and bit 19 equal to bit 26 = black, otherwise white)
- 31: gender (0 = male, 1 = female)

Parameters

  face | the face in the old format

Returns
  the face in the new format

Definition at line 43 of file company_sl.cpp.

References ClampU(), ETHNICITY_BLACK, GB(), GE_WF, GE_WM, GENDER_FEMALE, HasBit(), ScaleCompanyManagerFaceValue(), SetBit(), and SetCompanyManagerFaceBits().

## Variable Documentation

## ◆ _company_ai_build_rec_desc

const SaveLoad _company_ai_build_rec_desc[]
| static

Initial value:
= {
SLE_CONDNULL(2, SL_MIN_VERSION, SLV_6),
SLE_CONDNULL(4, SLV_6, SLV_107),
SLE_CONDNULL(2, SL_MIN_VERSION, SLV_6),
SLE_CONDNULL(4, SLV_6, SLV_107),
SLE_CONDNULL(8, SL_MIN_VERSION, SLV_107),
}

Definition at line 396 of file company_sl.cpp.

## ◆ _company_ai_desc

const SaveLoad _company_ai_desc[]
| static

Initial value:
= {
SLE_CONDNULL(2, SL_MIN_VERSION, SLV_107),
SLE_CONDNULL(2, SL_MIN_VERSION, SLV_13),
SLE_CONDNULL(4, SLV_13, SLV_107),
SLE_CONDNULL(8, SL_MIN_VERSION, SLV_107),
SLE_CONDVAR(CompanyOldAI, num_build_rec, SLE_UINT8, SL_MIN_VERSION, SLV_107),
SLE_CONDNULL(3, SL_MIN_VERSION, SLV_107),
SLE_CONDNULL(2, SL_MIN_VERSION, SLV_6),
SLE_CONDNULL(4, SLV_6, SLV_107),
SLE_CONDNULL(2, SL_MIN_VERSION, SLV_6),
SLE_CONDNULL(4, SLV_6, SLV_107),
SLE_CONDNULL(2, SL_MIN_VERSION, SLV_107),
SLE_CONDNULL(2, SL_MIN_VERSION, SLV_6),
SLE_CONDNULL(4, SLV_6, SLV_107),
SLE_CONDNULL(2, SL_MIN_VERSION, SLV_6),
SLE_CONDNULL(4, SLV_6, SLV_107),
SLE_CONDNULL(2, SL_MIN_VERSION, SLV_107),
SLE_CONDNULL(2, SL_MIN_VERSION, SLV_69),
SLE_CONDNULL(4, SLV_69, SLV_107),
SLE_CONDNULL(18, SL_MIN_VERSION, SLV_107),
SLE_CONDNULL(20, SL_MIN_VERSION, SLV_107),
SLE_CONDNULL(32, SL_MIN_VERSION, SLV_107),
SLE_CONDNULL(64, SLV_2, SLV_107),
}

Definition at line 365 of file company_sl.cpp.

## ◆ _company_chunk_handlers

const ChunkHandler _company_chunk_handlers[]

Initial value:
= {
{ 'PLYR', Save_PLYR, Load_PLYR, Ptrs_PLYR, Check_PLYR, CH_ARRAY | CH_LAST},
}

## ◆ _company_economy_desc

const SaveLoad _company_economy_desc[]
| static

Initial value:
= {
SLE_CONDVAR(CompanyEconomyEntry, income, SLE_FILE_I32 | SLE_VAR_I64, SL_MIN_VERSION, SLV_2),
SLE_CONDVAR(CompanyEconomyEntry, income, SLE_INT64, SLV_2, SL_MAX_VERSION),
SLE_CONDVAR(CompanyEconomyEntry, expenses, SLE_FILE_I32 | SLE_VAR_I64, SL_MIN_VERSION, SLV_2),
SLE_CONDVAR(CompanyEconomyEntry, expenses, SLE_INT64, SLV_2, SL_MAX_VERSION),
SLE_CONDVAR(CompanyEconomyEntry, company_value, SLE_FILE_I32 | SLE_VAR_I64, SL_MIN_VERSION, SLV_2),
SLE_CONDVAR(CompanyEconomyEntry, company_value, SLE_INT64, SLV_2, SL_MAX_VERSION),
SLE_CONDVAR(CompanyEconomyEntry, delivered_cargo[NUM_CARGO - 1], SLE_INT32, SL_MIN_VERSION, SLV_170),
SLE_CONDARR(CompanyEconomyEntry, delivered_cargo, SLE_UINT32, 32, SLV_170, SLV_EXTEND_CARGOTYPES),
SLE_CONDARR(CompanyEconomyEntry, delivered_cargo, SLE_UINT32, NUM_CARGO, SLV_EXTEND_CARGOTYPES, SL_MAX_VERSION),
SLE_VAR(CompanyEconomyEntry, performance_history, SLE_INT32),
}

Definition at line 343 of file company_sl.cpp.

## ◆ _company_livery_desc

const SaveLoad _company_livery_desc[]
| static

Initial value:
= {
SLE_CONDVAR(Livery, in_use, SLE_UINT8, SLV_34, SL_MAX_VERSION),
SLE_CONDVAR(Livery, colour1, SLE_UINT8, SLV_34, SL_MAX_VERSION),
SLE_CONDVAR(Livery, colour2, SLE_UINT8, SLV_34, SL_MAX_VERSION),
}

Definition at line 405 of file company_sl.cpp.

## ◆ _company_settings_desc

const SaveLoad _company_settings_desc[]
| static

Initial value:
= {
SLE_CONDNULL(512, SLV_16, SLV_19),
SLE_CONDREF(Company, engine_renew_list, REF_ENGINE_RENEWS, SLV_19, SL_MAX_VERSION),
SLE_CONDVAR(Company, settings.engine_renew, SLE_BOOL, SLV_16, SL_MAX_VERSION),
SLE_CONDVAR(Company, settings.engine_renew_months, SLE_INT16, SLV_16, SL_MAX_VERSION),
SLE_CONDVAR(Company, settings.engine_renew_money, SLE_UINT32, SLV_16, SL_MAX_VERSION),
SLE_CONDVAR(Company, settings.renew_keep_length, SLE_BOOL, SLV_2, SL_MAX_VERSION),
SLE_CONDVAR(Company, settings.vehicle.servint_ispercent, SLE_BOOL, SLV_120, SL_MAX_VERSION),
SLE_CONDVAR(Company, settings.vehicle.servint_trains, SLE_UINT16, SLV_120, SL_MAX_VERSION),
SLE_CONDVAR(Company, settings.vehicle.servint_roadveh, SLE_UINT16, SLV_120, SL_MAX_VERSION),
SLE_CONDVAR(Company, settings.vehicle.servint_aircraft, SLE_UINT16, SLV_120, SL_MAX_VERSION),
SLE_CONDVAR(Company, settings.vehicle.servint_ships, SLE_UINT16, SLV_120, SL_MAX_VERSION),
SLE_CONDNULL(63, SLV_2, SLV_144),
}

Definition at line 300 of file company_sl.cpp.

## ◆ _company_settings_skip_desc

const SaveLoad _company_settings_skip_desc[]
| static

Initial value:
= {
SLE_CONDNULL(512, SLV_16, SLV_19),
SLE_CONDNULL(2, SLV_19, SLV_69),
SLE_CONDNULL(4, SLV_69, SL_MAX_VERSION),
SLE_CONDNULL(1, SLV_16, SL_MAX_VERSION),
SLE_CONDNULL(2, SLV_16, SL_MAX_VERSION),
SLE_CONDNULL(4, SLV_16, SL_MAX_VERSION),
SLE_CONDNULL(1, SLV_2, SL_MAX_VERSION),
SLE_CONDNULL(1, SLV_120, SL_MAX_VERSION),
SLE_CONDNULL(2, SLV_120, SL_MAX_VERSION),
SLE_CONDNULL(2, SLV_120, SL_MAX_VERSION),
SLE_CONDNULL(2, SLV_120, SL_MAX_VERSION),
SLE_CONDNULL(2, SLV_120, SL_MAX_VERSION),
SLE_CONDNULL(63, SLV_2, SLV_144),
}

Definition at line 321 of file company_sl.cpp.

SLV_69
@ SLV_69
69 10319
Definition: saveload.h:125
SLV_144
@ SLV_144
144 20334
Definition: saveload.h:215
SL_MIN_VERSION
@ SL_MIN_VERSION
First savegame version.
Definition: saveload.h:31
SLE_CONDARR
#define SLE_CONDARR(base, variable, type, length, from, to)
Storage of an array in some savegame versions.
Definition: saveload.h:572
SLE_CONDVAR
#define SLE_CONDVAR(base, variable, type, from, to)
Storage of a variable in some savegame versions.
Definition: saveload.h:551
CH_LAST
@ CH_LAST
Last chunk in this array.
Definition: saveload.h:410
SLE_CONDNULL
#define SLE_CONDNULL(length, from, to)
Empty space in some savegame versions.
Definition: saveload.h:677
CompanyEconomyEntry
Statistics about the economy.
Definition: company_base.h:22
CompanyOldAI
Definition: company_sl.cpp:361
SLV_EXTEND_CARGOTYPES
@ SLV_EXTEND_CARGOTYPES
199 PR#6802 Extend cargotypes to 64
Definition: saveload.h:282
SLE_CONDREF
#define SLE_CONDREF(base, variable, type, from, to)
Storage of a reference in some savegame versions.
Definition: saveload.h:561
SLV_120
@ SLV_120
120 16439
Definition: saveload.h:187
settings
fluid_settings_t * settings
FluidSynth settings handle.
Definition: fluidsynth.cpp:21
REF_ENGINE_RENEWS
@ REF_ENGINE_RENEWS
Load/save a reference to an engine renewal (autoreplace).
Definition: saveload.h:396
SLV_170
@ SLV_170
170 23826
Definition: saveload.h:247
SLV_107
@ SLV_107
107 15027
Definition: saveload.h:171
SLV_2
@ SLV_2
2.0 0.3.0 2.1 0.3.1, 0.3.2
Definition: saveload.h:34
SL_MAX_VERSION
@ SL_MAX_VERSION
Highest possible saveload version.
Definition: saveload.h:328
SLV_16
@ SLV_16
16.0 2817 16.1 3155
Definition: saveload.h:60
SLE_VAR
#define SLE_VAR(base, variable, type)
Storage of a variable in every version of a savegame.
Definition: saveload.h:621
SLV_6
@ SLV_6
6.0 1721 6.1 1768
Definition: saveload.h:46
NUM_CARGO
@ NUM_CARGO
Maximal number of cargo types in a game.
Definition: cargo_type.h:64
SLV_19
@ SLV_19
19 3396
Definition: saveload.h:65
Company
Definition: company_base.h:110
Livery
Information about a particular livery.
Definition: livery.h:78
SLV_34
@ SLV_34
34 6455
Definition: saveload.h:83
SLV_13
@ SLV_13
13.1 2080 0.4.0, 0.4.0.1
Definition: saveload.h:56