Compare commits

...

36 Commits

Author SHA1 Message Date
Claudio Tiecher 3b53f7585f
Merge 8425a17a2e into 81e068c7b2 2024-05-08 22:10:11 -03:00
Aaron van Geffen 81e068c7b2
Merge pull request #21990 from AaronVanGeffen/config-include
Remove Config.h include (and therefore Drawing.h) from many places
2024-05-09 00:00:42 +02:00
Aaron van Geffen a61a561d01 Remove Currency.h include from Localisation.h 2024-05-08 23:41:42 +02:00
Aaron van Geffen a627cf7a1e Remove Drawing.h include from Config.h 2024-05-08 23:18:53 +02:00
Aaron van Geffen ca6f142a97 Remove Config.h include from many places 2024-05-08 22:29:32 +02:00
Michael Steenbeek ca1118c2f1
Merge pull request #21985 from AaronVanGeffen/guest-constants
Use constants for balloon/umbrella/hat sprites in more places
2024-05-08 22:23:22 +02:00
Aaron van Geffen 779e65d8b2 GameBottomToolbar: use constants for balloon/umbrella/hat sprites 2024-05-07 23:00:46 +02:00
Aaron van Geffen 73c592b137 Guest window: use constants for balloon/umbrella/hat sprites 2024-05-07 23:00:36 +02:00
Claudio Tiecher 8425a17a2e Part of #21421: apply clang-format 2024-05-06 16:40:40 +02:00
Claudio Tiecher cc6d69cb94 Part of #21421: apply correct network stream version number 2024-05-06 16:36:51 +02:00
Claudio Tiecher 20df80a453 Part of #21421: improved on comments about AddClamp func 2024-05-06 16:18:57 +02:00
Claudio Tiecher bdb7b9949c Part of #21421: fix reference to kAddClampBody 2024-05-06 16:18:57 +02:00
Claudio Tiecher c32020bb96 Part of #21421: using std::numerics for finding bounds 2024-05-06 16:18:57 +02:00
Claudio Tiecher c4cc84c454 Part of #21421: apply clang format 2024-05-06 16:18:57 +02:00
Claudio Tiecher 1449f3db8f Part of #21421: fix more merge conflict 2024-05-06 16:18:56 +02:00
Claudio Tiecher d24522a916 Part of #21421: fix merge conflict 2024-05-06 16:18:56 +02:00
Claudio Tiecher 89d221f96a Part of #21421: revert to nbsp in Currency.cpp 2024-05-06 16:18:56 +02:00
Claudio Tiecher 2f3af08d08 Part of #21421: incorporate feedback from #21760 2024-05-06 16:18:56 +02:00
Claudio Tiecher 8e73eb1d07 Part of #21421: applied clang-format to Util.cpp 2024-05-06 16:18:56 +02:00
Claudio Tiecher 33c9c27298 Part of #21421: refactor ADD_CLAMP_BODY 2024-05-06 16:18:56 +02:00
Claudio Tiecher 4e47730ac2 Part of #21421: refactor SCROLLABLE_ROW_HEIGHT 2024-05-06 16:18:56 +02:00
Claudio Tiecher 345b9a935f Part of #21421: refactor CURRENCY_RATE_MAX_NUM_DIGITS 2024-05-06 16:18:56 +02:00
Claudio Tiecher f698fbfc54 Part of #21421: refactor CURRENCY_SYMBOL_MAX_SIZE 2024-05-06 16:18:56 +02:00
Claudio Tiecher 1f7070b948 Part of #21421: deleted FONT(X) and FONT_OPENRCT2_SPRITE 2024-05-06 16:18:56 +02:00
Claudio Tiecher ca7dc0c826 Part of #21421: refactor REAL_NAME_END 2024-05-06 16:18:56 +02:00
Claudio Tiecher 505a80f319 Part of #21421: refactor REAL_NAME_START 2024-05-06 16:18:56 +02:00
Claudio Tiecher a1eb6f04e3 Part of #21421: deleted USER_STRING_END 2024-05-06 16:18:56 +02:00
Claudio Tiecher 80df0082d9 Part of #21421: refactor USER_STRING_MAX_LENGTH 2024-05-06 16:18:56 +02:00
Claudio Tiecher 7282e4f8b3 Part of #21421: deleted MAX_USER_STRINGS 2024-05-06 16:18:56 +02:00
Claudio Tiecher ea2efcdc36 Part of #21421: MONEY_STRING_MAXLENGTH 2024-05-06 16:18:56 +02:00
Claudio Tiecher 44b234aa42 Part of #21421: refactor NETWORK_STREAM_VERSION and _ID 2024-05-06 16:18:49 +02:00
Claudio Tiecher ae975a8050 Part of #21421: refactor FINANCE_GRAPH_SIZE 2024-05-06 16:13:35 +02:00
Claudio Tiecher 83b8629b9c Part of #21421: refactor EXPENDITURE_TABLE_MONTH_COUNT 2024-05-06 16:13:35 +02:00
Claudio Tiecher e6084b7fa4 Part of #21421: refactor MAX_SERVER_DESCRIPTION_LENGTH 2024-05-06 16:13:35 +02:00
Claudio Tiecher 1ae4400c95 Part of #21421: deleted unused OBJECT_SELECTION_NOT_... 2024-05-06 16:13:35 +02:00
Claudio Tiecher aaf6e63441 Part of #21421: refactor TUNNEL_MAX_COUNT 2024-05-06 16:13:35 +02:00
85 changed files with 306 additions and 326 deletions

View File

@ -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;

View File

@ -17,7 +17,6 @@
#include <openrct2/OpenRCT2.h>
#include <openrct2/actions/CheatSetAction.h>
#include <openrct2/actions/ParkSetDateAction.h>
#include <openrct2/config/Config.h>
#include <openrct2/localisation/Date.h>
#include <openrct2/localisation/Formatter.h>
#include <openrct2/localisation/Localisation.h>
@ -359,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;
@ -710,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);
@ -790,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);

View File

@ -14,6 +14,7 @@
#include <openrct2/core/String.hpp>
#include <openrct2/drawing/Drawing.h>
#include <openrct2/interface/Colour.h>
#include <openrct2/localisation/Currency.h>
#include <openrct2/localisation/Formatter.h>
#include <openrct2/localisation/Localisation.h>
#include <openrct2/util/Util.h>
@ -109,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;
}
}
@ -122,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;
}
}
@ -164,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;

View File

@ -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;

View File

@ -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;

View File

@ -16,7 +16,6 @@
#include <openrct2/GameState.h>
#include <openrct2/actions/ParkSetLoanAction.h>
#include <openrct2/actions/ParkSetResearchFundingAction.h>
#include <openrct2/config/Config.h>
#include <openrct2/localisation/Date.h>
#include <openrct2/localisation/Formatter.h>
#include <openrct2/localisation/Localisation.h>
@ -604,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

View File

