mirror of https://github.com/OpenRCT2/OpenRCT2.git
* Part of #21421: refactor TUNNEL_MAX_COUNT * Part of #21421: deleted unused OBJECT_SELECTION_NOT_... * Part of #21421: refactor MAX_SERVER_DESCRIPTION_LENGTH * Part of #21421: refactor EXPENDITURE_TABLE_MONTH_COUNT * Part of #21421: refactor FINANCE_GRAPH_SIZE * Part of #21421: refactor NETWORK_STREAM_VERSION and _ID * Part of #21421: MONEY_STRING_MAXLENGTH * Part of #21421: deleted MAX_USER_STRINGS * Part of #21421: refactor USER_STRING_MAX_LENGTH * Part of #21421: deleted USER_STRING_END * Part of #21421: refactor REAL_NAME_START * Part of #21421: refactor REAL_NAME_END * Part of #21421: deleted FONT(X) and FONT_OPENRCT2_SPRITE * Part of #21421: refactor CURRENCY_SYMBOL_MAX_SIZE * Part of #21421: refactor CURRENCY_RATE_MAX_NUM_DIGITS * Part of #21421: refactor SCROLLABLE_ROW_HEIGHT * Part of #21421: refactor ADD_CLAMP_BODY * Part of #21421: applied clang-format to Util.cpp * Part of #21421: incorporate feedback from #21760 * Part of #21421: revert to nbsp in Currency.cpp * Part of #21421: fix merge conflict * Part of #21421: fix more merge conflict * Part of #21421: apply clang format * Part of #21421: using std::numerics for finding bounds * Part of #21421: fix reference to kAddClampBody * Part of #21421: improved on comments about AddClamp func * Part of #21421: apply correct network stream version number * Part of #21421: apply clang-format
This commit is contained in:
parent
24a2db9fc9
commit
10a5d790c6
|
@ -52,7 +52,7 @@ static Widget WindowAssetPacksWidgets[] = {
|
|||
class AssetPacksWindow final : public Window
|
||||
{
|
||||
private:
|
||||
static constexpr int32_t ItemHeight = SCROLLABLE_ROW_HEIGHT + 1;
|
||||
static constexpr int32_t ItemHeight = kScrollableRowHeight + 1;
|
||||
static constexpr int32_t ItemCheckBoxSize = ItemHeight - 3;
|
||||
std::optional<size_t> _highlightedIndex;
|
||||
std::optional<size_t> _selectedIndex;
|
||||
|
|
|
@ -358,7 +358,7 @@ static StringId window_cheats_page_titles[] = {
|
|||
class CheatsWindow final : public Window
|
||||
{
|
||||
private:
|
||||
char _moneySpinnerText[MONEY_STRING_MAXLENGTH]{};
|
||||
char _moneySpinnerText[kMoneyStringMaxlength]{};
|
||||
money64 _moneySpinnerValue = CHEATS_MONEY_DEFAULT;
|
||||
int32_t _parkRatingSpinnerValue{};
|
||||
int32_t _yearSpinnerValue = 1;
|
||||
|
@ -709,13 +709,13 @@ static StringId window_cheats_page_titles[] = {
|
|||
switch (widgetIndex)
|
||||
{
|
||||
case WIDX_MONEY_SPINNER_INCREMENT:
|
||||
_moneySpinnerValue = AddClamp_money64(
|
||||
_moneySpinnerValue = AddClamp<money64>(
|
||||
CHEATS_MONEY_INCREMENT_DIV * (_moneySpinnerValue / CHEATS_MONEY_INCREMENT_DIV),
|
||||
CHEATS_MONEY_INCREMENT_DIV);
|
||||
InvalidateWidget(WIDX_MONEY_SPINNER);
|
||||
break;
|
||||
case WIDX_MONEY_SPINNER_DECREMENT:
|
||||
_moneySpinnerValue = AddClamp_money64(
|
||||
_moneySpinnerValue = AddClamp<money64>(
|
||||
CHEATS_MONEY_INCREMENT_DIV * (_moneySpinnerValue / CHEATS_MONEY_INCREMENT_DIV),
|
||||
-CHEATS_MONEY_INCREMENT_DIV);
|
||||
InvalidateWidget(WIDX_MONEY_SPINNER);
|
||||
|
@ -789,10 +789,10 @@ static StringId window_cheats_page_titles[] = {
|
|||
CheatsSet(CheatType::NoMoney, GetGameState().Park.Flags & PARK_FLAGS_NO_MONEY ? 0 : 1);
|
||||
break;
|
||||
case WIDX_MONEY_SPINNER:
|
||||
MoneyToString(_moneySpinnerValue, _moneySpinnerText, MONEY_STRING_MAXLENGTH, false);
|
||||
MoneyToString(_moneySpinnerValue, _moneySpinnerText, kMoneyStringMaxlength, false);
|
||||
WindowTextInputRawOpen(
|
||||
this, WIDX_MONEY_SPINNER, STR_ENTER_NEW_VALUE, STR_ENTER_NEW_VALUE, {}, _moneySpinnerText,
|
||||
MONEY_STRING_MAXLENGTH);
|
||||
kMoneyStringMaxlength);
|
||||
break;
|
||||
case WIDX_SET_MONEY:
|
||||
CheatsSet(CheatType::SetMoney, _moneySpinnerValue);
|
||||
|
|
|
@ -110,7 +110,7 @@ static Widget window_custom_currency_widgets[] = {
|
|||
case WIDX_SYMBOL_TEXT:
|
||||
WindowTextInputRawOpen(
|
||||
this, WIDX_SYMBOL_TEXT, STR_CUSTOM_CURRENCY_SYMBOL_INPUT_TITLE, STR_CUSTOM_CURRENCY_SYMBOL_INPUT_DESC,
|
||||
{}, CurrencyDescriptors[EnumValue(CurrencyType::Custom)].symbol_unicode, CURRENCY_SYMBOL_MAX_SIZE);
|
||||
{}, CurrencyDescriptors[EnumValue(CurrencyType::Custom)].symbol_unicode, kCurrencySymbolMaxSize);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ static Widget window_custom_currency_widgets[] = {
|
|||
WindowTextInputOpen(
|
||||
this, WIDX_RATE, STR_RATE_INPUT_TITLE, STR_RATE_INPUT_DESC, {}, STR_FORMAT_INTEGER,
|
||||
static_cast<uint32_t>(CurrencyDescriptors[EnumValue(CurrencyType::Custom)].rate),
|
||||
CURRENCY_RATE_MAX_NUM_DIGITS);
|
||||
kCurrencyRateMaxNumDigits);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ static Widget window_custom_currency_widgets[] = {
|
|||
case WIDX_SYMBOL_TEXT:
|
||||
SafeStrCpy(
|
||||
CurrencyDescriptors[EnumValue(CurrencyType::Custom)].symbol_unicode, std::string(text).c_str(),
|
||||
CURRENCY_SYMBOL_MAX_SIZE);
|
||||
kCurrencySymbolMaxSize);
|
||||
|
||||
gConfigGeneral.CustomCurrencySymbol = CurrencyDescriptors[EnumValue(CurrencyType::Custom)].symbol_unicode;
|
||||
|
||||
|
|
|
@ -230,11 +230,11 @@ static Widget _inventionListDragWidgets[] = {
|
|||
ScreenSize size{};
|
||||
if (scrollIndex == 0)
|
||||
{
|
||||
size.height = static_cast<int32_t>(gameState.ResearchItemsInvented.size()) * SCROLLABLE_ROW_HEIGHT;
|
||||
size.height = static_cast<int32_t>(gameState.ResearchItemsInvented.size()) * kScrollableRowHeight;
|
||||
}
|
||||
else
|
||||
{
|
||||
size.height = static_cast<int32_t>(gameState.ResearchItemsUninvented.size()) * SCROLLABLE_ROW_HEIGHT;
|
||||
size.height = static_cast<int32_t>(gameState.ResearchItemsUninvented.size()) * kScrollableRowHeight;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
@ -279,14 +279,14 @@ static Widget _inventionListDragWidgets[] = {
|
|||
GfxClear(dpi, paletteIndex);
|
||||
|
||||
int16_t boxWidth = widgets[WIDX_RESEARCH_ORDER_SCROLL].width();
|
||||
int32_t itemY = -SCROLLABLE_ROW_HEIGHT;
|
||||
int32_t itemY = -kScrollableRowHeight;
|
||||
auto* dragItem = WindowEditorInventionsListDragGetItem();
|
||||
|
||||
const auto& researchList = scrollIndex == 0 ? gameState.ResearchItemsInvented : gameState.ResearchItemsUninvented;
|
||||
for (const auto& researchItem : researchList)
|
||||
{
|
||||
itemY += SCROLLABLE_ROW_HEIGHT;
|
||||
if (itemY + SCROLLABLE_ROW_HEIGHT < dpi.y || itemY >= dpi.y + dpi.height)
|
||||
itemY += kScrollableRowHeight;
|
||||
if (itemY + kScrollableRowHeight < dpi.y || itemY >= dpi.y + dpi.height)
|
||||
continue;
|
||||
|
||||
if (_selectedResearchItem == &researchItem)
|
||||
|
@ -296,7 +296,7 @@ static Widget _inventionListDragWidgets[] = {
|
|||
{
|
||||
// Highlight
|
||||
top = itemY;
|
||||
bottom = itemY + SCROLLABLE_ROW_HEIGHT - 1;
|
||||
bottom = itemY + kScrollableRowHeight - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -559,7 +559,7 @@ static Widget _inventionListDragWidgets[] = {
|
|||
auto& researchList = isInvented ? gameState.ResearchItemsInvented : gameState.ResearchItemsUninvented;
|
||||
for (auto& researchItem : researchList)
|
||||
{
|
||||
y -= SCROLLABLE_ROW_HEIGHT;
|
||||
y -= kScrollableRowHeight;
|
||||
if (y < 0)
|
||||
{
|
||||
return &researchItem;
|
||||
|
@ -575,7 +575,7 @@ static Widget _inventionListDragWidgets[] = {
|
|||
auto& researchList = isInvented ? gameState.ResearchItemsInvented : gameState.ResearchItemsUninvented;
|
||||
for (auto& researchItem : researchList)
|
||||
{
|
||||
y -= SCROLLABLE_ROW_HEIGHT;
|
||||
y -= kScrollableRowHeight;
|
||||
if (y < 0)
|
||||
{
|
||||
return &researchItem;
|
||||
|
|
|
@ -584,7 +584,7 @@ static std::vector<Widget> _window_editor_object_selection_widgets = {
|
|||
*/
|
||||
ScreenSize OnScrollGetSize(int32_t scrollIndex) override
|
||||
{
|
||||
const auto newHeight = static_cast<int32_t>(_listItems.size() * SCROLLABLE_ROW_HEIGHT);
|
||||
const auto newHeight = static_cast<int32_t>(_listItems.size() * kScrollableRowHeight);
|
||||
return { 0, newHeight };
|
||||
}
|
||||
|
||||
|
@ -729,7 +729,7 @@ static std::vector<Widget> _window_editor_object_selection_widgets = {
|
|||
for (size_t i = 0; i < _listItems.size(); i++)
|
||||
{
|
||||
const auto& listItem = _listItems[i];
|
||||
if (screenCoords.y + SCROLLABLE_ROW_HEIGHT >= dpi.y && screenCoords.y <= dpi.y + dpi.height)
|
||||
if (screenCoords.y + kScrollableRowHeight >= dpi.y && screenCoords.y <= dpi.y + dpi.height)
|
||||
{
|
||||
// Draw checkbox
|
||||
if (!(gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER) && !(*listItem.flags & 0x20))
|
||||
|
@ -741,7 +741,7 @@ static std::vector<Widget> _window_editor_object_selection_widgets = {
|
|||
&& !(*listItem.flags & ObjectSelectionFlags::Flag6);
|
||||
if (highlighted)
|
||||
{
|
||||
auto bottom = screenCoords.y + (SCROLLABLE_ROW_HEIGHT - 1);
|
||||
auto bottom = screenCoords.y + (kScrollableRowHeight - 1);
|
||||
GfxFilterRect(dpi, { 0, screenCoords.y, width, bottom }, FilterPaletteID::PaletteDarken1);
|
||||
}
|
||||
|
||||
|
@ -800,7 +800,7 @@ static std::vector<Widget> _window_editor_object_selection_widgets = {
|
|||
ft.Add<const char*>(gCommonStringFormatBuffer);
|
||||
DrawTextEllipsised(dpi, screenCoords, width_limit, STR_STRING, ft, { colour, FontStyle::Medium, darkness });
|
||||
}
|
||||
screenCoords.y += SCROLLABLE_ROW_HEIGHT;
|
||||
screenCoords.y += kScrollableRowHeight;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1538,7 +1538,7 @@ static std::vector<Widget> _window_editor_object_selection_widgets = {
|
|||
*/
|
||||
int32_t GetObjectFromObjectSelection(ObjectType object_type, int32_t y)
|
||||
{
|
||||
int32_t listItemIndex = y / SCROLLABLE_ROW_HEIGHT;
|
||||
int32_t listItemIndex = y / kScrollableRowHeight;
|
||||
if (listItemIndex < 0 || static_cast<size_t>(listItemIndex) >= _listItems.size())
|
||||
return -1;
|
||||
|
||||
|
|
|
@ -603,7 +603,7 @@ static Widget _windowFinancesResearchWidgets[] =
|
|||
|
||||
uint16_t SummaryMaxAvailableMonth()
|
||||
{
|
||||
return std::min<uint16_t>(GetDate().GetMonthsElapsed(), EXPENDITURE_TABLE_MONTH_COUNT - 1);
|
||||
return std::min<uint16_t>(GetDate().GetMonthsElapsed(), kExpenditureTableMonthCount - 1);
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
|
|
@ -129,9 +129,9 @@ static Widget window_guest_list_widgets[] = {
|
|||
char Name[256];
|
||||
};
|
||||
|
||||
static constexpr uint8_t SUMMARISED_GUEST_ROW_HEIGHT = SCROLLABLE_ROW_HEIGHT + 11;
|
||||
static constexpr uint8_t SUMMARISED_GUEST_ROW_HEIGHT = kScrollableRowHeight + 11;
|
||||
static constexpr auto GUESTS_PER_PAGE = 2000;
|
||||
static constexpr const auto GUEST_PAGE_HEIGHT = GUESTS_PER_PAGE * SCROLLABLE_ROW_HEIGHT;
|
||||
static constexpr const auto GUEST_PAGE_HEIGHT = GUESTS_PER_PAGE * kScrollableRowHeight;
|
||||
static constexpr size_t MaxGroups = 240;
|
||||
|
||||
TabId _selectedTab{};
|
||||
|
@ -500,7 +500,7 @@ static Widget window_guest_list_widgets[] = {
|
|||
{
|
||||
case TabId::Individual:
|
||||
// Count the number of guests
|
||||
y = static_cast<int32_t>(_guestList.size()) * SCROLLABLE_ROW_HEIGHT;
|
||||
y = static_cast<int32_t>(_guestList.size()) * kScrollableRowHeight;
|
||||
_numPages = (_guestList.size() + GUESTS_PER_PAGE - 1) / GUESTS_PER_PAGE;
|
||||
if (_numPages == 0)
|
||||
_selectedPage = 0;
|
||||
|
@ -539,7 +539,7 @@ static Widget window_guest_list_widgets[] = {
|
|||
|
||||
void OnScrollMouseOver(int32_t scrollIndex, const ScreenCoordsXY& screenCoords) override
|
||||
{
|
||||
auto i = screenCoords.y / (_selectedTab == TabId::Individual ? SCROLLABLE_ROW_HEIGHT : SUMMARISED_GUEST_ROW_HEIGHT);
|
||||
auto i = screenCoords.y / (_selectedTab == TabId::Individual ? kScrollableRowHeight : SUMMARISED_GUEST_ROW_HEIGHT);
|
||||
i += static_cast<int32_t>(_selectedPage * GUESTS_PER_PAGE);
|
||||
if (static_cast<size_t>(i) != _highlightedIndex)
|
||||
{
|
||||
|
@ -554,7 +554,7 @@ static Widget window_guest_list_widgets[] = {
|
|||
{
|
||||
case TabId::Individual:
|
||||
{
|
||||
auto i = screenCoords.y / SCROLLABLE_ROW_HEIGHT;
|
||||
auto i = screenCoords.y / kScrollableRowHeight;
|
||||
i += static_cast<int32_t>(_selectedPage * GUESTS_PER_PAGE);
|
||||
for (const auto& guestItem : _guestList)
|
||||
{
|
||||
|
@ -667,14 +667,14 @@ static Widget window_guest_list_widgets[] = {
|
|||
for (const auto& guestItem : _guestList)
|
||||
{
|
||||
// Check if y is beyond the scroll control
|
||||
if (y + SCROLLABLE_ROW_HEIGHT + 1 >= -0x7FFF && y + SCROLLABLE_ROW_HEIGHT + 1 > dpi.y && y < 0x7FFF
|
||||
if (y + kScrollableRowHeight + 1 >= -0x7FFF && y + kScrollableRowHeight + 1 > dpi.y && y < 0x7FFF
|
||||
&& y < dpi.y + dpi.height)
|
||||
{
|
||||
// Highlight backcolour and text colour (format)
|
||||
StringId format = STR_BLACK_STRING;
|
||||
if (index == _highlightedIndex)
|
||||
{
|
||||
GfxFilterRect(dpi, { 0, y, 800, y + SCROLLABLE_ROW_HEIGHT - 1 }, FilterPaletteID::PaletteDarken1);
|
||||
GfxFilterRect(dpi, { 0, y, 800, y + kScrollableRowHeight - 1 }, FilterPaletteID::PaletteDarken1);
|
||||
format = STR_WINDOW_COLOUR_2_STRINGID;
|
||||
}
|
||||
|
||||
|
@ -722,7 +722,7 @@ static Widget window_guest_list_widgets[] = {
|
|||
break;
|
||||
}
|
||||
}
|
||||
y += SCROLLABLE_ROW_HEIGHT;
|
||||
y += kScrollableRowHeight;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -904,14 +904,14 @@ static Widget window_loadsave_widgets[] =
|
|||
|
||||
ScreenSize OnScrollGetSize(int32_t scrollIndex) override
|
||||
{
|
||||
return { 0, no_list_items * SCROLLABLE_ROW_HEIGHT };
|
||||
return { 0, no_list_items * kScrollableRowHeight };
|
||||
}
|
||||
|
||||
void OnScrollMouseOver(int32_t scrollIndex, const ScreenCoordsXY& screenCoords) override
|
||||
{
|
||||
int32_t selectedItem;
|
||||
|
||||
selectedItem = screenCoords.y / SCROLLABLE_ROW_HEIGHT;
|
||||
selectedItem = screenCoords.y / kScrollableRowHeight;
|
||||
if (selectedItem >= no_list_items)
|
||||
return;
|
||||
|
||||
|
@ -924,7 +924,7 @@ static Widget window_loadsave_widgets[] =
|
|||
{
|
||||
int32_t selectedItem;
|
||||
|
||||
selectedItem = screenCoords.y / SCROLLABLE_ROW_HEIGHT;
|
||||
selectedItem = screenCoords.y / kScrollableRowHeight;
|
||||
if (selectedItem >= no_list_items)
|
||||
return;
|
||||
|
||||
|
@ -965,11 +965,11 @@ static Widget window_loadsave_widgets[] =
|
|||
|
||||
for (int32_t i = 0; i < no_list_items; i++)
|
||||
{
|
||||
int32_t y = i * SCROLLABLE_ROW_HEIGHT;
|
||||
int32_t y = i * kScrollableRowHeight;
|
||||
if (y > dpi.y + dpi.height)
|
||||
break;
|
||||
|
||||
if (y + SCROLLABLE_ROW_HEIGHT < dpi.y)
|
||||
if (y + kScrollableRowHeight < dpi.y)
|
||||
continue;
|
||||
|
||||
StringId stringId = STR_BLACK_STRING;
|
||||
|
@ -978,7 +978,7 @@ static Widget window_loadsave_widgets[] =
|
|||
if (i == selected_list_item)
|
||||
{
|
||||
stringId = STR_WINDOW_COLOUR_2_STRINGID;
|
||||
GfxFilterRect(dpi, { 0, y, listWidth, y + SCROLLABLE_ROW_HEIGHT }, FilterPaletteID::PaletteDarken1);
|
||||
GfxFilterRect(dpi, { 0, y, listWidth, y + kScrollableRowHeight }, FilterPaletteID::PaletteDarken1);
|
||||
}
|
||||
// display a marker next to the currently loaded game file
|
||||
if (_listItems[i].loaded)
|
||||
|
|
|
@ -569,7 +569,7 @@ static constexpr StringId WindowMultiplayerPageTitles[] = {
|
|||
Invalidate();
|
||||
}
|
||||
|
||||
screenSize = { 0, NetworkGetNumPlayers() * SCROLLABLE_ROW_HEIGHT };
|
||||
screenSize = { 0, NetworkGetNumPlayers() * kScrollableRowHeight };
|
||||
int32_t i = screenSize.height - window_multiplayer_players_widgets[WIDX_LIST].bottom
|
||||
+ window_multiplayer_players_widgets[WIDX_LIST].top + 21;
|
||||
if (i < 0)
|
||||
|
@ -590,7 +590,7 @@ static constexpr StringId WindowMultiplayerPageTitles[] = {
|
|||
Invalidate();
|
||||
}
|
||||
|
||||
screenSize = { 0, NetworkGetNumActions() * SCROLLABLE_ROW_HEIGHT };
|
||||
screenSize = { 0, NetworkGetNumActions() * kScrollableRowHeight };
|
||||
int32_t i = screenSize.height - window_multiplayer_groups_widgets[WIDX_LIST].bottom
|
||||
+ window_multiplayer_groups_widgets[WIDX_LIST].top + 21;
|
||||
if (i < 0)
|
||||
|
@ -612,7 +612,7 @@ static constexpr StringId WindowMultiplayerPageTitles[] = {
|
|||
{
|
||||
case WINDOW_MULTIPLAYER_PAGE_PLAYERS:
|
||||
{
|
||||
int32_t index = screenCoords.y / SCROLLABLE_ROW_HEIGHT;
|
||||
int32_t index = screenCoords.y / kScrollableRowHeight;
|
||||
if (index >= no_list_items)
|
||||
return;
|
||||
|
||||
|
@ -626,7 +626,7 @@ static constexpr StringId WindowMultiplayerPageTitles[] = {
|
|||
|
||||
case WINDOW_MULTIPLAYER_PAGE_GROUPS:
|
||||
{
|
||||
int32_t index = screenCoords.y / SCROLLABLE_ROW_HEIGHT;
|
||||
int32_t index = screenCoords.y / kScrollableRowHeight;
|
||||
if (index >= no_list_items)
|
||||
return;
|
||||
|
||||
|
@ -648,7 +648,7 @@ static constexpr StringId WindowMultiplayerPageTitles[] = {
|
|||
case WINDOW_MULTIPLAYER_PAGE_PLAYERS:
|
||||
case WINDOW_MULTIPLAYER_PAGE_GROUPS:
|
||||
{
|
||||
int32_t index = screenCoords.y / SCROLLABLE_ROW_HEIGHT;
|
||||
int32_t index = screenCoords.y / kScrollableRowHeight;
|
||||
if (index >= no_list_items)
|
||||
return;
|
||||
|
||||
|
@ -751,7 +751,7 @@ static constexpr StringId WindowMultiplayerPageTitles[] = {
|
|||
break;
|
||||
}
|
||||
|
||||
if (screenCoords.y + SCROLLABLE_ROW_HEIGHT + 1 >= dpi.y)
|
||||
if (screenCoords.y + kScrollableRowHeight + 1 >= dpi.y)
|
||||
{
|
||||
thread_local std::string _buffer;
|
||||
_buffer.reserve(512);
|
||||
|
@ -762,7 +762,7 @@ static constexpr StringId WindowMultiplayerPageTitles[] = {
|
|||
if (listPosition == selected_list_item)
|
||||
{
|
||||
GfxFilterRect(
|
||||
dpi, { 0, screenCoords.y, 800, screenCoords.y + SCROLLABLE_ROW_HEIGHT - 1 },
|
||||
dpi, { 0, screenCoords.y, 800, screenCoords.y + kScrollableRowHeight - 1 },
|
||||
FilterPaletteID::PaletteDarken1);
|
||||
_buffer += NetworkGetPlayerName(player);
|
||||
colour = colours[2];
|
||||
|
@ -831,7 +831,7 @@ static constexpr StringId WindowMultiplayerPageTitles[] = {
|
|||
screenCoords.x = 356;
|
||||
GfxDrawString(dpi, screenCoords, _buffer.c_str(), { colour });
|
||||
}
|
||||
screenCoords.y += SCROLLABLE_ROW_HEIGHT;
|
||||
screenCoords.y += kScrollableRowHeight;
|
||||
listPosition++;
|
||||
}
|
||||
}
|
||||
|
@ -893,7 +893,7 @@ static constexpr StringId WindowMultiplayerPageTitles[] = {
|
|||
if (i == selected_list_item)
|
||||
{
|
||||
GfxFilterRect(
|
||||
dpi, { 0, screenCoords.y, 800, screenCoords.y + SCROLLABLE_ROW_HEIGHT - 1 },
|
||||
dpi, { 0, screenCoords.y, 800, screenCoords.y + kScrollableRowHeight - 1 },
|
||||
FilterPaletteID::PaletteDarken1);
|
||||
}
|
||||
if (screenCoords.y > dpi.y + dpi.height)
|
||||
|
@ -901,7 +901,7 @@ static constexpr StringId WindowMultiplayerPageTitles[] = {
|
|||
break;
|
||||
}
|
||||
|
||||
if (screenCoords.y + SCROLLABLE_ROW_HEIGHT + 1 >= dpi.y)
|
||||
if (screenCoords.y + kScrollableRowHeight + 1 >= dpi.y)
|
||||
{
|
||||
int32_t groupindex = NetworkGetGroupIndex(_selectedGroup);
|
||||
if (groupindex != -1)
|
||||
|
@ -918,7 +918,7 @@ static constexpr StringId WindowMultiplayerPageTitles[] = {
|
|||
ft.Add<uint16_t>(NetworkGetActionNameStringID(i));
|
||||
DrawTextBasic(dpi, { 10, screenCoords.y }, STR_WINDOW_COLOUR_2_STRINGID, ft);
|
||||
}
|
||||
screenCoords.y += SCROLLABLE_ROW_HEIGHT;
|
||||
screenCoords.y += kScrollableRowHeight;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -465,19 +465,19 @@ static Widget window_object_load_error_widgets[] = {
|
|||
|
||||
ScreenSize OnScrollGetSize(const int32_t scrollIndex) override
|
||||
{
|
||||
return ScreenSize(0, no_list_items * SCROLLABLE_ROW_HEIGHT);
|
||||
return ScreenSize(0, no_list_items * kScrollableRowHeight);
|
||||
}
|
||||
|
||||
void OnScrollMouseDown(const int32_t scrollIndex, const ScreenCoordsXY& screenCoords) override
|
||||
{
|
||||
const auto selectedItem = screenCoords.y / SCROLLABLE_ROW_HEIGHT;
|
||||
const auto selectedItem = screenCoords.y / kScrollableRowHeight;
|
||||
SelectObjectFromList(selectedItem);
|
||||
}
|
||||
|
||||
void OnScrollMouseOver(const int32_t scrollIndex, const ScreenCoordsXY& screenCoords) override
|
||||
{
|
||||
// Highlight item that the cursor is over, or remove highlighting if none
|
||||
const auto selectedItem = screenCoords.y / SCROLLABLE_ROW_HEIGHT;
|
||||
const auto selectedItem = screenCoords.y / kScrollableRowHeight;
|
||||
if (selectedItem < 0 || selectedItem >= no_list_items)
|
||||
_highlightedIndex = -1;
|
||||
else
|
||||
|
@ -513,15 +513,15 @@ static Widget window_object_load_error_widgets[] = {
|
|||
for (int32_t i = 0; i < no_list_items; i++)
|
||||
{
|
||||
ScreenCoordsXY screenCoords;
|
||||
screenCoords.y = i * SCROLLABLE_ROW_HEIGHT;
|
||||
screenCoords.y = i * kScrollableRowHeight;
|
||||
if (screenCoords.y > dpi.y + dpi.height)
|
||||
break;
|
||||
|
||||
if (screenCoords.y + SCROLLABLE_ROW_HEIGHT < dpi.y)
|
||||
if (screenCoords.y + kScrollableRowHeight < dpi.y)
|
||||
continue;
|
||||
|
||||
const auto screenRect = ScreenRect{ { 0, screenCoords.y },
|
||||
{ listWidth, screenCoords.y + SCROLLABLE_ROW_HEIGHT - 1 } };
|
||||
{ listWidth, screenCoords.y + kScrollableRowHeight - 1 } };
|
||||
// If hovering over item, change the color and fill the backdrop.
|
||||
if (i == selected_list_item)
|
||||
GfxFillRect(dpi, screenRect, ColourMapA[colours[1]].darker);
|
||||
|
|
|
@ -427,7 +427,7 @@ static constexpr WindowParkAward _parkAwards[] = {
|
|||
{
|
||||
auto& park = OpenRCT2::GetGameState().Park;
|
||||
WindowTextInputRawOpen(
|
||||
this, WIDX_RENAME, STR_PARK_NAME, STR_ENTER_PARK_NAME, {}, park.Name.c_str(), USER_STRING_MAX_LENGTH);
|
||||
this, WIDX_RENAME, STR_PARK_NAME, STR_ENTER_PARK_NAME, {}, park.Name.c_str(), kUserStringMaxLength);
|
||||
break;
|
||||
}
|
||||
case WIDX_CLOSE_LIGHT:
|
||||
|
@ -853,11 +853,10 @@ static constexpr WindowParkAward _parkAwards[] = {
|
|||
}
|
||||
case WIDX_PRICE:
|
||||
{
|
||||
utf8 _moneyInputText[MONEY_STRING_MAXLENGTH] = {};
|
||||
MoneyToString(Park::GetEntranceFee(), _moneyInputText, MONEY_STRING_MAXLENGTH, false);
|
||||
utf8 _moneyInputText[kMoneyStringMaxlength] = {};
|
||||
MoneyToString(Park::GetEntranceFee(), _moneyInputText, kMoneyStringMaxlength, false);
|
||||
WindowTextInputRawOpen(
|
||||
this, WIDX_PRICE, STR_ENTER_NEW_VALUE, STR_ENTER_NEW_VALUE, {}, _moneyInputText,
|
||||
MONEY_STRING_MAXLENGTH);
|
||||
this, WIDX_PRICE, STR_ENTER_NEW_VALUE, STR_ENTER_NEW_VALUE, {}, _moneyInputText, kMoneyStringMaxlength);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6110,7 +6110,7 @@ static_assert(std::size(RatingNames) == 6);
|
|||
|
||||
void IncomeOnMouseUp(WidgetIndex widgetIndex)
|
||||
{
|
||||
utf8 _moneyInputText[MONEY_STRING_MAXLENGTH] = {};
|
||||
utf8 _moneyInputText[kMoneyStringMaxlength] = {};
|
||||
|
||||
switch (widgetIndex)
|
||||
{
|
||||
|
@ -6137,10 +6137,10 @@ static_assert(std::size(RatingNames) == 6);
|
|||
auto ride = GetRide(rideId);
|
||||
if (ride != nullptr)
|
||||
{
|
||||
MoneyToString(ride->price[0], _moneyInputText, MONEY_STRING_MAXLENGTH, true);
|
||||
MoneyToString(ride->price[0], _moneyInputText, kMoneyStringMaxlength, true);
|
||||
WindowTextInputRawOpen(
|
||||
this, WIDX_PRIMARY_PRICE, STR_ENTER_NEW_VALUE, STR_ENTER_NEW_VALUE, {}, _moneyInputText,
|
||||
MONEY_STRING_MAXLENGTH);
|
||||
kMoneyStringMaxlength);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -6151,10 +6151,10 @@ static_assert(std::size(RatingNames) == 6);
|
|||
{
|
||||
auto price64 = IncomeGetSecondaryPrice();
|
||||
|
||||
MoneyToString(price64, _moneyInputText, MONEY_STRING_MAXLENGTH, true);
|
||||
MoneyToString(price64, _moneyInputText, kMoneyStringMaxlength, true);
|
||||
WindowTextInputRawOpen(
|
||||
this, WIDX_SECONDARY_PRICE, STR_ENTER_NEW_VALUE, STR_ENTER_NEW_VALUE, {}, _moneyInputText,
|
||||
MONEY_STRING_MAXLENGTH);
|
||||
kMoneyStringMaxlength);
|
||||
}
|
||||
break;
|
||||
case WIDX_SECONDARY_PRICE_SAME_THROUGHOUT_PARK:
|
||||
|
|
|
@ -385,7 +385,7 @@ static Widget _rideListWidgets[] = {
|
|||
*/
|
||||
ScreenSize OnScrollGetSize(int32_t scrollIndex) override
|
||||
{
|
||||
const auto newHeight = static_cast<int32_t>(_rideList.size() * SCROLLABLE_ROW_HEIGHT);
|
||||
const auto newHeight = static_cast<int32_t>(_rideList.size() * kScrollableRowHeight);
|
||||
if (selected_list_item != -1)
|
||||
{
|
||||
selected_list_item = -1;
|
||||
|
@ -410,7 +410,7 @@ static Widget _rideListWidgets[] = {
|
|||
*/
|
||||
void OnScrollMouseDown(int32_t scrollIndex, const ScreenCoordsXY& screenCoords) override
|
||||
{
|
||||
const auto index = screenCoords.y / SCROLLABLE_ROW_HEIGHT;
|
||||
const auto index = screenCoords.y / kScrollableRowHeight;
|
||||
if (index < 0 || static_cast<size_t>(index) >= _rideList.size())
|
||||
return;
|
||||
|
||||
|
@ -436,7 +436,7 @@ static Widget _rideListWidgets[] = {
|
|||
*/
|
||||
void OnScrollMouseOver(int32_t scrollIndex, const ScreenCoordsXY& screenCoords) override
|
||||
{
|
||||
const auto index = screenCoords.y / SCROLLABLE_ROW_HEIGHT;
|
||||
const auto index = screenCoords.y / kScrollableRowHeight;
|
||||
if (index < 0 || static_cast<size_t>(index) >= _rideList.size())
|
||||
return;
|
||||
|
||||
|
@ -551,7 +551,7 @@ static Widget _rideListWidgets[] = {
|
|||
if (i == static_cast<size_t>(selected_list_item))
|
||||
{
|
||||
// Background highlight
|
||||
GfxFilterRect(dpi, { 0, y, 800, y + SCROLLABLE_ROW_HEIGHT - 1 }, FilterPaletteID::PaletteDarken1);
|
||||
GfxFilterRect(dpi, { 0, y, 800, y + kScrollableRowHeight - 1 }, FilterPaletteID::PaletteDarken1);
|
||||
format = (_quickDemolishMode ? STR_LIGHTPINK_STRINGID : STR_WINDOW_COLOUR_2_STRINGID);
|
||||
}
|
||||
|
||||
|
@ -741,7 +741,7 @@ static Widget _rideListWidgets[] = {
|
|||
ft.Add<StringId>(formatSecondary);
|
||||
}
|
||||
DrawTextEllipsised(dpi, { 160, y - 1 }, 157, format, ft);
|
||||
y += SCROLLABLE_ROW_HEIGHT;
|
||||
y += kScrollableRowHeight;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -263,7 +263,7 @@ static Widget window_shortcut_change_widgets[] = {
|
|||
|
||||
ScreenSize OnScrollGetSize(int32_t scrollIndex) override
|
||||
{
|
||||
auto h = static_cast<int32_t>(_list.size() * SCROLLABLE_ROW_HEIGHT);
|
||||
auto h = static_cast<int32_t>(_list.size() * kScrollableRowHeight);
|
||||
auto bottom = std::max(0, h - widgets[WIDX_SCROLL].bottom + widgets[WIDX_SCROLL].top + 21);
|
||||
if (bottom < scrolls[0].v_top)
|
||||
{
|
||||
|
@ -275,7 +275,7 @@ static Widget window_shortcut_change_widgets[] = {
|
|||
|
||||
void OnScrollMouseOver(int32_t scrollIndex, const ScreenCoordsXY& screenCoords) override
|
||||
{
|
||||
auto index = static_cast<int_fast16_t>((screenCoords.y - 1) / SCROLLABLE_ROW_HEIGHT);
|
||||
auto index = static_cast<int_fast16_t>((screenCoords.y - 1) / kScrollableRowHeight);
|
||||
if (static_cast<size_t>(index) < _list.size())
|
||||
{
|
||||
_highlightedItem = index;
|
||||
|
@ -289,7 +289,7 @@ static Widget window_shortcut_change_widgets[] = {
|
|||
|
||||
void OnScrollMouseDown(int32_t scrollIndex, const ScreenCoordsXY& screenCoords) override
|
||||
{
|
||||
auto selectedItem = static_cast<size_t>((screenCoords.y - 1) / SCROLLABLE_ROW_HEIGHT);
|
||||
auto selectedItem = static_cast<size_t>((screenCoords.y - 1) / kScrollableRowHeight);
|
||||
if (selectedItem < _list.size())
|
||||
{
|
||||
// Is this a separator?
|
||||
|
@ -314,13 +314,13 @@ static Widget window_shortcut_change_widgets[] = {
|
|||
|
||||
for (size_t i = 0; i < _list.size(); ++i)
|
||||
{
|
||||
auto y = static_cast<int32_t>(1 + i * SCROLLABLE_ROW_HEIGHT);
|
||||
auto y = static_cast<int32_t>(1 + i * kScrollableRowHeight);
|
||||
if (y > dpi.y + dpi.height)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (y + SCROLLABLE_ROW_HEIGHT < dpi.y)
|
||||
if (y + kScrollableRowHeight < dpi.y)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -504,7 +504,7 @@ static Widget window_shortcut_change_widgets[] = {
|
|||
|
||||
void DrawSeparator(DrawPixelInfo& dpi, int32_t y, int32_t scrollWidth)
|
||||
{
|
||||
const int32_t top = y + (SCROLLABLE_ROW_HEIGHT / 2) - 1;
|
||||
const int32_t top = y + (kScrollableRowHeight / 2) - 1;
|
||||
GfxFillRect(dpi, { { 0, top }, { scrollWidth, top } }, ColourMapA[colours[0]].mid_dark);
|
||||
GfxFillRect(dpi, { { 0, top + 1 }, { scrollWidth, top + 1 } }, ColourMapA[colours[0]].lightest);
|
||||
}
|
||||
|
@ -516,7 +516,7 @@ static Widget window_shortcut_change_widgets[] = {
|
|||
if (isHighlighted)
|
||||
{
|
||||
format = STR_WINDOW_COLOUR_2_STRINGID;
|
||||
GfxFilterRect(dpi, { 0, y - 1, scrollWidth, y + (SCROLLABLE_ROW_HEIGHT - 2) }, FilterPaletteID::PaletteDarken1);
|
||||
GfxFilterRect(dpi, { 0, y - 1, scrollWidth, y + (kScrollableRowHeight - 2) }, FilterPaletteID::PaletteDarken1);
|
||||
}
|
||||
|
||||
auto bindingOffset = (scrollWidth * 2) / 3;
|
||||
|
|
|
@ -323,7 +323,7 @@ static Widget _staffListWidgets[] = {
|
|||
Invalidate();
|
||||
}
|
||||
|
||||
auto scrollHeight = static_cast<int32_t>(_staffList.size()) * SCROLLABLE_ROW_HEIGHT;
|
||||
auto scrollHeight = static_cast<int32_t>(_staffList.size()) * kScrollableRowHeight;
|
||||
auto i = scrollHeight - widgets[WIDX_STAFF_LIST_LIST].bottom + widgets[WIDX_STAFF_LIST_LIST].top + 21;
|
||||
if (i < 0)
|
||||
i = 0;
|
||||
|
@ -339,7 +339,7 @@ static Widget _staffListWidgets[] = {
|
|||
|
||||
void OnScrollMouseOver(int32_t scrollIndex, const ScreenCoordsXY& screenCoords) override
|
||||
{
|
||||
auto i = static_cast<size_t>(screenCoords.y / SCROLLABLE_ROW_HEIGHT);
|
||||
auto i = static_cast<size_t>(screenCoords.y / kScrollableRowHeight);
|
||||
if (i != _highlightedIndex)
|
||||
{
|
||||
_highlightedIndex = static_cast<size_t>(i);
|
||||
|
@ -349,7 +349,7 @@ static Widget _staffListWidgets[] = {
|
|||
|
||||
void OnScrollMouseDown(int32_t scrollIndex, const ScreenCoordsXY& screenCoords) override
|
||||
{
|
||||
int32_t i = screenCoords.y / SCROLLABLE_ROW_HEIGHT;
|
||||
int32_t i = screenCoords.y / kScrollableRowHeight;
|
||||
for (const auto& entry : _staffList)
|
||||
{
|
||||
if (i == 0)
|
||||
|
@ -409,7 +409,7 @@ static Widget _staffListWidgets[] = {
|
|||
|
||||
if (i == _highlightedIndex)
|
||||
{
|
||||
GfxFilterRect(dpi, { 0, y, 800, y + (SCROLLABLE_ROW_HEIGHT - 1) }, FilterPaletteID::PaletteDarken1);
|
||||
GfxFilterRect(dpi, { 0, y, 800, y + (kScrollableRowHeight - 1) }, FilterPaletteID::PaletteDarken1);
|
||||
format = (_quickFireMode ? STR_LIGHTPINK_STRINGID : STR_WINDOW_COLOUR_2_STRINGID);
|
||||
}
|
||||
|
||||
|
@ -451,7 +451,7 @@ static Widget _staffListWidgets[] = {
|
|||
}
|
||||
}
|
||||
|
||||
y += SCROLLABLE_ROW_HEIGHT;
|
||||
y += kScrollableRowHeight;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -993,7 +993,7 @@ static uint64_t PageDisabledWidgets[] = {
|
|||
|
||||
ScreenSize OnScrollGetSize(int32_t scrollIndex) override
|
||||
{
|
||||
return ScreenSize(WW - 30, windowTileInspectorElementCount * SCROLLABLE_ROW_HEIGHT);
|
||||
return ScreenSize(WW - 30, windowTileInspectorElementCount * kScrollableRowHeight);
|
||||
}
|
||||
|
||||
void OnScrollMouseDown(int32_t scrollIndex, const ScreenCoordsXY& screenCoords) override
|
||||
|
@ -1003,7 +1003,7 @@ static uint64_t PageDisabledWidgets[] = {
|
|||
return;
|
||||
|
||||
// Because the list items are displayed in reverse order, subtract the calculated index from the amount of elements
|
||||
const int16_t index = windowTileInspectorElementCount - (screenCoords.y - 1) / SCROLLABLE_ROW_HEIGHT - 1;
|
||||
const int16_t index = windowTileInspectorElementCount - (screenCoords.y - 1) / kScrollableRowHeight - 1;
|
||||
const ScreenRect checkboxColumnRect{ { 2, 0 }, { 15, screenCoords.y } };
|
||||
if (index >= 0 && checkboxColumnRect.Contains(screenCoords))
|
||||
{ // Checkbox was clicked
|
||||
|
@ -1017,7 +1017,7 @@ static uint64_t PageDisabledWidgets[] = {
|
|||
|
||||
void OnScrollMouseOver(int32_t scrollIndex, const ScreenCoordsXY& screenCoords) override
|
||||
{
|
||||
int16_t index = windowTileInspectorElementCount - (screenCoords.y - 1) / SCROLLABLE_ROW_HEIGHT - 1;
|
||||
int16_t index = windowTileInspectorElementCount - (screenCoords.y - 1) / kScrollableRowHeight - 1;
|
||||
if (index < 0 || index >= windowTileInspectorElementCount)
|
||||
_highlightedIndex = -1;
|
||||
else
|
||||
|
@ -1584,7 +1584,7 @@ static uint64_t PageDisabledWidgets[] = {
|
|||
}
|
||||
|
||||
ScreenCoordsXY screenCoords{};
|
||||
screenCoords.y = SCROLLABLE_ROW_HEIGHT * (windowTileInspectorElementCount - 1);
|
||||
screenCoords.y = kScrollableRowHeight * (windowTileInspectorElementCount - 1);
|
||||
int32_t i = 0;
|
||||
char buffer[256];
|
||||
|
||||
|
@ -1601,7 +1601,7 @@ static uint64_t PageDisabledWidgets[] = {
|
|||
|
||||
// Draw row background colour
|
||||
auto fillRectangle = ScreenRect{ { 0, screenCoords.y },
|
||||
{ listWidth, screenCoords.y + SCROLLABLE_ROW_HEIGHT - 1 } };
|
||||
{ listWidth, screenCoords.y + kScrollableRowHeight - 1 } };
|
||||
if (selectedRow)
|
||||
GfxFillRect(dpi, fillRectangle, ColourMapA[colours[1]].mid_dark);
|
||||
else if (hoveredRow)
|
||||
|
@ -1718,7 +1718,7 @@ static uint64_t PageDisabledWidgets[] = {
|
|||
if (last)
|
||||
DrawTextBasic(dpi, screenCoords + ScreenCoordsXY{ LastFlagColumnXY.x, 0 }, stringFormat, checkboxFormatter);
|
||||
|
||||
screenCoords.y -= SCROLLABLE_ROW_HEIGHT;
|
||||
screenCoords.y -= kScrollableRowHeight;
|
||||
i++;
|
||||
} while (!(tileElement++)->IsLastForTile());
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ static Widget _trackListWidgets[] = {
|
|||
{
|
||||
private:
|
||||
std::vector<TrackDesignFileRef> _trackDesigns;
|
||||
utf8 _filterString[USER_STRING_MAX_LENGTH]{};
|
||||
utf8 _filterString[kUserStringMaxLength]{};
|
||||
std::vector<uint16_t> _filteredTrackIds;
|
||||
uint16_t _loadedTrackDesignIndex;
|
||||
std::unique_ptr<TrackDesign> _loadedTrackDesign;
|
||||
|
@ -172,7 +172,7 @@ static Widget _trackListWidgets[] = {
|
|||
maxItems++;
|
||||
}
|
||||
|
||||
int32_t index = screenCoords.y / SCROLLABLE_ROW_HEIGHT;
|
||||
int32_t index = screenCoords.y / kScrollableRowHeight;
|
||||
if (index < 0 || static_cast<uint32_t>(index) >= maxItems)
|
||||
{
|
||||
index = -1;
|
||||
|
@ -328,7 +328,7 @@ static Widget _trackListWidgets[] = {
|
|||
// Extra item: custom design
|
||||
numItems++;
|
||||
}
|
||||
int32_t scrollHeight = static_cast<int32_t>(numItems * SCROLLABLE_ROW_HEIGHT);
|
||||
int32_t scrollHeight = static_cast<int32_t>(numItems * kScrollableRowHeight);
|
||||
|
||||
return { width, scrollHeight };
|
||||
}
|
||||
|
@ -519,7 +519,7 @@ static Widget _trackListWidgets[] = {
|
|||
{
|
||||
// Vehicle design not available
|
||||
DrawTextEllipsised(dpi, screenPos, 368, STR_VEHICLE_DESIGN_UNAVAILABLE, {}, { TextAlignment::CENTRE });
|
||||
screenPos.y -= SCROLLABLE_ROW_HEIGHT;
|
||||
screenPos.y -= kScrollableRowHeight;
|
||||
}
|
||||
|
||||
if (_loadedTrackDesign->track_flags & TRACK_DESIGN_FLAG_SCENERY_UNAVAILABLE)
|
||||
|
@ -529,7 +529,7 @@ static Widget _trackListWidgets[] = {
|
|||
// Scenery not available
|
||||
DrawTextEllipsised(
|
||||
dpi, screenPos, 368, STR_DESIGN_INCLUDES_SCENERY_WHICH_IS_UNAVAILABLE, {}, { TextAlignment::CENTRE });
|
||||
screenPos.y -= SCROLLABLE_ROW_HEIGHT;
|
||||
screenPos.y -= kScrollableRowHeight;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -696,7 +696,7 @@ static Widget _trackListWidgets[] = {
|
|||
{
|
||||
// Highlight
|
||||
GfxFilterRect(
|
||||
dpi, { screenCoords, { width, screenCoords.y + SCROLLABLE_ROW_HEIGHT - 1 } },
|
||||
dpi, { screenCoords, { width, screenCoords.y + kScrollableRowHeight - 1 } },
|
||||
FilterPaletteID::PaletteDarken1);
|
||||
stringId = STR_WINDOW_COLOUR_2_STRINGID;
|
||||
}
|
||||
|
@ -708,20 +708,20 @@ static Widget _trackListWidgets[] = {
|
|||
auto ft = Formatter();
|
||||
ft.Add<StringId>(STR_BUILD_CUSTOM_DESIGN);
|
||||
DrawTextBasic(dpi, screenCoords - ScreenCoordsXY{ 0, 1 }, stringId, ft);
|
||||
screenCoords.y += SCROLLABLE_ROW_HEIGHT;
|
||||
screenCoords.y += kScrollableRowHeight;
|
||||
listIndex++;
|
||||
}
|
||||
|
||||
for (auto i : _filteredTrackIds)
|
||||
{
|
||||
if (screenCoords.y + SCROLLABLE_ROW_HEIGHT >= dpi.y && screenCoords.y < dpi.y + dpi.height)
|
||||
if (screenCoords.y + kScrollableRowHeight >= dpi.y && screenCoords.y < dpi.y + dpi.height)
|
||||
{
|
||||
StringId stringId;
|
||||
if (listIndex == static_cast<size_t>(selected_list_item))
|
||||
{
|
||||
// Highlight
|
||||
GfxFilterRect(
|
||||
dpi, { screenCoords, { width, screenCoords.y + SCROLLABLE_ROW_HEIGHT - 1 } },
|
||||
dpi, { screenCoords, { width, screenCoords.y + kScrollableRowHeight - 1 } },
|
||||
FilterPaletteID::PaletteDarken1);
|
||||
stringId = STR_WINDOW_COLOUR_2_STRINGID;
|
||||
}
|
||||
|
@ -737,7 +737,7 @@ static Widget _trackListWidgets[] = {
|
|||
DrawTextBasic(dpi, screenCoords - ScreenCoordsXY{ 0, 1 }, stringId, ft);
|
||||
}
|
||||
|
||||
screenCoords.y += SCROLLABLE_ROW_HEIGHT;
|
||||
screenCoords.y += kScrollableRowHeight;
|
||||
listIndex++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ namespace OpenRCT2
|
|||
ClimateState ClimateNext;
|
||||
uint16_t ClimateUpdateTimer;
|
||||
money64 Cash;
|
||||
money64 CashHistory[FINANCE_GRAPH_SIZE];
|
||||
money64 CashHistory[kFinanceGraphSize];
|
||||
money64 InitialCash;
|
||||
money64 GuestInitialCash;
|
||||
uint8_t GuestInitialHappiness;
|
||||
|
@ -68,7 +68,7 @@ namespace OpenRCT2
|
|||
money64 TotalIncomeFromAdmissions;
|
||||
money64 TotalRideValueForMoney;
|
||||
uint16_t WeeklyProfitAverageDivisor;
|
||||
money64 WeeklyProfitHistory[FINANCE_GRAPH_SIZE];
|
||||
money64 WeeklyProfitHistory[kFinanceGraphSize];
|
||||
Objective ScenarioObjective;
|
||||
uint16_t ScenarioParkRatingWarningDays;
|
||||
money64 ScenarioCompletedCompanyValue;
|
||||
|
@ -76,7 +76,7 @@ namespace OpenRCT2
|
|||
money64 BankLoan;
|
||||
uint8_t BankLoanInterestRate;
|
||||
money64 MaxBankLoan;
|
||||
money64 ExpenditureTable[EXPENDITURE_TABLE_MONTH_COUNT][EnumValue(ExpenditureType::Count)];
|
||||
money64 ExpenditureTable[kExpenditureTableMonthCount][EnumValue(ExpenditureType::Count)];
|
||||
random_engine_t ScenarioRand;
|
||||
TileCoordsXY MapSize;
|
||||
money64 LandPrice;
|
||||
|
|
|
@ -598,7 +598,7 @@ void CheatSetAction::SetMoney(money64 amount) const
|
|||
|
||||
void CheatSetAction::AddMoney(money64 amount) const
|
||||
{
|
||||
GetGameState().Cash = AddClamp_money64(GetGameState().Cash, amount);
|
||||
GetGameState().Cash = AddClamp<money64>(GetGameState().Cash, amount);
|
||||
|
||||
WindowInvalidateByClass(WindowClass::Finances);
|
||||
WindowInvalidateByClass(WindowClass::BottomToolbar);
|
||||
|
|
|
@ -3850,7 +3850,7 @@ void Guest::UpdateRideFreeVehicleEnterRide(Ride& ride)
|
|||
}
|
||||
else
|
||||
{
|
||||
ride.total_profit = AddClamp_money64(ride.total_profit, ridePrice);
|
||||
ride.total_profit = AddClamp<money64>(ride.total_profit, ridePrice);
|
||||
ride.window_invalidate_flags |= RIDE_INVALIDATE_RIDE_INCOME;
|
||||
SpendMoney(PaidOnRides, ridePrice, ExpenditureType::ParkRideTickets);
|
||||
}
|
||||
|
|
|
@ -2561,7 +2561,7 @@ StringId GetRealNameStringIDFromPeepID(uint32_t id)
|
|||
dx += 0x1000;
|
||||
}
|
||||
dx /= 4;
|
||||
dx += REAL_NAME_START;
|
||||
dx += kRealNameStart;
|
||||
return dx;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,9 +30,6 @@ extern TTFFontSetDescriptor TTFFontNanum;
|
|||
extern TTFFontSetDescriptor TTFFontArial;
|
||||
extern TTFFontSetDescriptor TTFFontArialUnicode;
|
||||
extern TTFFontSetDescriptor TTFFontMicroHei;
|
||||
# define FONT(x) x
|
||||
#else
|
||||
# define FONT(x) FONT_OPENRCT2_SPRITE
|
||||
#endif // NO_TTF
|
||||
|
||||
void TryLoadFonts(OpenRCT2::Localisation::LocalisationService& localisationService);
|
||||
|
|
|
@ -41,7 +41,7 @@ enum class CloseWindowModifier : uint8_t;
|
|||
|
||||
constexpr uint8_t CloseButtonWidth = 10;
|
||||
|
||||
#define SCROLLABLE_ROW_HEIGHT 12
|
||||
constexpr int32_t kScrollableRowHeight = 12;
|
||||
constexpr uint8_t kListRowHeight = 12;
|
||||
constexpr uint8_t kTableCellHeight = 12;
|
||||
constexpr uint8_t kButtonFaceHeight = 12;
|
||||
|
|
|
@ -44,6 +44,6 @@ void CurrencyLoadCustomCurrencyConfig()
|
|||
{
|
||||
SafeStrCpy(
|
||||
CurrencyDescriptors[EnumValue(CurrencyType::Custom)].symbol_unicode, gConfigGeneral.CustomCurrencySymbol.c_str(),
|
||||
CURRENCY_SYMBOL_MAX_SIZE);
|
||||
kCurrencySymbolMaxSize);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
#include "../util/Util.h"
|
||||
#include "CurrencyTypes.h"
|
||||
|
||||
#define CURRENCY_SYMBOL_MAX_SIZE 8
|
||||
#define CURRENCY_RATE_MAX_NUM_DIGITS 9
|
||||
constexpr size_t kCurrencySymbolMaxSize = 8;
|
||||
constexpr size_t kCurrencyRateMaxNumDigits = 9;
|
||||
|
||||
// Currency format specification - inspired by OpenTTD
|
||||
struct CurrencyDescriptor
|
||||
|
@ -24,9 +24,9 @@ struct CurrencyDescriptor
|
|||
// Rate is relative to 0.10 GBP
|
||||
int32_t rate;
|
||||
CurrencyAffix affix_unicode;
|
||||
utf8 symbol_unicode[CURRENCY_SYMBOL_MAX_SIZE];
|
||||
utf8 symbol_unicode[kCurrencySymbolMaxSize];
|
||||
CurrencyAffix affix_ascii;
|
||||
char symbol_ascii[CURRENCY_SYMBOL_MAX_SIZE];
|
||||
char symbol_ascii[kCurrencySymbolMaxSize];
|
||||
StringId stringId;
|
||||
};
|
||||
|
||||
|
|
|
@ -285,7 +285,7 @@ namespace OpenRCT2
|
|||
{
|
||||
if (IsRealNameStringId(id))
|
||||
{
|
||||
auto realNameIndex = id - REAL_NAME_START;
|
||||
auto realNameIndex = id - kRealNameStart;
|
||||
ss << real_names[realNameIndex % std::size(real_names)];
|
||||
ss << ' ';
|
||||
ss << real_name_initials[(realNameIndex >> 10) % std::size(real_name_initials)];
|
||||
|
@ -625,7 +625,7 @@ namespace OpenRCT2
|
|||
|
||||
bool IsRealNameStringId(StringId id)
|
||||
{
|
||||
return id >= REAL_NAME_START && id <= REAL_NAME_END;
|
||||
return id >= kRealNameStart && id <= kRealNameEnd;
|
||||
}
|
||||
|
||||
FmtString GetFmtStringById(StringId id)
|
||||
|
|
|
@ -68,8 +68,6 @@ enum class RCT2LanguageId
|
|||
End = 255
|
||||
};
|
||||
|
||||
#define FONT_OPENRCT2_SPRITE NULL
|
||||
|
||||
#include "../interface/FontFamilies.h"
|
||||
|
||||
struct LanguageDescriptor
|
||||
|
|
|
@ -34,16 +34,14 @@ utf8* GetStringEnd(const utf8* text);
|
|||
size_t GetStringSize(const utf8* text);
|
||||
|
||||
// The maximum number of characters allowed for string/money conversions (anything above will risk integer overflow issues)
|
||||
#define MONEY_STRING_MAXLENGTH 14
|
||||
constexpr size_t kMoneyStringMaxlength = 14;
|
||||
money64 StringToMoney(const char* string_to_monetise);
|
||||
void MoneyToString(money64 amount, char* buffer_to_put_value_to, size_t buffer_len, bool forceDecimals);
|
||||
|
||||
#define MAX_USER_STRINGS 1024
|
||||
#define USER_STRING_MAX_LENGTH 32
|
||||
constexpr size_t kUserStringMaxLength = 32;
|
||||
|
||||
#define USER_STRING_END 0x8FFF
|
||||
#define REAL_NAME_START 0xA000
|
||||
#define REAL_NAME_END 0xDFFF
|
||||
constexpr uint16_t kRealNameStart = 0xA000;
|
||||
constexpr uint16_t kRealNameEnd = 0xDFFF;
|
||||
|
||||
constexpr size_t CommonTextBufferSize = 512;
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ void FinancePayment(money64 amount, ExpenditureType type)
|
|||
{
|
||||
// overflow check
|
||||
auto& gameState = GetGameState();
|
||||
gameState.Cash = AddClamp_money64(gameState.Cash, -amount);
|
||||
gameState.Cash = AddClamp<money64>(gameState.Cash, -amount);
|
||||
|
||||
gameState.ExpenditureTable[0][EnumValue(type)] -= amount;
|
||||
if (dword_988E60[EnumValue(type)] & 1)
|
||||
|
@ -186,14 +186,14 @@ void FinancePayRideUpkeep()
|
|||
void FinanceResetHistory()
|
||||
{
|
||||
auto& gameState = GetGameState();
|
||||
for (int32_t i = 0; i < FINANCE_GRAPH_SIZE; i++)
|
||||
for (auto i = 0; i < kFinanceGraphSize; i++)
|
||||
{
|
||||
gameState.CashHistory[i] = kMoney64Undefined;
|
||||
gameState.WeeklyProfitHistory[i] = kMoney64Undefined;
|
||||
gameState.Park.ValueHistory[i] = kMoney64Undefined;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < EXPENDITURE_TABLE_MONTH_COUNT; ++i)
|
||||
for (uint32_t i = 0; i < kExpenditureTableMonthCount; ++i)
|
||||
{
|
||||
for (uint32_t j = 0; j < static_cast<int32_t>(ExpenditureType::Count); ++j)
|
||||
{
|
||||
|
@ -318,18 +318,18 @@ money64 FinanceGetCurrentCash()
|
|||
void FinanceShiftExpenditureTable()
|
||||
{
|
||||
auto& gameState = GetGameState();
|
||||
// If EXPENDITURE_TABLE_MONTH_COUNT months have passed then is full, sum the oldest month
|
||||
if (GetDate().GetMonthsElapsed() >= EXPENDITURE_TABLE_MONTH_COUNT)
|
||||
// If kExpenditureTableMonthCount months have passed then is full, sum the oldest month
|
||||
if (GetDate().GetMonthsElapsed() >= kExpenditureTableMonthCount)
|
||||
{
|
||||
const money64 sum = std::accumulate(
|
||||
std::cbegin(gameState.ExpenditureTable[EXPENDITURE_TABLE_MONTH_COUNT - 1]),
|
||||
std::cend(gameState.ExpenditureTable[EXPENDITURE_TABLE_MONTH_COUNT - 1]), money64{});
|
||||
std::cbegin(gameState.ExpenditureTable[kExpenditureTableMonthCount - 1]),
|
||||
std::cend(gameState.ExpenditureTable[kExpenditureTableMonthCount - 1]), money64{});
|
||||
|
||||
GetGameState().HistoricalProfit += sum;
|
||||
}
|
||||
|
||||
// Shift the table
|
||||
for (size_t i = EXPENDITURE_TABLE_MONTH_COUNT - 1; i >= 1; i--)
|
||||
for (size_t i = kExpenditureTableMonthCount - 1; i >= 1; i--)
|
||||
{
|
||||
for (size_t j = 0; j < static_cast<int32_t>(ExpenditureType::Count); j++)
|
||||
{
|
||||
|
|
|
@ -31,8 +31,8 @@ enum class ExpenditureType : int32_t
|
|||
Count
|
||||
};
|
||||
|
||||
#define EXPENDITURE_TABLE_MONTH_COUNT 16
|
||||
#define FINANCE_GRAPH_SIZE 128
|
||||
constexpr uint8_t kExpenditureTableMonthCount = 16;
|
||||
constexpr uint8_t kFinanceGraphSize = 128;
|
||||
|
||||
constexpr uint8_t MaxBankLoanInterestRate = 255;
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "../GameStateSnapshots.h"
|
||||
#include "../OpenRCT2.h"
|
||||
#include "../PlatformEnvironment.h"
|
||||
#include "../Version.h"
|
||||
#include "../actions/LoadOrQuitAction.h"
|
||||
#include "../actions/NetworkModifyGroupAction.h"
|
||||
#include "../actions/PeepPickupAction.h"
|
||||
|
@ -45,9 +46,9 @@ using namespace OpenRCT2;
|
|||
// It is used for making sure only compatible builds get connected, even within
|
||||
// single OpenRCT2 version.
|
||||
|
||||
#define NETWORK_STREAM_VERSION "0"
|
||||
constexpr uint8_t kNetworkStreamVersion = 0;
|
||||
|
||||
#define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION
|
||||
const std::string kNetworkStreamID = std::string(OPENRCT2_VERSION) + "-" + std::to_string(kNetworkStreamVersion);
|
||||
|
||||
static Peep* _pickup_peep = nullptr;
|
||||
static int32_t _pickup_peep_old_x = LOCATION_NULL;
|
||||
|
@ -4056,7 +4057,7 @@ u8string NetworkGetServerProviderWebsite()
|
|||
|
||||
std::string NetworkGetVersion()
|
||||
{
|
||||
return NETWORK_STREAM_ID;
|
||||
return kNetworkStreamID;
|
||||
}
|
||||
|
||||
NetworkStats NetworkGetStats()
|
||||
|
|
|
@ -40,8 +40,6 @@ namespace ObjectSelectionFlags
|
|||
constexpr uint8_t AllFlags = 0xFF;
|
||||
}; // namespace ObjectSelectionFlags
|
||||
|
||||
#define OBJECT_SELECTION_NOT_SELECTED_OR_REQUIRED 0
|
||||
|
||||
enum class ObjectSourceGame : uint8_t
|
||||
{
|
||||
Custom,
|
||||
|
|
|
@ -125,7 +125,7 @@ struct TunnelEntry
|
|||
// the quadrant index is based on the x and y components combined.
|
||||
static constexpr int32_t MaxPaintQuadrants = kMaximumMapSizeTechnical * 2;
|
||||
|
||||
#define TUNNEL_MAX_COUNT 65
|
||||
constexpr uint8_t kTunnelMaxCount = 65;
|
||||
|
||||
/**
|
||||
* A pool of PaintEntry instances that can be rented out.
|
||||
|
@ -202,8 +202,8 @@ struct PaintSessionCore
|
|||
SupportHeight SupportSegments[9];
|
||||
SupportHeight Support;
|
||||
uint16_t WaterHeight;
|
||||
TunnelEntry LeftTunnels[TUNNEL_MAX_COUNT];
|
||||
TunnelEntry RightTunnels[TUNNEL_MAX_COUNT];
|
||||
TunnelEntry LeftTunnels[kTunnelMaxCount];
|
||||
TunnelEntry RightTunnels[kTunnelMaxCount];
|
||||
uint8_t LeftTunnelCount;
|
||||
uint8_t RightTunnelCount;
|
||||
uint8_t VerticalTunnelHeight;
|
||||
|
|
|
@ -629,7 +629,7 @@ static void ViewportSurfaceDrawTileSideBottom(
|
|||
|
||||
neighbourCornerHeight1 = cornerHeight2;
|
||||
|
||||
for (uint32_t tunnelIndex = 0; tunnelIndex < TUNNEL_MAX_COUNT;)
|
||||
for (auto tunnelIndex = 0; tunnelIndex < kTunnelMaxCount;)
|
||||
{
|
||||
if (curHeight >= cornerHeight1 || curHeight >= cornerHeight2)
|
||||
{
|
||||
|
|
|
@ -335,7 +335,7 @@ static void PaintTileElementBase(PaintSession& session, const CoordsXY& origCoor
|
|||
void PaintUtilPushTunnelLeft(PaintSession& session, uint16_t height, uint8_t type)
|
||||
{
|
||||
session.LeftTunnels[session.LeftTunnelCount] = { static_cast<uint8_t>((height / 16)), type };
|
||||
if (session.LeftTunnelCount < TUNNEL_MAX_COUNT - 1)
|
||||
if (session.LeftTunnelCount < kTunnelMaxCount - 1)
|
||||
{
|
||||
session.LeftTunnels[session.LeftTunnelCount + 1] = { 0xFF, 0xFF };
|
||||
session.LeftTunnelCount++;
|
||||
|
@ -345,7 +345,7 @@ void PaintUtilPushTunnelLeft(PaintSession& session, uint16_t height, uint8_t typ
|
|||
void PaintUtilPushTunnelRight(PaintSession& session, uint16_t height, uint8_t type)
|
||||
{
|
||||
session.RightTunnels[session.RightTunnelCount] = { static_cast<uint8_t>((height / 16)), type };
|
||||
if (session.RightTunnelCount < TUNNEL_MAX_COUNT - 1)
|
||||
if (session.RightTunnelCount < kTunnelMaxCount - 1)
|
||||
{
|
||||
session.RightTunnels[session.RightTunnelCount + 1] = { 0xFF, 0xFF };
|
||||
session.RightTunnelCount++;
|
||||
|
|
|
@ -818,7 +818,7 @@ namespace OpenRCT2
|
|||
// Finances
|
||||
if (cs.GetMode() == OrcaStream::Mode::READING)
|
||||
{
|
||||
auto numMonths = std::min<uint32_t>(EXPENDITURE_TABLE_MONTH_COUNT, cs.Read<uint32_t>());
|
||||
auto numMonths = std::min<uint32_t>(kExpenditureTableMonthCount, cs.Read<uint32_t>());
|
||||
auto numTypes = std::min<uint32_t>(static_cast<uint32_t>(ExpenditureType::Count), cs.Read<uint32_t>());
|
||||
for (uint32_t i = 0; i < numMonths; i++)
|
||||
{
|
||||
|
@ -830,7 +830,7 @@ namespace OpenRCT2
|
|||
}
|
||||
else
|
||||
{
|
||||
auto numMonths = static_cast<uint32_t>(EXPENDITURE_TABLE_MONTH_COUNT);
|
||||
auto numMonths = static_cast<uint32_t>(kExpenditureTableMonthCount);
|
||||
auto numTypes = static_cast<uint32_t>(ExpenditureType::Count);
|
||||
|
||||
cs.Write(numMonths);
|
||||
|
|
|
@ -2509,7 +2509,7 @@ namespace RCT1
|
|||
{
|
||||
const auto originalString = _s4.StringTable[stringId % 1024];
|
||||
auto originalStringView = std::string_view(
|
||||
originalString, RCT12::GetRCTStringBufferLen(originalString, USER_STRING_MAX_LENGTH));
|
||||
originalString, RCT12::GetRCTStringBufferLen(originalString, kUserStringMaxLength));
|
||||
auto asUtf8 = RCT2StringToUTF8(originalStringView, RCT2LanguageId::EnglishUK);
|
||||
auto justText = RCT12RemoveFormattingUTF8(asUtf8);
|
||||
return justText.data();
|
||||
|
|
|
@ -2376,7 +2376,7 @@ namespace RCT2
|
|||
{
|
||||
const auto originalString = _s6.CustomStrings[stringId % 1024];
|
||||
auto originalStringView = std::string_view(
|
||||
originalString, RCT12::GetRCTStringBufferLen(originalString, USER_STRING_MAX_LENGTH));
|
||||
originalString, RCT12::GetRCTStringBufferLen(originalString, kUserStringMaxLength));
|
||||
auto asUtf8 = RCT2StringToUTF8(originalStringView, RCT2LanguageId::EnglishUK);
|
||||
auto justText = RCT12RemoveFormattingUTF8(asUtf8);
|
||||
return justText.data();
|
||||
|
|
|
@ -448,7 +448,7 @@ int32_t Vehicle::CableLiftUpdateTrackMotion()
|
|||
vehicleCount++;
|
||||
|
||||
massTotal += vehicle->mass;
|
||||
accelerationTotal = AddClamp_int32_t(accelerationTotal, vehicle->acceleration);
|
||||
accelerationTotal = AddClamp<int32_t>(accelerationTotal, vehicle->acceleration);
|
||||
}
|
||||
|
||||
int32_t newAcceleration = (accelerationTotal / vehicleCount) >> 9;
|
||||
|
|
|
@ -846,14 +846,14 @@ void Vehicle::UpdateMeasurements()
|
|||
|
||||
if (curRide->average_speed_test_timeout == 0 && absVelocity > 0x8000)
|
||||
{
|
||||
curRide->average_speed = AddClamp_int32_t(curRide->average_speed, absVelocity);
|
||||
curRide->average_speed = AddClamp<int32_t>(curRide->average_speed, absVelocity);
|
||||
stationForTestSegment.SegmentTime++;
|
||||
}
|
||||
|
||||
int32_t distance = abs(((velocity + acceleration) >> 10) * 42);
|
||||
if (NumLaps == 0)
|
||||
{
|
||||
stationForTestSegment.SegmentLength = AddClamp_int32_t(stationForTestSegment.SegmentLength, distance);
|
||||
stationForTestSegment.SegmentLength = AddClamp<int32_t>(stationForTestSegment.SegmentLength, distance);
|
||||
}
|
||||
|
||||
if (curRide->GetRideTypeDescriptor().HasFlag(RIDE_TYPE_FLAG_HAS_G_FORCES))
|
||||
|
@ -1162,7 +1162,7 @@ void Vehicle::UpdateMeasurements()
|
|||
if (distance < 0)
|
||||
return;
|
||||
|
||||
curRide->sheltered_length = AddClamp_int32_t(curRide->sheltered_length, distance);
|
||||
curRide->sheltered_length = AddClamp<int32_t>(curRide->sheltered_length, distance);
|
||||
}
|
||||
|
||||
struct SoundIdVolume
|
||||
|
|
|
@ -232,7 +232,7 @@ void ScenarioSuccessSubmitName(GameState_t& gameState, const char* name)
|
|||
static void ScenarioCheckEntranceFeeTooHigh()
|
||||
{
|
||||
const auto& gameState = GetGameState();
|
||||
const auto max_fee = AddClamp_money64(gameState.TotalRideValueForMoney, gameState.TotalRideValueForMoney / 2);
|
||||
const auto max_fee = AddClamp<money64>(gameState.TotalRideValueForMoney, gameState.TotalRideValueForMoney / 2);
|
||||
|
||||
if ((gameState.Park.Flags & PARK_FLAGS_PARK_OPEN) && Park::GetEntranceFee() > max_fee)
|
||||
{
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace OpenRCT2::Title
|
|||
struct
|
||||
{
|
||||
EntityId SpriteIndex{ EntityId::GetNull() };
|
||||
utf8 SpriteName[USER_STRING_MAX_LENGTH]{};
|
||||
utf8 SpriteName[kUserStringMaxLength]{};
|
||||
} Follow;
|
||||
|
||||
int16_t operator()(int16_t timer);
|
||||
|
|
|
@ -380,7 +380,7 @@ namespace OpenRCT2::Title
|
|||
{
|
||||
auto entityID = EntityId::FromUnderlying(atoi(parts[1].data()) & 0xFFFF);
|
||||
auto followCommand = FollowEntityCommand{ entityID };
|
||||
SafeStrCpy(followCommand.Follow.SpriteName, parts[2].data(), USER_STRING_MAX_LENGTH);
|
||||
SafeStrCpy(followCommand.Follow.SpriteName, parts[2].data(), kUserStringMaxLength);
|
||||
command = followCommand;
|
||||
}
|
||||
else if (String::IEquals(token, "WAIT"))
|
||||
|
|
|
@ -501,55 +501,6 @@ std::vector<uint8_t> Ungzip(const void* data, const size_t dataLen)
|
|||
return output;
|
||||
}
|
||||
|
||||
// Type-independent code left as macro to reduce duplicate code.
|
||||
#define ADD_CLAMP_BODY(value, value_to_add, min_cap, max_cap) \
|
||||
if ((value_to_add > 0) && (value > (max_cap - (value_to_add)))) \
|
||||
{ \
|
||||
value = max_cap; \
|
||||
} \
|
||||
else if ((value_to_add < 0) && (value < (min_cap - (value_to_add)))) \
|
||||
{ \
|
||||
value = min_cap; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
value += value_to_add; \
|
||||
}
|
||||
|
||||
int8_t AddClamp_int8_t(int8_t value, int8_t value_to_add)
|
||||
{
|
||||
ADD_CLAMP_BODY(value, value_to_add, INT8_MIN, INT8_MAX);
|
||||
return value;
|
||||
}
|
||||
|
||||
int16_t AddClamp_int16_t(int16_t value, int16_t value_to_add)
|
||||
{
|
||||
ADD_CLAMP_BODY(value, value_to_add, INT16_MIN, INT16_MAX);
|
||||
return value;
|
||||
}
|
||||
|
||||
int32_t AddClamp_int32_t(int32_t value, int32_t value_to_add)
|
||||
{
|
||||
ADD_CLAMP_BODY(value, value_to_add, INT32_MIN, INT32_MAX);
|
||||
return value;
|
||||
}
|
||||
|
||||
int64_t AddClamp_int64_t(int64_t value, int64_t value_to_add)
|
||||
{
|
||||
ADD_CLAMP_BODY(value, value_to_add, INT64_MIN, INT64_MAX);
|
||||
return value;
|
||||
}
|
||||
|
||||
money64 AddClamp_money64(money64 value, money64 value_to_add)
|
||||
{
|
||||
// This function is intended only for clarity, as money64
|
||||
// is technically the same as int64_t
|
||||
assert_struct_size(money64, sizeof(int64_t));
|
||||
return AddClamp_int64_t(value, value_to_add);
|
||||
}
|
||||
|
||||
#undef add_clamp_body
|
||||
|
||||
uint8_t Lerp(uint8_t a, uint8_t b, float t)
|
||||
{
|
||||
if (t <= 0)
|
||||
|
|
|
@ -40,12 +40,27 @@ bool UtilGzipCompress(FILE* source, FILE* dest);
|
|||
std::vector<uint8_t> Gzip(const void* data, const size_t dataLen);
|
||||
std::vector<uint8_t> Ungzip(const void* data, const size_t dataLen);
|
||||
|
||||
// TODO: Make these specialized template functions, or when possible Concepts in C++20
|
||||
int8_t AddClamp_int8_t(int8_t value, int8_t value_to_add);
|
||||
int16_t AddClamp_int16_t(int16_t value, int16_t value_to_add);
|
||||
int32_t AddClamp_int32_t(int32_t value, int32_t value_to_add);
|
||||
int64_t AddClamp_int64_t(int64_t value, int64_t value_to_add);
|
||||
money64 AddClamp_money64(money64 value, money64 value_to_add);
|
||||
template<typename T> constexpr T AddClamp(T value, T valueToAdd)
|
||||
{
|
||||
if (std::is_same_v<decltype(value), money64>)
|
||||
{
|
||||
assert_struct_size(money64, sizeof(int64_t));
|
||||
}
|
||||
auto maxCap = std::numeric_limits<T>::max();
|
||||
auto minCap = std::numeric_limits<T>::lowest();
|
||||
if ((valueToAdd > 0) && (value > (maxCap - (valueToAdd))))
|
||||
{
|
||||
return maxCap;
|
||||
}
|
||||
else if ((valueToAdd < 0) && (value < (minCap - (valueToAdd))))
|
||||
{
|
||||
return minCap;
|
||||
}
|
||||
else
|
||||
{
|
||||
return value + valueToAdd;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t Lerp(uint8_t a, uint8_t b, float t);
|
||||
float FLerp(float a, float b, float t);
|
||||
|
|
|
@ -514,7 +514,7 @@ namespace OpenRCT2::Park
|
|||
auto result = gameState.Park.Value - gameState.BankLoan;
|
||||
|
||||
// Clamp addition to prevent overflow
|
||||
result = AddClamp_money64(result, FinanceGetCurrentCash());
|
||||
result = AddClamp<money64>(result, FinanceGetCurrentCash());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ namespace OpenRCT2
|
|||
std::vector<CoordsXYZD> Entrances;
|
||||
uint32_t Size;
|
||||
money64 Value;
|
||||
money64 ValueHistory[FINANCE_GRAPH_SIZE];
|
||||
money64 ValueHistory[kFinanceGraphSize];
|
||||
|
||||
bool IsOpen() const;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue