Update to 14.0-beta1

This commit is contained in:
dP
2024-02-04 02:18:17 +05:30
parent 79037e2c65
commit 33ef333b57
1325 changed files with 138465 additions and 70987 deletions

View File

@@ -14,6 +14,7 @@
#include "vehicle_type.h"
#include "core/pool_type.hpp"
#include "newgrf_commons.h"
#include "timer/timer_game_calendar.h"
struct WagonOverride {
std::vector<EngineID> engines;
@@ -35,23 +36,23 @@ extern EnginePool _engine_pool;
struct Engine : EnginePool::PoolItem<&_engine_pool> {
std::string name; ///< Custom name of engine.
Date intro_date; ///< Date of introduction of the engine.
Date age;
uint16 reliability; ///< Current reliability of the engine.
uint16 reliability_spd_dec; ///< Speed of reliability decay between services (per day).
uint16 reliability_start; ///< Initial reliability of the engine.
uint16 reliability_max; ///< Maximal reliability of the engine.
uint16 reliability_final; ///< Final reliability of the engine.
uint16 duration_phase_1; ///< First reliability phase in months, increasing reliability from #reliability_start to #reliability_max.
uint16 duration_phase_2; ///< Second reliability phase in months, keeping #reliability_max.
uint16 duration_phase_3; ///< Third reliability phase in months, decaying to #reliability_final.
TimerGameCalendar::Date intro_date; ///< Date of introduction of the engine.
int32_t age; ///< Age of the engine in months.
uint16_t reliability; ///< Current reliability of the engine.
uint16_t reliability_spd_dec; ///< Speed of reliability decay between services (per day).
uint16_t reliability_start; ///< Initial reliability of the engine.
uint16_t reliability_max; ///< Maximal reliability of the engine.
uint16_t reliability_final; ///< Final reliability of the engine.
uint16_t duration_phase_1; ///< First reliability phase in months, increasing reliability from #reliability_start to #reliability_max.
uint16_t duration_phase_2; ///< Second reliability phase in months, keeping #reliability_max.
uint16_t duration_phase_3; ///< Third reliability phase in months, decaying to #reliability_final.
byte flags; ///< Flags of the engine. @see EngineFlags
CompanyMask preview_asked; ///< Bit for each company which has already been offered a preview.
CompanyID preview_company; ///< Company which is currently being offered a preview \c INVALID_COMPANY means no company.
byte preview_wait; ///< Daily countdown timer for timeout of offering the engine to the #preview_company company.
CompanyMask company_avail; ///< Bit for each company whether the engine is available for that company.
CompanyMask company_hidden; ///< Bit for each company whether the engine is normally hidden in the build gui for that company.
uint8 original_image_index; ///< Original vehicle image index, thus the image index of the overridden vehicle
uint8_t original_image_index; ///< Original vehicle image index, thus the image index of the overridden vehicle
VehicleType type; ///< %Vehicle type, ie #VEH_ROAD, #VEH_TRAIN, etc.
EngineDisplayFlags display_flags; ///< NOSAVE client-side-only display flags for build engine list.
@@ -75,7 +76,7 @@ struct Engine : EnginePool::PoolItem<&_engine_pool> {
*/
GRFFilePropsBase<NUM_CARGO + 2> grf_prop;
std::vector<WagonOverride> overrides;
uint16 list_position;
uint16_t list_position;
Engine() {}
Engine(VehicleType type, EngineID base);
@@ -87,7 +88,7 @@ struct Engine : EnginePool::PoolItem<&_engine_pool> {
* Usually a valid cargo is returned, even though the vehicle has zero capacity, and can therefore not carry anything. But the cargotype is still used
* for livery selection etc..
*
* Vehicles with CT_INVALID as default cargo are usually not available, but it can appear as default cargo of articulated parts.
* Vehicles with INVALID_CARGO as default cargo are usually not available, but it can appear as default cargo of articulated parts.
*
* @return The default cargo type.
* @see CanCarryCargo
@@ -97,7 +98,7 @@ struct Engine : EnginePool::PoolItem<&_engine_pool> {
return this->info.cargo_type;
}
uint DetermineCapacity(const Vehicle *v, uint16 *mail_capacity = nullptr) const;
uint DetermineCapacity(const Vehicle *v, uint16_t *mail_capacity = nullptr) const;
bool CanCarryCargo() const;
@@ -112,7 +113,7 @@ struct Engine : EnginePool::PoolItem<&_engine_pool> {
* @return The default capacity
* @see GetDefaultCargoType
*/
uint GetDisplayDefaultCapacity(uint16 *mail_capacity = nullptr) const
uint GetDisplayDefaultCapacity(uint16_t *mail_capacity = nullptr) const
{
return this->DetermineCapacity(nullptr, mail_capacity);
}
@@ -123,8 +124,8 @@ struct Engine : EnginePool::PoolItem<&_engine_pool> {
uint GetPower() const;
uint GetDisplayWeight() const;
uint GetDisplayMaxTractiveEffort() const;
Date GetLifeLengthInDays() const;
uint16 GetRange() const;
TimerGameCalendar::Date GetLifeLengthInDays() const;
uint16_t GetRange() const;
StringID GetAircraftTypeText() const;
/**
@@ -137,6 +138,18 @@ struct Engine : EnginePool::PoolItem<&_engine_pool> {
return c < MAX_COMPANIES && HasBit(this->company_hidden, c);
}
/**
* Get the last display variant for an engine.
* @return Engine's last display variant or engine itself if no last display variant is set.
*/
const Engine *GetDisplayVariant() const
{
if (this->display_last_variant == this->index || this->display_last_variant == INVALID_ENGINE) return this;
return Engine::Get(this->display_last_variant);
}
bool IsVariantHidden(CompanyID c) const;
/**
* Check if the engine is a ground vehicle.
* @return True iff the engine is a train or a road vehicle.
@@ -156,7 +169,7 @@ struct Engine : EnginePool::PoolItem<&_engine_pool> {
return this->grf_prop.grffile;
}
uint32 GetGRFID() const;
uint32_t GetGRFID() const;
struct EngineTypeFilter {
VehicleType vt;
@@ -177,10 +190,10 @@ struct Engine : EnginePool::PoolItem<&_engine_pool> {
};
struct EngineIDMapping {
uint32 grfid; ///< The GRF ID of the file the entity belongs to
uint16 internal_id; ///< The internal ID within the GRF file
uint32_t grfid; ///< The GRF ID of the file the entity belongs to
uint16_t internal_id; ///< The internal ID within the GRF file
VehicleType type; ///< The engine type
uint8 substitute_id; ///< The (original) entity ID to use if this GRF is not available (currently not used)
uint8_t substitute_id; ///< The (original) entity ID to use if this GRF is not available (currently not used)
};
/**
@@ -191,34 +204,34 @@ struct EngineOverrideManager : std::vector<EngineIDMapping> {
static const uint NUM_DEFAULT_ENGINES; ///< Number of default entries
void ResetToDefaultMapping();
EngineID GetID(VehicleType type, uint16 grf_local_id, uint32 grfid);
EngineID GetID(VehicleType type, uint16_t grf_local_id, uint32_t grfid);
static bool ResetToCurrentNewGRFConfig();
};
extern EngineOverrideManager _engine_mngr;
static inline const EngineInfo *EngInfo(EngineID e)
inline const EngineInfo *EngInfo(EngineID e)
{
return &Engine::Get(e)->info;
}
static inline const RailVehicleInfo *RailVehInfo(EngineID e)
inline const RailVehicleInfo *RailVehInfo(EngineID e)
{
return &Engine::Get(e)->u.rail;
}
static inline const RoadVehicleInfo *RoadVehInfo(EngineID e)
inline const RoadVehicleInfo *RoadVehInfo(EngineID e)
{
return &Engine::Get(e)->u.road;
}
static inline const ShipVehicleInfo *ShipVehInfo(EngineID e)
inline const ShipVehicleInfo *ShipVehInfo(EngineID e)
{
return &Engine::Get(e)->u.ship;
}
static inline const AircraftVehicleInfo *AircraftVehInfo(EngineID e)
inline const AircraftVehicleInfo *AircraftVehInfo(EngineID e)
{
return &Engine::Get(e)->u.air;
}