1
0
Fork 0

Compare commits

...

4 Commits

Author SHA1 Message Date
SamuXarick dd43a1a46d
Merge 5d8f3ae6db into 7546c1acab 2025-07-14 08:01:51 +00:00
Peter Nelson 7546c1acab
Codefix f220ed179d: GetUnicodeGlyph takes a unicode character. (#14438)
Previous change erroneously changed type to GlyphID, based on naming. It should actually be char32_t.
2025-07-14 08:01:42 +00:00
Peter Nelson a6143eea21
Codechange: Include more relevant headers for script_storage. (#14437) 2025-07-14 07:49:50 +01:00
SamuXarick 5d8f3ae6db Change: [Script] Improve some ScriptAirport return values for AT_OILRIG airport type
Affected functions are:
IsAirportInformationAvailable, GetAirportWidth, GetAirportHeight, GetAirportCoverageRadius, GetNumHangars, GetHangarOfAirport, GetNoiseLevelIncrease, GetNearestTown, GetMaintenanceCostFactor, GetMonthlyMaintenanceCost and GetAirportNumHelipads.

Add AT_OILRIG to the AirportType enum even though it can't be built.

Add an AirportTileTable for oilrig in AirportSpec definitions.
2025-05-27 21:19:32 +01:00
10 changed files with 41 additions and 29 deletions

View File

@ -877,12 +877,12 @@ ERROR: IsEnd() is invalid as Begin() is never called
GetAirportHeight(8): 2
GetAirportCoverageRadius(8): 4
GetAirportNumHelipads(8): 3
IsAirportInformationAvailable(9): false
IsAirportInformationAvailable(9): true
IsValidAirportType(9): false
GetAirportWidth(9): -1
GetAirportHeight(9): -1
GetAirportCoverageRadius(9): -1
GetAirportNumHelipads(9): -1
GetAirportWidth(9): 1
GetAirportHeight(9): 1
GetAirportCoverageRadius(9): 4
GetAirportNumHelipads(9): 1
GetBankBalance(): 1999999790
GetPrice(): 5400
BuildAirport(): true

View File

@ -43,26 +43,26 @@ SpriteFontCache::SpriteFontCache(FontSize fs) : FontCache(fs)
}
/**
* Get SpriteID associated with a GlyphID.
* @param key Glyph to find.
* @return SpriteID of glyph, or 0 if not present.
* Get SpriteID associated with a character.
* @param key Character to find.
* @return SpriteID for character, or 0 if not present.
*/
SpriteID SpriteFontCache::GetUnicodeGlyph(GlyphID key)
SpriteID SpriteFontCache::GetUnicodeGlyph(char32_t key)
{
const auto found = this->glyph_to_spriteid_map.find(key & ~SPRITE_GLYPH);
if (found == std::end(this->glyph_to_spriteid_map)) return 0;
const auto found = this->char_map.find(key);
if (found == std::end(this->char_map)) return 0;
return found->second;
}
void SpriteFontCache::SetUnicodeGlyph(char32_t key, SpriteID sprite)
{
this->glyph_to_spriteid_map[key] = sprite;
this->char_map[key] = sprite;
}
void SpriteFontCache::InitializeUnicodeGlyphMap()
{
/* Clear out existing glyph map if it exists */
this->glyph_to_spriteid_map.clear();
this->char_map.clear();
SpriteID base;
switch (this->fs) {

View File

@ -28,8 +28,8 @@ public:
bool IsBuiltInFont() override { return true; }
private:
std::unordered_map<GlyphID, SpriteID> glyph_to_spriteid_map{}; ///< Mapping of glyphs to sprite IDs.
SpriteID GetUnicodeGlyph(GlyphID key);
std::unordered_map<char32_t, SpriteID> char_map{}; ///< Mapping of characters to sprite IDs.
SpriteID GetUnicodeGlyph(char32_t key);
};
#endif /* SPRITEFONTCACHE_H */

View File

@ -28,6 +28,7 @@
* \li AICargo::CC_POTABLE
* \li AICargo::CC_NON_POTABLE
* \li AIVehicleList_Waypoint
* \li AIAirport::AT_OILRIG
*
* Other changes:
* \li AIBridge::GetBridgeID renamed to AIBridge::GetBridgeType

View File

@ -29,6 +29,7 @@
* \li GSCargo::CC_NON_POTABLE
* \li GSVehicleList_Waypoint
* \li GSBaseStation::GetOwner
* \li GSAirport::AT_OILRIG
*
* Other changes:
* \li GSBridge::GetBridgeID renamed to GSBridge::GetBridgeType

View File

@ -24,7 +24,7 @@
/* static */ bool ScriptAirport::IsAirportInformationAvailable(AirportType type)
{
return type >= 0 && type < (AirportType)NUM_AIRPORTS && AirportSpec::Get(type)->enabled;
return type == AT_OILRIG || (type >= 0 && type < (AirportType)NUM_AIRPORTS && AirportSpec::Get(type)->enabled);
}
/* static */ Money ScriptAirport::GetPrice(AirportType type)
@ -67,6 +67,7 @@
{
if (!IsAirportInformationAvailable(type)) return -1;
if (type == AT_OILRIG && !_settings_game.station.serve_neutral_industries) return (uint)CA_NONE;
return _settings_game.station.modified_catchment ? ::AirportSpec::Get(type)->catchment : (uint)CA_UNMODIFIED;
}
@ -96,9 +97,8 @@
if (!::IsTileType(tile, MP_STATION)) return -1;
const Station *st = ::Station::GetByTile(tile);
if (st->owner != ScriptObject::GetCompany() && ScriptCompanyMode::IsValid()) return -1;
if (st->owner != OWNER_NONE && st->owner != ScriptObject::GetCompany() && ScriptCompanyMode::IsValid()) return -1;
if (!st->facilities.Test(StationFacility::Airport)) return -1;
return st->airport.GetNumHangars();
}
@ -110,7 +110,7 @@
if (GetNumHangars(tile) < 1) return INVALID_TILE;
const Station *st = ::Station::GetByTile(tile);
if (st->owner != ScriptObject::GetCompany() && ScriptCompanyMode::IsValid()) return INVALID_TILE;
if (st->owner != OWNER_NONE && st->owner != ScriptObject::GetCompany() && ScriptCompanyMode::IsValid()) return INVALID_TILE;
if (!st->facilities.Test(StationFacility::Airport)) return INVALID_TILE;
return st->airport.GetHangarTile(0);
@ -143,7 +143,7 @@
return GetAirportNoiseLevelForDistance(as, dist);
}
return 1;
return type == AT_OILRIG ? 0 : 1;
}
/* static */ TownID ScriptAirport::GetNearestTown(TileIndex tile, AirportType type)

