Merge pull request #24720 from Gymnasiast/refactor/more-constants

More constant renames
This commit is contained in:
Michael Steenbeek authored and GitHub committed 2025-07-04 22:06:21 +02:00
commit 8d56534e46
23 files changed
+208 -199

No files matched your search

+7 -7
View File
@@ -197,7 +197,7 @@ namespace OpenRCT2::Ui::Windows
};
static_assert(std::size(_windowFinancesTabAnimationFrames) == WINDOW_FINANCES_PAGE_COUNT);
static constexpr int32_t EXPENDITURE_COLUMN_WIDTH = 80;
static constexpr int32_t kExpenditureColumnWidth = 80;
static constexpr uint32_t _windowFinancesPageHoldDownWidgets[] = {
(1uLL << WIDX_LOAN_INCREASE) | (1uLL << WIDX_LOAN_DECREASE), // WINDOW_FINANCES_PAGE_SUMMARY
@@ -387,7 +387,7 @@ namespace OpenRCT2::Ui::Windows
{
if (page == WINDOW_FINANCES_PAGE_SUMMARY)
{
return { EXPENDITURE_COLUMN_WIDTH * (SummaryMaxAvailableMonth() + 1), 0 };
return { kExpenditureColumnWidth * (SummaryMaxAvailableMonth() + 1), 0 };
}
return {};
@@ -431,7 +431,7 @@ namespace OpenRCT2::Ui::Windows
ft.Add<StringId>(STR_FINANCES_SUMMARY_MONTH_HEADING);
ft.Add<uint16_t>(monthyear);
DrawTextBasic(
rt, screenCoords + ScreenCoordsXY{ EXPENDITURE_COLUMN_WIDTH, 0 },
rt, screenCoords + ScreenCoordsXY{ kExpenditureColumnWidth, 0 },
monthyear == currentMonthYear ? STR_WINDOW_COLOUR_2_STRINGID : STR_BLACK_STRING, ft,
{ TextUnderline::On, TextAlignment::RIGHT });
screenCoords.y += 14;
@@ -449,7 +449,7 @@ namespace OpenRCT2::Ui::Windows
ft = Formatter();
ft.Add<money64>(expenditure);
DrawTextBasic(
rt, screenCoords + ScreenCoordsXY{ EXPENDITURE_COLUMN_WIDTH, 0 }, format, ft,
rt, screenCoords + ScreenCoordsXY{ kExpenditureColumnWidth, 0 }, format, ft,
{ TextAlignment::RIGHT });
}
screenCoords.y += kTableCellHeight;
@@ -461,14 +461,14 @@ namespace OpenRCT2::Ui::Windows
ft = Formatter();
ft.Add<money64>(profit);
DrawTextBasic(
rt, screenCoords + ScreenCoordsXY{ EXPENDITURE_COLUMN_WIDTH, 0 }, format, ft, { TextAlignment::RIGHT });
rt, screenCoords + ScreenCoordsXY{ kExpenditureColumnWidth, 0 }, format, ft, { TextAlignment::RIGHT });
GfxFillRect(
rt,
{ screenCoords + ScreenCoordsXY{ 10, -2 }, screenCoords + ScreenCoordsXY{ EXPENDITURE_COLUMN_WIDTH, -2 } },
{ screenCoords + ScreenCoordsXY{ 10, -2 }, screenCoords + ScreenCoordsXY{ kExpenditureColumnWidth, -2 } },
PaletteIndex::pi10);
screenCoords.x += EXPENDITURE_COLUMN_WIDTH;
screenCoords.x += kExpenditureColumnWidth;
}
_lastPaintedMonth = currentMonthYear;
+3 -3
View File
@@ -239,7 +239,7 @@ namespace OpenRCT2::Ui::Windows
};
// clang-format off
constexpr int32_t RCT1_LIGHT_OFFSET = 4;
constexpr int32_t kRCT1LightOffset = 4;
static constexpr auto kMainRideWidgets = makeWidgets(
makeWindowShim(kWindowTitle, kWindowSize),
@@ -1684,7 +1684,7 @@ namespace OpenRCT2::Ui::Windows
int32_t minHeight = 180;
if (ThemeGetFlags() & UITHEME_FLAG_USE_LIGHTS_RIDE)
{
minHeight += 20 + RCT1_LIGHT_OFFSET;
minHeight += 20 + kRCT1LightOffset;
auto ride = GetRide(rideId);
if (ride != nullptr)
@@ -2423,7 +2423,7 @@ namespace OpenRCT2::Ui::Windows
}
widgets[WIDX_OPEN_LIGHT].top = widgetHeight;
widgets[WIDX_OPEN_LIGHT].bottom = widgetHeight + 13;
widgetHeight += 14 - 24 + RCT1_LIGHT_OFFSET;
widgetHeight += 14 - 24 + kRCT1LightOffset;
}
else
{
+5 -5
View File
@@ -66,7 +66,7 @@ namespace OpenRCT2::Ui::Windows
);
// clang-format on
constexpr uint16_t TRACK_DESIGN_INDEX_UNLOADED = UINT16_MAX;
constexpr uint16_t kTrackDesignIndexUnloaded = UINT16_MAX;
RideSelection _window_track_list_item;
@@ -151,7 +151,7 @@ namespace OpenRCT2::Ui::Windows
}
else
{
if (_loadedTrackDesignIndex != TRACK_DESIGN_INDEX_UNLOADED
if (_loadedTrackDesignIndex != kTrackDesignIndexUnloaded
&& (_loadedTrackDesign->gameStateData.hasFlag(TrackDesignGameStateFlag::VehicleUnavailable)))
{
ContextShowError(STR_THIS_DESIGN_WILL_BE_BUILT_WITH_AN_ALTERNATIVE_VEHICLE_TYPE, kStringIdNone, {});
@@ -236,7 +236,7 @@ namespace OpenRCT2::Ui::Windows
_trackDesignPreviewPixels.resize(4 * kTrackPreviewImageSize);
_loadedTrackDesign = nullptr;
_loadedTrackDesignIndex = TRACK_DESIGN_INDEX_UNLOADED;
_loadedTrackDesignIndex = kTrackDesignIndexUnloaded;
}
void ReopenTrackManager()
@@ -282,7 +282,7 @@ namespace OpenRCT2::Ui::Windows
break;
case WIDX_TOGGLE_SCENERY:
gTrackDesignSceneryToggle = !gTrackDesignSceneryToggle;
_loadedTrackDesignIndex = TRACK_DESIGN_INDEX_UNLOADED;
_loadedTrackDesignIndex = kTrackDesignIndexUnloaded;
Invalidate();
break;
case WIDX_BACK:
@@ -492,7 +492,7 @@ namespace OpenRCT2::Ui::Windows
}
else
{
_loadedTrackDesignIndex = TRACK_DESIGN_INDEX_UNLOADED;
_loadedTrackDesignIndex = kTrackDesignIndexUnloaded;
}
}
+5 -5
View File
@@ -38,7 +38,7 @@ namespace OpenRCT2::Ui::Windows
static constexpr StringId kWindowTitle = STR_VIEWPORT_NO;
static constexpr ScreenSize kWindowSize = { 200, 200 };
static constexpr ScreenSize VIEWPORT_BUTTON = { 24, 24 };
static constexpr ScreenSize kButtonSize = { 24, 24 };
#pragma endregion
@@ -47,10 +47,10 @@ namespace OpenRCT2::Ui::Windows
makeWindowShim(kWindowTitle, kWindowSize),
makeWidget({ 0, 14}, kWindowSize - ScreenSize( 1, 1), WidgetType::resize, WindowColour::secondary ), // resize
makeWidget({ 3, 17}, kWindowSize - ScreenSize(26, 3), WidgetType::viewport, WindowColour::primary ), // viewport
makeWidget({kWindowSize.width - 25, 17}, VIEWPORT_BUTTON, WidgetType::flatBtn, WindowColour::primary , ImageId(SPR_G2_ZOOM_IN), STR_ZOOM_IN_TIP ), // zoom in
makeWidget({kWindowSize.width - 25, 41}, VIEWPORT_BUTTON, WidgetType::flatBtn, WindowColour::primary , ImageId(SPR_G2_ZOOM_OUT), STR_ZOOM_OUT_TIP ), // zoom out
makeWidget({kWindowSize.width - 25, 65}, VIEWPORT_BUTTON, WidgetType::flatBtn, WindowColour::primary , ImageId(SPR_LOCATE), STR_LOCATE_SUBJECT_TIP), // locate
makeWidget({kWindowSize.width - 25, 89}, VIEWPORT_BUTTON, WidgetType::flatBtn, WindowColour::primary , ImageId(SPR_ROTATE_ARROW),STR_LOCATE_SUBJECT_TIP) // rotate
makeWidget({kWindowSize.width - 25, 17}, kButtonSize, WidgetType::flatBtn, WindowColour::primary , ImageId(SPR_G2_ZOOM_IN), STR_ZOOM_IN_TIP ), // zoom in
makeWidget({kWindowSize.width - 25, 41}, kButtonSize, WidgetType::flatBtn, WindowColour::primary , ImageId(SPR_G2_ZOOM_OUT), STR_ZOOM_OUT_TIP ), // zoom out
makeWidget({kWindowSize.width - 25, 65}, kButtonSize, WidgetType::flatBtn, WindowColour::primary , ImageId(SPR_LOCATE), STR_LOCATE_SUBJECT_TIP), // locate
makeWidget({kWindowSize.width - 25, 89}, kButtonSize, WidgetType::flatBtn, WindowColour::primary , ImageId(SPR_ROTATE_ARROW),STR_LOCATE_SUBJECT_TIP) // rotate
);
// clang-format on
+2 -2
View File
@@ -739,7 +739,7 @@ namespace OpenRCT2
if (String::iequals(Path::GetExtension(path), ".sea"))
{
auto data = DecryptSea(fs::u8path(path));
auto ms = MemoryStream(data.data(), data.size(), MEMORY_ACCESS::READ);
auto ms = MemoryStream(data.data(), data.size(), MemoryAccess::read);
if (!LoadParkFromStream(&ms, path, loadTitleScreenOnFail, asScenario))
{
throw std::runtime_error(".sea file may have been renamed.");
@@ -1088,7 +1088,7 @@ namespace OpenRCT2
break;
}
auto ms = MemoryStream(data.data(), data.size(), MEMORY_ACCESS::READ);
auto ms = MemoryStream(data.data(), data.size(), MemoryAccess::read);
if (!LoadParkFromStream(&ms, gOpenRCT2StartupActionPath, true))
{
Console::Error::WriteLine("Failed to load '%s'", gOpenRCT2StartupActionPath);
+1 -1
View File
@@ -70,7 +70,7 @@ GameActions::Result ParkMarketingAction::Execute() const
MarketingCampaign campaign{};
campaign.Type = _type;
campaign.WeeksLeft = _numWeeks;
campaign.Flags = MarketingCampaignFlags::FIRST_WEEK;
campaign.flags = { MarketingCampaignFlag::firstWeek };
if (campaign.Type == ADVERTISING_CAMPAIGN_RIDE_FREE || campaign.Type == ADVERTISING_CAMPAIGN_RIDE)
{
campaign.RideId = RideId::FromUnderlying(_item);
+10 -10
View File
@@ -421,7 +421,7 @@ public:
void SetPrivate(std::string_view pem) override
{
auto der = ReadPEM(pem, SZ_PRIVATE_BEGIN_TOKEN, SZ_PRIVATE_END_TOKEN);
auto der = ReadPEM(pem, kPrivateKeyBeginToken, kPrivateKeyEndToken);
DerReader derReader(der);
RsaKeyParams params;
derReader.ReadSequenceHeader();
@@ -439,7 +439,7 @@ public:
void SetPublic(std::string_view pem) override
{
auto der = ReadPEM(pem, SZ_PUBLIC_BEGIN_TOKEN, SZ_PUBLIC_END_TOKEN);
auto der = ReadPEM(pem, kPublicKeyBeginToken, kPublicKeyEndToken);
DerReader derReader(der);
RsaKeyParams params;
derReader.ReadSequenceHeader();
@@ -465,9 +465,9 @@ public:
auto b64 = EncodeBase64(derBytes);
std::ostringstream sb;
sb << std::string(SZ_PRIVATE_BEGIN_TOKEN) << std::endl;
sb << std::string(kPrivateKeyBeginToken) << std::endl;
sb << b64;
sb << std::string(SZ_PRIVATE_END_TOKEN) << std::endl;
sb << std::string(kPrivateKeyEndToken) << std::endl;
return sb.str();
}
@@ -481,9 +481,9 @@ public:
auto b64 = EncodeBase64(derBytes);
std::ostringstream sb;
sb << std::string(SZ_PUBLIC_BEGIN_TOKEN) << std::endl;
sb << std::string(kPublicKeyBeginToken) << std::endl;
sb << b64;
sb << std::string(SZ_PUBLIC_END_TOKEN) << std::endl;
sb << std::string(kPublicKeyEndToken) << std::endl;
return sb.str();
}
@@ -506,10 +506,10 @@ public:
}
private:
static constexpr const char* SZ_PUBLIC_BEGIN_TOKEN = "-----BEGIN RSA PUBLIC KEY-----";
static constexpr const char* SZ_PUBLIC_END_TOKEN = "-----END RSA PUBLIC KEY-----";
static constexpr const char* SZ_PRIVATE_BEGIN_TOKEN = "-----BEGIN RSA PRIVATE KEY-----";
static constexpr const char* SZ_PRIVATE_END_TOKEN = "-----END RSA PRIVATE KEY-----";
static constexpr const char* kPublicKeyBeginToken = "-----BEGIN RSA PUBLIC KEY-----";
static constexpr const char* kPublicKeyEndToken = "-----END RSA PUBLIC KEY-----";
static constexpr const char* kPrivateKeyBeginToken = "-----BEGIN RSA PRIVATE KEY-----";
static constexpr const char* kPrivateKeyEndToken = "-----END RSA PRIVATE KEY-----";
BCRYPT_KEY_HANDLE _hKey{};
BCRYPT_KEY_HANDLE _hAlg{};
+5 -5
View File
@@ -22,7 +22,7 @@ namespace OpenRCT2
_dataCapacity = copy._dataCapacity;
_dataSize = copy._dataSize;
if (_access & MEMORY_ACCESS::OWNER)
if (_access.has(MemoryAccess::owner))
{
_data = Memory::Allocate<uint8_t>(_dataCapacity);
std::memcpy(_data, copy._data, _dataCapacity);
@@ -43,7 +43,7 @@ namespace OpenRCT2
std::memcpy(_data, v.data(), v.size());
}
MemoryStream::MemoryStream(void* data, size_t dataSize, uint8_t access)
MemoryStream::MemoryStream(void* data, size_t dataSize, AccessFlags access)
{
_access = access;
_dataCapacity = dataSize;
@@ -66,7 +66,7 @@ namespace OpenRCT2
MemoryStream::~MemoryStream()
{
if (_access & MEMORY_ACCESS::OWNER)
if (_access.has(MemoryAccess::owner))
Memory::Free(_data);
_data = nullptr;
@@ -79,7 +79,7 @@ namespace OpenRCT2
{
if (this != &mv)
{
if (_access & MEMORY_ACCESS::OWNER)
if (_access.has(MemoryAccess::owner))
Memory::Free(_data);
_access = mv._access;
@@ -188,7 +188,7 @@ namespace OpenRCT2
{
if (_position + static_cast<size_t>(length) > _dataCapacity)
{
if (_access & MEMORY_ACCESS::OWNER)
if (_access.has(MemoryAccess::owner))
{
// resize to the larger of the requested capacity and double the current capacity, with a minimum of 8.
size_t newCapacity = std::max(_position + static_cast<size_t>(length), _dataCapacity * 2);
+12 -10
View File
@@ -9,6 +9,7 @@
#pragma once
#include "../core/FlagHolder.hpp"
#include "IStream.hpp"
#include <algorithm>
@@ -17,12 +18,13 @@
namespace OpenRCT2
{
namespace MEMORY_ACCESS
enum class MemoryAccess : uint8_t
{
constexpr uint8_t READ = 1 << 0;
constexpr uint8_t WRITE = 1 << 1;
constexpr uint8_t OWNER = 1 << 2;
}; // namespace MEMORY_ACCESS
read,
write,
owner,
};
using AccessFlags = FlagHolder<uint8_t, MemoryAccess>;
/**
* A stream for reading and writing to a buffer in memory. By default this buffer can grow.
@@ -30,7 +32,7 @@ namespace OpenRCT2
class MemoryStream final : public IStream
{
private:
uint8_t _access = MEMORY_ACCESS::READ | MEMORY_ACCESS::WRITE | MEMORY_ACCESS::OWNER;
AccessFlags _access = { MemoryAccess::read, MemoryAccess::write, MemoryAccess::owner };
size_t _dataCapacity = 0;
size_t _dataSize = 0;
uint8_t* _data = nullptr;
@@ -42,9 +44,9 @@ namespace OpenRCT2
MemoryStream(MemoryStream&& mv) noexcept;
explicit MemoryStream(size_t capacity);
MemoryStream(const std::vector<uint8_t>& v);
MemoryStream(void* data, size_t dataSize, uint8_t access = MEMORY_ACCESS::READ);
MemoryStream(void* data, size_t dataSize, AccessFlags access = { MemoryAccess::read });
MemoryStream(const void* data, size_t dataSize)
: MemoryStream(const_cast<void*>(data), dataSize, MEMORY_ACCESS::READ)
: MemoryStream(const_cast<void*>(data), dataSize, MemoryAccess::read)
{
}
virtual ~MemoryStream();
@@ -62,11 +64,11 @@ namespace OpenRCT2
bool CanRead() const override
{
return (_access & MEMORY_ACCESS::READ) != 0;
return _access.has(MemoryAccess::read);
}
bool CanWrite() const override
{
return (_access & MEMORY_ACCESS::WRITE) != 0;
return _access.has(MemoryAccess::write);
}
uint64_t GetLength() const override
+76 -76
View File
@@ -37,7 +37,7 @@ static uint8_t _spriteFontCharacterWidths[FontStyleCount][SPR_FONTS_GLYPH_COUNT]
TTFFontSetDescriptor* gCurrentTTFFontSet;
#endif // DISABLE_TTF
constexpr uint8_t CS_SPRITE_FONT_OFFSET = 32;
constexpr uint8_t kCSSpriteFontOffset = 32;
static const std::unordered_map<char32_t, int32_t> codepointOffsetMap = {
{ UnicodeChar::ae_uc, SPR_FONTS_AE_UPPER - SPR_FONTS_BEGIN },
@@ -47,38 +47,38 @@ static const std::unordered_map<char32_t, int32_t> codepointOffsetMap = {
{ UnicodeChar::o_stroke, SPR_FONTS_O_STROKE_LOWER - SPR_FONTS_BEGIN },
{ UnicodeChar::y_acute, SPR_FONTS_Y_ACUTE_LOWER - SPR_FONTS_BEGIN },
{ UnicodeChar::a_breve_uc, SPR_FONTS_A_BREVE_UPPER - SPR_FONTS_BEGIN },
{ UnicodeChar::a_breve, 226 - CS_SPRITE_FONT_OFFSET }, // Render as â, no visual difference in the RCT font
{ UnicodeChar::a_ogonek_uc, CSChar::a_ogonek_uc - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::a_ogonek, CSChar::a_ogonek - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::c_acute_uc, CSChar::c_acute_uc - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::c_acute, CSChar::c_acute - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::a_breve, 226 - kCSSpriteFontOffset }, // Render as â, no visual difference in the RCT font
{ UnicodeChar::a_ogonek_uc, CSChar::a_ogonek_uc - kCSSpriteFontOffset },
{ UnicodeChar::a_ogonek, CSChar::a_ogonek - kCSSpriteFontOffset },
{ UnicodeChar::c_acute_uc, CSChar::c_acute_uc - kCSSpriteFontOffset },
{ UnicodeChar::c_acute, CSChar::c_acute - kCSSpriteFontOffset },
{ UnicodeChar::c_caron_uc, SPR_FONTS_C_CARON_UPPER - SPR_FONTS_BEGIN },
{ UnicodeChar::c_caron, SPR_FONTS_C_CARON_LOWER - SPR_FONTS_BEGIN },
{ UnicodeChar::d_caron_uc, SPR_FONTS_D_CARON_UPPER - SPR_FONTS_BEGIN },
{ UnicodeChar::d_caron, SPR_FONTS_D_CARON_LOWER - SPR_FONTS_BEGIN },
{ UnicodeChar::e_ogonek_uc, CSChar::e_ogonek_uc - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::e_ogonek, CSChar::e_ogonek - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::e_ogonek_uc, CSChar::e_ogonek_uc - kCSSpriteFontOffset },
{ UnicodeChar::e_ogonek, CSChar::e_ogonek - kCSSpriteFontOffset },
{ UnicodeChar::e_caron_uc, SPR_FONTS_E_CARON_UPPER - SPR_FONTS_BEGIN },
{ UnicodeChar::e_caron, SPR_FONTS_E_CARON_LOWER - SPR_FONTS_BEGIN },
{ UnicodeChar::g_breve_uc, SPR_FONTS_G_BREVE_UPPER - SPR_FONTS_BEGIN },
{ UnicodeChar::g_breve, SPR_FONTS_G_BREVE_LOWER - SPR_FONTS_BEGIN },
{ UnicodeChar::i_with_dot_uc, SPR_FONTS_I_WITH_DOT_UPPER - SPR_FONTS_BEGIN },
{ UnicodeChar::i_without_dot, SPR_FONTS_I_WITHOUT_DOT_LOWER - SPR_FONTS_BEGIN },
{ UnicodeChar::l_stroke_uc, CSChar::l_stroke_uc - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::l_stroke, CSChar::l_stroke - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::n_acute_uc, CSChar::n_acute_uc - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::n_acute, CSChar::n_acute - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::l_stroke_uc, CSChar::l_stroke_uc - kCSSpriteFontOffset },
{ UnicodeChar::l_stroke, CSChar::l_stroke - kCSSpriteFontOffset },
{ UnicodeChar::n_acute_uc, CSChar::n_acute_uc - kCSSpriteFontOffset },
{ UnicodeChar::n_acute, CSChar::n_acute - kCSSpriteFontOffset },
{ UnicodeChar::n_caron_uc, SPR_FONTS_N_CARON_UPPER - SPR_FONTS_BEGIN },
{ UnicodeChar::n_caron, SPR_FONTS_N_CARON_LOWER - SPR_FONTS_BEGIN },
{ UnicodeChar::o_macron, CSChar::o_circumflex - CS_SPRITE_FONT_OFFSET }, // No visual difference
{ UnicodeChar::o_macron, CSChar::o_circumflex - kCSSpriteFontOffset }, // No visual difference
{ UnicodeChar::o_double_acute_uc, SPR_FONTS_O_DOUBLE_ACUTE_UPPER - SPR_FONTS_BEGIN },
{ UnicodeChar::o_double_acute, SPR_FONTS_O_DOUBLE_ACUTE_LOWER - SPR_FONTS_BEGIN },
{ UnicodeChar::oe_uc, SPR_FONTS_OE_UPPER - SPR_FONTS_BEGIN },
{ UnicodeChar::oe, SPR_FONTS_OE_LOWER - SPR_FONTS_BEGIN },
{ UnicodeChar::r_caron_uc, SPR_FONTS_R_CARON_UPPER - SPR_FONTS_BEGIN },
{ UnicodeChar::r_caron, SPR_FONTS_R_CARON_LOWER - SPR_FONTS_BEGIN },
{ UnicodeChar::s_acute_uc, CSChar::s_acute_uc - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::s_acute, CSChar::s_acute - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::s_acute_uc, CSChar::s_acute_uc - kCSSpriteFontOffset },
{ UnicodeChar::s_acute, CSChar::s_acute - kCSSpriteFontOffset },
{ UnicodeChar::s_cedilla_uc, SPR_FONTS_S_CEDILLA_UPPER - SPR_FONTS_BEGIN },
{ UnicodeChar::s_cedilla, SPR_FONTS_S_CEDILLA_LOWER - SPR_FONTS_BEGIN },
{ UnicodeChar::s_caron_uc, SPR_FONTS_S_CARON_UPPER - SPR_FONTS_BEGIN },
@@ -93,18 +93,18 @@ static const std::unordered_map<char32_t, int32_t> codepointOffsetMap = {
{ UnicodeChar::w_circumflex, SPR_FONTS_W_CIRCUMFLEX_LOWER - SPR_FONTS_BEGIN },
{ UnicodeChar::y_circumflex_uc, SPR_FONTS_Y_CIRCUMFLEX_UPPER - SPR_FONTS_BEGIN },
{ UnicodeChar::y_circumflex, SPR_FONTS_Y_CIRCUMFLEX_LOWER - SPR_FONTS_BEGIN },
{ UnicodeChar::z_acute_uc, CSChar::z_acute_uc - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::z_acute, CSChar::z_acute - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::z_dot_uc, CSChar::z_dot_uc - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::z_dot, CSChar::z_dot - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::z_acute_uc, CSChar::z_acute_uc - kCSSpriteFontOffset },
{ UnicodeChar::z_acute, CSChar::z_acute - kCSSpriteFontOffset },
{ UnicodeChar::z_dot_uc, CSChar::z_dot_uc - kCSSpriteFontOffset },
{ UnicodeChar::z_dot, CSChar::z_dot - kCSSpriteFontOffset },
{ UnicodeChar::z_caron_uc, SPR_FONTS_Z_CARON_UPPER - SPR_FONTS_BEGIN },
{ UnicodeChar::z_caron, SPR_FONTS_Z_CARON_LOWER - SPR_FONTS_BEGIN },
{ UnicodeChar::f_with_hook_uc, 'F' - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::f_with_hook_uc, 'F' - kCSSpriteFontOffset },
{ UnicodeChar::s_comma_uc, SPR_FONTS_S_CEDILLA_UPPER - SPR_FONTS_BEGIN }, // No visual difference
{ UnicodeChar::s_comma, SPR_FONTS_S_CEDILLA_LOWER - SPR_FONTS_BEGIN }, // Ditto
{ UnicodeChar::t_comma_uc, SPR_FONTS_T_COMMA_UPPER - SPR_FONTS_BEGIN },
{ UnicodeChar::t_comma, SPR_FONTS_T_COMMA_LOWER - SPR_FONTS_BEGIN },
{ UnicodeChar::sharp_s_uc, 223 - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::sharp_s_uc, 223 - kCSSpriteFontOffset },
{ UnicodeChar::c_circumflex_uc, SPR_FONTS_C_CIRCUMFLEX_UPPER - SPR_FONTS_BEGIN },
{ UnicodeChar::c_circumflex, SPR_FONTS_C_CIRCUMFLEX_LOWER - SPR_FONTS_BEGIN },
{ UnicodeChar::g_circumflex_uc, SPR_FONTS_G_CIRCUMFLEX_UPPER - SPR_FONTS_BEGIN },
@@ -119,34 +119,34 @@ static const std::unordered_map<char32_t, int32_t> codepointOffsetMap = {
{ UnicodeChar::u_breve, SPR_FONTS_U_BREVE_LOWER - SPR_FONTS_BEGIN },
// Cyrillic alphabet
{ UnicodeChar::cyrillic_io_uc, 203 - CS_SPRITE_FONT_OFFSET }, // Looks just like Ë
{ UnicodeChar::cyrillic_io_uc, 203 - kCSSpriteFontOffset }, // Looks just like Ë
{ UnicodeChar::cyrillic_ukrainian_ie_uc, SPR_FONTS_CYRILLIC_UKRAINIAN_IE_UPPER - SPR_FONTS_BEGIN },
{ UnicodeChar::cyrillic_dze_uc, 'S' - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::cyrillic_dotted_i_uc, 'I' - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::cyrillic_yi_uc, 207 - CS_SPRITE_FONT_OFFSET }, // Looks just like Ï
{ UnicodeChar::cyrillic_je_uc, 'J' - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::cyrillic_a_uc, 'A' - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::cyrillic_dze_uc, 'S' - kCSSpriteFontOffset },
{ UnicodeChar::cyrillic_dotted_i_uc, 'I' - kCSSpriteFontOffset },
{ UnicodeChar::cyrillic_yi_uc, 207 - kCSSpriteFontOffset }, // Looks just like Ï
{ UnicodeChar::cyrillic_je_uc, 'J' - kCSSpriteFontOffset },
{ UnicodeChar::cyrillic_a_uc, 'A' - kCSSpriteFontOffset },
{ UnicodeChar::cyrillic_be_uc, SPR_FONTS_CYRILLIC_BE_UPPER - SPR_FONTS_BEGIN },
{ UnicodeChar::cyrillic_ve_uc, 'B' - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::cyrillic_ve_uc, 'B' - kCSSpriteFontOffset },
{ UnicodeChar::cyrillic_ghe_uc, SPR_FONTS_CYRILLIC_GHE_UPPER - SPR_FONTS_BEGIN },
{ UnicodeChar::cyrillic_de_uc, SPR_FONTS_CYRILLIC_DE_UPPER - SPR_FONTS_BEGIN },
{ UnicodeChar::cyrillic_ie_uc, 'E' - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::cyrillic_ie_uc, 'E' - kCSSpriteFontOffset },
{ UnicodeChar::cyrillic_zhe_uc, SPR_FONTS_CYRILLIC_ZHE_UPPER - SPR_FONTS_BEGIN },
{ UnicodeChar::cyrillic_ze_uc, SPR_FONTS_CYRILLIC_ZE_UPPER - SPR_FONTS_BEGIN },
{ UnicodeChar::cyrillic_i_uc, SPR_FONTS_CYRILLIC_I_UPPER - SPR_FONTS_BEGIN },
{ UnicodeChar::cyrillic_short_i_uc, SPR_FONTS_CYRILLIC_SHORT_I_UPPER - SPR_FONTS_BEGIN },
{ UnicodeChar::cyrillic_ka_uc, 'K' - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::cyrillic_ka_uc, 'K' - kCSSpriteFontOffset },
{ UnicodeChar::cyrillic_el_uc, SPR_FONTS_CYRILLIC_EL_UPPER - SPR_FONTS_BEGIN },
{ UnicodeChar::cyrillic_em_uc, 'M' - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::cyrillic_en_uc, 'H' - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::cyrillic_o_uc, 'O' - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::cyrillic_em_uc, 'M' - kCSSpriteFontOffset },
{ UnicodeChar::cyrillic_en_uc, 'H' - kCSSpriteFontOffset },
{ UnicodeChar::cyrillic_o_uc, 'O' - kCSSpriteFontOffset },
{ UnicodeChar::cyrillic_pe_uc, SPR_FONTS_CYRILLIC_PE_UPPER - SPR_FONTS_BEGIN },
{ UnicodeChar::cyrillic_er_uc, 'P' - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::cyrillic_es_uc, 'C' - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::cyrillic_te_uc, 'T' - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::cyrillic_er_uc, 'P' - kCSSpriteFontOffset },
{ UnicodeChar::cyrillic_es_uc, 'C' - kCSSpriteFontOffset },
{ UnicodeChar::cyrillic_te_uc, 'T' - kCSSpriteFontOffset },
{ UnicodeChar::cyrillic_u_uc, SPR_FONTS_CYRILLIC_U_UPPER - SPR_FONTS_BEGIN },
{ UnicodeChar::cyrillic_ef_uc, SPR_FONTS_CYRILLIC_EF_UPPER - SPR_FONTS_BEGIN },
{ UnicodeChar::cyrillic_ha_uc, 'X' - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::cyrillic_ha_uc, 'X' - kCSSpriteFontOffset },
{ UnicodeChar::cyrillic_tse_uc, SPR_FONTS_CYRILLIC_TSE_UPPER - SPR_FONTS_BEGIN },
{ UnicodeChar::cyrillic_che_uc, SPR_FONTS_CYRILLIC_CHE_UPPER - SPR_FONTS_BEGIN },
{ UnicodeChar::cyrillic_sha_uc, SPR_FONTS_CYRILLIC_SHA_UPPER - SPR_FONTS_BEGIN },
@@ -158,12 +158,12 @@ static const std::unordered_map<char32_t, int32_t> codepointOffsetMap = {
{ UnicodeChar::cyrillic_yu_uc, SPR_FONTS_CYRILLIC_YU_UPPER - SPR_FONTS_BEGIN },
{ UnicodeChar::cyrillic_ya_uc, SPR_FONTS_CYRILLIC_YA_UPPER - SPR_FONTS_BEGIN },
{ UnicodeChar::cyrillic_a, 'a' - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::cyrillic_a, 'a' - kCSSpriteFontOffset },
{ UnicodeChar::cyrillic_be, SPR_FONTS_CYRILLIC_BE_LOWER - SPR_FONTS_BEGIN },
{ UnicodeChar::cyrillic_ve, SPR_FONTS_CYRILLIC_VE_LOWER - SPR_FONTS_BEGIN },
{ UnicodeChar::cyrillic_ghe, SPR_FONTS_CYRILLIC_GHE_LOWER - SPR_FONTS_BEGIN },
{ UnicodeChar::cyrillic_de, SPR_FONTS_CYRILLIC_DE_LOWER - SPR_FONTS_BEGIN },
{ UnicodeChar::cyrillic_ie, 'e' - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::cyrillic_ie, 'e' - kCSSpriteFontOffset },
{ UnicodeChar::cyrillic_zhe, SPR_FONTS_CYRILLIC_ZHE_LOWER - SPR_FONTS_BEGIN },
{ UnicodeChar::cyrillic_ze, SPR_FONTS_CYRILLIC_ZE_LOWER - SPR_FONTS_BEGIN },
{ UnicodeChar::cyrillic_i, SPR_FONTS_CYRILLIC_I_LOWER - SPR_FONTS_BEGIN },
@@ -172,14 +172,14 @@ static const std::unordered_map<char32_t, int32_t> codepointOffsetMap = {
{ UnicodeChar::cyrillic_el, SPR_FONTS_CYRILLIC_EL_LOWER - SPR_FONTS_BEGIN },
{ UnicodeChar::cyrillic_em, SPR_FONTS_CYRILLIC_EM_LOWER - SPR_FONTS_BEGIN },
{ UnicodeChar::cyrillic_en, SPR_FONTS_CYRILLIC_EN_LOWER - SPR_FONTS_BEGIN },
{ UnicodeChar::cyrillic_o, 'o' - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::cyrillic_o, 'o' - kCSSpriteFontOffset },
{ UnicodeChar::cyrillic_pe, SPR_FONTS_CYRILLIC_PE_LOWER - SPR_FONTS_BEGIN },
{ UnicodeChar::cyrillic_er, 'p' - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::cyrillic_es, 'c' - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::cyrillic_er, 'p' - kCSSpriteFontOffset },
{ UnicodeChar::cyrillic_es, 'c' - kCSSpriteFontOffset },
{ UnicodeChar::cyrillic_te, SPR_FONTS_CYRILLIC_TE_LOWER - SPR_FONTS_BEGIN },
{ UnicodeChar::cyrillic_u, 'y' - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::cyrillic_u, 'y' - kCSSpriteFontOffset },
{ UnicodeChar::cyrillic_ef, SPR_FONTS_CYRILLIC_EF_LOWER - SPR_FONTS_BEGIN },
{ UnicodeChar::cyrillic_ha, 'x' - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::cyrillic_ha, 'x' - kCSSpriteFontOffset },
{ UnicodeChar::cyrillic_tse, SPR_FONTS_CYRILLIC_TSE_LOWER - SPR_FONTS_BEGIN },
{ UnicodeChar::cyrillic_che, SPR_FONTS_CYRILLIC_CHE_LOWER - SPR_FONTS_BEGIN },
{ UnicodeChar::cyrillic_sha, SPR_FONTS_CYRILLIC_SHA_LOWER - SPR_FONTS_BEGIN },
@@ -190,12 +190,12 @@ static const std::unordered_map<char32_t, int32_t> codepointOffsetMap = {
{ UnicodeChar::cyrillic_e, SPR_FONTS_CYRILLIC_E_LOWER - SPR_FONTS_BEGIN },
{ UnicodeChar::cyrillic_yu, SPR_FONTS_CYRILLIC_YU_LOWER - SPR_FONTS_BEGIN },
{ UnicodeChar::cyrillic_ya, SPR_FONTS_CYRILLIC_YA_LOWER - SPR_FONTS_BEGIN },
{ UnicodeChar::cyrillic_io, 235 - CS_SPRITE_FONT_OFFSET }, // Looks just like ë
{ UnicodeChar::cyrillic_io, 235 - kCSSpriteFontOffset }, // Looks just like ë
{ UnicodeChar::cyrillic_ukrainian_ie, SPR_FONTS_CYRILLIC_UKRAINIAN_IE_LOWER - SPR_FONTS_BEGIN },
{ UnicodeChar::cyrillic_dze, 's' - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::cyrillic_dotted_i, 'i' - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::cyrillic_yi, 239 - CS_SPRITE_FONT_OFFSET }, // Looks just like ï
{ UnicodeChar::cyrillic_je, 'J' - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::cyrillic_dze, 's' - kCSSpriteFontOffset },
{ UnicodeChar::cyrillic_dotted_i, 'i' - kCSSpriteFontOffset },
{ UnicodeChar::cyrillic_yi, 239 - kCSSpriteFontOffset }, // Looks just like ï
{ UnicodeChar::cyrillic_je, 'J' - kCSSpriteFontOffset },
{ UnicodeChar::cyrillic_ghe_upturn_uc, SPR_FONTS_CYRILLIC_GHE_UPTURN_UPPER - SPR_FONTS_BEGIN },
{ UnicodeChar::cyrillic_ghe_upturn, SPR_FONTS_CYRILLIC_GHE_UPTURN_LOWER - SPR_FONTS_BEGIN },
@@ -204,47 +204,47 @@ static const std::unordered_map<char32_t, int32_t> codepointOffsetMap = {
{ UnicodeChar::vertical_bar, SPR_FONTS_VERTICAL_BAR - SPR_FONTS_BEGIN },
{ UnicodeChar::right_brace, SPR_FONTS_RIGHT_BRACE - SPR_FONTS_BEGIN },
{ UnicodeChar::tilde, SPR_FONTS_TILDE - SPR_FONTS_BEGIN },
{ UnicodeChar::non_breaking_space, ' ' - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::non_breaking_space, ' ' - kCSSpriteFontOffset },
{ UnicodeChar::interpunct, SPR_FONTS_INTERPUNCT - SPR_FONTS_BEGIN },
{ UnicodeChar::multiplication_sign, CSChar::cross - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::en_dash, '-' - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::em_dash, '-' - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::single_quote_open, '`' - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::single_quote_end, '\'' - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::single_german_quote_open, ',' - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::multiplication_sign, CSChar::cross - kCSSpriteFontOffset },
{ UnicodeChar::en_dash, '-' - kCSSpriteFontOffset },
{ UnicodeChar::em_dash, '-' - kCSSpriteFontOffset },
{ UnicodeChar::single_quote_open, '`' - kCSSpriteFontOffset },
{ UnicodeChar::single_quote_end, '\'' - kCSSpriteFontOffset },
{ UnicodeChar::single_german_quote_open, ',' - kCSSpriteFontOffset },
{ UnicodeChar::german_quote_open, SPR_FONTS_GERMAN_OPENQUOTES - SPR_FONTS_BEGIN },
{ UnicodeChar::bullet, CSChar::bullet - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::bullet, CSChar::bullet - kCSSpriteFontOffset },
{ UnicodeChar::ellipsis, SPR_FONTS_ELLIPSIS - SPR_FONTS_BEGIN },
{ UnicodeChar::narrow_non_breaking_space, ' ' - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::quote_open, CSChar::quote_open - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::quote_close, CSChar::quote_close - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::narrow_non_breaking_space, ' ' - kCSSpriteFontOffset },
{ UnicodeChar::quote_open, CSChar::quote_open - kCSSpriteFontOffset },
{ UnicodeChar::quote_close, CSChar::quote_close - kCSSpriteFontOffset },
// Currency
{ UnicodeChar::guilder, SPR_FONTS_GUILDER_SIGN - SPR_FONTS_BEGIN },
{ UnicodeChar::euro, CSChar::euro - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::euro, CSChar::euro - kCSSpriteFontOffset },
{ UnicodeChar::rouble, SPR_FONTS_ROUBLE_SIGN - SPR_FONTS_BEGIN },
// Dingbats
{ UnicodeChar::up, CSChar::up - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::small_up, CSChar::small_up - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::right, CSChar::right - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::down, CSChar::down - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::small_down, CSChar::small_down - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::left, CSChar::left - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::air, CSChar::air - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::tick, CSChar::tick - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::plus, '+' - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::minus, '-' - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::up, CSChar::up - kCSSpriteFontOffset },
{ UnicodeChar::small_up, CSChar::small_up - kCSSpriteFontOffset },
{ UnicodeChar::right, CSChar::right - kCSSpriteFontOffset },
{ UnicodeChar::down, CSChar::down - kCSSpriteFontOffset },
{ UnicodeChar::small_down, CSChar::small_down - kCSSpriteFontOffset },
{ UnicodeChar::left, CSChar::left - kCSSpriteFontOffset },
{ UnicodeChar::air, CSChar::air - kCSSpriteFontOffset },
{ UnicodeChar::tick, CSChar::tick - kCSSpriteFontOffset },
{ UnicodeChar::plus, '+' - kCSSpriteFontOffset },
{ UnicodeChar::minus, '-' - kCSSpriteFontOffset },
// Emoji
{ UnicodeChar::cross, CSChar::cross - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::water, CSChar::water - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::cross, CSChar::cross - kCSSpriteFontOffset },
{ UnicodeChar::water, CSChar::water - kCSSpriteFontOffset },
{ UnicodeChar::eye, SPR_FONTS_EYE - SPR_FONTS_BEGIN },
{ UnicodeChar::road, CSChar::road - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::railway, CSChar::railway - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::road, CSChar::road - kCSSpriteFontOffset },
{ UnicodeChar::railway, CSChar::railway - kCSSpriteFontOffset },
// Misc
{ UnicodeChar::superscript_minus_one, CSChar::superscript_minus_one - CS_SPRITE_FONT_OFFSET },
{ UnicodeChar::superscript_minus_one, CSChar::superscript_minus_one - kCSSpriteFontOffset },
};
static char32_t _smallestCodepointValue = 0;
+2 -2
View File
@@ -27,7 +27,7 @@
using namespace OpenRCT2;
// Don't try to load more than language files that exceed 64 MiB
constexpr uint64_t MAX_LANGUAGE_SIZE = 64 * 1024 * 1024;
static constexpr uint64_t kMaxLanguageSize = 64 * 1024 * 1024;
class LanguagePack final : public ILanguagePack
{
@@ -48,7 +48,7 @@ public:
OpenRCT2::FileStream fs = OpenRCT2::FileStream(path, OpenRCT2::FileMode::open);
size_t fileLength = static_cast<size_t>(fs.GetLength());
if (fileLength > MAX_LANGUAGE_SIZE)
if (fileLength > kMaxLanguageSize)
{
throw IOException("Language file too large.");
}
+24 -22
View File
@@ -24,27 +24,29 @@
using namespace OpenRCT2;
constexpr uint8_t NEGATIVE = 0;
constexpr uint8_t POSITIVE = 1;
static constexpr uint8_t AwardPositiveMap[] = {
NEGATIVE, // AwardType::MostUntidy
POSITIVE, // AwardType::MostTidy
POSITIVE, // AwardType::BestRollerCoasters
POSITIVE, // AwardType::BestValue
POSITIVE, // AwardType::MostBeautiful
NEGATIVE, // AwardType::WorstValue
POSITIVE, // AwardType::Safest
POSITIVE, // AwardType::BestStaff
POSITIVE, // AwardType::BestFood
NEGATIVE, // AwardType::WorstFood
POSITIVE, // AwardType::BestToilets
NEGATIVE, // AwardType::MostDisappointing
POSITIVE, // AwardType::BestWaterRides
POSITIVE, // AwardType::BestCustomDesignedRides
POSITIVE, // AwardType::MostDazzlingRideColours
NEGATIVE, // AwardType::MostConfusingLayout
POSITIVE, // AwardType::BestGentleRides
enum class AwardEffect : uint8_t
{
negative,
positive
};
static constexpr AwardEffect kAwardPositiveMap[] = {
AwardEffect::negative, // AwardType::MostUntidy
AwardEffect::positive, // AwardType::MostTidy
AwardEffect::positive, // AwardType::BestRollerCoasters
AwardEffect::positive, // AwardType::BestValue
AwardEffect::positive, // AwardType::MostBeautiful
AwardEffect::negative, // AwardType::WorstValue
AwardEffect::positive, // AwardType::Safest
AwardEffect::positive, // AwardType::BestStaff
AwardEffect::positive, // AwardType::BestFood
AwardEffect::negative, // AwardType::WorstFood
AwardEffect::positive, // AwardType::BestToilets
AwardEffect::negative, // AwardType::MostDisappointing
AwardEffect::positive, // AwardType::BestWaterRides
AwardEffect::positive, // AwardType::BestCustomDesignedRides
AwardEffect::positive, // AwardType::MostDazzlingRideColours
AwardEffect::negative, // AwardType::MostConfusingLayout
AwardEffect::positive, // AwardType::BestGentleRides
};
static constexpr StringId AwardNewsStrings[] = {
@@ -69,7 +71,7 @@ static constexpr StringId AwardNewsStrings[] = {
bool AwardIsPositive(AwardType type)
{
return AwardPositiveMap[EnumValue(type)];
return kAwardPositiveMap[EnumValue(type)] == AwardEffect::positive;
}
#pragma region Award checks
+2 -2
View File
@@ -120,11 +120,11 @@ void MarketingUpdate()
for (auto it = gameState.marketingCampaigns.begin(); it != gameState.marketingCampaigns.end();)
{
auto& campaign = *it;
if (campaign.Flags & MarketingCampaignFlags::FIRST_WEEK)
if (campaign.flags.has(MarketingCampaignFlag::firstWeek))
{
// This ensures the campaign is active for x full weeks if started within the
// middle of a week.
campaign.Flags &= ~MarketingCampaignFlags::FIRST_WEEK;
campaign.flags.unset(MarketingCampaignFlag::firstWeek);
}
else if (campaign.WeeksLeft > 0)
{
+11 -6
View File
@@ -10,6 +10,7 @@
#pragma once
#include "../Cheats.h"
#include "../core/FlagHolder.hpp"
#include "../localisation/StringIdType.h"
#include "../ride/RideTypes.h"
#include "../ride/ShopItem.h"
@@ -41,11 +42,20 @@ enum
CAMPAIGN_ACTIVE_FLAG = (1 << 7)
};
namespace OpenRCT2
{
enum class MarketingCampaignFlag : uint8_t
{
firstWeek,
};
using MarketingCampaignFlags = FlagHolder<uint8_t, MarketingCampaignFlag>;
} // namespace OpenRCT2
struct MarketingCampaign
{
uint8_t Type{};
uint8_t WeeksLeft{};
uint8_t Flags{};
OpenRCT2::MarketingCampaignFlags flags{};
union
{
::RideId RideId{};
@@ -53,11 +63,6 @@ struct MarketingCampaign
};
};
namespace OpenRCT2::MarketingCampaignFlags
{
constexpr uint8_t FIRST_WEEK = 1 << 0;
}
extern const money64 AdvertisingCampaignPricePerWeek[ADVERTISING_CAMPAIGN_COUNT];
extern const StringId kMarketingCampaignNames[ADVERTISING_CAMPAIGN_COUNT][3];
+5 -5
View File
@@ -30,9 +30,9 @@ namespace
{
using namespace std::chrono_literals;
constexpr const char* APPLICATION_ID = "378612438200877056";
constexpr const char* STEAM_APP_ID = nullptr;
constexpr auto REFRESH_INTERVAL = 5.0s;
constexpr const char* kApplicationID = "378612438200877056";
constexpr const char* kSteamAppID = nullptr;
constexpr auto kRefreshInterval = 5.0s;
} // namespace
static void OnReady([[maybe_unused]] const DiscordUser* request)
@@ -56,7 +56,7 @@ DiscordService::DiscordService()
handlers.ready = OnReady;
handlers.disconnected = OnDisconnected;
handlers.errored = OnErrored;
Discord_Initialize(APPLICATION_ID, &handlers, 1, STEAM_APP_ID);
Discord_Initialize(kApplicationID, &handlers, 1, kSteamAppID);
}
DiscordService::~DiscordService()
@@ -74,7 +74,7 @@ void DiscordService::Tick()
{
Discord_RunCallbacks();
if (_updateTimer.GetElapsedTime() < REFRESH_INTERVAL)
if (_updateTimer.GetElapsedTime() < kRefreshInterval)
return;
RefreshPresence();
+2 -2
View File
@@ -2400,8 +2400,8 @@ void NetworkBase::Client_Handle_OBJECTS_LIST(NetworkConnection& connection, Netw
uint32_t totalObjects = 0;
packet >> index >> totalObjects;
static constexpr uint32_t OBJECT_START_INDEX = 0;
if (index == OBJECT_START_INDEX)
static constexpr uint32_t kObjectStartIndex = 0;
if (index == kObjectStartIndex)
{
_missingObjects.clear();
}
+4 -4
View File
@@ -268,8 +268,8 @@ std::future<std::vector<ServerListEntry>> ServerList::FetchLocalServerListAsync(
{
auto broadcastAddress = broadcastEndpoint.GetHostname();
return std::async(std::launch::async, [broadcastAddress] {
constexpr auto RECV_DELAY_MS = 10;
constexpr auto RECV_WAIT_MS = 2000;
constexpr auto kReceiveDelayInMs = 10;
constexpr auto kReceiveWaitInMs = 2000;
std::string_view msg = kNetworkLanBroadcastMsg;
auto udpSocket = CreateUdpSocket();
@@ -282,7 +282,7 @@ std::future<std::vector<ServerListEntry>> ServerList::FetchLocalServerListAsync(
}
std::vector<ServerListEntry> entries;
for (int i = 0; i < (RECV_WAIT_MS / RECV_DELAY_MS); i++)
for (int i = 0; i < (kReceiveWaitInMs / kReceiveDelayInMs); i++)
{
try
{
@@ -314,7 +314,7 @@ std::future<std::vector<ServerListEntry>> ServerList::FetchLocalServerListAsync(
{
LOG_WARNING("Error receiving data: %s", e.what());
}
Platform::Sleep(RECV_DELAY_MS);
Platform::Sleep(kReceiveDelayInMs);
}
return entries;
});
+1 -1
View File
@@ -947,7 +947,7 @@ namespace OpenRCT2
cs.ReadWriteVector(gameState.marketingCampaigns, [&cs](MarketingCampaign& campaign) {
cs.ReadWrite(campaign.Type);
cs.ReadWrite(campaign.WeeksLeft);
cs.ReadWrite(campaign.Flags);
cs.ReadWrite(campaign.flags.holder);
cs.ReadWrite(campaign.RideId);
});
+2 -2
View File
@@ -32,7 +32,7 @@
#include <unistd.h>
// The name of the mutex used to prevent multiple instances of the game from running
static constexpr const utf8* SINGLE_INSTANCE_MUTEX_NAME = u8"openrct2.lock";
static constexpr const utf8* kSingleInstanceMutexName = u8"openrct2.lock";
namespace OpenRCT2::Platform
{
@@ -308,7 +308,7 @@ namespace OpenRCT2::Platform
// take care of that, because flock keeps the lock as long as the
// file is open and closes it automatically on file close.
// This is intentional.
int32_t pidFile = open(SINGLE_INSTANCE_MUTEX_NAME, O_CREAT | O_RDWR, 0666);
int32_t pidFile = open(kSingleInstanceMutexName, O_CREAT | O_RDWR, 0666);
if (pidFile == -1)
{
+2 -2
View File
@@ -47,7 +47,7 @@
linker, \
"\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
// The name of the mutex used to prevent multiple instances of the game from running
static constexpr wchar_t SINGLE_INSTANCE_MUTEX_NAME[] = L"RollerCoaster Tycoon 2_GSKMUTEX";
static constexpr wchar_t kSingleInstanceMutexName[] = L"RollerCoaster Tycoon 2_GSKMUTEX";
#define SOFTWARE_CLASSES L"Software\\Classes"
#define MUI_CACHE L"Local Settings\\Software\\Microsoft\\Windows\\Shell\\MuiCache"
@@ -776,7 +776,7 @@ namespace OpenRCT2::Platform
bool LockSingleInstance()
{
// Check if operating system mutex exists
HANDLE mutex = CreateMutexW(nullptr, FALSE, SINGLE_INSTANCE_MUTEX_NAME);
HANDLE mutex = CreateMutexW(nullptr, FALSE, kSingleInstanceMutexName);
if (mutex == nullptr)
{
LOG_ERROR("unable to create mutex");
+2 -2
View File
@@ -874,12 +874,12 @@ namespace OpenRCT2::RCT12
{
size_t GetRCTStringBufferLen(const char* buffer, size_t maxBufferLen)
{
constexpr char MULTIBYTE = static_cast<char>(255);
constexpr char kMultibyte = static_cast<char>(255);
size_t len = 0;
for (size_t i = 0; i < maxBufferLen; i++)
{
auto ch = buffer[i];
if (ch == MULTIBYTE)
if (ch == kMultibyte)
{
i += 2;
+24 -24
View File
@@ -16,13 +16,13 @@
namespace OpenRCT2
{
// Allow chunks to be uncompressed to a maximum of 16 MiB
constexpr size_t MAX_UNCOMPRESSED_CHUNK_SIZE = 16 * 1024 * 1024;
constexpr size_t kMaxUncompressedChunkSize = 16 * 1024 * 1024;
constexpr const char* EXCEPTION_MSG_CORRUPT_CHUNK_SIZE = "Corrupt chunk size.";
constexpr const char* EXCEPTION_MSG_CORRUPT_RLE = "Corrupt RLE compression data.";
constexpr const char* EXCEPTION_MSG_DESTINATION_TOO_SMALL = "Chunk data larger than allocated destination capacity.";
constexpr const char* EXCEPTION_MSG_INVALID_CHUNK_ENCODING = "Invalid chunk encoding.";
constexpr const char* EXCEPTION_MSG_ZERO_SIZED_CHUNK = "Encountered zero-sized chunk.";
constexpr const char* kExceptionMessageCorruptChunkSize = "Corrupt chunk size.";
constexpr const char* kExceptionMessageCorruptRLE = "Corrupt RLE compression data.";
constexpr const char* kExceptionMessageDestinationTooSmall = "Chunk data larger than allocated destination capacity.";
constexpr const char* kExceptionMessageInvalidChunkEncoding = "Invalid chunk encoding.";
constexpr const char* kExceptionMessageZeroSizedChunk = "Encountered zero-sized chunk.";
static MemoryStream DecodeChunk(const void* src, const SawyerCoding::ChunkHeader& header);
@@ -53,8 +53,8 @@ namespace OpenRCT2
try
{
auto header = _stream->ReadValue<SawyerCoding::ChunkHeader>();
if (header.length >= MAX_UNCOMPRESSED_CHUNK_SIZE)
throw SawyerChunkException(EXCEPTION_MSG_CORRUPT_CHUNK_SIZE);
if (header.length >= kMaxUncompressedChunkSize)
throw SawyerChunkException(kExceptionMessageCorruptChunkSize);
switch (header.encoding)
{
@@ -66,19 +66,19 @@ namespace OpenRCT2
auto compressedData = std::make_unique<uint8_t[]>(header.length);
if (_stream->TryRead(compressedData.get(), header.length) != header.length)
{
throw SawyerChunkException(EXCEPTION_MSG_CORRUPT_CHUNK_SIZE);
throw SawyerChunkException(kExceptionMessageCorruptChunkSize);
}
auto buffer = DecodeChunk(compressedData.get(), header);
if (buffer.GetLength() == 0)
{
throw SawyerChunkException(EXCEPTION_MSG_ZERO_SIZED_CHUNK);
throw SawyerChunkException(kExceptionMessageZeroSizedChunk);
}
return std::make_shared<SawyerChunk>(static_cast<SawyerEncoding>(header.encoding), std::move(buffer));
}
default:
throw SawyerChunkException(EXCEPTION_MSG_INVALID_CHUNK_ENCODING);
throw SawyerChunkException(kExceptionMessageInvalidChunkEncoding);
}
}
catch (const std::exception&)
@@ -98,21 +98,21 @@ namespace OpenRCT2
int64_t compressedDataLength64 = _stream->GetLength() - _stream->GetPosition() - 4;
if (compressedDataLength64 < 0 || compressedDataLength64 > std::numeric_limits<uint32_t>::max())
{
throw SawyerChunkException(EXCEPTION_MSG_ZERO_SIZED_CHUNK);
throw SawyerChunkException(kExceptionMessageZeroSizedChunk);
}
uint32_t compressedDataLength = compressedDataLength64;
auto compressedData = std::make_unique<uint8_t[]>(compressedDataLength);
if (_stream->TryRead(compressedData.get(), compressedDataLength) != compressedDataLength)
{
throw SawyerChunkException(EXCEPTION_MSG_CORRUPT_CHUNK_SIZE);
throw SawyerChunkException(kExceptionMessageCorruptChunkSize);
}
SawyerCoding::ChunkHeader header{ CHUNK_ENCODING_RLE, compressedDataLength };
auto buffer = DecodeChunk(compressedData.get(), header);
if (buffer.GetLength() == 0)
{
throw SawyerChunkException(EXCEPTION_MSG_ZERO_SIZED_CHUNK);
throw SawyerChunkException(kExceptionMessageZeroSizedChunk);
}
return std::make_shared<SawyerChunk>(SawyerEncoding::rle, std::move(buffer));
}
@@ -160,11 +160,11 @@ namespace OpenRCT2
if (i >= srcLength)
{
throw SawyerChunkException(EXCEPTION_MSG_CORRUPT_RLE);
throw SawyerChunkException(kExceptionMessageCorruptRLE);
}
if (buf.GetLength() + count > MAX_UNCOMPRESSED_CHUNK_SIZE)
if (buf.GetLength() + count > kMaxUncompressedChunkSize)
{
throw SawyerChunkException(EXCEPTION_MSG_DESTINATION_TOO_SMALL);
throw SawyerChunkException(kExceptionMessageDestinationTooSmall);
}
for (size_t n = 0; n < count; n++)
@@ -178,15 +178,15 @@ namespace OpenRCT2
if (i + 1 >= srcLength)
{
throw SawyerChunkException(EXCEPTION_MSG_CORRUPT_RLE);
throw SawyerChunkException(kExceptionMessageCorruptRLE);
}
if (buf.GetLength() + len > MAX_UNCOMPRESSED_CHUNK_SIZE)
if (buf.GetLength() + len > kMaxUncompressedChunkSize)
{
throw SawyerChunkException(EXCEPTION_MSG_DESTINATION_TOO_SMALL);
throw SawyerChunkException(kExceptionMessageDestinationTooSmall);
}
if (i + 1 + len > srcLength)
{
throw SawyerChunkException(EXCEPTION_MSG_CORRUPT_RLE);
throw SawyerChunkException(kExceptionMessageCorruptRLE);
}
const auto* pos = src8 + i + 1;
@@ -210,7 +210,7 @@ namespace OpenRCT2
{
if (i + 1 >= srcLength)
{
throw SawyerChunkException(EXCEPTION_MSG_CORRUPT_RLE);
throw SawyerChunkException(kExceptionMessageCorruptRLE);
}
i++;
buf.WriteValue(src8[i]);
@@ -224,7 +224,7 @@ namespace OpenRCT2
if (copySrc < static_cast<const uint8_t*>(buf.GetData())
|| copySrc + count > static_cast<const uint8_t*>(buf.GetData()) + buf.GetLength())
{
throw SawyerChunkException(EXCEPTION_MSG_CORRUPT_RLE);
throw SawyerChunkException(kExceptionMessageCorruptRLE);
}
// We need a temporary buffer as the vector might invalidate the pointer.
@@ -279,7 +279,7 @@ namespace OpenRCT2
buf = DecodeChunkRotate(src, header.length);
break;
default:
throw SawyerChunkException(EXCEPTION_MSG_INVALID_CHUNK_ENCODING);
throw SawyerChunkException(kExceptionMessageInvalidChunkEncoding);
}
// Return the stream with the position at the beginning.
+1 -1
View File
@@ -1615,7 +1615,7 @@ namespace OpenRCT2::RCT2
campaign.WeeksLeft = _s6.CampaignWeeksLeft[i] & ~(CAMPAIGN_ACTIVE_FLAG | CAMPAIGN_FIRST_WEEK_FLAG);
if ((_s6.CampaignWeeksLeft[i] & CAMPAIGN_FIRST_WEEK_FLAG) != 0)
{
campaign.Flags |= MarketingCampaignFlags::FIRST_WEEK;
campaign.flags.set(MarketingCampaignFlag::firstWeek);
}
if (campaign.Type == ADVERTISING_CAMPAIGN_RIDE_FREE || campaign.Type == ADVERTISING_CAMPAIGN_RIDE)
{