@ -26,6 +26,7 @@
#include <openrct2/management/Finance.h>
#include <openrct2/management/NewsItem.h>
#include <openrct2/peep/PeepAnimationData.h>
#include <openrct2/peep/PeepSpriteIds.h>
#include <openrct2/sprites.h>
#include <openrct2/world/Park.h>
@ -296,15 +297,18 @@ static Widget window_game_bottom_toolbar_widgets[] =
auto* guest = peep->As<Guest>();
if (guest != nullptr)
{
if (image_id_base >= 0x2A1D && image_id_base < 0x2A3D)
if (image_id_base >= kPeepSpriteBalloonStateWatchRideId
&& image_id_base < kPeepSpriteBalloonStateSittingIdleId + 4)
{
GfxDrawSprite(cliped_dpi, ImageId(image_id_base + 32, guest->BalloonColour), clipCoords);
}
else if (image_id_base >= 0x2BBD && image_id_base < 0x2BDD)
if (image_id_base >= kPeepSpriteUmbrellaStateNoneId
&& image_id_base < kPeepSpriteUmbrellaStateSittingIdleId + 4)
{
GfxDrawSprite(cliped_dpi, ImageId(image_id_base + 32, guest->UmbrellaColour), clipCoords);
}
else if (image_id_base >= 0x29DD && image_id_base < 0x29FD)
if (image_id_base >= kPeepSpriteHatStateWatchRideId
&& image_id_base < kPeepSpriteHatStateSittingIdleId + 4)
{
GfxDrawSprite(cliped_dpi, ImageId(image_id_base + 32, guest->HatColour), clipCoords);
}

View File

@ -28,6 +28,7 @@
#include <openrct2/management/Marketing.h>
#include <openrct2/network/network.h>
#include <openrct2/peep/PeepAnimationData.h>
#include <openrct2/peep/PeepSpriteIds.h>
#include <openrct2/ride/RideData.h>
#include <openrct2/ride/ShopItem.h>
#include <openrct2/scenario/Scenario.h>
@ -561,19 +562,21 @@ static_assert(_guestWindowPageWidgets.size() == WINDOW_GUEST_PAGE_COUNT);
if (guest != nullptr)
{
// If holding a balloon
if (animationFrame >= 0x2A1D && animationFrame < 0x2A3D)
if (animationFrame >= kPeepSpriteBalloonStateWatchRideId
&& animationFrame < kPeepSpriteBalloonStateSittingIdleId + 4)
{
GfxDrawSprite(clipDpi, ImageId(animationFrame + 32, guest->BalloonColour), screenCoords);
}
// If holding umbrella
if (animationFrame >= 0x2BBD && animationFrame < 0x2BDD)
if (animationFrame >= kPeepSpriteUmbrellaStateNoneId
&& animationFrame < kPeepSpriteUmbrellaStateSittingIdleId + 4)
{
GfxDrawSprite(clipDpi, ImageId(animationFrame + 32, guest->UmbrellaColour), screenCoords);
}
// If wearing hat
if (animationFrame >= 0x29DD && animationFrame < 0x29FD)
if (animationFrame >= kPeepSpriteHatStateWatchRideId && animationFrame < kPeepSpriteHatStateSittingIdleId + 4)
{
GfxDrawSprite(clipDpi, ImageId(animationFrame + 32, guest->HatColour), screenCoords);
}

View File

@ -14,7 +14,6 @@
#include <openrct2/Context.h>
#include <openrct2/Game.h>
#include <openrct2/GameState.h>
#include <openrct2/config/Config.h>
#include <openrct2/drawing/Drawing.h>
#include <openrct2/entity/EntityRegistry.h>
#include <openrct2/entity/Guest.h>
@ -130,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{};
@ -501,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;
@ -540,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)
{
@ -555,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)
{
@ -668,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;
}
@ -723,7 +722,7 @@ static Widget window_guest_list_widgets[] = {
break;
}
}
y += SCROLLABLE_ROW_HEIGHT;
y += kScrollableRowHeight;
index++;
}
}

View File

@ -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)

View File

@ -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;
}
}

View File

@ -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);

View File

@ -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);
}
}
}

View File

@ -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:

View File

@ -18,7 +18,6 @@
#include <openrct2/GameState.h>
#include <openrct2/actions/RideDemolishAction.h>
#include <openrct2/actions/RideSetStatusAction.h>
#include <openrct2/config/Config.h>
#include <openrct2/drawing/Drawing.h>
#include <openrct2/interface/Colour.h>
#include <openrct2/localisation/Formatter.h>
@ -386,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;
@ -411,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;
@ -437,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;
@ -552,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);
}
@ -742,7 +741,7 @@ static Widget _rideListWidgets[] = {
ft.Add<StringId>(formatSecondary);
}
DrawTextEllipsised(dpi, { 160, y - 1 }, 157, format, ft);
y += SCROLLABLE_ROW_HEIGHT;
y += kScrollableRowHeight;
}
}

View File

@ -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;

View File

@ -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++;
}
}

View File

@ -13,7 +13,6 @@
#include <openrct2-ui/interface/Widget.h>
#include <openrct2-ui/windows/Window.h>
#include <openrct2/Context.h>
#include <openrct2/config/Config.h>
#include <openrct2/core/String.hpp>
#include <openrct2/drawing/Drawing.h>
#include <openrct2/localisation/Formatter.h>

View File