View File

@ -34,6 +34,7 @@ public:
AT_HELIPORT = ::AT_HELIPORT, ///< The heliport.
AT_HELISTATION = ::AT_HELISTATION, ///< The helistation.
AT_HELIDEPOT = ::AT_HELIDEPOT, ///< The helidepot.
AT_OILRIG = ::AT_OILRIG, ///< The oil rig heliport.
AT_INVALID = ::AT_INVALID, ///< Invalid airport.
};

View File

@ -24,10 +24,12 @@
#include "api/script_event.hpp"
#include "api/script_log.hpp"
#include "../company_base.h"
#include "../company_func.h"
#include "../company_type.h"
#include "../fileio_func.h"
#include "../goal_type.h"
#include "../league_type.h"
#include "../signs_type.h"
#include "../story_type.h"
#include "../misc/endian_buffer.hpp"
#include "../safeguards.h"

View File

@ -12,12 +12,10 @@
#include <queue>
#include "../signs_func.h"
#include "../vehicle_func.h"
#include "../command_type.h"
#include "../company_type.h"
#include "../rail_type.h"
#include "../road_type.h"
#include "../group.h"
#include "../goal_type.h"
#include "../story_type.h"
#include "script_types.hpp"
#include "script_log_types.hpp"

View File

@ -359,6 +359,15 @@ static const std::initializer_list<AirportTileLayout> _tile_table_helistation =
{ _tile_table_helistation_0, DIR_N },
};
/** Tiles for oilrig */
static const std::initializer_list<AirportTileTable> _tile_table_oilrig_0 = {
MK(0, 0, APT_EMPTY),
};
static const std::initializer_list<AirportTileLayout> _tile_table_oilrig = {
{ _tile_table_oilrig_0, DIR_N, }
};
#undef MK
/** General AirportSpec definition. */
@ -377,7 +386,7 @@ static const std::initializer_list<AirportTileLayout> _tile_table_helistation =
/* The helidepot and helistation have ATP_TTDP_SMALL because they are at ground level */
extern const AirportSpec _origin_airport_specs[] = {
AS(country, 4, 3, 0, 1959, 4, 3, 7, ATP_TTDP_SMALL, APC_SMALL, STR_AIRPORT_SMALL, SPR_AIRPORT_PREVIEW_SMALL),
AS(country, 4, 3, CalendarTime::MIN_YEAR, 1959, 4, 3, 7, ATP_TTDP_SMALL, APC_SMALL, STR_AIRPORT_SMALL, SPR_AIRPORT_PREVIEW_SMALL),
AS(city, 6, 6, 1955, CalendarTime::MAX_YEAR, 5, 5, 24, ATP_TTDP_LARGE, APC_LARGE, STR_AIRPORT_CITY, SPR_AIRPORT_PREVIEW_LARGE),
AS_ND(heliport, 1, 1, 1963, CalendarTime::MAX_YEAR, 4, 1, 4, ATP_TTDP_HELIPORT, APC_HELIPORT, STR_AIRPORT_HELIPORT, SPR_AIRPORT_PREVIEW_HELIPORT),
AS(metropolitan, 6, 6, 1980, CalendarTime::MAX_YEAR, 6, 8, 28, ATP_TTDP_LARGE, APC_LARGE, STR_AIRPORT_METRO, SPR_AIRPORT_PREVIEW_METROPOLITAN),
@ -386,7 +395,7 @@ extern const AirportSpec _origin_airport_specs[] = {
AS(helidepot, 2, 2, 1976, CalendarTime::MAX_YEAR, 4, 2, 7, ATP_TTDP_SMALL, APC_HELIPORT, STR_AIRPORT_HELIDEPOT, SPR_AIRPORT_PREVIEW_HELIDEPOT),
AS(intercontinental, 9, 11, 2002, CalendarTime::MAX_YEAR, 10, 25, 72, ATP_TTDP_LARGE, APC_HUB, STR_AIRPORT_INTERCONTINENTAL, SPR_AIRPORT_PREVIEW_INTERCONTINENTAL),
AS(helistation, 4, 2, 1980, CalendarTime::MAX_YEAR, 4, 3, 14, ATP_TTDP_SMALL, APC_HELIPORT, STR_AIRPORT_HELISTATION, SPR_AIRPORT_PREVIEW_HELISTATION),
AS_GENERIC(&_airportfta_oilrig, {}, {}, 1, 1, 0, 4, 0, 0, 0, ATP_TTDP_OILRIG, APC_HELIPORT, STR_NULL, 0, false),
AS_GENERIC(&_airportfta_oilrig, _tile_table_oilrig, {}, 1, 1, 0, 4, CalendarTime::MIN_YEAR, CalendarTime::MIN_YEAR, 0, ATP_TTDP_OILRIG, APC_HELIPORT, STR_NULL, 0, false),
};
static_assert(NEW_AIRPORT_OFFSET == lengthof(_origin_airport_specs));