Update to 1.10.0-beta1

This commit is contained in:
dP
2019-10-31 22:24:28 +03:00
parent b84a475e14
commit 599ccf0c2b
1470 changed files with 354219 additions and 16795 deletions

View File

@@ -21,7 +21,7 @@
/** Resolver for the airport scope. */
struct AirportScopeResolver : public ScopeResolver {
struct Station *st; ///< Station of the airport for which the callback is run, or \c NULL for build gui.
struct Station *st; ///< Station of the airport for which the callback is run, or \c nullptr for build gui.
byte airport_id; ///< Type of airport for which the callback is run.
byte layout; ///< Layout of the airport to build.
TileIndex tile; ///< Tile for the callback, only valid for airporttile callbacks.
@@ -30,7 +30,7 @@ struct AirportScopeResolver : public ScopeResolver {
* Constructor of the scope resolver for an airport.
* @param ro Surrounding resolver.
* @param tile %Tile for the callback, only valid for airporttile callbacks.
* @param st %Station of the airport for which the callback is run, or \c NULL for build gui.
* @param st %Station of the airport for which the callback is run, or \c nullptr for build gui.
* @param airport_id Type of airport for which the callback is run.
* @param layout Layout of the airport to build.
*/
@@ -39,9 +39,9 @@ struct AirportScopeResolver : public ScopeResolver {
{
}
/* virtual */ uint32 GetRandomBits() const;
/* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
/* virtual */ void StorePSA(uint pos, int32 value);
uint32 GetRandomBits() const override;
uint32 GetVariable(byte variable, uint32 parameter, bool *available) const override;
void StorePSA(uint pos, int32 value) override;
};
/** Resolver object for airports. */
@@ -51,7 +51,7 @@ struct AirportResolverObject : public ResolverObject {
AirportResolverObject(TileIndex tile, Station *st, byte airport_id, byte layout,
CallbackID callback = CBID_NO_CALLBACK, uint32 callback_param1 = 0, uint32 callback_param2 = 0);
/* virtual */ ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0)
ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) override
{
switch (scope) {
case VSG_SCOPE_SELF: return &this->airport_scope;
@@ -59,7 +59,7 @@ struct AirportResolverObject : public ResolverObject {
}
}
/* virtual */ const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const;
const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const override;
};
/**
@@ -130,6 +130,24 @@ bool AirportSpec::IsAvailable() const
return _cur_year <= this->max_year;
}
/**
* Check if the airport would be within the map bounds at the given tile.
* @param table Selected layout table. This affects airport rotation, and therefore dimensions.
* @param tile Top corner of the airport.
* @return true iff the airport would be within the map bounds at the given tile.
*/
bool AirportSpec::IsWithinMapBounds(byte table, TileIndex tile) const
{
if (table >= this->num_table) return false;
byte w = this->size_x;
byte h = this->size_y;
if (this->rotation[table] == DIR_E || this->rotation[table] == DIR_W) Swap(w, h);
return TileX(tile) + w < MapSizeX() &&
TileY(tile) + h < MapSizeY();
}
/**
* This function initializes the airportspec array.
*/
@@ -184,14 +202,14 @@ void AirportOverrideManager::SetEntitySpec(AirportSpec *as)
case 0x40: return this->layout;
}
if (this->st == NULL) {
if (this->st == nullptr) {
*available = false;
return UINT_MAX;
}
switch (variable) {
/* Get a variable from the persistent storage */
case 0x7C: return (this->st->airport.psa != NULL) ? this->st->airport.psa->GetValue(parameter) : 0;
case 0x7C: return (this->st->airport.psa != nullptr) ? this->st->airport.psa->GetValue(parameter) : 0;
case 0xF0: return this->st->facilities;
case 0xFA: return Clamp(this->st->build_date - DAYS_TILL_ORIGINAL_BASE_YEAR, 0, 65535);
@@ -207,12 +225,12 @@ void AirportOverrideManager::SetEntitySpec(AirportSpec *as)
if (group->num_loaded > 0) return group->loaded[0];
if (group->num_loading > 0) return group->loading[0];
return NULL;
return nullptr;
}
/* virtual */ uint32 AirportScopeResolver::GetRandomBits() const
{
return this->st == NULL ? 0 : this->st->random_bits;
return this->st == nullptr ? 0 : this->st->random_bits;
}
/**
@@ -222,14 +240,14 @@ void AirportOverrideManager::SetEntitySpec(AirportSpec *as)
*/
/* virtual */ void AirportScopeResolver::StorePSA(uint pos, int32 value)
{
if (this->st == NULL) return;
if (this->st == nullptr) return;
if (this->st->airport.psa == NULL) {
if (this->st->airport.psa == nullptr) {
/* There is no need to create a storage if the value is zero. */
if (value == 0) return;
/* Create storage on first modification. */
uint32 grfid = (this->ro.grffile != NULL) ? this->ro.grffile->grfid : 0;
uint32 grfid = (this->ro.grffile != nullptr) ? this->ro.grffile->grfid : 0;
assert(PersistentStorage::CanAllocateItem());
this->st->airport.psa = new PersistentStorage(grfid, GSF_AIRPORTS, this->st->airport.tile);
}
@@ -239,7 +257,7 @@ void AirportOverrideManager::SetEntitySpec(AirportSpec *as)
/**
* Constructor of the airport resolver.
* @param tile %Tile for the callback, only valid for airporttile callbacks.
* @param st %Station of the airport for which the callback is run, or \c NULL for build gui.
* @param st %Station of the airport for which the callback is run, or \c nullptr for build gui.
* @param airport_id Type of airport for which the callback is run.
* @param layout Layout of the airport to build.
* @param callback Callback ID.
@@ -255,9 +273,9 @@ AirportResolverObject::AirportResolverObject(TileIndex tile, Station *st, byte a
SpriteID GetCustomAirportSprite(const AirportSpec *as, byte layout)
{
AirportResolverObject object(INVALID_TILE, NULL, as->GetIndex(), layout);
AirportResolverObject object(INVALID_TILE, nullptr, as->GetIndex(), layout);
const SpriteGroup *group = object.Resolve();
if (group == NULL) return as->preview_sprite;
if (group == nullptr) return as->preview_sprite;
return group->GetResult();
}
@@ -277,7 +295,7 @@ uint16 GetAirportCallback(CallbackID callback, uint32 param1, uint32 param2, Sta
*/
StringID GetAirportTextCallback(const AirportSpec *as, byte layout, uint16 callback)
{
AirportResolverObject object(INVALID_TILE, NULL, as->GetIndex(), layout, (CallbackID)callback);
AirportResolverObject object(INVALID_TILE, nullptr, as->GetIndex(), layout, (CallbackID)callback);
uint16 cb_res = object.ResolveCallback();
if (cb_res == CALLBACK_FAILED || cb_res == 0x400) return STR_UNDEFINED;
if (cb_res > 0x400) {