@ -15,7 +15,6 @@
#include <openrct2/Context.h>
#include <openrct2/Game.h>
#include <openrct2/Input.h>
#include <openrct2/config/Config.h>
#include <openrct2/drawing/Drawing.h>
#include <openrct2/localisation/Formatter.h>
#include <openrct2/localisation/Localisation.h>

View File

@ -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());
}

View File

@ -10,7 +10,6 @@
#include <openrct2-ui/interface/Widget.h>
#include <openrct2-ui/windows/Window.h>
#include <openrct2/Context.h>
#include <openrct2/config/Config.h>
#include <openrct2/localisation/Localisation.h>
#include <openrct2/sprites.h>

View File

@ -18,7 +18,6 @@
#include <openrct2/ParkImporter.h>
#include <openrct2/PlatformEnvironment.h>
#include <openrct2/actions/LoadOrQuitAction.h>
#include <openrct2/config/Config.h>
#include <openrct2/localisation/Localisation.h>
#include <openrct2/sprites.h>
#include <openrct2/ui/UiContext.h>

View File

@ -10,7 +10,6 @@
#include <openrct2-ui/interface/Widget.h>
#include <openrct2-ui/windows/Window.h>
#include <openrct2/Context.h>
#include <openrct2/config/Config.h>
#include <openrct2/localisation/Localisation.h>
namespace OpenRCT2::Ui::Windows

View File

@ -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++;
}
}

View File

@ -12,7 +12,6 @@
#include "GameState.h"
#include "actions/CheatSetAction.h"
#include "actions/ParkSetLoanAction.h"
#include "config/Config.h"
#include "core/DataSerialiser.h"
#include "localisation/Localisation.h"
#include "network/network.h"

View File

@ -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;

View File

@ -15,6 +15,7 @@
#include "core/Path.hpp"
#include "core/String.hpp"
#include "platform/Platform.h"
#include "util/Util.h"
using namespace OpenRCT2;

View File

@ -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);

View File

@ -11,7 +11,6 @@
#include "../Context.h"
#include "../GameState.h"
#include "../config/Config.h"
#include "../core/MemoryStream.h"
#include "../drawing/Drawing.h"
#include "../localisation/Localisation.h"

View File

@ -12,6 +12,7 @@
#include "../OpenRCT2.h"
#include "../core/Console.hpp"
#include "../core/String.hpp"
#include "../drawing/Font.h"
#include "../platform/Platform.h"
#include <cstring>

View File

@ -11,6 +11,7 @@
#include "../Game.h"
#include "../GameState.h"
#include "../OpenRCT2.h"
#include "../config/ConfigTypes.h"
#include "../core/Console.hpp"
#include "../entity/EntityRegistry.h"
#include "../network/network.h"

View File

@ -10,19 +10,13 @@
#pragma once
#include "../core/String.hpp"
#include "../drawing/Drawing.h"
#include "../localisation/Currency.h"
#include "../localisation/CurrencyTypes.h"
#include "ConfigTypes.h"
#include <atomic>
#include <string>
enum class MeasurementFormat : int32_t;
enum class TemperatureUnit : int32_t;
enum class ScaleQuality : int32_t;
enum class Sort : int32_t;
enum class VirtualFloorStyles : int32_t;
enum class DrawingEngine : int32_t;
enum class TitleMusicKind : int32_t;
struct Gx;
struct GeneralConfiguration
{
@ -221,43 +215,6 @@ struct PluginConfiguration
u8string AllowedHosts;
};
enum class Sort : int32_t
{
NameAscending,
NameDescending,
DateAscending,
DateDescending,
};
enum class TemperatureUnit : int32_t
{
Celsius,
Fahrenheit
};
enum class ScaleQuality : int32_t
{
NearestNeighbour,
Linear,
SmoothNearestNeighbour
};
enum class MeasurementFormat : int32_t
{
Imperial,
Metric,
SI
};
enum class TitleMusicKind : int32_t
{
None,
Random,
OpenRCT2,
RCT1,
RCT2,
};
extern GeneralConfiguration gConfigGeneral;
extern InterfaceConfiguration gConfigInterface;
extern SoundConfiguration gConfigSound;

View File

