mirror of https://github.com/OpenRCT2/OpenRCT2.git
Merge pull request #15991 from ZehMatt/refactor/bannerid
Use TIdentifier for BannerIndex
This commit is contained in:
commit
cec30e093d
|
@ -582,7 +582,7 @@ bool ViewportInteractionRightClick(const ScreenCoordsXY& screenCoords)
|
||||||
ViewportInteractionRemoveLargeScenery(info.Element, info.Loc);
|
ViewportInteractionRemoveLargeScenery(info.Element, info.Loc);
|
||||||
break;
|
break;
|
||||||
case ViewportInteractionItem::Banner:
|
case ViewportInteractionItem::Banner:
|
||||||
context_open_detail_window(WD_BANNER, info.Element->AsBanner()->GetIndex());
|
context_open_detail_window(WD_BANNER, info.Element->AsBanner()->GetIndex().ToUnderlying());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -669,7 +669,7 @@ static void ViewportInteractionRemoveParkWall(TileElement* tileElement, const Co
|
||||||
auto* wallEntry = tileElement->AsWall()->GetEntry();
|
auto* wallEntry = tileElement->AsWall()->GetEntry();
|
||||||
if (wallEntry->scrolling_mode != SCROLLING_MODE_NONE)
|
if (wallEntry->scrolling_mode != SCROLLING_MODE_NONE)
|
||||||
{
|
{
|
||||||
context_open_detail_window(WD_SIGN_SMALL, tileElement->AsWall()->GetBannerIndex());
|
context_open_detail_window(WD_SIGN_SMALL, tileElement->AsWall()->GetBannerIndex().ToUnderlying());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -690,7 +690,7 @@ static void ViewportInteractionRemoveLargeScenery(TileElement* tileElement, cons
|
||||||
if (sceneryEntry->scrolling_mode != SCROLLING_MODE_NONE)
|
if (sceneryEntry->scrolling_mode != SCROLLING_MODE_NONE)
|
||||||
{
|
{
|
||||||
auto bannerIndex = tileElement->AsLargeScenery()->GetBannerIndex();
|
auto bannerIndex = tileElement->AsLargeScenery()->GetBannerIndex();
|
||||||
context_open_detail_window(WD_SIGN, bannerIndex);
|
context_open_detail_window(WD_SIGN, bannerIndex.ToUnderlying());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -88,9 +88,14 @@ private:
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BannerIndex GetBannerIndex() const
|
||||||
|
{
|
||||||
|
return BannerIndex::FromUnderlying(number);
|
||||||
|
}
|
||||||
|
|
||||||
BannerElement* GetBannerElement()
|
BannerElement* GetBannerElement()
|
||||||
{
|
{
|
||||||
auto* banner = GetBanner(number);
|
auto* banner = GetBanner(GetBannerIndex());
|
||||||
if (banner == nullptr)
|
if (banner == nullptr)
|
||||||
{
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -109,7 +114,7 @@ private:
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (bannerElement->GetIndex() == number)
|
if (bannerElement->GetIndex() == GetBannerIndex())
|
||||||
{
|
{
|
||||||
return bannerElement;
|
return bannerElement;
|
||||||
}
|
}
|
||||||
|
@ -131,7 +136,7 @@ public:
|
||||||
void Initialise(rct_windownumber _number)
|
void Initialise(rct_windownumber _number)
|
||||||
{
|
{
|
||||||
number = _number;
|
number = _number;
|
||||||
auto* banner = GetBanner(number);
|
auto* banner = GetBanner(BannerIndex::FromUnderlying(number));
|
||||||
|
|
||||||
auto* bannerElement = GetBannerElement();
|
auto* bannerElement = GetBannerElement();
|
||||||
if (bannerElement == nullptr)
|
if (bannerElement == nullptr)
|
||||||
|
@ -144,7 +149,7 @@ public:
|
||||||
void OnMouseDown(rct_widgetindex widgetIndex) override
|
void OnMouseDown(rct_widgetindex widgetIndex) override
|
||||||
{
|
{
|
||||||
rct_widget* widget = &widgets[widgetIndex];
|
rct_widget* widget = &widgets[widgetIndex];
|
||||||
auto* banner = GetBanner(number);
|
auto* banner = GetBanner(GetBannerIndex());
|
||||||
if (banner == nullptr)
|
if (banner == nullptr)
|
||||||
{
|
{
|
||||||
Close();
|
Close();
|
||||||
|
@ -177,7 +182,7 @@ public:
|
||||||
|
|
||||||
void OnMouseUp(rct_widgetindex widgetIndex) override
|
void OnMouseUp(rct_widgetindex widgetIndex) override
|
||||||
{
|
{
|
||||||
auto* banner = GetBanner(number);
|
auto* banner = GetBanner(GetBannerIndex());
|
||||||
if (banner == nullptr)
|
if (banner == nullptr)
|
||||||
{
|
{
|
||||||
Close();
|
Close();
|
||||||
|
@ -207,7 +212,7 @@ public:
|
||||||
{
|
{
|
||||||
textinput_cancel();
|
textinput_cancel();
|
||||||
auto bannerSetStyle = BannerSetStyleAction(
|
auto bannerSetStyle = BannerSetStyleAction(
|
||||||
BannerSetStyleType::NoEntry, number, banner->flags ^ BANNER_FLAG_NO_ENTRY);
|
BannerSetStyleType::NoEntry, GetBannerIndex(), banner->flags ^ BANNER_FLAG_NO_ENTRY);
|
||||||
GameActions::Execute(&bannerSetStyle);
|
GameActions::Execute(&bannerSetStyle);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -223,7 +228,7 @@ public:
|
||||||
if (dropdownIndex == -1)
|
if (dropdownIndex == -1)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
auto bannerSetStyle = BannerSetStyleAction(BannerSetStyleType::PrimaryColour, number, dropdownIndex);
|
auto bannerSetStyle = BannerSetStyleAction(BannerSetStyleType::PrimaryColour, GetBannerIndex(), dropdownIndex);
|
||||||
GameActions::Execute(&bannerSetStyle);
|
GameActions::Execute(&bannerSetStyle);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -231,7 +236,7 @@ public:
|
||||||
{
|
{
|
||||||
if (dropdownIndex == -1)
|
if (dropdownIndex == -1)
|
||||||
break;
|
break;
|
||||||
auto bannerSetStyle = BannerSetStyleAction(BannerSetStyleType::TextColour, number, dropdownIndex + 1);
|
auto bannerSetStyle = BannerSetStyleAction(BannerSetStyleType::TextColour, GetBannerIndex(), dropdownIndex + 1);
|
||||||
GameActions::Execute(&bannerSetStyle);
|
GameActions::Execute(&bannerSetStyle);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -242,7 +247,7 @@ public:
|
||||||
{
|
{
|
||||||
if (widgetIndex == WIDX_BANNER_TEXT)
|
if (widgetIndex == WIDX_BANNER_TEXT)
|
||||||
{
|
{
|
||||||
auto bannerSetNameAction = BannerSetNameAction(number, std::string(text));
|
auto bannerSetNameAction = BannerSetNameAction(GetBannerIndex(), std::string(text));
|
||||||
GameActions::Execute(&bannerSetNameAction);
|
GameActions::Execute(&bannerSetNameAction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -265,7 +270,7 @@ public:
|
||||||
|
|
||||||
void OnPrepareDraw() override
|
void OnPrepareDraw() override
|
||||||
{
|
{
|
||||||
auto* banner = GetBanner(number);
|
auto* banner = GetBanner(GetBannerIndex());
|
||||||
if (banner == nullptr)
|
if (banner == nullptr)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -59,9 +59,14 @@ class SignWindow final : public Window
|
||||||
private:
|
private:
|
||||||
bool _isSmall = false;
|
bool _isSmall = false;
|
||||||
|
|
||||||
|
BannerIndex GetBannerIndex() const
|
||||||
|
{
|
||||||
|
return BannerIndex::FromUnderlying(number);
|
||||||
|
}
|
||||||
|
|
||||||
void ShowTextInput()
|
void ShowTextInput()
|
||||||
{
|
{
|
||||||
auto* banner = GetBanner(number);
|
auto* banner = GetBanner(GetBannerIndex());
|
||||||
if (banner != nullptr)
|
if (banner != nullptr)
|
||||||
{
|
{
|
||||||
auto bannerText = banner->GetText();
|
auto bannerText = banner->GetText();
|
||||||
|
@ -87,14 +92,14 @@ public:
|
||||||
{
|
{
|
||||||
number = windowNumber;
|
number = windowNumber;
|
||||||
_isSmall = isSmall;
|
_isSmall = isSmall;
|
||||||
auto* banner = GetBanner(number);
|
auto* banner = GetBanner(GetBannerIndex());
|
||||||
if (banner == nullptr)
|
if (banner == nullptr)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto signViewPosition = banner->position.ToCoordsXY().ToTileCentre();
|
auto signViewPosition = banner->position.ToCoordsXY().ToTileCentre();
|
||||||
auto* tileElement = banner_get_tile_element(number);
|
auto* tileElement = banner_get_tile_element(GetBannerIndex());
|
||||||
if (tileElement == nullptr)
|
if (tileElement == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -138,7 +143,7 @@ public:
|
||||||
|
|
||||||
void OnMouseUp(rct_widgetindex widgetIndex) override
|
void OnMouseUp(rct_widgetindex widgetIndex) override
|
||||||
{
|
{
|
||||||
auto* banner = GetBanner(number);
|
auto* banner = GetBanner(GetBannerIndex());
|
||||||
if (banner == nullptr)
|
if (banner == nullptr)
|
||||||
{
|
{
|
||||||
Close();
|
Close();
|
||||||
|
@ -151,7 +156,7 @@ public:
|
||||||
break;
|
break;
|
||||||
case WIDX_SIGN_DEMOLISH:
|
case WIDX_SIGN_DEMOLISH:
|
||||||
{
|
{
|
||||||
auto* tileElement = banner_get_tile_element(number);
|
auto* tileElement = banner_get_tile_element(GetBannerIndex());
|
||||||
if (tileElement == nullptr)
|
if (tileElement == nullptr)
|
||||||
{
|
{
|
||||||
Close();
|
Close();
|
||||||
|
@ -203,7 +208,7 @@ public:
|
||||||
if (dropdownIndex == -1)
|
if (dropdownIndex == -1)
|
||||||
return;
|
return;
|
||||||
list_information_type = dropdownIndex;
|
list_information_type = dropdownIndex;
|
||||||
auto signSetStyleAction = SignSetStyleAction(number, dropdownIndex, var_492, !_isSmall);
|
auto signSetStyleAction = SignSetStyleAction(GetBannerIndex(), dropdownIndex, var_492, !_isSmall);
|
||||||
GameActions::Execute(&signSetStyleAction);
|
GameActions::Execute(&signSetStyleAction);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -212,7 +217,7 @@ public:
|
||||||
if (dropdownIndex == -1)
|
if (dropdownIndex == -1)
|
||||||
return;
|
return;
|
||||||
var_492 = dropdownIndex;
|
var_492 = dropdownIndex;
|
||||||
auto signSetStyleAction = SignSetStyleAction(number, list_information_type, dropdownIndex, !_isSmall);
|
auto signSetStyleAction = SignSetStyleAction(GetBannerIndex(), list_information_type, dropdownIndex, !_isSmall);
|
||||||
GameActions::Execute(&signSetStyleAction);
|
GameActions::Execute(&signSetStyleAction);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -227,7 +232,7 @@ public:
|
||||||
{
|
{
|
||||||
if (widgetIndex == WIDX_SIGN_TEXT && !text.empty())
|
if (widgetIndex == WIDX_SIGN_TEXT && !text.empty())
|
||||||
{
|
{
|
||||||
auto signSetNameAction = SignSetNameAction(number, std::string(text));
|
auto signSetNameAction = SignSetNameAction(GetBannerIndex(), std::string(text));
|
||||||
GameActions::Execute(&signSetNameAction);
|
GameActions::Execute(&signSetNameAction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -288,7 +293,7 @@ public:
|
||||||
{
|
{
|
||||||
RemoveViewport();
|
RemoveViewport();
|
||||||
|
|
||||||
auto banner = GetBanner(number);
|
auto banner = GetBanner(GetBannerIndex());
|
||||||
if (banner == nullptr)
|
if (banner == nullptr)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -2356,8 +2356,8 @@ static void WindowTileInspectorScrollpaint(rct_window* w, rct_drawpixelinfo* dpi
|
||||||
break;
|
break;
|
||||||
case TILE_ELEMENT_TYPE_BANNER:
|
case TILE_ELEMENT_TYPE_BANNER:
|
||||||
snprintf(
|
snprintf(
|
||||||
buffer, sizeof(buffer), "%s (%d)", language_get_string(STR_BANNER_WINDOW_TITLE),
|
buffer, sizeof(buffer), "%s (%u)", language_get_string(STR_BANNER_WINDOW_TITLE),
|
||||||
tileElement->AsBanner()->GetIndex());
|
tileElement->AsBanner()->GetIndex().ToUnderlying());
|
||||||
typeName = buffer;
|
typeName = buffer;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -2005,7 +2005,7 @@ static void WindowTopToolbarSceneryToolDown(const ScreenCoordsXY& windowPos, rct
|
||||||
{
|
{
|
||||||
auto data = result->GetData<BannerPlaceActionResult>();
|
auto data = result->GetData<BannerPlaceActionResult>();
|
||||||
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::PlaceItem, result->Position);
|
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::PlaceItem, result->Position);
|
||||||
context_open_detail_window(WD_BANNER, data.bannerId);
|
context_open_detail_window(WD_BANNER, data.bannerId.ToUnderlying());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
GameActions::Execute(&bannerPlaceAction);
|
GameActions::Execute(&bannerPlaceAction);
|
||||||
|
|
|
@ -15,3 +15,5 @@
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
using ParkEntranceIndex = TIdentifier<uint8_t, std::numeric_limits<uint8_t>::max(), struct ParkEntranceIndexTag>;
|
using ParkEntranceIndex = TIdentifier<uint8_t, std::numeric_limits<uint8_t>::max(), struct ParkEntranceIndexTag>;
|
||||||
|
|
||||||
|
using BannerIndex = TIdentifier<uint16_t, std::numeric_limits<uint16_t>::max(), struct BannerIndexTag>;
|
||||||
|
|
|
@ -983,9 +983,9 @@ namespace OpenRCT2
|
||||||
cs.Write(static_cast<uint32_t>(numBanners));
|
cs.Write(static_cast<uint32_t>(numBanners));
|
||||||
|
|
||||||
[[maybe_unused]] size_t numWritten = 0;
|
[[maybe_unused]] size_t numWritten = 0;
|
||||||
for (BannerIndex i = 0; i < MAX_BANNERS; i++)
|
for (BannerIndex::UnderlyingType i = 0; i < MAX_BANNERS; i++)
|
||||||
{
|
{
|
||||||
auto banner = GetBanner(i);
|
auto banner = GetBanner(BannerIndex::FromUnderlying(i));
|
||||||
if (banner != nullptr)
|
if (banner != nullptr)
|
||||||
{
|
{
|
||||||
ReadWriteBanner(version, cs, *banner);
|
ReadWriteBanner(version, cs, *banner);
|
||||||
|
@ -1001,9 +1001,9 @@ namespace OpenRCT2
|
||||||
{
|
{
|
||||||
std::vector<Banner> banners;
|
std::vector<Banner> banners;
|
||||||
cs.ReadWriteVector(banners, [version, &cs](Banner& banner) { ReadWriteBanner(version, cs, banner); });
|
cs.ReadWriteVector(banners, [version, &cs](Banner& banner) { ReadWriteBanner(version, cs, banner); });
|
||||||
for (size_t i = 0; i < banners.size(); i++)
|
for (BannerIndex::UnderlyingType i = 0; i < banners.size(); i++)
|
||||||
{
|
{
|
||||||
auto bannerIndex = static_cast<BannerIndex>(i);
|
auto bannerIndex = BannerIndex::FromUnderlying(i);
|
||||||
auto banner = GetOrCreateBanner(bannerIndex);
|
auto banner = GetOrCreateBanner(bannerIndex);
|
||||||
if (banner != nullptr)
|
if (banner != nullptr)
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
struct BannerPlaceActionResult
|
struct BannerPlaceActionResult
|
||||||
{
|
{
|
||||||
BannerIndex bannerId = BANNER_INDEX_NULL;
|
BannerIndex bannerId = BannerIndex::GetNull();
|
||||||
};
|
};
|
||||||
|
|
||||||
class BannerPlaceAction final : public GameActionBase<GameCommand::PlaceBanner>
|
class BannerPlaceAction final : public GameActionBase<GameCommand::PlaceBanner>
|
||||||
|
|
|
@ -62,7 +62,7 @@ GameActions::Result BannerRemoveAction::Query() const
|
||||||
}
|
}
|
||||||
|
|
||||||
auto bannerIndex = bannerElement->GetIndex();
|
auto bannerIndex = bannerElement->GetIndex();
|
||||||
if (bannerIndex == BANNER_INDEX_NULL)
|
if (bannerIndex == BannerIndex::GetNull())
|
||||||
{
|
{
|
||||||
log_error("Invalid banner index. index = ", bannerIndex);
|
log_error("Invalid banner index. index = ", bannerIndex);
|
||||||
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_REMOVE_THIS, STR_NONE);
|
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_REMOVE_THIS, STR_NONE);
|
||||||
|
@ -101,7 +101,7 @@ GameActions::Result BannerRemoveAction::Execute() const
|
||||||
}
|
}
|
||||||
|
|
||||||
auto bannerIndex = bannerElement->GetIndex();
|
auto bannerIndex = bannerElement->GetIndex();
|
||||||
if (bannerIndex == BANNER_INDEX_NULL)
|
if (bannerIndex == BannerIndex::GetNull())
|
||||||
{
|
{
|
||||||
log_error("Invalid banner index. index = ", bannerIndex);
|
log_error("Invalid banner index. index = ", bannerIndex);
|
||||||
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_REMOVE_THIS, STR_NONE);
|
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_REMOVE_THIS, STR_NONE);
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
class BannerSetNameAction final : public GameActionBase<GameCommand::SetBannerName>
|
class BannerSetNameAction final : public GameActionBase<GameCommand::SetBannerName>
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
BannerIndex _bannerIndex{ BANNER_INDEX_NULL };
|
BannerIndex _bannerIndex{ BannerIndex::GetNull() };
|
||||||
std::string _name;
|
std::string _name;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -25,7 +25,7 @@ class BannerSetStyleAction final : public GameActionBase<GameCommand::SetBannerS
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
BannerSetStyleType _type{ BannerSetStyleType::Count };
|
BannerSetStyleType _type{ BannerSetStyleType::Count };
|
||||||
BannerIndex _bannerIndex{ BANNER_INDEX_NULL };
|
BannerIndex _bannerIndex{ BannerIndex::GetNull() };
|
||||||
uint8_t _parameter{};
|
uint8_t _parameter{};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include "../Game.h"
|
#include "../Game.h"
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
#include "../core/DataSerialiser.h"
|
#include "../core/DataSerialiser.h"
|
||||||
|
#include "../core/Identifier.hpp"
|
||||||
#include "../localisation/StringIds.h"
|
#include "../localisation/StringIds.h"
|
||||||
#include "GameActionResult.h"
|
#include "GameActionResult.h"
|
||||||
|
|
||||||
|
@ -86,6 +87,13 @@ public:
|
||||||
param = static_cast<T>(value);
|
param = static_cast<T>(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T, T TNull, typename TTag> void Visit(std::string_view name, TIdentifier<T, TNull, TTag>& param)
|
||||||
|
{
|
||||||
|
auto value = param.ToUnderlying();
|
||||||
|
Visit(name, value);
|
||||||
|
param = TIdentifier<T, TNull, TTag>::FromUnderlying(value);
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T, size_t _TypeID> void Visit(std::string_view name, NetworkObjectId_t<T, _TypeID>& param)
|
template<typename T, size_t _TypeID> void Visit(std::string_view name, NetworkObjectId_t<T, _TypeID>& param)
|
||||||
{
|
{
|
||||||
Visit(name, param.id);
|
Visit(name, param.id);
|
||||||
|
|
|
@ -17,7 +17,7 @@ struct LargeSceneryPlaceActionResult
|
||||||
{
|
{
|
||||||
uint8_t GroundFlags{ 0 };
|
uint8_t GroundFlags{ 0 };
|
||||||
int32_t firstTileHeight{ 0 };
|
int32_t firstTileHeight{ 0 };
|
||||||
BannerIndex bannerId = BANNER_INDEX_NULL;
|
BannerIndex bannerId = BannerIndex::GetNull();
|
||||||
};
|
};
|
||||||
|
|
||||||
class LargeSceneryPlaceAction final : public GameActionBase<GameCommand::PlaceLargeScenery>
|
class LargeSceneryPlaceAction final : public GameActionBase<GameCommand::PlaceLargeScenery>
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
class SignSetNameAction final : public GameActionBase<GameCommand::SetSignName>
|
class SignSetNameAction final : public GameActionBase<GameCommand::SetSignName>
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
BannerIndex _bannerIndex{ BANNER_INDEX_NULL };
|
BannerIndex _bannerIndex{ BannerIndex::GetNull() };
|
||||||
std::string _name;
|
std::string _name;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
class SignSetStyleAction final : public GameActionBase<GameCommand::SetSignStyle>
|
class SignSetStyleAction final : public GameActionBase<GameCommand::SetSignStyle>
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
BannerIndex _bannerIndex{ BANNER_INDEX_NULL };
|
BannerIndex _bannerIndex{ BannerIndex::GetNull() };
|
||||||
uint8_t _mainColour{};
|
uint8_t _mainColour{};
|
||||||
uint8_t _textColour{};
|
uint8_t _textColour{};
|
||||||
bool _isLarge{};
|
bool _isLarge{};
|
||||||
|
|
|
@ -371,7 +371,7 @@ GameActions::Result WallPlaceAction::Execute() const
|
||||||
wallElement->SetAcrossTrack(wallAcrossTrack);
|
wallElement->SetAcrossTrack(wallAcrossTrack);
|
||||||
|
|
||||||
wallElement->SetEntryIndex(_wallType);
|
wallElement->SetEntryIndex(_wallType);
|
||||||
wallElement->SetBannerIndex(banner != nullptr ? banner->id : BANNER_INDEX_NULL);
|
wallElement->SetBannerIndex(banner != nullptr ? banner->id : BannerIndex::GetNull());
|
||||||
|
|
||||||
if (wallEntry->flags & WALL_SCENERY_HAS_TERNARY_COLOUR)
|
if (wallEntry->flags & WALL_SCENERY_HAS_TERNARY_COLOUR)
|
||||||
{
|
{
|
||||||
|
@ -385,7 +385,7 @@ GameActions::Result WallPlaceAction::Execute() const
|
||||||
|
|
||||||
res.Cost = wallEntry->price;
|
res.Cost = wallEntry->price;
|
||||||
|
|
||||||
const auto bannerId = banner != nullptr ? banner->id : BANNER_INDEX_NULL;
|
const auto bannerId = banner != nullptr ? banner->id : BannerIndex::GetNull();
|
||||||
res.SetData(WallPlaceActionResult{ wallElement->GetBaseZ(), bannerId });
|
res.SetData(WallPlaceActionResult{ wallElement->GetBaseZ(), bannerId });
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
struct WallPlaceActionResult
|
struct WallPlaceActionResult
|
||||||
{
|
{
|
||||||
int32_t BaseHeight{};
|
int32_t BaseHeight{};
|
||||||
BannerIndex BannerId = BANNER_INDEX_NULL;
|
BannerIndex BannerId = BannerIndex::GetNull();
|
||||||
};
|
};
|
||||||
|
|
||||||
class WallPlaceAction final : public GameActionBase<GameCommand::PlaceWall>
|
class WallPlaceAction final : public GameActionBase<GameCommand::PlaceWall>
|
||||||
|
|
|
@ -839,3 +839,24 @@ template<> struct DataSerializerTraits_t<TileCoordsXYZD>
|
||||||
stream->Write(msg, strlen(msg));
|
stream->Write(msg, strlen(msg));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename T, T TNull, typename TTag> struct DataSerializerTraits_t<TIdentifier<T, TNull, TTag>>
|
||||||
|
{
|
||||||
|
static void encode(OpenRCT2::IStream* stream, const TIdentifier<T, TNull, TTag>& id)
|
||||||
|
{
|
||||||
|
stream->WriteValue(ByteSwapBE(id.ToUnderlying()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void decode(OpenRCT2::IStream* stream, TIdentifier<T, TNull, TTag>& id)
|
||||||
|
{
|
||||||
|
auto temp = ByteSwapBE(stream->ReadValue<T>());
|
||||||
|
id = TIdentifier<T, TNull, TTag>::FromUnderlying(temp);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void log(OpenRCT2::IStream* stream, const TIdentifier<T, TNull, TTag>& id)
|
||||||
|
{
|
||||||
|
char msg[128] = {};
|
||||||
|
snprintf(msg, sizeof(msg), "Id(%u)", static_cast<uint32_t>(id.ToUnderlying()));
|
||||||
|
stream->Write(msg, strlen(msg));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
|
@ -32,6 +32,8 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
using UnderlyingType = T;
|
||||||
|
|
||||||
constexpr TIdentifier() = default;
|
constexpr TIdentifier() = default;
|
||||||
|
|
||||||
static constexpr TIdentifier GetNull() noexcept
|
static constexpr TIdentifier GetNull() noexcept
|
||||||
|
@ -63,4 +65,14 @@ public:
|
||||||
{
|
{
|
||||||
return _handle != other;
|
return _handle != other;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr bool operator==(const TIdentifier& other) const noexcept
|
||||||
|
{
|
||||||
|
return _handle == other._handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr bool operator!=(const TIdentifier& other) const noexcept
|
||||||
|
{
|
||||||
|
return _handle != other._handle;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include "../world/Location.hpp"
|
#include "../world/Location.hpp"
|
||||||
#include "Crypt.h"
|
#include "Crypt.h"
|
||||||
#include "FileStream.h"
|
#include "FileStream.h"
|
||||||
|
#include "Identifier.hpp"
|
||||||
#include "MemoryStream.h"
|
#include "MemoryStream.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
@ -312,6 +313,21 @@ namespace OpenRCT2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T, T TNullValue, typename TTag> void ReadWrite(TIdentifier<T, TNullValue, TTag>& value)
|
||||||
|
{
|
||||||
|
if (_mode == Mode::READING)
|
||||||
|
{
|
||||||
|
T temp{};
|
||||||
|
ReadWrite(temp);
|
||||||
|
value = TIdentifier<T, TNullValue, TTag>::FromUnderlying(temp);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto temp = value.ToUnderlying();
|
||||||
|
ReadWrite(temp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ReadWrite(bool& value)
|
void ReadWrite(bool& value)
|
||||||
{
|
{
|
||||||
uint8_t value8 = value ? 1 : 0;
|
uint8_t value8 = value ? 1 : 0;
|
||||||
|
|
|
@ -1790,7 +1790,7 @@ namespace RCT1
|
||||||
wallElement->SetPrimaryColour(colourA);
|
wallElement->SetPrimaryColour(colourA);
|
||||||
wallElement->SetSecondaryColour(colourB);
|
wallElement->SetSecondaryColour(colourB);
|
||||||
wallElement->SetTertiaryColour(colourC);
|
wallElement->SetTertiaryColour(colourC);
|
||||||
wallElement->SetBannerIndex(BANNER_INDEX_NULL);
|
wallElement->SetBannerIndex(BannerIndex::GetNull());
|
||||||
wallElement->SetAcrossTrack(false);
|
wallElement->SetAcrossTrack(false);
|
||||||
wallElement->SetAnimationIsBackwards(false);
|
wallElement->SetAnimationIsBackwards(false);
|
||||||
wallElement->SetSlope(edgeSlope);
|
wallElement->SetSlope(edgeSlope);
|
||||||
|
@ -1826,20 +1826,20 @@ namespace RCT1
|
||||||
if (index < std::size(_s4.banners))
|
if (index < std::size(_s4.banners))
|
||||||
{
|
{
|
||||||
auto srcBanner = &_s4.banners[index];
|
auto srcBanner = &_s4.banners[index];
|
||||||
auto dstBanner = GetOrCreateBanner(index);
|
auto dstBanner = GetOrCreateBanner(BannerIndex::FromUnderlying(index));
|
||||||
if (dstBanner == nullptr)
|
if (dstBanner == nullptr)
|
||||||
{
|
{
|
||||||
dst2->SetIndex(BANNER_INDEX_NULL);
|
dst2->SetIndex(BannerIndex::GetNull());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ImportBanner(dstBanner, srcBanner);
|
ImportBanner(dstBanner, srcBanner);
|
||||||
dst2->SetIndex(index);
|
dst2->SetIndex(BannerIndex::FromUnderlying(index));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dst2->SetIndex(BANNER_INDEX_NULL);
|
dst2->SetIndex(BannerIndex::GetNull());
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1364,7 +1364,7 @@ namespace RCT2
|
||||||
dst2->SetAnimationIsBackwards(src2->AnimationIsBackwards());
|
dst2->SetAnimationIsBackwards(src2->AnimationIsBackwards());
|
||||||
|
|
||||||
// Import banner information
|
// Import banner information
|
||||||
dst2->SetBannerIndex(BANNER_INDEX_NULL);
|
dst2->SetBannerIndex(BannerIndex::GetNull());
|
||||||
auto entry = dst2->GetEntry();
|
auto entry = dst2->GetEntry();
|
||||||
if (entry != nullptr && entry->scrolling_mode != SCROLLING_MODE_NONE)
|
if (entry != nullptr && entry->scrolling_mode != SCROLLING_MODE_NONE)
|
||||||
{
|
{
|
||||||
|
@ -1372,15 +1372,15 @@ namespace RCT2
|
||||||
if (bannerIndex < std::size(_s6.banners))
|
if (bannerIndex < std::size(_s6.banners))
|
||||||
{
|
{
|
||||||
auto srcBanner = &_s6.banners[bannerIndex];
|
auto srcBanner = &_s6.banners[bannerIndex];
|
||||||
auto dstBanner = GetOrCreateBanner(bannerIndex);
|
auto dstBanner = GetOrCreateBanner(BannerIndex::FromUnderlying(bannerIndex));
|
||||||
if (dstBanner == nullptr)
|
if (dstBanner == nullptr)
|
||||||
{
|
{
|
||||||
dst2->SetBannerIndex(BANNER_INDEX_NULL);
|
dst2->SetBannerIndex(BannerIndex::GetNull());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ImportBanner(dstBanner, srcBanner);
|
ImportBanner(dstBanner, srcBanner);
|
||||||
dst2->SetBannerIndex(src2->GetBannerIndex());
|
dst2->SetBannerIndex(BannerIndex::FromUnderlying(src2->GetBannerIndex()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1397,7 +1397,7 @@ namespace RCT2
|
||||||
dst2->SetSecondaryColour(src2->GetSecondaryColour());
|
dst2->SetSecondaryColour(src2->GetSecondaryColour());
|
||||||
|
|
||||||
// Import banner information
|
// Import banner information
|
||||||
dst2->SetBannerIndex(BANNER_INDEX_NULL);
|
dst2->SetBannerIndex(BannerIndex::GetNull());
|
||||||
auto entry = dst2->GetEntry();
|
auto entry = dst2->GetEntry();
|
||||||
if (entry != nullptr && entry->scrolling_mode != SCROLLING_MODE_NONE)
|
if (entry != nullptr && entry->scrolling_mode != SCROLLING_MODE_NONE)
|
||||||
{
|
{
|
||||||
|
@ -1405,15 +1405,15 @@ namespace RCT2
|
||||||
if (bannerIndex < std::size(_s6.banners))
|
if (bannerIndex < std::size(_s6.banners))
|
||||||
{
|
{
|
||||||
auto srcBanner = &_s6.banners[bannerIndex];
|
auto srcBanner = &_s6.banners[bannerIndex];
|
||||||
auto dstBanner = GetOrCreateBanner(bannerIndex);
|
auto dstBanner = GetOrCreateBanner(BannerIndex::FromUnderlying(bannerIndex));
|
||||||
if (dstBanner == nullptr)
|
if (dstBanner == nullptr)
|
||||||
{
|
{
|
||||||
dst2->SetBannerIndex(BANNER_INDEX_NULL);
|
dst2->SetBannerIndex(BannerIndex::GetNull());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ImportBanner(dstBanner, srcBanner);
|
ImportBanner(dstBanner, srcBanner);
|
||||||
dst2->SetBannerIndex(src2->GetBannerIndex());
|
dst2->SetBannerIndex(BannerIndex::FromUnderlying(src2->GetBannerIndex()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1431,20 +1431,20 @@ namespace RCT2
|
||||||
if (bannerIndex < std::size(_s6.banners))
|
if (bannerIndex < std::size(_s6.banners))
|
||||||
{
|
{
|
||||||
auto srcBanner = &_s6.banners[bannerIndex];
|
auto srcBanner = &_s6.banners[bannerIndex];
|
||||||
auto dstBanner = GetOrCreateBanner(bannerIndex);
|
auto dstBanner = GetOrCreateBanner(BannerIndex::FromUnderlying(bannerIndex));
|
||||||
if (dstBanner == nullptr)
|
if (dstBanner == nullptr)
|
||||||
{
|
{
|
||||||
dst2->SetIndex(BANNER_INDEX_NULL);
|
dst2->SetIndex(BannerIndex::GetNull());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ImportBanner(dstBanner, srcBanner);
|
ImportBanner(dstBanner, srcBanner);
|
||||||
dst2->SetIndex(bannerIndex);
|
dst2->SetIndex(BannerIndex::FromUnderlying(bannerIndex));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dst2->SetIndex(BANNER_INDEX_NULL);
|
dst2->SetIndex(BannerIndex::GetNull());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1034,35 +1034,36 @@ namespace OpenRCT2::Scripting
|
||||||
{
|
{
|
||||||
auto ctx = GetContext()->GetScriptEngine().GetContext();
|
auto ctx = GetContext()->GetScriptEngine().GetContext();
|
||||||
BannerIndex idx = _element->GetBannerIndex();
|
BannerIndex idx = _element->GetBannerIndex();
|
||||||
if (idx == BANNER_INDEX_NULL)
|
if (idx == BannerIndex::GetNull())
|
||||||
duk_push_null(ctx);
|
duk_push_null(ctx);
|
||||||
else
|
else
|
||||||
duk_push_int(ctx, idx);
|
duk_push_int(ctx, idx.ToUnderlying());
|
||||||
return DukValue::take_from_stack(ctx);
|
return DukValue::take_from_stack(ctx);
|
||||||
}
|
}
|
||||||
void ScTileElement::bannerIndex_set(uint16_t value)
|
void ScTileElement::bannerIndex_set(uint16_t value)
|
||||||
{
|
{
|
||||||
ThrowIfGameStateNotMutable();
|
ThrowIfGameStateNotMutable();
|
||||||
|
|
||||||
switch (_element->GetType())
|
switch (_element->GetType())
|
||||||
{
|
{
|
||||||
case TILE_ELEMENT_TYPE_LARGE_SCENERY:
|
case TILE_ELEMENT_TYPE_LARGE_SCENERY:
|
||||||
{
|
{
|
||||||
auto el = _element->AsLargeScenery();
|
auto el = _element->AsLargeScenery();
|
||||||
el->SetBannerIndex(value);
|
el->SetBannerIndex(BannerIndex::FromUnderlying(value));
|
||||||
Invalidate();
|
Invalidate();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TILE_ELEMENT_TYPE_WALL:
|
case TILE_ELEMENT_TYPE_WALL:
|
||||||
{
|
{
|
||||||
auto el = _element->AsWall();
|
auto el = _element->AsWall();
|
||||||
el->SetBannerIndex(value);
|
el->SetBannerIndex(BannerIndex::FromUnderlying(value));
|
||||||
Invalidate();
|
Invalidate();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TILE_ELEMENT_TYPE_BANNER:
|
case TILE_ELEMENT_TYPE_BANNER:
|
||||||
{
|
{
|
||||||
auto el = _element->AsBanner();
|
auto el = _element->AsBanner();
|
||||||
el->SetIndex(value);
|
el->SetIndex(BannerIndex::FromUnderlying(value));
|
||||||
Invalidate();
|
Invalidate();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
|
#include "../core/Identifier.hpp"
|
||||||
#include "../interface/Window.h"
|
#include "../interface/Window.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
@ -54,6 +55,12 @@ public:
|
||||||
Intent* putExtra(uint32_t key, int32_t value);
|
Intent* putExtra(uint32_t key, int32_t value);
|
||||||
Intent* putExtra(uint32_t key, std::string value);
|
Intent* putExtra(uint32_t key, std::string value);
|
||||||
Intent* putExtra(uint32_t key, close_callback value);
|
Intent* putExtra(uint32_t key, close_callback value);
|
||||||
|
|
||||||
|
template<typename T, T TNull, typename TTag> Intent* putExtra(uint32_t key, const TIdentifier<T, TNull, TTag>& value)
|
||||||
|
{
|
||||||
|
const auto val = value.ToUnderlying();
|
||||||
|
return putExtra(key, static_cast<uint32_t>(val));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
|
|
|
@ -113,22 +113,22 @@ static ride_id_t banner_get_ride_index_at(const CoordsXYZ& bannerCoords)
|
||||||
|
|
||||||
static BannerIndex BannerGetNewIndex()
|
static BannerIndex BannerGetNewIndex()
|
||||||
{
|
{
|
||||||
for (BannerIndex bannerIndex = 0; bannerIndex < MAX_BANNERS; bannerIndex++)
|
for (BannerIndex::UnderlyingType bannerIndex = 0; bannerIndex < MAX_BANNERS; bannerIndex++)
|
||||||
{
|
{
|
||||||
if (bannerIndex < _banners.size())
|
if (bannerIndex < _banners.size())
|
||||||
{
|
{
|
||||||
if (_banners[bannerIndex].IsNull())
|
if (_banners[bannerIndex].IsNull())
|
||||||
{
|
{
|
||||||
return bannerIndex;
|
return BannerIndex::FromUnderlying(bannerIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_banners.emplace_back();
|
_banners.emplace_back();
|
||||||
return static_cast<BannerIndex>(_banners.size() - 1);
|
return BannerIndex::FromUnderlying(bannerIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return BANNER_INDEX_NULL;
|
return BannerIndex::GetNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -238,12 +238,13 @@ ride_id_t banner_get_closest_ride_index(const CoordsXYZ& mapPos)
|
||||||
|
|
||||||
void banner_reset_broken_index()
|
void banner_reset_broken_index()
|
||||||
{
|
{
|
||||||
for (BannerIndex bannerIndex = 0; bannerIndex < _banners.size(); bannerIndex++)
|
for (BannerIndex::UnderlyingType index = 0; index < _banners.size(); index++)
|
||||||
{
|
{
|
||||||
auto tileElement = banner_get_tile_element(bannerIndex);
|
const auto bannerId = BannerIndex::FromUnderlying(index);
|
||||||
|
auto tileElement = banner_get_tile_element(bannerId);
|
||||||
if (tileElement == nullptr)
|
if (tileElement == nullptr)
|
||||||
{
|
{
|
||||||
auto banner = GetBanner(bannerIndex);
|
auto banner = GetBanner(bannerId);
|
||||||
if (banner != nullptr)
|
if (banner != nullptr)
|
||||||
{
|
{
|
||||||
banner->type = BANNER_NULL;
|
banner->type = BANNER_NULL;
|
||||||
|
@ -266,13 +267,14 @@ void fix_duplicated_banners()
|
||||||
for (auto* bannerElement : OpenRCT2::TileElementsView<BannerElement>(bannerPos))
|
for (auto* bannerElement : OpenRCT2::TileElementsView<BannerElement>(bannerPos))
|
||||||
{
|
{
|
||||||
auto bannerIndex = bannerElement->GetIndex();
|
auto bannerIndex = bannerElement->GetIndex();
|
||||||
if (bannerIndex == BANNER_INDEX_NULL)
|
if (bannerIndex == BannerIndex::GetNull())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (activeBanners[bannerIndex])
|
const auto index = bannerIndex.ToUnderlying();
|
||||||
|
if (activeBanners[index])
|
||||||
{
|
{
|
||||||
log_info(
|
log_info(
|
||||||
"Duplicated banner with index %d found at x = %d, y = %d and z = %d.", bannerIndex, x, y,
|
"Duplicated banner with index %d found at x = %d, y = %d and z = %d.", index, x, y,
|
||||||
bannerElement->base_height);
|
bannerElement->base_height);
|
||||||
|
|
||||||
// Banner index is already in use by another banner, so duplicate it
|
// Banner index is already in use by another banner, so duplicate it
|
||||||
|
@ -282,7 +284,7 @@ void fix_duplicated_banners()
|
||||||
log_error("Failed to create new banner.");
|
log_error("Failed to create new banner.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Guard::Assert(!activeBanners[newBanner->id]);
|
Guard::Assert(!activeBanners[index]);
|
||||||
|
|
||||||
// Copy over the original banner, but update the location
|
// Copy over the original banner, but update the location
|
||||||
const auto* oldBanner = GetBanner(bannerIndex);
|
const auto* oldBanner = GetBanner(bannerIndex);
|
||||||
|
@ -299,7 +301,7 @@ void fix_duplicated_banners()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mark banner index as in-use
|
// Mark banner index as in-use
|
||||||
activeBanners[bannerIndex] = true;
|
activeBanners[index] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -383,9 +385,10 @@ void UnlinkAllBannersForRide(ride_id_t rideId)
|
||||||
|
|
||||||
Banner* GetBanner(BannerIndex id)
|
Banner* GetBanner(BannerIndex id)
|
||||||
{
|
{
|
||||||
if (id < _banners.size())
|
const auto index = id.ToUnderlying();
|
||||||
|
if (index < _banners.size())
|
||||||
{
|
{
|
||||||
auto banner = &_banners[id];
|
auto banner = &_banners[index];
|
||||||
if (banner != nullptr && !banner->IsNull())
|
if (banner != nullptr && !banner->IsNull())
|
||||||
{
|
{
|
||||||
return banner;
|
return banner;
|
||||||
|
@ -396,14 +399,15 @@ Banner* GetBanner(BannerIndex id)
|
||||||
|
|
||||||
Banner* GetOrCreateBanner(BannerIndex id)
|
Banner* GetOrCreateBanner(BannerIndex id)
|
||||||
{
|
{
|
||||||
if (id < MAX_BANNERS)
|
const auto index = id.ToUnderlying();
|
||||||
|
if (index < MAX_BANNERS)
|
||||||
{
|
{
|
||||||
if (id >= _banners.size())
|
if (index >= _banners.size())
|
||||||
{
|
{
|
||||||
_banners.resize(id + 1);
|
_banners.resize(index + 1);
|
||||||
}
|
}
|
||||||
// Create the banner
|
// Create the banner
|
||||||
auto& banner = _banners[id];
|
auto& banner = _banners[index];
|
||||||
banner.id = id;
|
banner.id = id;
|
||||||
return &banner;
|
return &banner;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "../Identifiers.h"
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
#include "../ride/RideTypes.h"
|
#include "../ride/RideTypes.h"
|
||||||
#include "Location.hpp"
|
#include "Location.hpp"
|
||||||
|
@ -19,17 +20,14 @@ class Formatter;
|
||||||
struct TileElement;
|
struct TileElement;
|
||||||
struct WallElement;
|
struct WallElement;
|
||||||
|
|
||||||
using BannerIndex = uint16_t;
|
|
||||||
|
|
||||||
constexpr ObjectEntryIndex BANNER_NULL = OBJECT_ENTRY_INDEX_NULL;
|
constexpr ObjectEntryIndex BANNER_NULL = OBJECT_ENTRY_INDEX_NULL;
|
||||||
constexpr size_t MAX_BANNERS = 8192;
|
constexpr size_t MAX_BANNERS = 8192;
|
||||||
constexpr BannerIndex BANNER_INDEX_NULL = static_cast<BannerIndex>(-1);
|
|
||||||
|
|
||||||
constexpr uint8_t SCROLLING_MODE_NONE = 255;
|
constexpr uint8_t SCROLLING_MODE_NONE = 255;
|
||||||
|
|
||||||
struct Banner
|
struct Banner
|
||||||
{
|
{
|
||||||
BannerIndex id = BANNER_INDEX_NULL;
|
BannerIndex id = BannerIndex::GetNull();
|
||||||
ObjectEntryIndex type = BANNER_NULL;
|
ObjectEntryIndex type = BANNER_NULL;
|
||||||
uint8_t flags{};
|
uint8_t flags{};
|
||||||
std::string text;
|
std::string text;
|
||||||
|
|
|
@ -37,7 +37,7 @@ BannerIndex TileElement::GetBannerIndex() const
|
||||||
{
|
{
|
||||||
auto* sceneryEntry = AsLargeScenery()->GetEntry();
|
auto* sceneryEntry = AsLargeScenery()->GetEntry();
|
||||||
if (sceneryEntry == nullptr || sceneryEntry->scrolling_mode == SCROLLING_MODE_NONE)
|
if (sceneryEntry == nullptr || sceneryEntry->scrolling_mode == SCROLLING_MODE_NONE)
|
||||||
return BANNER_INDEX_NULL;
|
return BannerIndex::GetNull();
|
||||||
|
|
||||||
return AsLargeScenery()->GetBannerIndex();
|
return AsLargeScenery()->GetBannerIndex();
|
||||||
}
|
}
|
||||||
|
@ -45,14 +45,14 @@ BannerIndex TileElement::GetBannerIndex() const
|
||||||
{
|
{
|
||||||
auto* wallEntry = AsWall()->GetEntry();
|
auto* wallEntry = AsWall()->GetEntry();
|
||||||
if (wallEntry == nullptr || wallEntry->scrolling_mode == SCROLLING_MODE_NONE)
|
if (wallEntry == nullptr || wallEntry->scrolling_mode == SCROLLING_MODE_NONE)
|
||||||
return BANNER_INDEX_NULL;
|
return BannerIndex::GetNull();
|
||||||
|
|
||||||
return AsWall()->GetBannerIndex();
|
return AsWall()->GetBannerIndex();
|
||||||
}
|
}
|
||||||
case TILE_ELEMENT_TYPE_BANNER:
|
case TILE_ELEMENT_TYPE_BANNER:
|
||||||
return AsBanner()->GetIndex();
|
return AsBanner()->GetIndex();
|
||||||
default:
|
default:
|
||||||
return BANNER_INDEX_NULL;
|
return BannerIndex::GetNull();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ void TileElement::RemoveBannerEntry()
|
||||||
auto banner = GetBanner(bannerIndex);
|
auto banner = GetBanner(bannerIndex);
|
||||||
if (banner != nullptr)
|
if (banner != nullptr)
|
||||||
{
|
{
|
||||||
window_close_by_number(WC_BANNER, bannerIndex);
|
window_close_by_number(WC_BANNER, bannerIndex.ToUnderlying());
|
||||||
DeleteBanner(banner->id);
|
DeleteBanner(banner->id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -328,7 +328,7 @@ namespace OpenRCT2::TileInspector
|
||||||
{
|
{
|
||||||
// Check if the element to be pasted refers to a banner index
|
// Check if the element to be pasted refers to a banner index
|
||||||
auto bannerIndex = element.GetBannerIndex();
|
auto bannerIndex = element.GetBannerIndex();
|
||||||
if (bannerIndex != BANNER_INDEX_NULL)
|
if (bannerIndex != BannerIndex::GetNull())
|
||||||
{
|
{
|
||||||
// The element to be pasted refers to a banner index - make a copy of it
|
// The element to be pasted refers to a banner index - make a copy of it
|
||||||
auto newBanner = CreateBanner();
|
auto newBanner = CreateBanner();
|
||||||
|
|
Loading…
Reference in New Issue