OpenTTD Source 20250331-master-g3c15e0c889
|
NewGRF Action 0x00 handler for global variables. More...
#include "../stdafx.h"
#include "../debug.h"
#include "../currency.h"
#include "../landscape.h"
#include "../language.h"
#include "../rev.h"
#include "../string_func.h"
#include "../newgrf.h"
#include "../newgrf_badge.h"
#include "../newgrf_badge_type.h"
#include "../newgrf_cargo.h"
#include "../newgrf_engine.h"
#include "../newgrf_sound.h"
#include "../vehicle_base.h"
#include "../rail.h"
#include "newgrf_bytereader.h"
#include "newgrf_internal_vehicle.h"
#include "newgrf_internal.h"
#include "newgrf_stringmapping.h"
#include "table/strings.h"
#include "../safeguards.h"
Go to the source code of this file.
Functions | |
template<typename T , typename TGetTableFunc > | |
static ChangeInfoResult | LoadTranslationTable (uint first, uint last, ByteReader &buf, TGetTableFunc gettable, std::string_view name) |
Load a cargo- or railtype-translation table. | |
static ChangeInfoResult | LoadBadgeTranslationTable (uint first, uint last, ByteReader &buf, std::vector< BadgeID > &translation_table, const char *name) |
static std::string | ReadDWordAsString (ByteReader &reader) |
Helper to read a DWord worth of bytes from the reader and to return it as a valid string. | |
static ChangeInfoResult | GlobalVarChangeInfo (uint first, uint last, int prop, ByteReader &buf) |
Define properties for global variables. | |
static ChangeInfoResult | GlobalVarReserveInfo (uint first, uint last, int prop, ByteReader &buf) |
bool | GetGlobalVariable (uint8_t param, uint32_t *value, const GRFFile *grffile) |
Reads a variable common to VarAction2 and Action7/9/D. | |
NewGRF Action 0x00 handler for global variables.
Definition in file newgrf_act0_globalvar.cpp.
bool GetGlobalVariable | ( | uint8_t | param, |
uint32_t * | value, | ||
const GRFFile * | grffile | ||
) |
Reads a variable common to VarAction2 and Action7/9/D.
Returns VarAction2 variable 'param' resp. Action7/9/D variable '0x80 + param'. If a variable is not accessible from all four actions, it is handled in the action specific functions.
param | variable number (as for VarAction2, for Action7/9/D you have to subtract 0x80 first). |
value | returns the value of the variable. |
grffile | NewGRF querying the variable |
Definition at line 417 of file newgrf_act0_globalvar.cpp.
References _misc_grf_features, _settings_game, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::base(), Clamp(), GameSettings::construction, TimerGameCalendar::ConvertDateToYMD(), TimerGameCalendar::ConvertYMDToDate(), TimerGameTick::counter, TimerGameCalendar::date, TimerGameCalendar::date_fract, TimerGameConst< struct Calendar >::DAYS_TILL_ORIGINAL_BASE_YEAR, VehicleSettings::disable_elrails, GameSettings::game_creation, GB(), GetRailTypeInfo(), GetSnowLine(), GrfProcessingState::grfconfig, GrfProcessingState::grffile, GRFP_USE_MASK, TimerGame< struct Calendar >::IsLeapYear(), GameCreationSettings::landscape, ConstructionSettings::map_height_limit, TimerGameConst< struct Calendar >::ORIGINAL_BASE_YEAR, TimerGameConst< struct Calendar >::ORIGINAL_MAX_YEAR, GRFConfig::palette, RAILTYPE_ELECTRIC, RAILTYPE_MAGLEV, RAILTYPE_MONO, RAILTYPE_RAIL, VehicleSettings::road_side, SB(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set(), SP_CUSTOM, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), TILE_HEIGHT, to_underlying(), GRFFile::traininfo_vehicle_pitch, GRFFile::traininfo_vehicle_width, TrainWidth32Pixels, GameSettings::vehicle, and TimerGameCalendar::year.
|
static |
Define properties for global variables.
first | ID of the first global var. |
last | ID of the last global var. |
prop | The property to change. |
buf | The property value. |
Definition at line 107 of file newgrf_act0_globalvar.cpp.
References _currency_specs, _settings_game, AddStringForMapping(), GRFFile::badge_list, GRFFile::cargo_list, CIR_SUCCESS, CIR_UNKNOWN, GameSettings::construction, CURRENCY_END, GB(), LanguagePackHeader::GetCaseIndex(), LanguagePackHeader::GetGenderIndex(), GetLanguage(), GetNewgrfCurrencyIdConverted(), GrfProcessingState::grffile, IsSnowLineSet(), GRFFile::language_map, ConstructionSettings::map_height_limit, MAX_LANG, MAX_NUM_CASES, MAX_NUM_GENDERS, LanguageMap::Mapping::newgrf_id, NFO_UTF8_IDENTIFIER, LanguageMap::Mapping::openttd_id, GRFFile::price_base_multipliers, GRFFile::railtype_list, ByteReader::ReadByte(), ByteReader::ReadDWord(), ReadDWordAsString(), ByteReader::ReadString(), ByteReader::ReadWord(), GRFFile::roadtype_list, SetSnowLine(), SNOW_LINE_DAYS, SNOW_LINE_MONTHS, StrMakeValid(), GRFFile::tramtype_list, and Utf8Decode().
|
static |
Definition at line 333 of file newgrf_act0_globalvar.cpp.
|
static |
Definition at line 69 of file newgrf_act0_globalvar.cpp.
|
static |
Load a cargo- or railtype-translation table.
first | ID of the first translation table entry. |
last | ID of the last translation table entry. |
buf | The property value. |
gettable | Function to get storage for the translation table. |
name | Name of the table for debug output. |
Definition at line 44 of file newgrf_act0_globalvar.cpp.
References CIR_INVALID_ID, CIR_SUCCESS, GetCurrentGRFOverride(), GrfProcessingState::grffile, and ByteReader::ReadDWord().
|
static |
Helper to read a DWord worth of bytes from the reader and to return it as a valid string.
reader | The source of the DWord. |
Definition at line 92 of file newgrf_act0_globalvar.cpp.
References ByteReader::ReadByte(), and StrMakeValid().
Referenced by GlobalVarChangeInfo().