@ -0,0 +1,58 @@
/*****************************************************************************
* Copyright (c) 2014-2024 OpenRCT2 developers
*
* For a complete list of all authors, please refer to contributors.md
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
*
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
#pragma once
#include <cstdint>
enum class MeasurementFormat : int32_t;
enum class TemperatureUnit : int32_t;
enum class CurrencyType : uint8_t;
enum class ScaleQuality : int32_t;
enum class Sort : int32_t;
enum class VirtualFloorStyles : int32_t;
enum class DrawingEngine : int32_t;
enum class TitleMusicKind : int32_t;
enum class Sort : int32_t
{
NameAscending,
NameDescending,
DateAscending,
DateDescending,
};
enum class TemperatureUnit : int32_t
{
Celsius,
Fahrenheit
};
enum class ScaleQuality : int32_t
{
NearestNeighbour,
Linear,
SmoothNearestNeighbour
};
enum class MeasurementFormat : int32_t
{
Imperial,
Metric,
SI
};
enum class TitleMusicKind : int32_t
{
None,
Random,
OpenRCT2,
RCT1,
RCT2,
};

View File

@ -10,7 +10,6 @@
#include "NewDrawing.h"
#include "../Context.h"
#include "../config/Config.h"
#include "../drawing/Drawing.h"
#include "../interface/Screenshot.h"
#include "../localisation/StringIds.h"

View File

@ -19,8 +19,10 @@
# include "../OpenRCT2.h"
# include "../core/Numerics.hpp"
# include "../core/String.hpp"
# include "../drawing/Font.h"
# include "../localisation/LocalisationService.h"
# include "../platform/Platform.h"
# include "../util/Util.h"
# include "DrawingLock.hpp"
# include "TTF.h"

View File

@ -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);
}

View File

@ -2561,7 +2561,7 @@ StringId GetRealNameStringIDFromPeepID(uint32_t id)
dx += 0x1000;
}
dx /= 4;
dx += REAL_NAME_START;
dx += kRealNameStart;
return dx;
}

View File

@ -15,7 +15,6 @@
#include "../Input.h"
#include "../actions/StaffSetOrdersAction.h"
#include "../audio/audio.h"
#include "../config/Config.h"
#include "../core/DataSerialiser.h"
#include "../entity/EntityRegistry.h"
#include "../interface/Viewport.h"

View File

@ -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);

View File

@ -16,6 +16,7 @@
#include "../PlatformEnvironment.h"
#include "../actions/CheatSetAction.h"
#include "../audio/audio.h"
#include "../config/Config.h"
#include "../core/Console.hpp"
#include "../core/File.h"
#include "../core/Imaging.h"

View File

@ -11,6 +11,7 @@
#include "../Context.h"
#include "../OpenRCT2.h"
#include "../config/ConfigTypes.h"
#include "../platform/Platform.h"
#include "../scripting/ScriptEngine.h"

View File

@ -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;

View File

@ -176,6 +176,7 @@
<ClInclude Include="common.h" />
<ClInclude Include="config\Config.h" />
<ClInclude Include="config\ConfigEnum.hpp" />
<ClInclude Include="config\ConfigTypes.h" />
<ClInclude Include="config\IniReader.hpp" />
<ClInclude Include="config\IniWriter.hpp" />
<ClInclude Include="Context.h" />
@ -278,6 +279,7 @@
<ClInclude Include="Limits.h" />
<ClInclude Include="localisation\ConversionTables.h" />
<ClInclude Include="localisation\Currency.h" />
<ClInclude Include="localisation\CurrencyTypes.h" />
<ClInclude Include="localisation\Date.h" />
<ClInclude Include="localisation\FormatCodes.h" />
<ClInclude Include="localisation\Formatter.h" />

View File

@ -44,6 +44,6 @@ void CurrencyLoadCustomCurrencyConfig()
{
SafeStrCpy(
CurrencyDescriptors[EnumValue(CurrencyType::Custom)].symbol_unicode, gConfigGeneral.CustomCurrencySymbol.c_str(),
CURRENCY_SYMBOL_MAX_SIZE);
kCurrencySymbolMaxSize);
}
}

View File

@ -12,41 +12,10 @@
#include "../common.h"
#include "../core/String.hpp"
#include "../util/Util.h"
#include "CurrencyTypes.h"
// List of currencies
enum class CurrencyType : uint8_t
{
Pounds, // British Pound
Dollars, // US Dollar
Franc, // French Franc
DeutscheMark, // Deutsche Mark
Yen, // Japanese Yen
Peseta, // Spanish Peseta
Lira, // Italian Lira
Guilders, // Dutch Gilder
Krona, // Swedish Krona
Euros, // Euro
Won, // South Korean Won
Rouble, // Russian Rouble
CzechKoruna, // Czech koruna
HKD, // Hong Kong Dollar
TWD, // New Taiwan Dollar
Yuan, // Chinese Yuan
Forint, // Hungarian Forint
Custom, // Custom currency
Count // Last item
};
enum class CurrencyAffix
{
Prefix,
Suffix
};
#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
@ -55,13 +24,14 @@ 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;
};
// List of currency formats
// TODO: refactor into getter
extern CurrencyDescriptor CurrencyDescriptors[EnumValue(CurrencyType::Count)];
/**

View File

@ -0,0 +1,44 @@
/*****************************************************************************
* Copyright (c) 2014-2024 OpenRCT2 developers
*
* For a complete list of all authors, please refer to contributors.md
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
*
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
#pragma once
#include <cstdint>
// List of currencies
enum class CurrencyType : uint8_t
{
Pounds, // British Pound
Dollars, // US Dollar
Franc, // French Franc
DeutscheMark, // Deutsche Mark
Yen, // Japanese Yen
Peseta, // Spanish Peseta
Lira, // Italian Lira
Guilders, // Dutch Gilder
Krona, // Swedish Krona
Euros, // Euro
Won, // South Korean Won
Rouble, // Russian Rouble
CzechKoruna, // Czech koruna
HKD, // Hong Kong Dollar
TWD, // New Taiwan Dollar
Yuan, // Chinese Yuan
Forint, // Hungarian Forint
Custom, // Custom currency
Count // Last item
};
enum class CurrencyAffix
{
Prefix,
Suffix
};

View File

@ -11,6 +11,7 @@
#include "../config/Config.h"
#include "../util/Util.h"
#include "Currency.h"
#include "Formatter.h"
#include "Localisation.h"
#include "StringIds.h"
@ -284,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)];
@ -624,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)

View File

@ -68,8 +68,6 @@ enum class RCT2LanguageId
End = 255
};
#define FONT_OPENRCT2_SPRITE NULL
#include "../interface/FontFamilies.h"
struct LanguageDescriptor

View File

@ -26,6 +26,7 @@
#include "../management/Marketing.h"
#include "../ride/Ride.h"
#include "../util/Util.h"
#include "Currency.h"
#include "Date.h"
#include "Formatting.h"
#include "Localisation.h"

View File

@ -10,7 +10,6 @@
#pragma once
#include "../management/Marketing.h"
#include "Currency.h"
#include "Date.h"
#include "FormatCodes.h"
#include "Language.h"
@ -35,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;

View File

@ -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++)
{

View File

@ -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;

View File

@ -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()

View File

@ -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,

View File

@ -13,7 +13,6 @@
#include "../OpenRCT2.h"
#include "../PlatformEnvironment.h"
#include "../common.h"
#include "../config/Config.h"
#include "../core/Console.hpp"
#include "../core/DataSerialiser.h"
#include "../core/FileIndex.hpp"

View File

@ -14,6 +14,7 @@
#include "../core/Guard.hpp"
#include "../drawing/Drawing.h"
#include "../interface/Viewport.h"
#include "../localisation/Currency.h"
#include "../localisation/Formatting.h"
#include "../localisation/Localisation.h"
#include "../localisation/LocalisationService.h"

View File

@ -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;

View File

@ -11,7 +11,6 @@
#include "../../Game.h"
#include "../../GameState.h"
#include "../../config/Config.h"
#include "../../interface/Viewport.h"
#include "../../localisation/Date.h"
#include "../../object/SmallSceneryEntry.h"

View File

@ -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)
{

View File

@ -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++;

View File

@ -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);

View File

@ -16,9 +16,9 @@
#include "../Context.h"
#include "../Game.h"
#include "../config/Config.h"
#include "../core/File.h"
#include "../core/Path.hpp"
#include "../localisation/Currency.h"
#include "../localisation/Localisation.h"
#include "Platform.h"

View File

@ -14,7 +14,6 @@
# include "../Date.h"
# include "../core/Memory.hpp"
# include "../core/Path.hpp"
# include "../core/String.hpp"
# include "../util/Util.h"
# include <cerrno>

View File

@ -10,7 +10,8 @@
#pragma once
#include "../common.h"
#include "../config/Config.h"
#include "../config/ConfigTypes.h"
#include "../core/String.hpp"
#include <ctime>
#include <string>
@ -42,6 +43,7 @@ enum class SPECIAL_FOLDER
struct RealWorldDate;
struct RealWorldTime;
struct TTFFontDescriptor;
namespace Platform
{

View File

@ -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();

View File

@ -14,7 +14,6 @@
#include "../GameState.h"
#include "../OpenRCT2.h"
#include "../ParkImporter.h"
#include "../config/Config.h"
#include "../core/Console.hpp"
#include "../core/FileStream.h"
#include "../core/IStream.hpp"
@ -2377,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();

View File

@ -8,7 +8,6 @@
*****************************************************************************/
#include "../TrackImporter.h"
#include "../config/Config.h"
#include "../core/FileStream.h"
#include "../core/MemoryStream.h"
#include "../core/Path.hpp"

