mirror of https://github.com/OpenTTD/OpenTTD.git
Codechange: Make SpriteType, CargoSortType, SourceType and ScriptType enum classes. (#10663)
This avoids a (soft) namespace conflict between the four ST_* enums.
This commit is contained in:
parent
32c8e7feb8
commit
e97bf271dc
|
@ -332,13 +332,13 @@ foreach(LINE IN LISTS SOURCE_LINES)
|
|||
endif()
|
||||
|
||||
string(APPEND SQUIRREL_EXPORT "\n")
|
||||
string(APPEND SQUIRREL_EXPORT "\ntemplate <> const char *GetClassName<${CLS}, ST_${APIUC}>() { return \"${API_CLS}\"; }")
|
||||
string(APPEND SQUIRREL_EXPORT "\ntemplate <> const char *GetClassName<${CLS}, ScriptType::${APIUC}>() { return \"${API_CLS}\"; }")
|
||||
string(APPEND SQUIRREL_EXPORT "\n")
|
||||
|
||||
# Then do the registration functions of the class.
|
||||
string(APPEND SQUIRREL_EXPORT "\nvoid SQ${API_CLS}_Register(Squirrel *engine)")
|
||||
string(APPEND SQUIRREL_EXPORT "\n{")
|
||||
string(APPEND SQUIRREL_EXPORT "\n DefSQClass<${CLS}, ST_${APIUC}> SQ${API_CLS}(\"${API_CLS}\");")
|
||||
string(APPEND SQUIRREL_EXPORT "\n DefSQClass<${CLS}, ScriptType::${APIUC}> SQ${API_CLS}(\"${API_CLS}\");")
|
||||
if("${SUPER_CLS}" STREQUAL "Text" OR "${SUPER_CLS}" STREQUAL "ScriptObject" OR "${SUPER_CLS}" STREQUAL "AIAbstractiveList::Valuator")
|
||||
string(APPEND SQUIRREL_EXPORT "\n SQ${API_CLS}.PreRegister(engine);")
|
||||
else()
|
||||
|
|
|
@ -32,12 +32,12 @@ static bool CheckAPIVersion(const char *api_version)
|
|||
#if defined(_WIN32)
|
||||
#undef GetClassName
|
||||
#endif /* _WIN32 */
|
||||
template <> const char *GetClassName<AIInfo, ST_AI>() { return "AIInfo"; }
|
||||
template <> const char *GetClassName<AIInfo, ScriptType::AI>() { return "AIInfo"; }
|
||||
|
||||
/* static */ void AIInfo::RegisterAPI(Squirrel *engine)
|
||||
{
|
||||
/* Create the AIInfo class, and add the RegisterAI function */
|
||||
DefSQClass<AIInfo, ST_AI> SQAIInfo("AIInfo");
|
||||
DefSQClass<AIInfo, ScriptType::AI> SQAIInfo("AIInfo");
|
||||
SQAIInfo.PreRegister(engine);
|
||||
SQAIInfo.AddConstructor<void (AIInfo::*)(), 1>(engine, "x");
|
||||
SQAIInfo.DefSQAdvancedMethod(engine, &AIInfo::AddSetting, "AddSetting");
|
||||
|
|
|
@ -293,7 +293,7 @@ template <bool Tpal_to_rgb> Sprite *Blitter_32bppOptimized::EncodeInternal(const
|
|||
ZoomLevel zoom_min;
|
||||
ZoomLevel zoom_max;
|
||||
|
||||
if (sprite->type == ST_FONT) {
|
||||
if (sprite->type == SpriteType::Font) {
|
||||
zoom_min = ZOOM_LVL_NORMAL;
|
||||
zoom_max = ZOOM_LVL_NORMAL;
|
||||
} else {
|
||||
|
|
|
@ -28,7 +28,7 @@ Sprite *Blitter_32bppSSE_Base::Encode(const SpriteLoader::Sprite *sprite, Alloca
|
|||
*/
|
||||
ZoomLevel zoom_min = ZOOM_LVL_NORMAL;
|
||||
ZoomLevel zoom_max = ZOOM_LVL_NORMAL;
|
||||
if (sprite->type != ST_FONT) {
|
||||
if (sprite->type != SpriteType::Font) {
|
||||
zoom_min = _settings_client.gui.zoom_min;
|
||||
zoom_max = _settings_client.gui.zoom_max;
|
||||
if (zoom_max == zoom_min) zoom_max = ZOOM_LVL_MAX;
|
||||
|
|
|
@ -354,7 +354,7 @@ void Blitter_40bppAnim::DrawColourMappingRect(void *dst, int width, int height,
|
|||
anim = anim - width + _screen.pitch;
|
||||
} while (--height);
|
||||
} else if (pal == PALETTE_NEWSPAPER) {
|
||||
const uint8 *remap = GetNonSprite(pal, ST_RECOLOUR) + 1;
|
||||
const uint8 *remap = GetNonSprite(pal, SpriteType::Recolour) + 1;
|
||||
do {
|
||||
for (int i = 0; i != width; i++) {
|
||||
if (*anim == 0) *udst = MakeGrey(*udst);
|
||||
|
@ -366,7 +366,7 @@ void Blitter_40bppAnim::DrawColourMappingRect(void *dst, int width, int height,
|
|||
anim = anim - width + _screen.pitch;
|
||||
} while (--height);
|
||||
} else {
|
||||
const uint8 *remap = GetNonSprite(pal, ST_RECOLOUR) + 1;
|
||||
const uint8 *remap = GetNonSprite(pal, SpriteType::Recolour) + 1;
|
||||
do {
|
||||
for (int i = 0; i != width; i++) {
|
||||
*anim = remap[*anim];
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
void Blitter_8bppBase::DrawColourMappingRect(void *dst, int width, int height, PaletteID pal)
|
||||
{
|
||||
const uint8 *ctab = GetNonSprite(pal, ST_RECOLOUR) + 1;
|
||||
const uint8 *ctab = GetNonSprite(pal, SpriteType::Recolour) + 1;
|
||||
|
||||
do {
|
||||
for (int i = 0; i != width; i++) *((uint8 *)dst + i) = ctab[((uint8 *)dst)[i]];
|
||||
|
|
|
@ -127,7 +127,7 @@ Sprite *Blitter_8bppOptimized::Encode(const SpriteLoader::Sprite *sprite, Alloca
|
|||
ZoomLevel zoom_min;
|
||||
ZoomLevel zoom_max;
|
||||
|
||||
if (sprite->type == ST_FONT) {
|
||||
if (sprite->type == SpriteType::Font) {
|
||||
zoom_min = ZOOM_LVL_NORMAL;
|
||||
zoom_max = ZOOM_LVL_NORMAL;
|
||||
} else {
|
||||
|
|
|
@ -144,10 +144,10 @@ public:
|
|||
|
||||
|
||||
/** Types of cargo source and destination */
|
||||
enum SourceType : byte {
|
||||
ST_INDUSTRY, ///< Source/destination is an industry
|
||||
ST_TOWN, ///< Source/destination is a town
|
||||
ST_HEADQUARTERS, ///< Source/destination are company headquarters
|
||||
enum class SourceType : byte {
|
||||
Industry, ///< Source/destination is an industry
|
||||
Town, ///< Source/destination is a town
|
||||
Headquarters, ///< Source/destination are company headquarters
|
||||
};
|
||||
|
||||
typedef uint16 SourceID; ///< Contains either industry ID, town ID or company ID (or INVALID_SOURCE)
|
||||
|
|
|
@ -124,13 +124,13 @@ void AddCargoDelivery(CargoID cargo_type, CompanyID company, uint32 amount, Sour
|
|||
if (src != INVALID_SOURCE) {
|
||||
/* Handle pickup update. */
|
||||
switch (src_type) {
|
||||
case ST_INDUSTRY: {
|
||||
case SourceType::Industry: {
|
||||
CargoMonitorID num = EncodeCargoIndustryMonitor(company, cargo_type, src);
|
||||
CargoMonitorMap::iterator iter = _cargo_pickups.find(num);
|
||||
if (iter != _cargo_pickups.end()) iter->second += amount;
|
||||
break;
|
||||
}
|
||||
case ST_TOWN: {
|
||||
case SourceType::Town: {
|
||||
CargoMonitorID num = EncodeCargoTownMonitor(company, cargo_type, src);
|
||||
CargoMonitorMap::iterator iter = _cargo_pickups.find(num);
|
||||
if (iter != _cargo_pickups.end()) iter->second += amount;
|
||||
|
|
|
@ -26,7 +26,7 @@ INSTANTIATE_POOL_METHODS(CargoPacket)
|
|||
*/
|
||||
CargoPacket::CargoPacket()
|
||||
{
|
||||
this->source_type = ST_INDUSTRY;
|
||||
this->source_type = SourceType::Industry;
|
||||
this->source_id = INVALID_SOURCE;
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ public:
|
|||
|
||||
CargoPacket();
|
||||
CargoPacket(StationID source, TileIndex source_xy, uint16 count, SourceType source_type, SourceID source_id);
|
||||
CargoPacket(uint16 count, byte days_in_transit, StationID source, TileIndex source_xy, TileIndex loaded_at_xy, Money feeder_share = 0, SourceType source_type = ST_INDUSTRY, SourceID source_id = INVALID_SOURCE);
|
||||
CargoPacket(uint16 count, byte days_in_transit, StationID source, TileIndex source_xy, TileIndex loaded_at_xy, Money feeder_share = 0, SourceType source_type = SourceType::Industry, SourceID source_id = INVALID_SOURCE);
|
||||
|
||||
/** Destroy the packet. */
|
||||
~CargoPacket() { }
|
||||
|
|
|
@ -1087,7 +1087,7 @@ static uint DeliverGoodsToIndustry(const Station *st, CargoID cargo_type, uint n
|
|||
accepted += amount;
|
||||
|
||||
/* Update the cargo monitor. */
|
||||
AddCargoDelivery(cargo_type, company, amount, ST_INDUSTRY, source, st, ind->index);
|
||||
AddCargoDelivery(cargo_type, company, amount, SourceType::Industry, source, st, ind->index);
|
||||
}
|
||||
|
||||
return accepted;
|
||||
|
@ -1113,7 +1113,7 @@ static Money DeliverGoods(int num_pieces, CargoID cargo_type, StationID dest, Ti
|
|||
Station *st = Station::Get(dest);
|
||||
|
||||
/* Give the goods to the industry. */
|
||||
uint accepted_ind = DeliverGoodsToIndustry(st, cargo_type, num_pieces, src_type == ST_INDUSTRY ? src : INVALID_INDUSTRY, company->index);
|
||||
uint accepted_ind = DeliverGoodsToIndustry(st, cargo_type, num_pieces, src_type == SourceType::Industry ? src : INVALID_INDUSTRY, company->index);
|
||||
|
||||
/* If this cargo type is always accepted, accept all */
|
||||
uint accepted_total = HasBit(st->always_accepted, cargo_type) ? num_pieces : accepted_ind;
|
||||
|
|
|
@ -241,7 +241,7 @@ const Sprite *FreeTypeFontCache::InternalGetGlyph(GlyphID key, bool aa)
|
|||
/* FreeType has rendered the glyph, now we allocate a sprite and copy the image into it */
|
||||
SpriteLoader::Sprite sprite;
|
||||
sprite.AllocateData(ZOOM_LVL_NORMAL, static_cast<size_t>(width) * height);
|
||||
sprite.type = ST_FONT;
|
||||
sprite.type = SpriteType::Font;
|
||||
sprite.colours = (aa ? SCC_PAL | SCC_ALPHA : SCC_PAL);
|
||||
sprite.width = width;
|
||||
sprite.height = height;
|
||||
|
|
|
@ -113,14 +113,14 @@ const Sprite *SpriteFontCache::GetGlyph(GlyphID key)
|
|||
{
|
||||
SpriteID sprite = this->GetUnicodeGlyph(key);
|
||||
if (sprite == 0) sprite = this->GetUnicodeGlyph('?');
|
||||
return GetSprite(sprite, ST_FONT);
|
||||
return GetSprite(sprite, SpriteType::Font);
|
||||
}
|
||||
|
||||
uint SpriteFontCache::GetGlyphWidth(GlyphID key)
|
||||
{
|
||||
SpriteID sprite = this->GetUnicodeGlyph(key);
|
||||
if (sprite == 0) sprite = this->GetUnicodeGlyph('?');
|
||||
return SpriteExists(sprite) ? GetSprite(sprite, ST_FONT)->width + ScaleSpriteTrad(this->fs != FS_NORMAL ? 1 : 0) : 0;
|
||||
return SpriteExists(sprite) ? GetSprite(sprite, SpriteType::Font)->width + ScaleSpriteTrad(this->fs != FS_NORMAL ? 1 : 0) : 0;
|
||||
}
|
||||
|
||||
bool SpriteFontCache::GetDrawGlyphShadow()
|
||||
|
|
|
@ -141,7 +141,7 @@ const Sprite *TrueTypeFontCache::GetGlyph(GlyphID key)
|
|||
8, // width
|
||||
0, // x_offs
|
||||
0, // y_offs
|
||||
ST_FONT,
|
||||
SpriteType::Font,
|
||||
SCC_PAL,
|
||||
builtin_questionmark_data
|
||||
};
|
||||
|
|
|
@ -30,12 +30,12 @@ static bool CheckAPIVersion(const char *api_version)
|
|||
#if defined(_WIN32)
|
||||
#undef GetClassName
|
||||
#endif /* _WIN32 */
|
||||
template <> const char *GetClassName<GameInfo, ST_GS>() { return "GSInfo"; }
|
||||
template <> const char *GetClassName<GameInfo, ScriptType::GS>() { return "GSInfo"; }
|
||||
|
||||
/* static */ void GameInfo::RegisterAPI(Squirrel *engine)
|
||||
{
|
||||
/* Create the GSInfo class, and add the RegisterGS function */
|
||||
DefSQClass<GameInfo, ST_GS> SQGSInfo("GSInfo");
|
||||
DefSQClass<GameInfo, ScriptType::GS> SQGSInfo("GSInfo");
|
||||
SQGSInfo.PreRegister(engine);
|
||||
SQGSInfo.AddConstructor<void (GameInfo::*)(), 1>(engine, "x");
|
||||
SQGSInfo.DefSQAdvancedMethod(engine, &GameInfo::AddSetting, "AddSetting");
|
||||
|
|
28
src/gfx.cpp
28
src/gfx.cpp
|
@ -74,7 +74,7 @@ int _gui_scale_cfg; ///< GUI scale in config.
|
|||
*/
|
||||
static Rect _invalid_rect;
|
||||
static const byte *_colour_remap_ptr;
|
||||
static byte _string_colourremap[3]; ///< Recoloursprite for stringdrawing. The grf loader ensures that #ST_FONT sprites only use colours 0 to 2.
|
||||
static byte _string_colourremap[3]; ///< Recoloursprite for stringdrawing. The grf loader ensures that #SpriteType::Font sprites only use colours 0 to 2.
|
||||
|
||||
static const uint DIRTY_BLOCK_HEIGHT = 8;
|
||||
static const uint DIRTY_BLOCK_WIDTH = 64;
|
||||
|
@ -992,7 +992,7 @@ void DrawCharCentered(WChar c, const Rect &r, TextColour colour)
|
|||
*/
|
||||
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
|
||||
{
|
||||
const Sprite *sprite = GetSprite(sprid, ST_NORMAL);
|
||||
const Sprite *sprite = GetSprite(sprid, SpriteType::Normal);
|
||||
|
||||
if (offset != nullptr) {
|
||||
offset->x = UnScaleByZoom(sprite->x_offs, zoom);
|
||||
|
@ -1032,17 +1032,17 @@ void DrawSpriteViewport(SpriteID img, PaletteID pal, int x, int y, const SubSpri
|
|||
{
|
||||
SpriteID real_sprite = GB(img, 0, SPRITE_WIDTH);
|
||||
if (HasBit(img, PALETTE_MODIFIER_TRANSPARENT)) {
|
||||
_colour_remap_ptr = GetNonSprite(GB(pal, 0, PALETTE_WIDTH), ST_RECOLOUR) + 1;
|
||||
GfxMainBlitterViewport(GetSprite(real_sprite, ST_NORMAL), x, y, BM_TRANSPARENT, sub, real_sprite);
|
||||
_colour_remap_ptr = GetNonSprite(GB(pal, 0, PALETTE_WIDTH), SpriteType::Recolour) + 1;
|
||||
GfxMainBlitterViewport(GetSprite(real_sprite, SpriteType::Normal), x, y, BM_TRANSPARENT, sub, real_sprite);
|
||||
} else if (pal != PAL_NONE) {
|
||||
if (HasBit(pal, PALETTE_TEXT_RECOLOUR)) {
|
||||
SetColourRemap((TextColour)GB(pal, 0, PALETTE_WIDTH));
|
||||
} else {
|
||||
_colour_remap_ptr = GetNonSprite(GB(pal, 0, PALETTE_WIDTH), ST_RECOLOUR) + 1;
|
||||
_colour_remap_ptr = GetNonSprite(GB(pal, 0, PALETTE_WIDTH), SpriteType::Recolour) + 1;
|
||||
}
|
||||
GfxMainBlitterViewport(GetSprite(real_sprite, ST_NORMAL), x, y, GetBlitterMode(pal), sub, real_sprite);
|
||||
GfxMainBlitterViewport(GetSprite(real_sprite, SpriteType::Normal), x, y, GetBlitterMode(pal), sub, real_sprite);
|
||||
} else {
|
||||
GfxMainBlitterViewport(GetSprite(real_sprite, ST_NORMAL), x, y, BM_NORMAL, sub, real_sprite);
|
||||
GfxMainBlitterViewport(GetSprite(real_sprite, SpriteType::Normal), x, y, BM_NORMAL, sub, real_sprite);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1059,17 +1059,17 @@ void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub,
|
|||
{
|
||||
SpriteID real_sprite = GB(img, 0, SPRITE_WIDTH);
|
||||
if (HasBit(img, PALETTE_MODIFIER_TRANSPARENT)) {
|
||||
_colour_remap_ptr = GetNonSprite(GB(pal, 0, PALETTE_WIDTH), ST_RECOLOUR) + 1;
|
||||
GfxMainBlitter(GetSprite(real_sprite, ST_NORMAL), x, y, BM_TRANSPARENT, sub, real_sprite, zoom);
|
||||
_colour_remap_ptr = GetNonSprite(GB(pal, 0, PALETTE_WIDTH), SpriteType::Recolour) + 1;
|
||||
GfxMainBlitter(GetSprite(real_sprite, SpriteType::Normal), x, y, BM_TRANSPARENT, sub, real_sprite, zoom);
|
||||
} else if (pal != PAL_NONE) {
|
||||
if (HasBit(pal, PALETTE_TEXT_RECOLOUR)) {
|
||||
SetColourRemap((TextColour)GB(pal, 0, PALETTE_WIDTH));
|
||||
} else {
|
||||
_colour_remap_ptr = GetNonSprite(GB(pal, 0, PALETTE_WIDTH), ST_RECOLOUR) + 1;
|
||||
_colour_remap_ptr = GetNonSprite(GB(pal, 0, PALETTE_WIDTH), SpriteType::Recolour) + 1;
|
||||
}
|
||||
GfxMainBlitter(GetSprite(real_sprite, ST_NORMAL), x, y, GetBlitterMode(pal), sub, real_sprite, zoom);
|
||||
GfxMainBlitter(GetSprite(real_sprite, SpriteType::Normal), x, y, GetBlitterMode(pal), sub, real_sprite, zoom);
|
||||
} else {
|
||||
GfxMainBlitter(GetSprite(real_sprite, ST_NORMAL), x, y, BM_NORMAL, sub, real_sprite, zoom);
|
||||
GfxMainBlitter(GetSprite(real_sprite, SpriteType::Normal), x, y, BM_NORMAL, sub, real_sprite, zoom);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1220,7 +1220,7 @@ std::unique_ptr<uint32[]> DrawSpriteToRgbaBuffer(SpriteID spriteId, ZoomLevel zo
|
|||
|
||||
/* Gather information about the sprite to write, reserve memory */
|
||||
const SpriteID real_sprite = GB(spriteId, 0, SPRITE_WIDTH);
|
||||
const Sprite *sprite = GetSprite(real_sprite, ST_NORMAL);
|
||||
const Sprite *sprite = GetSprite(real_sprite, SpriteType::Normal);
|
||||
Dimension dim = GetSpriteSize(real_sprite, nullptr, zoom);
|
||||
size_t dim_size = static_cast<size_t>(dim.width) * dim.height;
|
||||
std::unique_ptr<uint32[]> result(new uint32[dim_size]);
|
||||
|
@ -1843,7 +1843,7 @@ void UpdateCursorSize()
|
|||
static_assert(lengthof(_cursor.sprite_seq) == lengthof(_cursor.sprite_pos));
|
||||
assert(_cursor.sprite_count <= lengthof(_cursor.sprite_seq));
|
||||
for (uint i = 0; i < _cursor.sprite_count; ++i) {
|
||||
const Sprite *p = GetSprite(GB(_cursor.sprite_seq[i].sprite, 0, SPRITE_WIDTH), ST_NORMAL);
|
||||
const Sprite *p = GetSprite(GB(_cursor.sprite_seq[i].sprite, 0, SPRITE_WIDTH), SpriteType::Normal);
|
||||
Point offs, size;
|
||||
offs.x = UnScaleGUI(p->x_offs) + _cursor.sprite_pos[i].x;
|
||||
offs.y = UnScaleGUI(p->y_offs) + _cursor.sprite_pos[i].y;
|
||||
|
|
|
@ -305,12 +305,12 @@ enum PaletteType {
|
|||
};
|
||||
|
||||
/** Types of sprites that might be loaded */
|
||||
enum SpriteType : byte {
|
||||
ST_NORMAL = 0, ///< The most basic (normal) sprite
|
||||
ST_MAPGEN = 1, ///< Special sprite for the map generator
|
||||
ST_FONT = 2, ///< A sprite used for fonts
|
||||
ST_RECOLOUR = 3, ///< Recolour sprite
|
||||
ST_INVALID = 4, ///< Pseudosprite or other unusable sprite, used only internally
|
||||
enum class SpriteType : byte {
|
||||
Normal = 0, ///< The most basic (normal) sprite
|
||||
MapGen = 1, ///< Special sprite for the map generator
|
||||
Font = 2, ///< A sprite used for fonts
|
||||
Recolour = 3, ///< Recolour sprite
|
||||
Invalid = 4, ///< Pseudosprite or other unusable sprite, used only internally
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -197,8 +197,8 @@ Industry::~Industry()
|
|||
CloseWindowById(WC_INDUSTRY_VIEW, this->index);
|
||||
DeleteNewGRFInspectWindow(GSF_INDUSTRIES, this->index);
|
||||
|
||||
DeleteSubsidyWith(ST_INDUSTRY, this->index);
|
||||
CargoPacket::InvalidateAllFrom(ST_INDUSTRY, this->index);
|
||||
DeleteSubsidyWith(SourceType::Industry, this->index);
|
||||
CargoPacket::InvalidateAllFrom(SourceType::Industry, this->index);
|
||||
|
||||
for (Station *st : this->stations_near) {
|
||||
st->RemoveIndustryToDeliver(this);
|
||||
|
@ -546,7 +546,7 @@ static bool TransportIndustryGoods(TileIndex tile)
|
|||
|
||||
i->this_month_production[j] += cw;
|
||||
|
||||
uint am = MoveGoodsToStation(i->produced_cargo[j], cw, ST_INDUSTRY, i->index, &i->stations_near, i->exclusive_consumer);
|
||||
uint am = MoveGoodsToStation(i->produced_cargo[j], cw, SourceType::Industry, i->index, &i->stations_near, i->exclusive_consumer);
|
||||
i->this_month_transported[j] += am;
|
||||
|
||||
moved_cargo |= (am != 0);
|
||||
|
|
|
@ -817,7 +817,7 @@ static void GenerateTerrain(int type, uint flag)
|
|||
uint32 r = Random();
|
||||
|
||||
/* Choose one of the templates from the graphics file. */
|
||||
const Sprite *templ = GetSprite((((r >> 24) * _genterrain_tbl_1[type]) >> 8) + _genterrain_tbl_2[type] + SPR_MAPGEN_BEGIN, ST_MAPGEN);
|
||||
const Sprite *templ = GetSprite((((r >> 24) * _genterrain_tbl_1[type]) >> 8) + _genterrain_tbl_2[type] + SPR_MAPGEN_BEGIN, SpriteType::MapGen);
|
||||
if (templ == nullptr) usererror("Map generator sprites could not be loaded");
|
||||
|
||||
/* Chose a random location to apply the template to. */
|
||||
|
|
|
@ -546,7 +546,7 @@ void ShowSelectGameWindow();
|
|||
void SetupColoursAndInitialWindow()
|
||||
{
|
||||
for (uint i = 0; i != 16; i++) {
|
||||
const byte *b = GetNonSprite(PALETTE_RECOLOUR_START + i, ST_RECOLOUR);
|
||||
const byte *b = GetNonSprite(PALETTE_RECOLOUR_START + i, SpriteType::Recolour);
|
||||
|
||||
assert(b);
|
||||
memcpy(_colour_gradient[i], b + 0xC6, sizeof(_colour_gradient[i]));
|
||||
|
|
|
@ -841,12 +841,12 @@ struct SpriteAlignerWindow : Window {
|
|||
this->SetWidgetLoweredState(WID_SA_CROSSHAIR, SpriteAlignerWindow::crosshair);
|
||||
|
||||
/* Oh yes, we assume there is at least one normal sprite! */
|
||||
while (GetSpriteType(this->current_sprite) != ST_NORMAL) this->current_sprite++;
|
||||
while (GetSpriteType(this->current_sprite) != SpriteType::Normal) this->current_sprite++;
|
||||
}
|
||||
|
||||
void SetStringParameters(int widget) const override
|
||||
{
|
||||
const Sprite *spr = GetSprite(this->current_sprite, ST_NORMAL);
|
||||
const Sprite *spr = GetSprite(this->current_sprite, SpriteType::Normal);
|
||||
switch (widget) {
|
||||
case WID_SA_CAPTION:
|
||||
SetDParam(0, this->current_sprite);
|
||||
|
@ -901,7 +901,7 @@ struct SpriteAlignerWindow : Window {
|
|||
switch (widget) {
|
||||
case WID_SA_SPRITE: {
|
||||
/* Center the sprite ourselves */
|
||||
const Sprite *spr = GetSprite(this->current_sprite, ST_NORMAL);
|
||||
const Sprite *spr = GetSprite(this->current_sprite, SpriteType::Normal);
|
||||
Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
|
||||
int x;
|
||||
int y;
|
||||
|
@ -949,7 +949,7 @@ struct SpriteAlignerWindow : Window {
|
|||
case WID_SA_PREVIOUS:
|
||||
do {
|
||||
this->current_sprite = (this->current_sprite == 0 ? GetMaxSpriteID() : this->current_sprite) - 1;
|
||||
} while (GetSpriteType(this->current_sprite) != ST_NORMAL);
|
||||
} while (GetSpriteType(this->current_sprite) != SpriteType::Normal);
|
||||
this->SetDirty();
|
||||
break;
|
||||
|
||||
|
@ -960,7 +960,7 @@ struct SpriteAlignerWindow : Window {
|
|||
case WID_SA_NEXT:
|
||||
do {
|
||||
this->current_sprite = (this->current_sprite + 1) % GetMaxSpriteID();
|
||||
} while (GetSpriteType(this->current_sprite) != ST_NORMAL);
|
||||
} while (GetSpriteType(this->current_sprite) != SpriteType::Normal);
|
||||
this->SetDirty();
|
||||
break;
|
||||
|
||||
|
@ -977,7 +977,7 @@ struct SpriteAlignerWindow : Window {
|
|||
uint i = this->vscroll->GetPosition() + (pt.y - nwid->pos_y) / step_size;
|
||||
if (i < _newgrf_debug_sprite_picker.sprites.size()) {
|
||||
SpriteID spr = _newgrf_debug_sprite_picker.sprites[i];
|
||||
if (GetSpriteType(spr) == ST_NORMAL) this->current_sprite = spr;
|
||||
if (GetSpriteType(spr) == SpriteType::Normal) this->current_sprite = spr;
|
||||
}
|
||||
this->SetDirty();
|
||||
break;
|
||||
|
@ -1000,7 +1000,7 @@ struct SpriteAlignerWindow : Window {
|
|||
* used by someone and the sprite cache isn't big enough for that
|
||||
* particular NewGRF developer.
|
||||
*/
|
||||
Sprite *spr = const_cast<Sprite *>(GetSprite(this->current_sprite, ST_NORMAL));
|
||||
Sprite *spr = const_cast<Sprite *>(GetSprite(this->current_sprite, SpriteType::Normal));
|
||||
|
||||
/* Remember the original offsets of the current sprite, if not already in mapping. */
|
||||
if (!(this->offs_start_map.Contains(this->current_sprite))) {
|
||||
|
@ -1045,7 +1045,7 @@ struct SpriteAlignerWindow : Window {
|
|||
|
||||
this->current_sprite = atoi(str);
|
||||
if (this->current_sprite >= GetMaxSpriteID()) this->current_sprite = 0;
|
||||
while (GetSpriteType(this->current_sprite) != ST_NORMAL) {
|
||||
while (GetSpriteType(this->current_sprite) != SpriteType::Normal) {
|
||||
this->current_sprite = (this->current_sprite + 1) % GetMaxSpriteID();
|
||||
}
|
||||
this->SetDirty();
|
||||
|
|
|
@ -588,7 +588,7 @@ static CommandCost ClearTile_Object(TileIndex tile, DoCommandFlag flags)
|
|||
if (flags & DC_EXEC) {
|
||||
c->location_of_HQ = INVALID_TILE; // reset HQ position
|
||||
SetWindowDirty(WC_COMPANY, c->index);
|
||||
CargoPacket::InvalidateAllFrom(ST_HEADQUARTERS, c->index);
|
||||
CargoPacket::InvalidateAllFrom(SourceType::Headquarters, c->index);
|
||||
}
|
||||
|
||||
/* cost of relocating company is 1% of company value */
|
||||
|
@ -686,7 +686,7 @@ static void TileLoop_Object(TileIndex tile)
|
|||
if (GB(r, 0, 8) < (256 / 4 / (6 - level))) {
|
||||
uint amt = GB(r, 0, 8) / 8 / 4 + 1;
|
||||
if (EconomyIsInRecession()) amt = (amt + 1) >> 1;
|
||||
MoveGoodsToStation(CT_PASSENGERS, amt, ST_HEADQUARTERS, GetTileOwner(tile), stations.GetStations());
|
||||
MoveGoodsToStation(CT_PASSENGERS, amt, SourceType::Headquarters, GetTileOwner(tile), stations.GetStations());
|
||||
}
|
||||
|
||||
/* Top town building generates 90, HQ can make up to 196. The
|
||||
|
@ -695,7 +695,7 @@ static void TileLoop_Object(TileIndex tile)
|
|||
if (GB(r, 8, 8) < (196 / 4 / (6 - level))) {
|
||||
uint amt = GB(r, 8, 8) / 8 / 4 + 1;
|
||||
if (EconomyIsInRecession()) amt = (amt + 1) >> 1;
|
||||
MoveGoodsToStation(CT_MAIL, amt, ST_HEADQUARTERS, GetTileOwner(tile), stations.GetStations());
|
||||
MoveGoodsToStation(CT_MAIL, amt, SourceType::Headquarters, GetTileOwner(tile), stations.GetStations());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -287,7 +287,7 @@ const Sprite *CoreTextFontCache::InternalGetGlyph(GlyphID key, bool use_aa)
|
|||
|
||||
SpriteLoader::Sprite sprite;
|
||||
sprite.AllocateData(ZOOM_LVL_NORMAL, width * height);
|
||||
sprite.type = ST_FONT;
|
||||
sprite.type = SpriteType::Font;
|
||||
sprite.colours = (use_aa ? SCC_PAL | SCC_ALPHA : SCC_PAL);
|
||||
sprite.width = width;
|
||||
sprite.height = height;
|
||||
|
|
|
@ -456,7 +456,7 @@ void Win32FontCache::ClearFontCache()
|
|||
/* GDI has rendered the glyph, now we allocate a sprite and copy the image into it. */
|
||||
SpriteLoader::Sprite sprite;
|
||||
sprite.AllocateData(ZOOM_LVL_NORMAL, width * height);
|
||||
sprite.type = ST_FONT;
|
||||
sprite.type = SpriteType::Font;
|
||||
sprite.colours = (aa ? SCC_PAL | SCC_ALPHA : SCC_PAL);
|
||||
sprite.width = width;
|
||||
sprite.height = height;
|
||||
|
|
|
@ -2254,19 +2254,19 @@ bool AfterLoadGame()
|
|||
case TE_PASSENGERS:
|
||||
case TE_MAIL:
|
||||
/* Town -> Town */
|
||||
s->src_type = s->dst_type = ST_TOWN;
|
||||
s->src_type = s->dst_type = SourceType::Town;
|
||||
if (Town::IsValidID(s->src) && Town::IsValidID(s->dst)) continue;
|
||||
break;
|
||||
case TE_GOODS:
|
||||
case TE_FOOD:
|
||||
/* Industry -> Town */
|
||||
s->src_type = ST_INDUSTRY;
|
||||
s->dst_type = ST_TOWN;
|
||||
s->src_type = SourceType::Industry;
|
||||
s->dst_type = SourceType::Town;
|
||||
if (Industry::IsValidID(s->src) && Town::IsValidID(s->dst)) continue;
|
||||
break;
|
||||
default:
|
||||
/* Industry -> Industry */
|
||||
s->src_type = s->dst_type = ST_INDUSTRY;
|
||||
s->src_type = s->dst_type = SourceType::Industry;
|
||||
if (Industry::IsValidID(s->src) && Industry::IsValidID(s->dst)) continue;
|
||||
break;
|
||||
}
|
||||
|
@ -2284,7 +2284,7 @@ bool AfterLoadGame()
|
|||
const Station *sd = Station::GetIfValid(s->dst);
|
||||
if (ss != nullptr && sd != nullptr && ss->owner == sd->owner &&
|
||||
Company::IsValidID(ss->owner)) {
|
||||
s->src_type = s->dst_type = ST_TOWN;
|
||||
s->src_type = s->dst_type = SourceType::Town;
|
||||
s->src = ss->town->index;
|
||||
s->dst = sd->town->index;
|
||||
s->awarded = ss->owner;
|
||||
|
|
|
@ -7,11 +7,11 @@
|
|||
|
||||
#include "../script_controller.hpp"
|
||||
|
||||
template <> const char *GetClassName<ScriptController, ST_AI>() { return "AIController"; }
|
||||
template <> const char *GetClassName<ScriptController, ScriptType::AI>() { return "AIController"; }
|
||||
|
||||
void SQAIController_Register(Squirrel *engine)
|
||||
{
|
||||
DefSQClass<ScriptController, ST_AI> SQAIController("AIController");
|
||||
DefSQClass<ScriptController, ScriptType::AI> SQAIController("AIController");
|
||||
SQAIController.PreRegister(engine);
|
||||
|
||||
SQAIController.DefSQStaticMethod(engine, &ScriptController::GetTick, "GetTick", 1, ".");
|
||||
|
|
|
@ -7,11 +7,11 @@
|
|||
|
||||
#include "../script_controller.hpp"
|
||||
|
||||
template <> const char *GetClassName<ScriptController, ST_GS>() { return "GSController"; }
|
||||
template <> const char *GetClassName<ScriptController, ScriptType::GS>() { return "GSController"; }
|
||||
|
||||
void SQGSController_Register(Squirrel *engine)
|
||||
{
|
||||
DefSQClass<ScriptController, ST_GS> SQGSController("GSController");
|
||||
DefSQClass<ScriptController, ScriptType::GS> SQGSController("GSController");
|
||||
SQGSController.PreRegister(engine);
|
||||
|
||||
SQGSController.DefSQStaticMethod(engine, &ScriptController::GetTick, "GetTick", 1, ".");
|
||||
|
|
|
@ -25,7 +25,7 @@ public:
|
|||
*/
|
||||
enum SubsidyParticipantType {
|
||||
/* Values are important, as they represent the internal state of the game.
|
||||
* It is originally named SourceType. ST_HEADQUARTERS is intentionally
|
||||
* It is originally named SourceType. SourceType::Headquarters is intentionally
|
||||
* left out, as it cannot be used for Subsidies. */
|
||||
SPT_INDUSTRY = 0, ///< Subsidy participant is an industry
|
||||
SPT_TOWN = 1, ///< Subsidy participant is a town
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
#include <squirrel.h>
|
||||
|
||||
/** The type of script we're working with, i.e. for who is it? */
|
||||
enum ScriptType {
|
||||
ST_AI, ///< The script is for AI scripts.
|
||||
ST_GS, ///< The script is for Game scripts.
|
||||
enum class ScriptType {
|
||||
AI, ///< The script is for AI scripts.
|
||||
GS, ///< The script is for Game scripts.
|
||||
};
|
||||
|
||||
struct ScriptAllocator;
|
||||
|
|
|
@ -119,7 +119,7 @@ void DrawCommonTileSeqInGUI(int x, int y, const DrawTileSprites *dts, int32 orig
|
|||
Point pt = RemapCoords(dtss->delta_x, dtss->delta_y, dtss->delta_z);
|
||||
DrawSprite(image, pal, x + UnScaleGUI(pt.x), y + UnScaleGUI(pt.y));
|
||||
|
||||
const Sprite *spr = GetSprite(image & SPRITE_MASK, ST_NORMAL);
|
||||
const Sprite *spr = GetSprite(image & SPRITE_MASK, SpriteType::Normal);
|
||||
child_offset.x = UnScaleGUI(pt.x + spr->x_offs);
|
||||
child_offset.y = UnScaleGUI(pt.y + spr->y_offs);
|
||||
} else {
|
||||
|
|
|
@ -162,7 +162,7 @@ bool SpriteExists(SpriteID id)
|
|||
*/
|
||||
SpriteType GetSpriteType(SpriteID sprite)
|
||||
{
|
||||
if (!SpriteExists(sprite)) return ST_INVALID;
|
||||
if (!SpriteExists(sprite)) return SpriteType::Invalid;
|
||||
return GetSpriteCache(sprite)->type;
|
||||
}
|
||||
|
||||
|
@ -461,8 +461,8 @@ static void *ReadSprite(const SpriteCache *sc, SpriteID id, SpriteType sprite_ty
|
|||
SpriteFile &file = *sc->file;
|
||||
size_t file_pos = sc->file_pos;
|
||||
|
||||
assert(sprite_type != ST_RECOLOUR);
|
||||
assert(IsMapgenSpriteID(id) == (sprite_type == ST_MAPGEN));
|
||||
assert(sprite_type != SpriteType::Recolour);
|
||||
assert(IsMapgenSpriteID(id) == (sprite_type == SpriteType::MapGen));
|
||||
assert(sc->type == sprite_type);
|
||||
|
||||
Debug(sprite, 9, "Load sprite {}", id);
|
||||
|
@ -472,7 +472,7 @@ static void *ReadSprite(const SpriteCache *sc, SpriteID id, SpriteType sprite_ty
|
|||
sprite[ZOOM_LVL_NORMAL].type = sprite_type;
|
||||
|
||||
SpriteLoaderGrf sprite_loader(file.GetContainerVersion());
|
||||
if (sprite_type != ST_MAPGEN && encoder->Is32BppSupported()) {
|
||||
if (sprite_type != SpriteType::MapGen && encoder->Is32BppSupported()) {
|
||||
/* Try for 32bpp sprites first. */
|
||||
sprite_avail = sprite_loader.LoadSprite(sprite, file, file_pos, sprite_type, true, sc->control_flags);
|
||||
}
|
||||
|
@ -481,12 +481,12 @@ static void *ReadSprite(const SpriteCache *sc, SpriteID id, SpriteType sprite_ty
|
|||
}
|
||||
|
||||
if (sprite_avail == 0) {
|
||||
if (sprite_type == ST_MAPGEN) return nullptr;
|
||||
if (sprite_type == SpriteType::MapGen) return nullptr;
|
||||
if (id == SPR_IMG_QUERY) usererror("Okay... something went horribly wrong. I couldn't load the fallback sprite. What should I do?");
|
||||
return (void*)GetRawSprite(SPR_IMG_QUERY, ST_NORMAL, allocator, encoder);
|
||||
return (void*)GetRawSprite(SPR_IMG_QUERY, SpriteType::Normal, allocator, encoder);
|
||||
}
|
||||
|
||||
if (sprite_type == ST_MAPGEN) {
|
||||
if (sprite_type == SpriteType::MapGen) {
|
||||
/* Ugly hack to work around the problem that the old landscape
|
||||
* generator assumes that those sprites are stored uncompressed in
|
||||
* the memory, and they are only read directly by the code, never
|
||||
|
@ -516,10 +516,10 @@ static void *ReadSprite(const SpriteCache *sc, SpriteID id, SpriteType sprite_ty
|
|||
|
||||
if (!ResizeSprites(sprite, sprite_avail, encoder)) {
|
||||
if (id == SPR_IMG_QUERY) usererror("Okay... something went horribly wrong. I couldn't resize the fallback sprite. What should I do?");
|
||||
return (void*)GetRawSprite(SPR_IMG_QUERY, ST_NORMAL, allocator, encoder);
|
||||
return (void*)GetRawSprite(SPR_IMG_QUERY, SpriteType::Normal, allocator, encoder);
|
||||
}
|
||||
|
||||
if (sprite->type == ST_FONT && ZOOM_LVL_GUI != ZOOM_LVL_NORMAL) {
|
||||
if (sprite->type == SpriteType::Font && ZOOM_LVL_GUI != ZOOM_LVL_NORMAL) {
|
||||
/* Make ZOOM_LVL_NORMAL be ZOOM_LVL_GUI */
|
||||
sprite[ZOOM_LVL_NORMAL].width = sprite[ZOOM_LVL_GUI].width;
|
||||
sprite[ZOOM_LVL_NORMAL].height = sprite[ZOOM_LVL_GUI].height;
|
||||
|
@ -629,7 +629,7 @@ bool LoadNextSprite(int load_index, SpriteFile &file, uint file_sprite_id)
|
|||
file.ReadByte();
|
||||
return false;
|
||||
}
|
||||
type = ST_RECOLOUR;
|
||||
type = SpriteType::Recolour;
|
||||
data = ReadRecolourSprite(file, num);
|
||||
} else if (file.GetContainerVersion() >= 2 && grf_type == 0xFD) {
|
||||
if (num != 4) {
|
||||
|
@ -645,15 +645,15 @@ bool LoadNextSprite(int load_index, SpriteFile &file, uint file_sprite_id)
|
|||
} else {
|
||||
file_pos = SIZE_MAX;
|
||||
}
|
||||
type = ST_NORMAL;
|
||||
type = SpriteType::Normal;
|
||||
} else {
|
||||
file.SkipBytes(7);
|
||||
type = SkipSpriteData(file, grf_type, num - 8) ? ST_NORMAL : ST_INVALID;
|
||||
type = SkipSpriteData(file, grf_type, num - 8) ? SpriteType::Normal : SpriteType::Invalid;
|
||||
/* Inline sprites are not supported for container version >= 2. */
|
||||
if (file.GetContainerVersion() >= 2) return false;
|
||||
}
|
||||
|
||||
if (type == ST_INVALID) return false;
|
||||
if (type == SpriteType::Invalid) return false;
|
||||
|
||||
if (load_index >= MAX_SPRITES) {
|
||||
usererror("Tried to load too many sprites (#%d; max %d)", load_index, MAX_SPRITES);
|
||||
|
@ -662,8 +662,8 @@ bool LoadNextSprite(int load_index, SpriteFile &file, uint file_sprite_id)
|
|||
bool is_mapgen = IsMapgenSpriteID(load_index);
|
||||
|
||||
if (is_mapgen) {
|
||||
if (type != ST_NORMAL) usererror("Uhm, would you be so kind not to load a NewGRF that changes the type of the map generator sprites?");
|
||||
type = ST_MAPGEN;
|
||||
if (type != SpriteType::Normal) usererror("Uhm, would you be so kind not to load a NewGRF that changes the type of the map generator sprites?");
|
||||
type = SpriteType::MapGen;
|
||||
}
|
||||
|
||||
SpriteCache *sc = AllocateSpriteCache(load_index);
|
||||
|
@ -828,7 +828,7 @@ static void DeleteEntryFromSpriteCache()
|
|||
cur_lru = 0xffff;
|
||||
for (SpriteID i = 0; i != _spritecache_items; i++) {
|
||||
SpriteCache *sc = GetSpriteCache(i);
|
||||
if (sc->type != ST_RECOLOUR && sc->ptr != nullptr && sc->lru < cur_lru) {
|
||||
if (sc->type != SpriteType::Recolour && sc->ptr != nullptr && sc->lru < cur_lru) {
|
||||
cur_lru = sc->lru;
|
||||
best = i;
|
||||
}
|
||||
|
@ -888,7 +888,7 @@ void *SimpleSpriteAlloc(size_t size)
|
|||
|
||||
/**
|
||||
* Handles the case when a sprite of different type is requested than is present in the SpriteCache.
|
||||
* For ST_FONT sprites, it is normal. In other cases, default sprite is loaded instead.
|
||||
* For SpriteType::Font sprites, it is normal. In other cases, default sprite is loaded instead.
|
||||
* @param sprite ID of loaded sprite
|
||||
* @param requested requested sprite type
|
||||
* @param sc the currently known sprite cache for the requested sprite
|
||||
|
@ -898,33 +898,33 @@ void *SimpleSpriteAlloc(size_t size)
|
|||
static void *HandleInvalidSpriteRequest(SpriteID sprite, SpriteType requested, SpriteCache *sc, AllocatorProc *allocator)
|
||||
{
|
||||
static const char * const sprite_types[] = {
|
||||
"normal", // ST_NORMAL
|
||||
"map generator", // ST_MAPGEN
|
||||
"character", // ST_FONT
|
||||
"recolour", // ST_RECOLOUR
|
||||
"normal", // SpriteType::Normal
|
||||
"map generator", // SpriteType::MapGen
|
||||
"character", // SpriteType::Font
|
||||
"recolour", // SpriteType::Recolour
|
||||
};
|
||||
|
||||
SpriteType available = sc->type;
|
||||
if (requested == ST_FONT && available == ST_NORMAL) {
|
||||
if (sc->ptr == nullptr) sc->type = ST_FONT;
|
||||
if (requested == SpriteType::Font && available == SpriteType::Normal) {
|
||||
if (sc->ptr == nullptr) sc->type = SpriteType::Font;
|
||||
return GetRawSprite(sprite, sc->type, allocator);
|
||||
}
|
||||
|
||||
byte warning_level = sc->warned ? 6 : 0;
|
||||
sc->warned = true;
|
||||
Debug(sprite, warning_level, "Tried to load {} sprite #{} as a {} sprite. Probable cause: NewGRF interference", sprite_types[available], sprite, sprite_types[requested]);
|
||||
Debug(sprite, warning_level, "Tried to load {} sprite #{} as a {} sprite. Probable cause: NewGRF interference", sprite_types[static_cast<byte>(available)], sprite, sprite_types[static_cast<byte>(requested)]);
|
||||
|
||||
switch (requested) {
|
||||
case ST_NORMAL:
|
||||
case SpriteType::Normal:
|
||||
if (sprite == SPR_IMG_QUERY) usererror("Uhm, would you be so kind not to load a NewGRF that makes the 'query' sprite a non-normal sprite?");
|
||||
FALLTHROUGH;
|
||||
case ST_FONT:
|
||||
return GetRawSprite(SPR_IMG_QUERY, ST_NORMAL, allocator);
|
||||
case ST_RECOLOUR:
|
||||
case SpriteType::Font:
|
||||
return GetRawSprite(SPR_IMG_QUERY, SpriteType::Normal, allocator);
|
||||
case SpriteType::Recolour:
|
||||
if (sprite == PALETTE_TO_DARK_BLUE) usererror("Uhm, would you be so kind not to load a NewGRF that makes the 'PALETTE_TO_DARK_BLUE' sprite a non-remap sprite?");
|
||||
return GetRawSprite(PALETTE_TO_DARK_BLUE, ST_RECOLOUR, allocator);
|
||||
case ST_MAPGEN:
|
||||
/* this shouldn't happen, overriding of ST_MAPGEN sprites is checked in LoadNextSprite()
|
||||
return GetRawSprite(PALETTE_TO_DARK_BLUE, SpriteType::Recolour, allocator);
|
||||
case SpriteType::MapGen:
|
||||
/* this shouldn't happen, overriding of SpriteType::MapGen sprites is checked in LoadNextSprite()
|
||||
* (the only case the check fails is when these sprites weren't even loaded...) */
|
||||
default:
|
||||
NOT_REACHED();
|
||||
|
@ -942,8 +942,8 @@ static void *HandleInvalidSpriteRequest(SpriteID sprite, SpriteType requested, S
|
|||
*/
|
||||
void *GetRawSprite(SpriteID sprite, SpriteType type, AllocatorProc *allocator, SpriteEncoder *encoder)
|
||||
{
|
||||
assert(type != ST_MAPGEN || IsMapgenSpriteID(sprite));
|
||||
assert(type < ST_INVALID);
|
||||
assert(type != SpriteType::MapGen || IsMapgenSpriteID(sprite));
|
||||
assert(type < SpriteType::Invalid);
|
||||
|
||||
if (!SpriteExists(sprite)) {
|
||||
Debug(sprite, 1, "Tried to load non-existing sprite #{}. Probable cause: Wrong/missing NewGRFs", sprite);
|
||||
|
@ -1042,7 +1042,7 @@ void GfxClearSpriteCache()
|
|||
/* Clear sprite ptr for all cached items */
|
||||
for (uint i = 0; i != _spritecache_items; i++) {
|
||||
SpriteCache *sc = GetSpriteCache(i);
|
||||
if (sc->type != ST_RECOLOUR && sc->ptr != nullptr) DeleteEntryFromSpriteCache(i);
|
||||
if (sc->type != SpriteType::Recolour && sc->ptr != nullptr) DeleteEntryFromSpriteCache(i);
|
||||
}
|
||||
|
||||
VideoDriver::GetInstance()->ClearSystemSprites();
|
||||
|
|
|
@ -46,13 +46,13 @@ uint GetMaxSpriteID();
|
|||
|
||||
static inline const Sprite *GetSprite(SpriteID sprite, SpriteType type)
|
||||
{
|
||||
assert(type != ST_RECOLOUR);
|
||||
assert(type != SpriteType::Recolour);
|
||||
return (Sprite*)GetRawSprite(sprite, type);
|
||||
}
|
||||
|
||||
static inline const byte *GetNonSprite(SpriteID sprite, SpriteType type)
|
||||
{
|
||||
assert(type == ST_RECOLOUR);
|
||||
assert(type == SpriteType::Recolour);
|
||||
return (byte*)GetRawSprite(sprite, type);
|
||||
}
|
||||
|
||||
|
|
|
@ -164,8 +164,8 @@ bool DecodeSingleSprite(SpriteLoader::Sprite *sprite, SpriteFile &file, size_t f
|
|||
data->a = (colour_fmt & SCC_ALPHA) ? *dest++ : 0xFF;
|
||||
if (colour_fmt & SCC_PAL) {
|
||||
switch (sprite_type) {
|
||||
case ST_NORMAL: data->m = file.NeedsPaletteRemap() ? _palmap_w2d[*dest] : *dest; break;
|
||||
case ST_FONT: data->m = std::min<uint>(*dest, 2u); break;
|
||||
case SpriteType::Normal: data->m = file.NeedsPaletteRemap() ? _palmap_w2d[*dest] : *dest; break;
|
||||
case SpriteType::Font: data->m = std::min<uint>(*dest, 2u); break;
|
||||
default: data->m = *dest; break;
|
||||
}
|
||||
/* Magic blue. */
|
||||
|
@ -201,8 +201,8 @@ bool DecodeSingleSprite(SpriteLoader::Sprite *sprite, SpriteFile &file, size_t f
|
|||
sprite->data[i].a = (colour_fmt & SCC_ALPHA) ? *pixel++ : 0xFF;
|
||||
if (colour_fmt & SCC_PAL) {
|
||||
switch (sprite_type) {
|
||||
case ST_NORMAL: sprite->data[i].m = file.NeedsPaletteRemap() ? _palmap_w2d[*pixel] : *pixel; break;
|
||||
case ST_FONT: sprite->data[i].m = std::min<uint>(*pixel, 2u); break;
|
||||
case SpriteType::Normal: sprite->data[i].m = file.NeedsPaletteRemap() ? _palmap_w2d[*pixel] : *pixel; break;
|
||||
case SpriteType::Font: sprite->data[i].m = std::min<uint>(*pixel, 2u); break;
|
||||
default: sprite->data[i].m = *pixel; break;
|
||||
}
|
||||
/* Magic blue. */
|
||||
|
@ -230,7 +230,7 @@ uint8 LoadSpriteV1(SpriteLoader::Sprite *sprite, SpriteFile &file, size_t file_p
|
|||
/* Type 0xFF indicates either a colourmap or some other non-sprite info; we do not handle them here */
|
||||
if (type == 0xFF) return 0;
|
||||
|
||||
ZoomLevel zoom_lvl = (sprite_type != ST_MAPGEN) ? ZOOM_LVL_OUT_4X : ZOOM_LVL_NORMAL;
|
||||
ZoomLevel zoom_lvl = (sprite_type != SpriteType::MapGen) ? ZOOM_LVL_OUT_4X : ZOOM_LVL_NORMAL;
|
||||
|
||||
sprite[zoom_lvl].height = file.ReadByte();
|
||||
sprite[zoom_lvl].width = file.ReadWord();
|
||||
|
@ -279,7 +279,7 @@ uint8 LoadSpriteV2(SpriteLoader::Sprite *sprite, SpriteFile &file, size_t file_p
|
|||
bool is_wanted_colour_depth = (colour != 0 && (load_32bpp ? colour != SCC_PAL : colour == SCC_PAL));
|
||||
bool is_wanted_zoom_lvl;
|
||||
|
||||
if (sprite_type != ST_MAPGEN) {
|
||||
if (sprite_type != SpriteType::MapGen) {
|
||||
if (zoom < lengthof(zoom_lvl_map)) {
|
||||
is_wanted_zoom_lvl = true;
|
||||
if (_settings_client.gui.sprite_zoom_min >= ZOOM_LVL_OUT_2X &&
|
||||
|
@ -298,7 +298,7 @@ uint8 LoadSpriteV2(SpriteLoader::Sprite *sprite, SpriteFile &file, size_t file_p
|
|||
}
|
||||
|
||||
if (is_wanted_colour_depth && is_wanted_zoom_lvl) {
|
||||
ZoomLevel zoom_lvl = (sprite_type != ST_MAPGEN) ? zoom_lvl_map[zoom] : ZOOM_LVL_NORMAL;
|
||||
ZoomLevel zoom_lvl = (sprite_type != SpriteType::MapGen) ? zoom_lvl_map[zoom] : ZOOM_LVL_NORMAL;
|
||||
|
||||
if (HasBit(loaded_sprites, zoom_lvl)) {
|
||||
/* We already have this zoom level, skip sprite. */
|
||||
|
|
|
@ -831,17 +831,17 @@ enum SortOrder {
|
|||
|
||||
class CargoDataEntry;
|
||||
|
||||
enum CargoSortType {
|
||||
ST_AS_GROUPING, ///< by the same principle the entries are being grouped
|
||||
ST_COUNT, ///< by amount of cargo
|
||||
ST_STATION_STRING, ///< by station name
|
||||
ST_STATION_ID, ///< by station id
|
||||
ST_CARGO_ID, ///< by cargo id
|
||||
enum class CargoSortType : byte {
|
||||
AsGrouping, ///< by the same principle the entries are being grouped
|
||||
Count, ///< by amount of cargo
|
||||
StationString, ///< by station name
|
||||
StationID, ///< by station id
|
||||
CargoID, ///< by cargo id
|
||||
};
|
||||
|
||||
class CargoSorter {
|
||||
public:
|
||||
CargoSorter(CargoSortType t = ST_STATION_ID, SortOrder o = SO_ASCENDING) : type(t), order(o) {}
|
||||
CargoSorter(CargoSortType t = CargoSortType::StationID, SortOrder o = SO_ASCENDING) : type(t), order(o) {}
|
||||
CargoSortType GetSortType() {return this->type;}
|
||||
bool operator()(const CargoDataEntry *cd1, const CargoDataEntry *cd2) const;
|
||||
|
||||
|
@ -1012,7 +1012,7 @@ CargoDataEntry::CargoDataEntry() :
|
|||
station(INVALID_STATION),
|
||||
num_children(0),
|
||||
count(0),
|
||||
children(new CargoDataSet(CargoSorter(ST_CARGO_ID)))
|
||||
children(new CargoDataSet(CargoSorter(CargoSortType::CargoID)))
|
||||
{}
|
||||
|
||||
CargoDataEntry::CargoDataEntry(CargoID cargo, uint count, CargoDataEntry *parent) :
|
||||
|
@ -1101,7 +1101,7 @@ CargoDataEntry *CargoDataEntry::InsertOrRetrieve(Tid child_id)
|
|||
return *(this->children->insert(new CargoDataEntry(child_id, 0, this)).first);
|
||||
} else {
|
||||
CargoDataEntry *ret = *i;
|
||||
assert(this->children->value_comp().GetSortType() != ST_COUNT);
|
||||
assert(this->children->value_comp().GetSortType() != CargoSortType::Count);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
@ -1138,7 +1138,7 @@ CargoDataEntry *CargoDataEntry::Retrieve(CargoDataSet::iterator i) const
|
|||
if (i == this->children->end()) {
|
||||
return nullptr;
|
||||
} else {
|
||||
assert(this->children->value_comp().GetSortType() != ST_COUNT);
|
||||
assert(this->children->value_comp().GetSortType() != CargoSortType::Count);
|
||||
return *i;
|
||||
}
|
||||
}
|
||||
|
@ -1146,13 +1146,13 @@ CargoDataEntry *CargoDataEntry::Retrieve(CargoDataSet::iterator i) const
|
|||
bool CargoSorter::operator()(const CargoDataEntry *cd1, const CargoDataEntry *cd2) const
|
||||
{
|
||||
switch (this->type) {
|
||||
case ST_STATION_ID:
|
||||
case CargoSortType::StationID:
|
||||
return this->SortId<StationID>(cd1->GetStation(), cd2->GetStation());
|
||||
case ST_CARGO_ID:
|
||||
case CargoSortType::CargoID:
|
||||
return this->SortId<CargoID>(cd1->GetCargo(), cd2->GetCargo());
|
||||
case ST_COUNT:
|
||||
case CargoSortType::Count:
|
||||
return this->SortCount(cd1, cd2);
|
||||
case ST_STATION_STRING:
|
||||
case CargoSortType::StationString:
|
||||
return this->SortStation(cd1->GetStation(), cd2->GetStation());
|
||||
default:
|
||||
NOT_REACHED();
|
||||
|
@ -1268,7 +1268,7 @@ struct StationViewWindow : public Window {
|
|||
|
||||
/**
|
||||
* Sort types of the different 'columns'.
|
||||
* In fact only ST_COUNT and ST_AS_GROUPING are active and you can only
|
||||
* In fact only CargoSortType::Count and CargoSortType::AsGrouping are active and you can only
|
||||
* sort all the columns in the same way. The other options haven't been
|
||||
* included in the GUI due to lack of space.
|
||||
*/
|
||||
|
@ -1298,7 +1298,7 @@ struct StationViewWindow : public Window {
|
|||
this->FinishInitNested(window_number);
|
||||
|
||||
this->groupings[0] = GR_CARGO;
|
||||
this->sortings[0] = ST_AS_GROUPING;
|
||||
this->sortings[0] = CargoSortType::AsGrouping;
|
||||
this->SelectGroupBy(_settings_client.gui.station_gui_group_order);
|
||||
this->SelectSortBy(_settings_client.gui.station_gui_sort_by);
|
||||
this->sort_orders[0] = SO_ASCENDING;
|
||||
|
@ -1715,12 +1715,12 @@ struct StationViewWindow : public Window {
|
|||
*/
|
||||
int DrawEntries(CargoDataEntry *entry, const Rect &r, int pos, int maxrows, int column, CargoID cargo = CT_INVALID)
|
||||
{
|
||||
if (this->sortings[column] == ST_AS_GROUPING) {
|
||||
if (this->sortings[column] == CargoSortType::AsGrouping) {
|
||||
if (this->groupings[column] != GR_CARGO) {
|
||||
entry->Resort(ST_STATION_STRING, this->sort_orders[column]);
|
||||
entry->Resort(CargoSortType::StationString, this->sort_orders[column]);
|
||||
}
|
||||
} else {
|
||||
entry->Resort(ST_COUNT, this->sort_orders[column]);
|
||||
entry->Resort(CargoSortType::Count, this->sort_orders[column]);
|
||||
}
|
||||
for (CargoDataSet::iterator i = entry->Begin(); i != entry->End(); ++i) {
|
||||
CargoDataEntry *cd = *i;
|
||||
|
@ -1940,7 +1940,7 @@ struct StationViewWindow : public Window {
|
|||
* sorted by cargo ID. The others can theoretically be sorted
|
||||
* by different things but there is no UI for that. */
|
||||
ShowDropDownMenu(this, _sort_names,
|
||||
this->current_mode * 2 + (this->sortings[1] == ST_COUNT ? 1 : 0),
|
||||
this->current_mode * 2 + (this->sortings[1] == CargoSortType::Count ? 1 : 0),
|
||||
WID_SV_SORT_BY, 0, 0);
|
||||
break;
|
||||
}
|
||||
|
@ -1980,19 +1980,19 @@ struct StationViewWindow : public Window {
|
|||
switch (_sort_names[index]) {
|
||||
case STR_STATION_VIEW_WAITING_STATION:
|
||||
this->current_mode = MODE_WAITING;
|
||||
this->sortings[1] = this->sortings[2] = this->sortings[3] = ST_AS_GROUPING;
|
||||
this->sortings[1] = this->sortings[2] = this->sortings[3] = CargoSortType::AsGrouping;
|
||||
break;
|
||||
case STR_STATION_VIEW_WAITING_AMOUNT:
|
||||
this->current_mode = MODE_WAITING;
|
||||
this->sortings[1] = this->sortings[2] = this->sortings[3] = ST_COUNT;
|
||||
this->sortings[1] = this->sortings[2] = this->sortings[3] = CargoSortType::Count;
|
||||
break;
|
||||
case STR_STATION_VIEW_PLANNED_STATION:
|
||||
this->current_mode = MODE_PLANNED;
|
||||
this->sortings[1] = this->sortings[2] = this->sortings[3] = ST_AS_GROUPING;
|
||||
this->sortings[1] = this->sortings[2] = this->sortings[3] = CargoSortType::AsGrouping;
|
||||
break;
|
||||
case STR_STATION_VIEW_PLANNED_AMOUNT:
|
||||
this->current_mode = MODE_PLANNED;
|
||||
this->sortings[1] = this->sortings[2] = this->sortings[3] = ST_COUNT;
|
||||
this->sortings[1] = this->sortings[2] = this->sortings[3] = CargoSortType::Count;
|
||||
break;
|
||||
default:
|
||||
NOT_REACHED();
|
||||
|
|
|
@ -82,11 +82,11 @@ std::pair<NewsReferenceType, NewsReferenceType> SetupSubsidyDecodeParam(const Su
|
|||
SetDParam(parameter_offset, cs->name);
|
||||
|
||||
switch (s->src_type) {
|
||||
case ST_INDUSTRY:
|
||||
case SourceType::Industry:
|
||||
reftype1 = NR_INDUSTRY;
|
||||
SetDParam(parameter_offset + 1, STR_INDUSTRY_NAME);
|
||||
break;
|
||||
case ST_TOWN:
|
||||
case SourceType::Town:
|
||||
reftype1 = NR_TOWN;
|
||||
SetDParam(parameter_offset + 1, STR_TOWN_NAME);
|
||||
break;
|
||||
|
@ -95,11 +95,11 @@ std::pair<NewsReferenceType, NewsReferenceType> SetupSubsidyDecodeParam(const Su
|
|||
SetDParam(parameter_offset + 2, s->src);
|
||||
|
||||
switch (s->dst_type) {
|
||||
case ST_INDUSTRY:
|
||||
case SourceType::Industry:
|
||||
reftype2 = NR_INDUSTRY;
|
||||
SetDParam(parameter_offset + 4, STR_INDUSTRY_NAME);
|
||||
break;
|
||||
case ST_TOWN:
|
||||
case SourceType::Town:
|
||||
reftype2 = NR_TOWN;
|
||||
SetDParam(parameter_offset + 4, STR_TOWN_NAME);
|
||||
break;
|
||||
|
@ -124,8 +124,8 @@ std::pair<NewsReferenceType, NewsReferenceType> SetupSubsidyDecodeParam(const Su
|
|||
static inline void SetPartOfSubsidyFlag(SourceType type, SourceID index, PartOfSubsidy flag)
|
||||
{
|
||||
switch (type) {
|
||||
case ST_INDUSTRY: Industry::Get(index)->part_of_subsidy |= flag; return;
|
||||
case ST_TOWN: Town::Get(index)->cache.part_of_subsidy |= flag; return;
|
||||
case SourceType::Industry: Industry::Get(index)->part_of_subsidy |= flag; return;
|
||||
case SourceType::Town: Town::Get(index)->cache.part_of_subsidy |= flag; return;
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
}
|
||||
|
@ -196,8 +196,8 @@ static bool CheckSubsidyDuplicate(CargoID cargo, SourceType src_type, SourceID s
|
|||
*/
|
||||
static bool CheckSubsidyDistance(SourceType src_type, SourceID src, SourceType dst_type, SourceID dst)
|
||||
{
|
||||
TileIndex tile_src = (src_type == ST_TOWN) ? Town::Get(src)->xy : Industry::Get(src)->location.tile;
|
||||
TileIndex tile_dst = (dst_type == ST_TOWN) ? Town::Get(dst)->xy : Industry::Get(dst)->location.tile;
|
||||
TileIndex tile_src = (src_type == SourceType::Town) ? Town::Get(src)->xy : Industry::Get(src)->location.tile;
|
||||
TileIndex tile_dst = (dst_type == SourceType::Town) ? Town::Get(dst)->xy : Industry::Get(dst)->location.tile;
|
||||
|
||||
return (DistanceManhattan(tile_src, tile_dst) <= SUBSIDY_MAX_DISTANCE);
|
||||
}
|
||||
|
@ -250,20 +250,20 @@ CommandCost CmdCreateSubsidy(DoCommandFlag flags, CargoID cid, SourceType src_ty
|
|||
if (cid >= NUM_CARGO || !::CargoSpec::Get(cid)->IsValid()) return CMD_ERROR;
|
||||
|
||||
switch (src_type) {
|
||||
case ST_TOWN:
|
||||
case SourceType::Town:
|
||||
if (!Town::IsValidID(src)) return CMD_ERROR;
|
||||
break;
|
||||
case ST_INDUSTRY:
|
||||
case SourceType::Industry:
|
||||
if (!Industry::IsValidID(src)) return CMD_ERROR;
|
||||
break;
|
||||
default:
|
||||
return CMD_ERROR;
|
||||
}
|
||||
switch (dst_type) {
|
||||
case ST_TOWN:
|
||||
case SourceType::Town:
|
||||
if (!Town::IsValidID(dst)) return CMD_ERROR;
|
||||
break;
|
||||
case ST_INDUSTRY:
|
||||
case SourceType::Industry:
|
||||
if (!Industry::IsValidID(dst)) return CMD_ERROR;
|
||||
break;
|
||||
default:
|
||||
|
@ -297,9 +297,9 @@ bool FindSubsidyPassengerRoute()
|
|||
}
|
||||
|
||||
if (DistanceManhattan(src->xy, dst->xy) > SUBSIDY_MAX_DISTANCE) return false;
|
||||
if (CheckSubsidyDuplicate(CT_PASSENGERS, ST_TOWN, src->index, ST_TOWN, dst->index)) return false;
|
||||
if (CheckSubsidyDuplicate(CT_PASSENGERS, SourceType::Town, src->index, SourceType::Town, dst->index)) return false;
|
||||
|
||||
CreateSubsidy(CT_PASSENGERS, ST_TOWN, src->index, ST_TOWN, dst->index);
|
||||
CreateSubsidy(CT_PASSENGERS, SourceType::Town, src->index, SourceType::Town, dst->index);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -315,7 +315,7 @@ bool FindSubsidyTownCargoRoute()
|
|||
{
|
||||
if (!Subsidy::CanAllocateItem()) return false;
|
||||
|
||||
SourceType src_type = ST_TOWN;
|
||||
SourceType src_type = SourceType::Town;
|
||||
|
||||
/* Select a random town. */
|
||||
const Town *src_town = Town::GetRandom();
|
||||
|
@ -373,7 +373,7 @@ bool FindSubsidyIndustryCargoRoute()
|
|||
{
|
||||
if (!Subsidy::CanAllocateItem()) return false;
|
||||
|
||||
SourceType src_type = ST_INDUSTRY;
|
||||
SourceType src_type = SourceType::Industry;
|
||||
|
||||
/* Select a random industry. */
|
||||
const Industry *src_ind = Industry::GetRandom();
|
||||
|
@ -424,11 +424,11 @@ bool FindSubsidyIndustryCargoRoute()
|
|||
bool FindSubsidyCargoDestination(CargoID cid, SourceType src_type, SourceID src)
|
||||
{
|
||||
/* Choose a random destination. */
|
||||
SourceType dst_type = Chance16(1, 2) ? ST_TOWN : ST_INDUSTRY;
|
||||
SourceType dst_type = Chance16(1, 2) ? SourceType::Town : SourceType::Industry;
|
||||
|
||||
SourceID dst;
|
||||
switch (dst_type) {
|
||||
case ST_TOWN: {
|
||||
case SourceType::Town: {
|
||||
/* Select a random town. */
|
||||
const Town *dst_town = Town::GetRandom();
|
||||
|
||||
|
@ -448,7 +448,7 @@ bool FindSubsidyCargoDestination(CargoID cid, SourceType src_type, SourceID src)
|
|||
break;
|
||||
}
|
||||
|
||||
case ST_INDUSTRY: {
|
||||
case SourceType::Industry: {
|
||||
/* Select a random industry. */
|
||||
const Industry *dst_ind = Industry::GetRandom();
|
||||
if (dst_ind == nullptr) return false;
|
||||
|
@ -565,10 +565,10 @@ bool CheckSubsidised(CargoID cargo_type, CompanyID company, SourceType src_type,
|
|||
/* If the source isn't subsidised, don't continue */
|
||||
if (src == INVALID_SOURCE) return false;
|
||||
switch (src_type) {
|
||||
case ST_INDUSTRY:
|
||||
case SourceType::Industry:
|
||||
if (!(Industry::Get(src)->part_of_subsidy & POS_SRC)) return false;
|
||||
break;
|
||||
case ST_TOWN:
|
||||
case SourceType::Town:
|
||||
if (!(Town::Get(src)->cache.part_of_subsidy & POS_SRC)) return false;
|
||||
break;
|
||||
default: return false;
|
||||
|
@ -580,7 +580,7 @@ bool CheckSubsidised(CargoID cargo_type, CompanyID company, SourceType src_type,
|
|||
if (!st->rect.IsEmpty()) {
|
||||
for (const Subsidy *s : Subsidy::Iterate()) {
|
||||
/* Don't create the cache if there is no applicable subsidy with town as destination */
|
||||
if (s->dst_type != ST_TOWN) continue;
|
||||
if (s->dst_type != SourceType::Town) continue;
|
||||
if (s->cargo_type != cargo_type || s->src_type != src_type || s->src != src) continue;
|
||||
if (s->IsAwarded() && s->awarded != company) continue;
|
||||
|
||||
|
@ -601,7 +601,7 @@ bool CheckSubsidised(CargoID cargo_type, CompanyID company, SourceType src_type,
|
|||
for (Subsidy *s : Subsidy::Iterate()) {
|
||||
if (s->cargo_type == cargo_type && s->src_type == src_type && s->src == src && (!s->IsAwarded() || s->awarded == company)) {
|
||||
switch (s->dst_type) {
|
||||
case ST_INDUSTRY:
|
||||
case SourceType::Industry:
|
||||
for (const auto &i : st->industries_near) {
|
||||
if (s->dst == i.industry->index) {
|
||||
assert(i.industry->part_of_subsidy & POS_DST);
|
||||
|
@ -610,7 +610,7 @@ bool CheckSubsidised(CargoID cargo_type, CompanyID company, SourceType src_type,
|
|||
}
|
||||
}
|
||||
break;
|
||||
case ST_TOWN:
|
||||
case SourceType::Town:
|
||||
for (const Town *tp : towns_near) {
|
||||
if (s->dst == tp->index) {
|
||||
assert(tp->cache.part_of_subsidy & POS_DST);
|
||||
|
|
|
@ -23,8 +23,8 @@ struct Subsidy : SubsidyPool::PoolItem<&_subsidy_pool> {
|
|||
CargoID cargo_type; ///< Cargo type involved in this subsidy, CT_INVALID for invalid subsidy
|
||||
uint16 remaining; ///< Remaining months when this subsidy is valid
|
||||
CompanyID awarded; ///< Subsidy is awarded to this company; INVALID_COMPANY if it's not awarded to anyone
|
||||
SourceType src_type; ///< Source of subsidised path (ST_INDUSTRY or ST_TOWN)
|
||||
SourceType dst_type; ///< Destination of subsidised path (ST_INDUSTRY or ST_TOWN)
|
||||
SourceType src_type; ///< Source of subsidised path (SourceType::Industry or SourceType::Town)
|
||||
SourceType dst_type; ///< Destination of subsidised path (SourceType::Industry or SourceType::Town)
|
||||
SourceID src; ///< Index of source. Either TownID or IndustryID
|
||||
SourceID dst; ///< Index of destination. Either TownID or IndustryID
|
||||
|
||||
|
|
|
@ -77,8 +77,8 @@ struct SubsidyListWindow : Window {
|
|||
/* determine src coordinate for subsidy and try to scroll to it */
|
||||
TileIndex xy;
|
||||
switch (s->src_type) {
|
||||
case ST_INDUSTRY: xy = Industry::Get(s->src)->location.tile; break;
|
||||
case ST_TOWN: xy = Town::Get(s->src)->xy; break;
|
||||
case SourceType::Industry: xy = Industry::Get(s->src)->location.tile; break;
|
||||
case SourceType::Town: xy = Town::Get(s->src)->xy; break;
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
|
||||
|
@ -87,8 +87,8 @@ struct SubsidyListWindow : Window {
|
|||
|
||||
/* otherwise determine dst coordinate for subsidy and scroll to it */
|
||||
switch (s->dst_type) {
|
||||
case ST_INDUSTRY: xy = Industry::Get(s->dst)->location.tile; break;
|
||||
case ST_TOWN: xy = Town::Get(s->dst)->xy; break;
|
||||
case SourceType::Industry: xy = Industry::Get(s->dst)->location.tile; break;
|
||||
case SourceType::Town: xy = Town::Get(s->dst)->xy; break;
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
|
||||
|
|
|
@ -145,9 +145,9 @@ Town::~Town()
|
|||
/* Clear the persistent storage list. */
|
||||
this->psa_list.clear();
|
||||
|
||||
DeleteSubsidyWith(ST_TOWN, this->index);
|
||||
DeleteSubsidyWith(SourceType::Town, this->index);
|
||||
DeleteNewGRFInspectWindow(GSF_FAKE_TOWNS, this->index);
|
||||
CargoPacket::InvalidateAllFrom(ST_TOWN, this->index);
|
||||
CargoPacket::InvalidateAllFrom(SourceType::Town, this->index);
|
||||
MarkWholeScreenDirty();
|
||||
}
|
||||
|
||||
|
@ -566,7 +566,7 @@ static void TileLoop_Town(TileIndex tile)
|
|||
uint amt = GB(callback, 0, 8);
|
||||
if (amt == 0) continue;
|
||||
|
||||
uint moved = MoveGoodsToStation(cargo, amt, ST_TOWN, t->index, stations.GetStations());
|
||||
uint moved = MoveGoodsToStation(cargo, amt, SourceType::Town, t->index, stations.GetStations());
|
||||
|
||||
const CargoSpec *cs = CargoSpec::Get(cargo);
|
||||
t->supplied[cs->Index()].new_max += amt;
|
||||
|
@ -581,7 +581,7 @@ static void TileLoop_Town(TileIndex tile)
|
|||
|
||||
if (EconomyIsInRecession()) amt = (amt + 1) >> 1;
|
||||
t->supplied[CT_PASSENGERS].new_max += amt;
|
||||
t->supplied[CT_PASSENGERS].new_act += MoveGoodsToStation(CT_PASSENGERS, amt, ST_TOWN, t->index, stations.GetStations());
|
||||
t->supplied[CT_PASSENGERS].new_act += MoveGoodsToStation(CT_PASSENGERS, amt, SourceType::Town, t->index, stations.GetStations());
|
||||
}
|
||||
|
||||
if (GB(r, 8, 8) < hs->mail_generation) {
|
||||
|
@ -589,7 +589,7 @@ static void TileLoop_Town(TileIndex tile)
|
|||
|
||||
if (EconomyIsInRecession()) amt = (amt + 1) >> 1;
|
||||
t->supplied[CT_MAIL].new_max += amt;
|
||||
t->supplied[CT_MAIL].new_act += MoveGoodsToStation(CT_MAIL, amt, ST_TOWN, t->index, stations.GetStations());
|
||||
t->supplied[CT_MAIL].new_act += MoveGoodsToStation(CT_MAIL, amt, SourceType::Town, t->index, stations.GetStations());
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -606,7 +606,7 @@ static void TileLoop_Town(TileIndex tile)
|
|||
/* Adjust and apply */
|
||||
if (EconomyIsInRecession()) amt = (amt + 1) >> 1;
|
||||
t->supplied[CT_PASSENGERS].new_max += amt;
|
||||
t->supplied[CT_PASSENGERS].new_act += MoveGoodsToStation(CT_PASSENGERS, amt, ST_TOWN, t->index, stations.GetStations());
|
||||
t->supplied[CT_PASSENGERS].new_act += MoveGoodsToStation(CT_PASSENGERS, amt, SourceType::Town, t->index, stations.GetStations());
|
||||
|
||||
/* Do the same for mail, with a fresh random */
|
||||
r = Random();
|
||||
|
@ -615,7 +615,7 @@ static void TileLoop_Town(TileIndex tile)
|
|||
amt = CountBits(r & genmask);
|
||||
if (EconomyIsInRecession()) amt = (amt + 1) >> 1;
|
||||
t->supplied[CT_MAIL].new_max += amt;
|
||||
t->supplied[CT_MAIL].new_act += MoveGoodsToStation(CT_MAIL, amt, ST_TOWN, t->index, stations.GetStations());
|
||||
t->supplied[CT_MAIL].new_act += MoveGoodsToStation(CT_MAIL, amt, SourceType::Town, t->index, stations.GetStations());
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -102,7 +102,7 @@ void VehicleSpriteSeq::GetBounds(Rect *bounds) const
|
|||
{
|
||||
bounds->left = bounds->top = bounds->right = bounds->bottom = 0;
|
||||
for (uint i = 0; i < this->count; ++i) {
|
||||
const Sprite *spr = GetSprite(this->seq[i].sprite, ST_NORMAL);
|
||||
const Sprite *spr = GetSprite(this->seq[i].sprite, SpriteType::Normal);
|
||||
if (i == 0) {
|
||||
bounds->left = spr->x_offs;
|
||||
bounds->top = spr->y_offs;
|
||||
|
|
|
@ -1114,7 +1114,7 @@ void OpenGLBackend::PopulateCursorCache()
|
|||
SpriteID sprite = _cursor.sprite_seq[i].sprite;
|
||||
|
||||
if (!this->cursor_cache.Contains(sprite)) {
|
||||
Sprite *old = this->cursor_cache.Insert(sprite, (Sprite *)GetRawSprite(sprite, ST_NORMAL, &SimpleSpriteAlloc, this));
|
||||
Sprite *old = this->cursor_cache.Insert(sprite, (Sprite *)GetRawSprite(sprite, SpriteType::Normal, &SimpleSpriteAlloc, this));
|
||||
if (old != nullptr) {
|
||||
OpenGLSprite *gl_sprite = (OpenGLSprite *)old->data;
|
||||
gl_sprite->~OpenGLSprite();
|
||||
|
@ -1272,10 +1272,10 @@ void OpenGLBackend::ReleaseAnimBuffer(const Rect &update_rect)
|
|||
Sprite *dest_sprite = (Sprite *)allocator(sizeof(*dest_sprite) + sizeof(OpenGLSprite));
|
||||
|
||||
OpenGLSprite *gl_sprite = (OpenGLSprite *)dest_sprite->data;
|
||||
new (gl_sprite) OpenGLSprite(sprite->width, sprite->height, sprite->type == ST_FONT ? 1 : ZOOM_LVL_COUNT, sprite->colours);
|
||||
new (gl_sprite) OpenGLSprite(sprite->width, sprite->height, sprite->type == SpriteType::Font ? 1 : ZOOM_LVL_COUNT, sprite->colours);
|
||||
|
||||
/* Upload texture data. */
|
||||
for (int i = 0; i < (sprite->type == ST_FONT ? 1 : ZOOM_LVL_COUNT); i++) {
|
||||
for (int i = 0; i < (sprite->type == SpriteType::Font ? 1 : ZOOM_LVL_COUNT); i++) {
|
||||
gl_sprite->Update(sprite[i].width, sprite[i].height, i, sprite[i].data);
|
||||
}
|
||||
|
||||
|
@ -1310,7 +1310,7 @@ void OpenGLBackend::RenderOglSprite(OpenGLSprite *gl_sprite, PaletteID pal, int
|
|||
_glBindBuffer(GL_PIXEL_UNPACK_BUFFER, OpenGLSprite::pal_pbo);
|
||||
_glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||
|
||||
_glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, 256, GetNonSprite(GB(pal, 0, PALETTE_WIDTH), ST_RECOLOUR) + 1);
|
||||
_glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, 256, GetNonSprite(GB(pal, 0, PALETTE_WIDTH), SpriteType::Recolour) + 1);
|
||||
_glTexSubImage1D(GL_TEXTURE_1D, 0, 0, 256, GL_RED, GL_UNSIGNED_BYTE, nullptr);
|
||||
|
||||
_glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
|
||||
|
|
|
@ -625,7 +625,7 @@ void OffsetGroundSprite(int x, int y)
|
|||
static void AddCombinedSprite(SpriteID image, PaletteID pal, int x, int y, int z, const SubSprite *sub)
|
||||
{
|
||||
Point pt = RemapCoords(x, y, z);
|
||||
const Sprite *spr = GetSprite(image & SPRITE_MASK, ST_NORMAL);
|
||||
const Sprite *spr = GetSprite(image & SPRITE_MASK, SpriteType::Normal);
|
||||
|
||||
if (pt.x + spr->x_offs >= _vd.dpi.left + _vd.dpi.width ||
|
||||
pt.x + spr->x_offs + spr->width <= _vd.dpi.left ||
|
||||
|
@ -691,7 +691,7 @@ void AddSortableSpriteToDraw(SpriteID image, PaletteID pal, int x, int y, int w,
|
|||
top = tmp_top = RemapCoords(x + bb_offset_x, y + bb_offset_y, z + dz ).y;
|
||||
bottom = RemapCoords(x + w , y + h , z + bb_offset_z).y + 1;
|
||||
} else {
|
||||
const Sprite *spr = GetSprite(image & SPRITE_MASK, ST_NORMAL);
|
||||
const Sprite *spr = GetSprite(image & SPRITE_MASK, SpriteType::Normal);
|
||||
left = tmp_left = (pt.x += spr->x_offs);
|
||||
right = (pt.x + spr->width );
|
||||
top = tmp_top = (pt.y += spr->y_offs);
|
||||
|
|
Loading…
Reference in New Issue