OpenTTD Source 20250528-master-g3aca5d62a8
|
Base of all NewGRF support. More...
#include "stdafx.h"
#include "core/backup_type.hpp"
#include "core/container_func.hpp"
#include "debug.h"
#include "fileio_func.h"
#include "engine_func.h"
#include "engine_base.h"
#include "bridge.h"
#include "town.h"
#include "newgrf_engine.h"
#include "newgrf_text.h"
#include "spritecache.h"
#include "currency.h"
#include "landscape.h"
#include "newgrf_badge.h"
#include "newgrf_badge_config.h"
#include "newgrf_cargo.h"
#include "newgrf_sound.h"
#include "newgrf_station.h"
#include "industrytype.h"
#include "newgrf_canal.h"
#include "newgrf_townname.h"
#include "newgrf_industries.h"
#include "newgrf_airporttiles.h"
#include "newgrf_airport.h"
#include "newgrf_object.h"
#include "network/core/config.h"
#include "smallmap_gui.h"
#include "genworld.h"
#include "error_func.h"
#include "vehicle_base.h"
#include "road.h"
#include "newgrf_roadstop.h"
#include "newgrf/newgrf_bytereader.h"
#include "newgrf/newgrf_internal_vehicle.h"
#include "newgrf/newgrf_internal.h"
#include "newgrf/newgrf_stringmapping.h"
#include "table/strings.h"
#include "safeguards.h"
Go to the source code of this file.
Data Structures | |
struct | InvokeGrfActionHandler |
Helper class to invoke a GrfActionHandler. More... | |
Functions | |
std::span< const GRFFile > | GetAllGRFFiles () |
void | GrfMsgI (int severity, const std::string &msg) |
Debug() function dedicated to newGRF debugging messages Function is essentially the same as Debug(grf, severity, ...) with the addition of file:line information when parsing grf files. | |
GRFFile * | GetFileByGRFID (uint32_t grfid) |
Obtain a NewGRF file by its grfID. | |
static GRFFile * | GetFileByFilename (const std::string &filename) |
Obtain a NewGRF file by its filename. | |
static void | ClearTemporaryNewGRFData (GRFFile *gf) |
Reset all NewGRFData that was used only while processing data. | |
GRFError * | DisableGrf (StringID message, GRFConfig *config) |
Disable a GRF. | |
void | DisableStaticNewGRFInfluencingNonStaticNewGRFs (GRFConfig &c) |
Disable a static NewGRF when it is influencing another (non-static) NewGRF as this could cause desyncs. | |
void | SetNewGRFOverride (uint32_t source_grfid, uint32_t target_grfid) |
Set the override for a NewGRF. | |
GRFFile * | GetCurrentGRFOverride () |
Get overridden GRF for current GRF if present. | |
Engine * | GetNewEngine (const GRFFile *file, VehicleType type, uint16_t internal_id, bool static_access) |
Returns the engine associated to a certain internal_id, resp. | |
EngineID | GetNewEngineID (const GRFFile *file, VehicleType type, uint16_t internal_id) |
Return the ID of a new engine. | |
CargoTypes | TranslateRefitMask (uint32_t refit_mask) |
Translate the refit mask. | |
void | ConvertTTDBasePrice (uint32_t base_pointer, std::string_view error_location, Price *index) |
Converts TTD(P) Base Price pointers into the enum used by OTTD See http://wiki.ttdpatch.net/tiki-index.php?page=BaseCosts. | |
void | GRFUnsafe (ByteReader &) |
Set the current NewGRF as unsafe for static use. | |
static void | ResetNewGRF () |
Reset and clear all NewGRFs. | |
static void | ResetNewGRFErrors () |
Clear all NewGRF errors. | |
void | ResetCallbacks (bool final) |
void | ResetGRM () |
void | ResetNewGRFData () |
Reset all NewGRF loaded data. | |
void | ResetPersistentNewGRFData () |
Reset NewGRF data which is stored persistently in savegames. | |
std::span< const CargoLabel > | GetCargoTranslationTable (const GRFFile &grffile) |
Get the cargo translation table to use for the given GRF file. | |
static void | BuildCargoTranslationMap () |
Construct the Cargo Mapping. | |
static void | InitNewGRFFile (const GRFConfig &config) |
Prepare loading a NewGRF file with its config. | |
static CargoLabel | GetActiveCargoLabel (const std::initializer_list< CargoLabel > &labels) |
Find first cargo label that exists and is active from a list of cargo labels. | |
static CargoLabel | GetActiveCargoLabel (const std::variant< CargoLabel, MixedCargoType > &label) |
Get active cargo label from either a cargo label or climate-dependent mixed cargo type. | |
static void | CalculateRefitMasks () |
Precalculate refit masks from cargo classes for all vehicles. | |
static void | FinaliseCanals () |
Set to use the correct action0 properties for each canal feature. | |
static void | FinaliseEngineArray () |
Check for invalid engines. | |
void | FinaliseCargoArray () |
Check for invalid cargoes. | |
static bool | IsHouseSpecValid (HouseSpec &hs, const HouseSpec *next1, const HouseSpec *next2, const HouseSpec *next3, const std::string &filename) |
Check if a given housespec is valid and disable it if it's not. | |
static void | EnsureEarlyHouse (HouseZones bitmask) |
Make sure there is at least one house available in the year 0 for the given climate / housezone combination. | |
static void | FinaliseHouseArray () |
Add all new houses to the house array. | |
static void | FinaliseIndustriesArray () |
Add all new industries to the industry array. | |
static void | FinaliseObjectsArray () |
Add all new objects to the object array. | |
static void | FinaliseAirportsArray () |
Add all new airports to the airport array. | |
static void | DecodeSpecialSprite (ReusableBuffer< uint8_t > &allocator, uint num, GrfLoadingStage stage) |
static void | LoadNewGRFFileFromFile (GRFConfig &config, GrfLoadingStage stage, SpriteFile &file) |
Load a particular NewGRF from a SpriteFile. | |
void | LoadNewGRFFile (GRFConfig &config, GrfLoadingStage stage, Subdirectory subdir, bool temporary) |
Load a particular NewGRF. | |
static void | ActivateOldShore () |
Relocates the old shore sprites at new positions. | |
static void | ActivateOldTramDepot () |
Replocate the old tram depot sprites to the new position, if no new ones were loaded. | |
static void | FinalisePriceBaseMultipliers () |
Decide whether price base multipliers of grfs shall apply globally or only to the grf specifying them. | |
template<typename T > | |
void | AddBadgeToSpecs (T &specs, GrfSpecFeature feature, Badge &badge) |
static void | FinaliseBadges () |
Finish up applying badges to things. | |
void | InitGRFTownGeneratorNames () |
Allocate memory for the NewGRF town names. | |
static void | AfterLoadGRFs () |
Finish loading NewGRFs and execute needed post-processing. | |
void | LoadNewGRF (SpriteID load_index, uint num_baseset) |
Load all the NewGRFs. | |
Variables | |
static std::vector< GRFFile > | _grf_files |
List of all loaded GRF files. | |
GrfMiscBits | _misc_grf_features {} |
Miscellaneous GRF features, set by Action 0x0D, parameter 0x9E. | |
GRFLoadedFeatures | _loaded_newgrf_features |
Indicates which are the newgrf features currently loaded ingame. | |
GrfProcessingState | _cur_gps |
ReferenceThroughBaseContainer< std::vector< GRFTempEngineData > > | _gted |
Temporary engine data used during NewGRF loading. | |
static std::map< uint32_t, uint32_t > | _grf_id_overrides |
Base of all NewGRF support.
Definition in file newgrf.cpp.
|
static |
Relocates the old shore sprites at new positions.
Definition at line 1409 of file newgrf.cpp.
References _loaded_newgrf_features, GRFLoadedFeatures::shore, SHORE_REPLACE_ACTION_5, SHORE_REPLACE_ACTION_A, SHORE_REPLACE_NONE, and SPR_SHORE_BASE.
Referenced by AfterLoadGRFs().
|
static |
Replocate the old tram depot sprites to the new position, if no new ones were loaded.
Definition at line 1446 of file newgrf.cpp.
References _loaded_newgrf_features, GRFLoadedFeatures::tram, and TRAMWAY_REPLACE_DEPOT_WITH_TRACK.
Referenced by AfterLoadGRFs().
void AddBadgeToSpecs | ( | T & | specs, |
GrfSpecFeature | feature, | ||
Badge & | badge | ||
) |
Definition at line 1575 of file newgrf.cpp.
|
static |
Finish loading NewGRFs and execute needed post-processing.
Definition at line 1614 of file newgrf.cpp.
References _gted, ActivateOldShore(), ActivateOldTramDepot(), BindAirportSpecs(), BuildIndustriesLegend(), BuildLinkStatsLegend(), CalculateRefitMasks(), CommitVehicleListOrderChanges(), FinaliseAirportsArray(), FinaliseBadges(), FinaliseCanals(), FinaliseCargoArray(), FinaliseEngineArray(), FinaliseHouseArray(), FinaliseIndustriesArray(), FinaliseObjectsArray(), FinalisePriceBaseMultipliers(), FinaliseStringMapping(), GetRailTypeByLabel(), GetRoadTypeByLabel(), InitGRFTownGeneratorNames(), InitializeSortedCargoSpecs(), InitRailTypes(), InitRoadTypes(), INVALID_RAILTYPE, INVALID_ROADTYPE, Engine::IterateType(), RoadIsTram, GRFFile::roadtype_list, ROADTYPE_ROAD, ROADTYPE_TRAM, SetYearEngineAgingStops(), SortIndustryTypes(), GRFFile::tramtype_list, VEH_ROAD, and VEH_TRAIN.
Referenced by LoadNewGRF().
|
static |
Construct the Cargo Mapping.
Definition at line 529 of file newgrf.cpp.
References GRFFile::cargo_map, find_index(), GetCargoTranslationTable(), GrfProcessingState::grffile, and CargoSpec::Iterate().
Referenced by LoadNewGRF().
|
static |
Precalculate refit masks from cargo classes for all vehicles.
< Set if the vehicle shall carry only the default cargo
Definition at line 639 of file newgrf.cpp.
References _cargo_mask, _gted, _settings_game, _standard_cargo_mask, Armoured, Bulk, CALLBACK_FAILED, GRFFile::cargo_list, GRFFile::cargo_map, CBID_VEHICLE_CUSTOM_REFIT, EngineInfo::climates, ClrBit(), CT_INVALID, CT_PASSENGERS, CustomRefit, ErrorUnknownCallbackResult(), Express, FindFirstBit(), GameSettings::game_creation, GetActiveCargoLabel(), GetVehicleCallback(), HasBit(), IsDefaultCargo(), IsValidCargoType(), CargoSpec::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_engine_pool >::Iterate(), GameCreationSettings::landscape, Liquid, Mail, GRFTempEngineData::NONEMPTY, NUM_CARGO, Passengers, PieceGoods, RAILVEH_WAGON, Refrigerated, SetBit(), VEH_AIRCRAFT, VEH_SHIP, and VEH_TRAIN.
Referenced by AfterLoadGRFs().
|
static |
Reset all NewGRFData that was used only while processing data.
Definition at line 123 of file newgrf.cpp.
References GRFFile::labels.
Referenced by DisableGrf(), and LoadNewGRF().
void ConvertTTDBasePrice | ( | uint32_t | base_pointer, |
std::string_view | error_location, | ||
Price * | index | ||
) |
Converts TTD(P) Base Price pointers into the enum used by OTTD See http://wiki.ttdpatch.net/tiki-index.php?page=BaseCosts.
base_pointer | TTD(P) Base Price Pointer | |
error_location | Function name for grf error messages | |
[out] | index | If base_pointer is valid, index is assigned to the matching price; else it is left unchanged |
< Position of first base price
< Size of each base price record
Definition at line 327 of file newgrf.cpp.
Referenced by RailVehicleChangeInfo(), and RoadVehicleChangeInfo().
|
static |
Definition at line 1234 of file newgrf.cpp.
Disable a GRF.
message | Error message or STR_NULL. |
config | GRFConfig to disable, nullptr for current. |
Definition at line 134 of file newgrf.cpp.
References ClearTemporaryNewGRFData(), GRFConfig::error, GCS_DISABLED, GetFileByGRFID(), GrfProcessingState::grfconfig, GrfProcessingState::grffile, GRFIdentifier::grfid, GRFConfig::ident, GrfProcessingState::nfo_line, GrfProcessingState::skip_sprites, and GRFConfig::status.
Referenced by DisableStaticNewGRFInfluencingNonStaticNewGRFs(), FeatureTownName(), IndustriesChangeInfo(), IndustrytilesChangeInfo(), LoadNewGRFFileFromFile(), ParamSet(), ReadSpriteLayout(), ReadSpriteLayoutRegisters(), ReadSpriteLayoutSprite(), TownHouseChangeInfo(), and TranslateGRFStrings().
void DisableStaticNewGRFInfluencingNonStaticNewGRFs | ( | GRFConfig & | c | ) |
Disable a static NewGRF when it is influencing another (non-static) NewGRF as this could cause desyncs.
We could just tell the NewGRF querying that the file doesn't exist, but that might give unwanted results. Disabling the NewGRF gives the best result as no NewGRF author can complain about that.
c | The NewGRF to disable. |
Definition at line 164 of file newgrf.cpp.
References GRFError::data, DisableGrf(), GRFConfig::GetName(), and GrfProcessingState::grfconfig.
Referenced by ParamSet().
|
static |
Make sure there is at least one house available in the year 0 for the given climate / housezone combination.
bitmask | The climate and housezone to check for. Exactly one climate bit and one housezone bit should be set. |
Definition at line 995 of file newgrf.cpp.
References TimerGameConst< struct Calendar >::MAX_YEAR, TimerGameConst< struct Calendar >::MIN_YEAR, and HouseSpec::Specs().
Referenced by FinaliseHouseArray().
|
static |
Add all new airports to the airport array.
Airport properties can be set at any time in the GRF file, so we can only add a airport spec to the airport array after the file has finished loading.
Definition at line 1170 of file newgrf.cpp.
References _grf_files.
Referenced by AfterLoadGRFs().
|
static |
Finish up applying badges to things.
Definition at line 1585 of file newgrf.cpp.
References _grf_files, AddBadgeClassesToConfiguration(), ApplyBadgeFeaturesToClassBadges(), Badge::features, GetBadgeByLabel(), Badge::index, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_engine_pool >::Iterate(), and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set().
Referenced by AfterLoadGRFs().
|
static |
Set to use the correct action0 properties for each canal feature.
Definition at line 835 of file newgrf.cpp.
References _water_feature.
Referenced by AfterLoadGRFs().
void FinaliseCargoArray | ( | ) |
Check for invalid cargoes.
Definition at line 919 of file newgrf.cpp.
Referenced by AfterLoadGRFs().
|
static |
Check for invalid engines.
Definition at line 846 of file newgrf.cpp.
References _loaded_newgrf_features, _settings_game, AppendCopyableBadgeList(), GameSettings::game_creation, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_engine_pool >::Get(), GetEngineLiveryScheme(), GetNewEngineID(), GetRailTypeInfo(), GetRoadTypeInfo(), HasVariants, IsFolded, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_engine_pool >::Iterate(), GameCreationSettings::landscape, RAILVEH_WAGON, SetBit(), GRFLoadedFeatures::used_liveries, VEH_ROAD, and VEH_TRAIN.
Referenced by AfterLoadGRFs().
|
static |
Add all new houses to the house array.
House properties can be set at any time in the GRF file, so we can only add a house spec to the house array after the file has finished loading. We also need to check the dates, due to the TTDPatch behaviour described below that we need to emulate.
Definition at line 1020 of file newgrf.cpp.
References _grf_files, HouseSpec::accepts_cargo, HouseSpec::accepts_cargo_label, HouseSpec::building_flags, HouseSpec::cargo_acceptance, EnsureEarlyHouse(), HouseSpec::Get(), GetClimateMaskForLandscape(), IsHouseSpecValid(), IsValidCargoType(), lengthof, NUM_HOUSES, HouseOverrideManager::SetEntitySpec(), and HouseSpec::Specs().
Referenced by AfterLoadGRFs().
|
static |
Add all new industries to the industry array.
Industry properties can be set at any time in the GRF file, so we can only add a industry spec to the industry array after the file has finished loading.
Definition at line 1094 of file newgrf.cpp.
References _grf_files, GetActiveCargoLabel(), IsValidCargoType(), MapNewGRFIndustryType(), and IndustryOverrideManager::SetEntitySpec().
Referenced by AfterLoadGRFs().
|
static |
Add all new objects to the object array.
Object properties can be set at any time in the GRF file, so we can only add an object spec to the object array after the file has finished loading.
Definition at line 1148 of file newgrf.cpp.
References _grf_files, ObjectSpec::BindToClasses(), and ObjectOverrideManager::SetEntitySpec().
Referenced by AfterLoadGRFs().
|
static |
Decide whether price base multipliers of grfs shall apply globally or only to the grf specifying them.
Features, to which '_grf_id_overrides' applies. Currently vehicle features only.
Definition at line 1461 of file newgrf.cpp.
References _grf_files, Debug, PriceBaseSpec::fallback_price, PriceBaseSpec::grf_feature, GRFFile::grf_features, GRFFile::price_base_multipliers, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set(), SetPriceBaseMultiplier(), and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().
Referenced by AfterLoadGRFs().
|
static |
Find first cargo label that exists and is active from a list of cargo labels.
labels | List of cargo labels. |
Definition at line 604 of file newgrf.cpp.
References CT_INVALID.
Referenced by CalculateRefitMasks(), FinaliseIndustriesArray(), and GetActiveCargoLabel().
|
static |
Get active cargo label from either a cargo label or climate-dependent mixed cargo type.
label | Cargo label or climate-dependent mixed cargo type. |
Definition at line 618 of file newgrf.cpp.
References GetActiveCargoLabel(), MCT_GRAIN_WHEAT_MAIZE, MCT_LIVESTOCK_FRUIT, and MCT_VALUABLES_GOLD_DIAMONDS.
std::span< const GRFFile > GetAllGRFFiles | ( | ) |
Definition at line 64 of file newgrf.cpp.
std::span< const CargoLabel > GetCargoTranslationTable | ( | const GRFFile & | grffile | ) |
Get the cargo translation table to use for the given GRF file.
grffile | GRF file. |
Definition at line 513 of file newgrf.cpp.
References GRFFile::cargo_list, GetClimateDependentCargoTranslationTable(), and GetClimateIndependentCargoTranslationTable().
Referenced by BuildCargoTranslationMap().
GRFFile * GetCurrentGRFOverride | ( | ) |
Get overridden GRF for current GRF if present.
Definition at line 192 of file newgrf.cpp.
References GetFileByGRFID(), and GrfProcessingState::grffile.
Referenced by LoadTranslationTable().
|
static |
Obtain a NewGRF file by its filename.
filename | The filename to obtain the file for. |
Definition at line 115 of file newgrf.cpp.
References _grf_files.
Referenced by InitNewGRFFile(), and LoadNewGRFFile().
GRFFile * GetFileByGRFID | ( | uint32_t | grfid | ) |
Obtain a NewGRF file by its grfID.
grfid | The grfID to obtain the file for |
Definition at line 103 of file newgrf.cpp.
References _grf_files.
Referenced by DisableGrf(), GetCurrentGRFOverride(), LanguageMap::GetLanguageMap(), GetNewEngine(), ImportGRFSound(), LoadNewGRF(), and ParamSet().
Engine * GetNewEngine | ( | const GRFFile * | file, |
VehicleType | type, | ||
uint16_t | internal_id, | ||
bool | static_access | ||
) |
Returns the engine associated to a certain internal_id, resp.
allocates it.
file | NewGRF that wants to change the engine. |
type | Vehicle type. |
internal_id | Engine ID inside the NewGRF. |
static_access | If the engine is not present, return nullptr instead of allocating a new engine. (Used for static Action 0x04). |
Definition at line 210 of file newgrf.cpp.
References _engine_counts, _gted, _settings_game, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_engine_pool >::CanAllocateItem(), VehicleSettings::dynamic_engines, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_engine_pool >::Get(), GetFileByGRFID(), EngineOverrideManager::GetID(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_engine_pool >::GetPoolSize(), GetRailTypeInfo(), Engine::grf_prop, GRFFilePropsBase::HasGrfFile(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, RailTypeInfo::label, RailVehicleInfo::railtype, GRFFilePropsBase::SetGRFFile(), EngineOverrideManager::UseUnreservedID(), VEH_TRAIN, and GameSettings::vehicle.
Referenced by AircraftVehicleChangeInfo(), RailVehicleChangeInfo(), RoadVehicleChangeInfo(), and ShipVehicleChangeInfo().
EngineID GetNewEngineID | ( | const GRFFile * | file, |
VehicleType | type, | ||
uint16_t | internal_id | ||
) |
Return the ID of a new engine.
file | The NewGRF file providing the engine. |
type | The Vehicle type. |
internal_id | NewGRF-internal ID of the engine. |
Definition at line 291 of file newgrf.cpp.
References _settings_game, VehicleSettings::dynamic_engines, EngineOverrideManager::GetID(), and GameSettings::vehicle.
Referenced by FinaliseEngineArray(), and GetNextArticulatedPart().
void GrfMsgI | ( | int | severity, |
const std::string & | msg | ||
) |
Debug() function dedicated to newGRF debugging messages Function is essentially the same as Debug(grf, severity, ...) with the addition of file:line information when parsing grf files.
NOTE: for the above reason(s) GrfMsg() should ONLY be used for loading/parsing grf files, not for runtime debug messages as there is no file information available during that time.
severity | debugging severity level, see debug.h |
msg | the message |
Definition at line 89 of file newgrf.cpp.
References Debug, GRFConfig::filename, GrfProcessingState::grfconfig, and GrfProcessingState::nfo_line.
void GRFUnsafe | ( | ByteReader & | ) |
Set the current NewGRF as unsafe for static use.
Definition at line 368 of file newgrf.cpp.
References GRFConfig::flags, GrfProcessingState::grfconfig, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set(), GrfProcessingState::skip_sprites, and Unsafe.
|
extern |
Allocate memory for the NewGRF town names.
Definition at line 80 of file newgrf_townname.cpp.
References GRFTownName::styles.
Referenced by AfterLoadGRFs().
|
static |
Prepare loading a NewGRF file with its config.
config | The NewGRF configuration struct with name, id, parameters and alike. |
Definition at line 546 of file newgrf.cpp.
References _grf_files, GRFConfig::filename, GetFileByFilename(), and GrfProcessingState::grffile.
Referenced by LoadNewGRF().
|
static |
Check if a given housespec is valid and disable it if it's not.
The housespecs that follow it are used to check the validity of multitile houses.
hs | The housespec to check. |
next1 | The housespec that follows hs . |
next2 | The housespec that follows next1 . |
next3 | The housespec that follows next2 . |
filename | The filename of the newgrf this house was defined in. |
Definition at line 949 of file newgrf.cpp.
References BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Any(), HouseSpec::building_availability, HouseSpec::building_flags, Debug, HouseSpec::enabled, HouseSpec::Get(), HouseSpec::grf_prop, GRFFilePropsBase::local_id, and HouseSpec::population.
Referenced by FinaliseHouseArray().
void LoadNewGRF | ( | SpriteID | load_index, |
uint | num_baseset | ||
) |
Load all the NewGRFs.
load_index | The offset for the first sprite to add. |
num_baseset | Number of NewGRFs at the front of the list to look up in the baseset dir instead of the newgrf dir. |
Definition at line 1735 of file newgrf.cpp.
References _display_opt, _grfconfig, _networking, _settings_game, AfterLoadGRFs(), BASESET_DIR, BuildCargoTranslationMap(), GrfProcessingState::ClearDataForNextFile(), ClearTemporaryNewGRFData(), TimerGameCalendar::ConvertYMDToDate(), TimerGameEconomy::ConvertYMDToDate(), TimerGameTick::counter, TimerGameCalendar::date, TimerGameEconomy::date, TimerGameCalendar::date_fract, TimerGameEconomy::date_fract, Debug, FioCheckFileExists(), GameSettings::game_creation, GCS_ACTIVATED, GCS_DISABLED, GCS_INITIALISED, GCS_NOT_FOUND, GCS_UNKNOWN, GetFileByGRFID(), GrfProcessingState::grfconfig, GrfProcessingState::grffile, InitializePatchFlags(), InitNewGRFFile(), InitOnly, LoadNewGRFFile(), NETWORK_MAX_GRF_COUNT, NEWGRF_DIR, Reserved, ResetNewGRFData(), SetNewGRFOverride(), GrfProcessingState::spriteid, GrfProcessingState::stage, GameCreationSettings::starting_year, Static, System, TimerGameCalendar::year, and TimerGameEconomy::year.
Referenced by LoadSpriteTables().
void LoadNewGRFFile | ( | GRFConfig & | config, |
GrfLoadingStage | stage, | ||
Subdirectory | subdir, | ||
bool | temporary | ||
) |
Load a particular NewGRF.
config | The configuration of the to be loaded NewGRF. |
stage | The loading stage of the NewGRF. |
subdir | The sub directory to find the NewGRF in. |
temporary | The NewGRF/sprite file is to be loaded temporarily and should be closed immediately, contrary to loading the SpriteFile and having it cached by the SpriteCache. |
Definition at line 1373 of file newgrf.cpp.
References GRFConfig::filename, GRFConfig::flags, GCS_INITIALISED, GetFileByFilename(), GrfProcessingState::grffile, GRFP_USE_MASK, LoadNewGRFFileFromFile(), OpenCachedSpriteFile(), GRFConfig::palette, Reserved, GRFConfig::status, and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().
Referenced by FillGRFDetails(), and LoadNewGRF().
|
static |
Load a particular NewGRF from a SpriteFile.
config | The configuration of the to be loaded NewGRF. |
stage | The loading stage of the NewGRF. |
file | The file to load the GRF data from. |
Definition at line 1277 of file newgrf.cpp.
References GrfProcessingState::ClearDataForNextFile(), Debug, DisableGrf(), GrfProcessingState::file, GRFConfig::filename, SpriteFile::GetContainerVersion(), GrfProcessingState::grfconfig, GrfProcessingState::nfo_line, RandomAccessFile::ReadByte(), RandomAccessFile::ReadDword(), ReadGRFSpriteOffsets(), RandomAccessFile::ReadWord(), GrfProcessingState::skip_sprites, RandomAccessFile::SkipBytes(), and SkipSpriteData().
Referenced by LoadNewGRFFile().
|
extern |
Definition at line 267 of file newgrf_act2.cpp.
|
extern |
Definition at line 37 of file newgrf_actd.cpp.
|
static |
Reset and clear all NewGRFs.
Definition at line 377 of file newgrf.cpp.
References _grf_files, _grfconfig, GrfProcessingState::grfconfig, and GrfProcessingState::grffile.
Referenced by ResetNewGRFData().
void ResetNewGRFData | ( | ) |
Reset all NewGRF loaded data.
Definition at line 403 of file newgrf.cpp.
References _gted, _loaded_newgrf_features, _misc_grf_features, _settings_game, _water_feature, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::CleanPool(), CleanUpStrings(), ClearSnowLine(), GameSettings::game_creation, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_engine_pool >::GetPoolSize(), GetRailTypeInfo(), GRFLoadedFeatures::has_2CC, Engine::IterateType(), RailTypeInfo::label, GameCreationSettings::landscape, NewGRFClass< Tspec, Tindex, Tmax >::Reset(), AirportSpec::ResetAirports(), AirportTileSpec::ResetAirportTiles(), ResetBadges(), ResetBridges(), ResetCurrencies(), ResetGenericCallbacks(), ResetIndustries(), ResetNewGRF(), ResetNewGRFErrors(), ResetObjects(), ResetPriceBaseMultipliers(), ResetRailTypes(), ResetRoadTypes(), SetupCargoForClimate(), SetupEngines(), GRFLoadedFeatures::shore, SHORE_REPLACE_NONE, GRFLoadedFeatures::tram, TRAMWAY_REPLACE_DEPOT_NONE, GRFLoadedFeatures::used_liveries, and VEH_TRAIN.
Referenced by LoadNewGRF(), and ShutdownGame().
|
static |
Clear all NewGRF errors.
Definition at line 390 of file newgrf.cpp.
References _grfconfig.
Referenced by ResetNewGRFData().
void ResetPersistentNewGRFData | ( | ) |
Reset NewGRF data which is stored persistently in savegames.
Definition at line 497 of file newgrf.cpp.
References OverrideManagerBase::ResetMapping(), and EngineOverrideManager::ResetToDefaultMapping().
void SetNewGRFOverride | ( | uint32_t | source_grfid, |
uint32_t | target_grfid | ||
) |
Set the override for a NewGRF.
source_grfid | The grfID which wants to override another NewGRF. |
target_grfid | The grfID which is being overridden. |
Definition at line 177 of file newgrf.cpp.
Referenced by LoadNewGRF().
CargoTypes TranslateRefitMask | ( | uint32_t | refit_mask | ) |
Translate the refit mask.
refit_mask is uint32_t as it has not been mapped to CargoTypes.
Definition at line 310 of file newgrf.cpp.
References GetCargoTranslation(), GrfProcessingState::grffile, IsValidCargoType(), and SetBit().
Referenced by AircraftVehicleChangeInfo(), RailVehicleChangeInfo(), RoadVehicleChangeInfo(), ShipVehicleChangeInfo(), and StationChangeInfo().
GrfProcessingState _cur_gps |
Definition at line 75 of file newgrf.cpp.
|
static |
List of all loaded GRF files.
Definition at line 62 of file newgrf.cpp.
Referenced by FinaliseAirportsArray(), FinaliseBadges(), FinaliseHouseArray(), FinaliseIndustriesArray(), FinaliseObjectsArray(), FinalisePriceBaseMultipliers(), GetFileByFilename(), GetFileByGRFID(), InitNewGRFFile(), and ResetNewGRF().
|
static |
Definition at line 170 of file newgrf.cpp.
ReferenceThroughBaseContainer<std::vector<GRFTempEngineData> > _gted |
Temporary engine data used during NewGRF loading.
Definition at line 77 of file newgrf.cpp.
Referenced by AfterLoadGRFs(), AircraftVehicleChangeInfo(), CalculateRefitMasks(), GetNewEngine(), RailVehicleChangeInfo(), ResetNewGRFData(), RoadVehicleChangeInfo(), and ShipVehicleChangeInfo().
GRFLoadedFeatures _loaded_newgrf_features |
Indicates which are the newgrf features currently loaded ingame.
Definition at line 73 of file newgrf.cpp.
Referenced by ActivateOldShore(), ActivateOldTramDepot(), AircraftVehicleChangeInfo(), DrawRoadDepotSprite(), DrawTile_Road(), SelectCompanyLiveryWindow::DrawWidget(), FinaliseEngineArray(), ObjectChangeInfo(), SelectCompanyLiveryWindow::OnClick(), SelectCompanyLiveryWindow::OnDropdownSelect(), SelectCompanyLiveryWindow::OnInvalidateData(), RailVehicleChangeInfo(), ResetNewGRFData(), RoadVehicleChangeInfo(), ShipVehicleChangeInfo(), and SelectCompanyLiveryWindow::UpdateWidgetSize().
GrfMiscBits _misc_grf_features {} |
Miscellaneous GRF features, set by Action 0x0D, parameter 0x9E.
Definition at line 70 of file newgrf.cpp.
Referenced by GetGlobalVariable(), HasGrfMiscBit(), ParamSet(), and ResetNewGRFData().