View File

@ -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;

View File

@ -11,7 +11,6 @@
#include "../Context.h"
#include "../PlatformEnvironment.h"
#include "../config/Config.h"
#include "../core/Collections.hpp"
#include "../core/Console.hpp"
#include "../core/File.h"

View File

@ -10,7 +10,6 @@
#include "../Context.h"
#include "../Game.h"
#include "../audio/audio.h"
#include "../config/Config.h"
#include "../interface/Viewport.h"
#include "../localisation/Localisation.h"
#include "../localisation/StringIds.h"

View File

@ -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

View File

@ -7,7 +7,6 @@
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
#include "../../config/Config.h"
#include "../../entity/EntityRegistry.h"
#include "../../entity/Guest.h"
#include "../../interface/Viewport.h"

View File

@ -8,7 +8,6 @@
*****************************************************************************/
#include "../../common.h"
#include "../../config/Config.h"
#include "../../interface/Viewport.h"
#include "../../paint/Paint.h"
#include "../../paint/support/WoodenSupports.h"

View File

@ -7,7 +7,6 @@
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
#include "../../config/Config.h"
#include "../../entity/EntityRegistry.h"
#include "../../interface/Viewport.h"
#include "../../paint/Paint.h"

View File

@ -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)
{

View File

@ -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);

