26static std::string _ai_saveload_name;
27static int _ai_saveload_version;
28static std::string _ai_saveload_settings;
29static bool _ai_saveload_is_random;
31static const SaveLoad _ai_company_desc[] = {
38static const SaveLoad _ai_running_desc[] = {
44static void SaveReal_AIPL(
int arg)
46 CompanyID index =
static_cast<CompanyID
>(arg);
50 _ai_saveload_name = config->
GetName();
54 _ai_saveload_name.clear();
55 _ai_saveload_version = -1;
66 _ai_saveload_name = config->
GetName();
83 for (CompanyID c = CompanyID::Begin(); c < MAX_COMPANIES; ++c) {
91 _ai_saveload_is_random =
false;
92 _ai_saveload_version = -1;
104 if (_ai_saveload_name.empty() || _ai_saveload_is_random) {
106 config->
Change(std::nullopt, -1,
false);
108 config->
Change(_ai_saveload_name, _ai_saveload_version,
false);
112 config->
Change(_ai_saveload_name, -1,
false);
114 if (_ai_saveload_name !=
"%_dummy") {
129 SlObject(
nullptr, _ai_running_desc);
131 Company::Get(index)->ai_config = std::make_unique<AIConfig>();
133 config->
Change(_ai_saveload_name, _ai_saveload_version,
false);
137 config->
Change(_ai_saveload_name, -1,
false);
139 if (_ai_saveload_name !=
"%_dummy") {
152 _ai_saveload_version = -1;
163 for (CompanyID i = CompanyID::Begin(); i < MAX_COMPANIES; ++i) {
Base functions for all AIs.
AIConfig stores the configuration settings of every AI.
The AIInstance tracks an AI.
Loading for ai chunks before table headers were added.
const SaveLoadCompat _ai_company_sl_compat[]
Original field order for _ai_company_desc.
AI instantion of script configuration.
static AIConfig * GetConfig(CompanyID company, ScriptSettingSource source=ScriptSettingSource::Default)
Get the AI configuration of specific company.
static void Save(CompanyID company)
Save data from an AI to a savegame.
@ ForceCurrentGame
Get the Script config from the current game.
bool HasScript() const
Is this config attached to an Script?
void Change(std::optional< std::string_view > name, int version=-1, bool force_exact_match=false)
Set another Script to be loaded in this slot.
void StringToSettings(std::string_view value)
Convert a string which is stored in the config file or savegames to custom settings of this Script.
const std::string & GetName() const
Get the name of the Script.
int GetVersion() const
Get the version of the Script.
std::string SettingsToString() const
Convert the custom settings to a string that can be stored in the config file or savegames.
static ScriptData * Load(int version)
Load data from a savegame.
static void LoadEmpty()
Load and discard data from a savegame.
Definition of stuff that is very close to a company, like the company struct itself.
Functions related to debugging.
#define Debug(facility, severity, format_string,...)
Output a line of debugging information.
@ Script
Script message facility.
@ Critical
Critical, user should know about this.
bool _networking
are we in networking mode?
bool _network_server
network-server is active
Basic functions/variables used all over the place.
A number of safeguards to prevent using unsafe methods.
std::vector< SaveLoad > SlCompatTableHeader(const SaveLoadTable &slt, const SaveLoadCompatTable &slct)
Load a table header in a savegame compatible way.
int SlIterateArray()
Iterate through the elements of an array and read the whole thing.
void SlErrorCorrupt(const std::string &msg)
Error handler for corrupt savegames.
void SlObject(void *object, const SaveLoadTable &slt)
Main SaveLoad function.
std::vector< SaveLoad > SlTableHeader(const SaveLoadTable &slt)
Save or Load a table header.
void SlAutolength(AutolengthProc *proc, int arg)
Do something of which I have no idea what it is :P.
Functions/types related to saving and loading games.
#define SLE_GLOBAL_ADDRESS(variable)
Macro to be able to pass the variable type and construct the SaveLoad::AddressFunction given a global...
std::reference_wrapper< const ChunkHandler > ChunkHandlerRef
A reference to ChunkHandler.
std::span< const ChunkHandlerRef > ChunkHandlerTable
A table of ChunkHandler entries.
@ AILocalConfig
Saveload version: 332, GitHub pull request: 12003 Config of running AI is stored inside Company.
@ StoreAIVersion
Saveload version: 108, SVN revision: 15045 Store the version of the AI script.
@ SplitLoadWaitCounters
Saveload version: 136, SVN revision: 18764 Split counters for (un)loading and signal waiting/turning...
@ Table
An Array with a header describing the elements.
Functions/types related to errors from savegames.
Definition of base types and functions in a cross-platform compatible way.
void Save() const override
Save the chunk.
void Load() const override
Load the chunk.
ChunkHandler(ChunkId id, ChunkType type)
Create this ChunkHandler.
static bool IsValidAiID(auto index)
Is this company a valid company, controlled by the computer (a NoAI program)?
static Company * Get(auto index)
static SaveLoad Variable(std::string name, AddressFunction< T > address_func, SaveLoadVersion from=SaveLoadVersion::MinVersion, SaveLoadVersion to=SaveLoadVersion::MaxVersion, size_t extra=0)
Storage of a variable in some savegame versions.
static SaveLoad String(std::string name, AddressFunction< T > address_func, StringValidationSettings string_validation_settings={}, SaveLoadVersion from=SaveLoadVersion::MinVersion, SaveLoadVersion to=SaveLoadVersion::MaxVersion, size_t extra=0)
Storage of a string in some savegame versions.