33 for (uint
id = first;
id < last; ++id) {
44 _gted[e->index].railtypelabels.clear();
45 if (tracktype < _cur_gps.grffile->railtype_list.size()) {
46 _gted[e->index].railtypelabels.push_back(_cur_gps.grffile->railtype_list[tracktype]);
51 case 0:
_gted[e->index].railtypelabels.push_back(rvi->
engclass >= 2 ? RAILTYPE_LABEL_ELECTRIC : RAILTYPE_LABEL_RAIL);
break;
52 case 1:
_gted[e->index].railtypelabels.push_back(RAILTYPE_LABEL_MONO);
break;
53 case 2:
_gted[e->index].railtypelabels.push_back(RAILTYPE_LABEL_MAGLEV);
break;
55 GrfMsg(1,
"RailVehicleChangeInfo: Invalid track type {} specified, ignoring", tracktype);
69 if (speed == 0xFFFF) speed = 0;
79 if (rvi->
power != 0) {
98 uint8_t orig_spriteid = spriteid;
105 rvi->image_index = spriteid;
107 GrfMsg(1,
"RailVehicleChangeInfo: Invalid Sprite {} specified, ignoring", orig_spriteid);
108 rvi->image_index = 0;
119 rvi->railveh_type = rvi->
power == 0 ?
130 _gted[e->index].defaultcargo_grf = _cur_gps.grffile;
135 ei->cargo_type = INVALID_CARGO;
139 if (ei->cargo_type == INVALID_CARGO) GrfMsg(2,
"RailVehicleChangeInfo: Invalid cargo type {}, using first refittable", ctype);
154 GrfMsg(2,
"RailVehicleChangeInfo: Property 0x18 'AI rank' not used by NoAI, ignored.");
169 if (traction <= 0x07) {
171 }
else if (traction <= 0x27) {
173 }
else if (traction <= 0x31) {
175 }
else if (traction <= 0x37) {
177 }
else if (traction <= 0x41) {
183 if (_cur_gps.grffile->railtype_list.empty() && !
_gted[e->index].railtypelabels.empty()) {
186 if (
_gted[e->index].railtypelabels[0] == RAILTYPE_LABEL_RAIL && engclass >=
EC_ELECTRIC)
_gted[e->index].railtypelabels[0] = RAILTYPE_LABEL_ELECTRIC;
187 if (
_gted[e->index].railtypelabels[0] == RAILTYPE_LABEL_ELECTRIC && engclass <
EC_ELECTRIC)
_gted[e->index].railtypelabels[0] = RAILTYPE_LABEL_RAIL;
208 _gted[e->index].UpdateRefittability(mask != 0);
210 _gted[e->index].defaultcargo_grf = _cur_gps.grffile;
251 GrfMsg(2,
"RailVehicleChangeInfo: Nonsensical weight of {} tons, ignoring", weight << 8);
272 _gted[e->index].cargo_allowed = CargoClasses{buf.
ReadWord()};
273 _gted[e->index].UpdateRefittability(
_gted[e->index].cargo_allowed.Any());
274 _gted[e->index].defaultcargo_grf = _cur_gps.grffile;
278 _gted[e->index].cargo_disallowed = CargoClasses{buf.
ReadWord()};
279 _gted[e->index].UpdateRefittability(
false);
293 _gted[e->index].UpdateRefittability(prop == 0x2C && count != 0);
294 if (prop == 0x2C)
_gted[e->index].defaultcargo_grf = _cur_gps.grffile;
295 CargoTypes &ctt = prop == 0x2C ?
_gted[e->index].ctt_include_mask :
_gted[e->index].ctt_exclude_mask;
313 ei->extra_flags =
static_cast<ExtraEngineFlags
>(buf.
ReadDWord());
324 _gted[e->index].cargo_allowed_required = CargoClasses{buf.
ReadWord()};
334 _gted[e->index].railtypelabels.clear();
338 if (tracktype < _cur_gps.grffile->railtype_list.size()) {
339 _gted[e->index].railtypelabels.push_back(_cur_gps.grffile->railtype_list[tracktype]);
341 GrfMsg(1,
"RailVehicleChangeInfo: Invalid track type {} specified, ignoring", tracktype);
constexpr T SB(T &x, const uint8_t s, const uint8_t n, const U d)
Set n bits in x starting at bit s to d.
constexpr T SetBit(T &x, const uint8_t y)
Set a bit in a variable.
constexpr bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
static constexpr CargoLabel CT_INVALID
Invalid cargo type.
uint8_t CargoType
Cargo slots to indicate a cargo type within a game.
bool IsValidCargoType(CargoType cargo)
Test whether cargo type is not INVALID_CARGO.
constexpr bool Test(Tvalue_type value) const
Test if the value-th bit is set.
constexpr Tstorage base() const noexcept
Retrieve the raw value behind this bit set.
Class to read from a NewGRF file.
uint32_t ReadDWord()
Read a single DWord (32 bits).
uint16_t ReadWord()
Read a single Word (16 bits).
uint16_t ReadExtendedByte()
Read a single Extended Byte (8 or 16 bits).
uint8_t ReadByte()
Read a single byte (8 bits).
Functions related to debugging.
@ Uses2CC
Vehicle uses two company colours.
@ VE_TYPE_COUNT
Number of bits used for the effect type.
@ VE_TYPE_START
First bit used for the type of effect.
@ VE_DISABLE_EFFECT
Flag to disable visual effect.
@ VE_DEFAULT
Default value to indicate that visual effect should be based on engine class.
PoolID< uint16_t, struct EngineIDTag, 64000, 0xFFFF > EngineID
Unique identification number of an engine.
EngineClass
Type of rail engine.
@ EC_DIESEL
Diesel rail engine.
@ EC_STEAM
Steam rail engine.
@ EC_MAGLEV
Maglev engine.
@ EC_ELECTRIC
Electric rail engine.
@ EC_MONORAIL
Mono rail engine.
@ RAILVEH_SINGLEHEAD
indicates a "standalone" locomotive
@ RAILVEH_WAGON
simple wagon, not motorized
@ RAILVEH_MULTIHEAD
indicates a combination of two locomotives
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....
Engine * GetNewEngine(const GRFFile *file, VehicleType type, uint16_t internal_id, bool static_access)
Returns the engine associated to a certain internal_id, resp.
TypedIndexContainer< std::vector< GRFTempEngineData >, EngineID > _gted
Temporary engine data used during NewGRF loading.
GRFLoadedFeatures _loaded_newgrf_features
Indicates which are the newgrf features currently loaded ingame.
CargoTypes TranslateRefitMask(uint32_t refit_mask)
Translate the refit mask.
ChangeInfoResult CommonVehicleChangeInfo(EngineInfo *ei, int prop, ByteReader &buf)
Define properties common to all vehicles.
std::vector< BadgeID > ReadBadgeList(ByteReader &buf, GrfSpecFeature feature)
Read a list of badges.
ChangeInfoResult RailVehicleChangeInfo(uint first, uint last, int prop, ByteReader &buf)
Define properties for rail vehicles.
NewGRF buffer reader definition.
CargoType GetCargoTranslation(uint8_t cargo, const GRFFile *grffile, bool usebit)
Translate a GRF-local cargo slot/bitnum into a CargoType.
Cargo support for NewGRFs.
void AlterVehicleListOrder(EngineID engine, uint16_t target)
Record a vehicle ListOrderChange.
Functions for NewGRF engines.
NewGRF internal processing state.
ChangeInfoResult
Possible return values for the GrfChangeInfoHandler functions.
@ CIR_INVALID_ID
Attempt to modify an invalid ID.
@ CIR_UNHANDLED
Variable was parsed but unread.
@ CIR_SUCCESS
Variable was parsed and read.
NewGRF internal processing state for vehicles.
static bool IsValidNewGRFImageIndex(uint8_t image_index)
Helper to check whether an image index is valid for a particular NewGRF vehicle.
@ PROP_TRAIN_SHORTEN_FACTOR
Shorter vehicles.
@ PROP_TRAIN_CURVE_SPEED_MOD
Modifier to maximum speed in curves.
@ PROP_TRAIN_COST_FACTOR
Purchase cost (if dualheaded: sum of both vehicles).
@ PROP_TRAIN_USER_DATA
User defined data for vehicle variable 0x42.
@ PROP_TRAIN_WEIGHT
Weight in t (if dualheaded: for each single vehicle).
@ PROP_TRAIN_CARGO_CAPACITY
Capacity (if dualheaded: for each single vehicle).
@ PROP_TRAIN_TRACTIVE_EFFORT
Tractive effort coefficient in 1/256.
@ PROP_TRAIN_CARGO_AGE_PERIOD
Number of ticks before carried cargo is aged.
@ PROP_TRAIN_RUNNING_COST_FACTOR
Yearly runningcost (if dualheaded: sum of both vehicles).
@ PROP_TRAIN_POWER
Power in hp (if dualheaded: sum of both vehicles).
@ PROP_TRAIN_SPEED
Max. speed: 1 unit = 1/1.6 mph = 1 km-ish/h.
A number of safeguards to prevent using unsafe methods.
Definition of base types and functions in a cross-platform compatible way.
Information about a vehicle.
uint16_t cargo_age_period
Number of ticks before carried cargo is aged.
EngineMiscFlags misc_flags
Miscellaneous flags.
EngineID variant_id
Engine variant ID. If set, will be treated specially in purchase lists.
VehicleCallbackMasks callback_mask
Bitmask of vehicle callbacks that have to be called.
TimerGameCalendar::Date base_intro
Basic date of engine introduction (without random parts).
int8_t retire_early
Number of years early to retire vehicle.
Information about a rail vehicle.
uint16_t power
Power of engine (hp); For multiheaded engines the sum of both engine powers.
uint8_t user_def_data
Property 0x25: "User-defined bit mask" Used only for (very few) NewGRF vehicles.
uint8_t running_cost
Running cost of engine; For multiheaded engines the sum of both running costs.
uint8_t cost_factor
Purchase cost factor; For multiheaded engines the sum of both engine prices.
uint8_t shorten_factor
length on main map for this type is 8 - shorten_factor
uint16_t pow_wag_power
Extra power applied to consist if wagon should be powered.
uint16_t max_speed
Maximum speed (1 unit = 1/1.6 mph = 1 km-ish/h).
int16_t curve_speed_mod
Modifier to maximum speed in curves (fixed-point binary with 8 fractional bits).
uint16_t weight
Weight of vehicle (tons); For multiheaded engines the weight of each single engine.
uint8_t capacity
Cargo capacity of vehicle; For multiheaded engines the capacity of each single engine.
uint8_t visual_effect
Bitstuffed NewGRF visual effect data.
uint8_t air_drag
Coefficient of air drag.
EngineClass engclass
Class of engine for this vehicle.
uint8_t ai_passenger_only
Bit value to tell AI that this engine is for passenger use only.
uint8_t tractive_effort
Tractive effort coefficient.
uint8_t pow_wag_weight
Extra weight applied to consist if wagon should be powered.
Base class for all vehicles.
@ CUSTOM_VEHICLE_SPRITENUM
Vehicle sprite from NewGRF.
@ VEH_TRAIN
Train vehicle type.