View File

@ -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"))

View File

@ -7,7 +7,6 @@
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
#include "../config/Config.h"
#include "../drawing/X8DrawingEngine.h"
#include "UiContext.h"
#include "WindowManager.h"

View File

@ -11,7 +11,7 @@
#include "../Context.h"
#include "../common.h"
#include "../config/Config.h"
#include "../config/ConfigTypes.h"
#include "../interface/Cursors.h"
#include <memory>

View File

@ -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)

View File

@ -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);

View File

@ -20,7 +20,6 @@
#include "../actions/ParkEntranceRemoveAction.h"
#include "../actions/WallRemoveAction.h"
#include "../audio/audio.h"
#include "../config/Config.h"
#include "../core/Guard.hpp"
#include "../interface/Cursors.h"
#include "../interface/Viewport.h"

View File

@ -16,7 +16,6 @@
#include "../GameState.h"
#include "../OpenRCT2.h"
#include "../actions/ParkSetParameterAction.h"
#include "../config/Config.h"
#include "../core/Memory.hpp"
#include "../core/String.hpp"
#include "../entity/Litter.h"
@ -515,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;
}

View File

@ -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;
};

View File

@ -18,7 +18,6 @@
#include <openrct2/OpenRCT2.h>
#include <openrct2/ParkImporter.h>
#include <openrct2/audio/AudioContext.h>
#include <openrct2/config/Config.h>
#include <openrct2/core/Crypt.h>
#include <openrct2/core/File.h>
#include <openrct2/core/MemoryStream.h>