Use std::size instead of Util::CountOf

This commit is contained in:
Hielke Morsink 2018-11-21 23:16:04 +01:00
parent 88b2f5fa53
commit 354d973a48
82 changed files with 2216 additions and 2180 deletions

View File

@ -12,6 +12,7 @@
#include <SDL2/SDL.h>
#include <algorithm>
#include <iterator>
#include <list>
#include <openrct2/Context.h>
#include <openrct2/OpenRCT2.h>
@ -22,7 +23,6 @@
#include <openrct2/common.h>
#include <openrct2/config/Config.h>
#include <openrct2/core/Guard.hpp>
#include <openrct2/core/Util.hpp>
#include <openrct2/localisation/Localisation.h>
#include <openrct2/platform/platform.h>
#include <speex/speex_resampler.h>
@ -103,14 +103,14 @@ namespace OpenRCT2::Audio
SDL_CloseAudioDevice(_deviceId);
// Free sources
for (size_t i = 0; i < Util::CountOf(_css1Sources); i++)
for (size_t i = 0; i < std::size(_css1Sources); i++)
{
if (_css1Sources[i] != _nullSource)
{
SafeDelete(_css1Sources[i]);
}
}
for (size_t i = 0; i < Util::CountOf(_musicSources); i++)
for (size_t i = 0; i < std::size(_musicSources); i++)
{
if (_musicSources[i] != _nullSource)
{
@ -162,7 +162,7 @@ namespace OpenRCT2::Audio
bool LoadMusic(size_t pathId) override
{
bool result = false;
if (pathId < Util::CountOf(_musicSources))
if (pathId < std::size(_musicSources))
{
IAudioSource* source = _musicSources[pathId];
if (source == nullptr)
@ -199,7 +199,7 @@ namespace OpenRCT2::Audio
void LoadAllSounds()
{
const utf8* css1Path = context_get_path_legacy(PATH_ID_CSS1);
for (size_t i = 0; i < Util::CountOf(_css1Sources); i++)
for (size_t i = 0; i < std::size(_css1Sources); i++)
{
auto source = AudioSource::CreateMemoryFromCSS1(css1Path, i, &_format);
if (source == nullptr)

View File

@ -9,6 +9,7 @@
#include "KeyboardShortcuts.h"
#include <iterator>
#include <openrct2-ui/interface/Viewport.h>
#include <openrct2-ui/interface/Widget.h>
#include <openrct2-ui/interface/Window.h>
@ -19,7 +20,6 @@
#include <openrct2/OpenRCT2.h>
#include <openrct2/audio/audio.h>
#include <openrct2/config/Config.h>
#include <openrct2/core/Util.hpp>
#include <openrct2/interface/Chat.h>
#include <openrct2/interface/Screenshot.h>
#include <openrct2/localisation/Localisation.h>
@ -57,7 +57,7 @@ void keyboard_shortcut_handle(int32_t key)
void keyboard_shortcut_handle_command(int32_t shortcutIndex)
{
if (shortcutIndex >= 0 && static_cast<uint32_t>(shortcutIndex) < Util::CountOf(shortcut_table))
if (shortcutIndex >= 0 && static_cast<uint32_t>(shortcutIndex) < std::size(shortcut_table))
{
shortcut_action action = shortcut_table[shortcutIndex];
if (action != nullptr)

View File

@ -9,6 +9,7 @@
#include <algorithm>
#include <cmath>
#include <iterator>
#include <openrct2-ui/interface/Dropdown.h>
#include <openrct2-ui/interface/Viewport.h>
#include <openrct2-ui/interface/Widget.h>
@ -20,7 +21,6 @@
#include <openrct2/OpenRCT2.h>
#include <openrct2/audio/audio.h>
#include <openrct2/config/Config.h>
#include <openrct2/core/Util.hpp>
#include <openrct2/interface/Chat.h>
#include <openrct2/interface/Cursors.h>
#include <openrct2/interface/InteractiveConsole.h>
@ -176,7 +176,7 @@ static rct_mouse_data* get_mouse_input()
else
{
rct_mouse_data* result = &_mouseInputQueue[_mouseInputQueueReadIndex];
_mouseInputQueueReadIndex = (_mouseInputQueueReadIndex + 1) % Util::CountOf(_mouseInputQueue);
_mouseInputQueueReadIndex = (_mouseInputQueueReadIndex + 1) % std::size(_mouseInputQueue);
return result;
}
}
@ -1546,7 +1546,7 @@ void invalidate_scroll()
void store_mouse_input(int32_t state, int32_t x, int32_t y)
{
uint32_t writeIndex = _mouseInputQueueWriteIndex;
uint32_t nextWriteIndex = (writeIndex + 1) % Util::CountOf(_mouseInputQueue);
uint32_t nextWriteIndex = (writeIndex + 1) % std::size(_mouseInputQueue);
// Check if the queue is full
if (nextWriteIndex != _mouseInputQueueReadIndex)

View File

@ -8,13 +8,13 @@
*****************************************************************************/
#include <algorithm>
#include <iterator>
#include <openrct2-ui/interface/Dropdown.h>
#include <openrct2-ui/interface/Widget.h>
#include <openrct2-ui/windows/Window.h>
#include <openrct2/Context.h>
#include <openrct2/Game.h>
#include <openrct2/config/Config.h>
#include <openrct2/core/Util.hpp>
#include <openrct2/localisation/Date.h>
#include <openrct2/localisation/Localisation.h>
#include <openrct2/network/network.h>
@ -732,7 +732,7 @@ static void window_cheats_misc_mousedown(rct_window* w, rct_widgetindex widgetIn
dropdownWidget = widget - 1;
for (size_t i = 0; i < Util::CountOf(_staffSpeedNames); i++)
for (size_t i = 0; i < std::size(_staffSpeedNames); i++)
{
gDropdownItemsArgs[i] = _staffSpeedNames[i];
gDropdownItemsFormat[i] = STR_DROPDOWN_MENU_LABEL;

View File

@ -8,11 +8,11 @@
*****************************************************************************/
#include <algorithm>
#include <iterator>
#include <openrct2-ui/interface/Dropdown.h>
#include <openrct2-ui/interface/Widget.h>
#include <openrct2/Context.h>
#include <openrct2/Input.h>
#include <openrct2/core/Util.hpp>
#include <openrct2/drawing/Drawing.h>
#include <openrct2/localisation/Localisation.h>
#include <openrct2/sprites.h>
@ -54,7 +54,7 @@ int32_t gDropdownDefaultIndex;
bool dropdown_is_checked(int32_t index)
{
if (index < 0 || index >= (int32_t)Util::CountOf(_dropdownItemsDisabled))
if (index < 0 || index >= (int32_t)std::size(_dropdownItemsDisabled))
{
return false;
}
@ -63,7 +63,7 @@ bool dropdown_is_checked(int32_t index)
bool dropdown_is_disabled(int32_t index)
{
if (index < 0 || index >= (int32_t)Util::CountOf(_dropdownItemsDisabled))
if (index < 0 || index >= (int32_t)std::size(_dropdownItemsDisabled))
{
return true;
}
@ -72,7 +72,7 @@ bool dropdown_is_disabled(int32_t index)
void dropdown_set_checked(int32_t index, bool value)
{
if (index < 0 || index >= (int32_t)Util::CountOf(_dropdownItemsDisabled))
if (index < 0 || index >= (int32_t)std::size(_dropdownItemsDisabled))
{
return;
}
@ -81,7 +81,7 @@ void dropdown_set_checked(int32_t index, bool value)
void dropdown_set_disabled(int32_t index, bool value)
{
if (index < 0 || index >= (int32_t)Util::CountOf(_dropdownItemsDisabled))
if (index < 0 || index >= (int32_t)std::size(_dropdownItemsDisabled))
{
return;
}

View File

@ -7,12 +7,12 @@
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
#include <iterator>
#include <openrct2-ui/interface/Widget.h>
#include <openrct2-ui/windows/Window.h>
#include <openrct2/Editor.h>
#include <openrct2/Input.h>
#include <openrct2/OpenRCT2.h>
#include <openrct2/core/Util.hpp>
#include <openrct2/interface/Cursors.h>
#include <openrct2/localisation/Localisation.h>
#include <openrct2/management/Research.h>
@ -203,7 +203,7 @@ static void research_rides_setup()
*/
static void research_scenery_groups_setup()
{
for (size_t i = 0; i < Util::CountOf(RequiredSelectedObjects); i++)
for (size_t i = 0; i < std::size(RequiredSelectedObjects); i++)
{
const rct_object_entry* object = &RequiredSelectedObjects[i];
@ -804,12 +804,12 @@ static void window_editor_inventions_list_scrollpaint(rct_window* w, rct_drawpix
const auto rideEntry = get_ride_entry(researchItem->entryIndex);
const rct_string_id rideGroupName = get_ride_naming(researchItem->baseRideType, rideEntry).name;
format_string(
groupNamePtr, Util::CountOf(groupNameBuffer), STR_INVENTIONS_LIST_RIDE_AND_VEHICLE_NAME, (void*)&rideGroupName);
format_string(vehicleNamePtr, Util::CountOf(vehicleNameBuffer), itemNameId, nullptr);
groupNamePtr, std::size(groupNameBuffer), STR_INVENTIONS_LIST_RIDE_AND_VEHICLE_NAME, (void*)&rideGroupName);
format_string(vehicleNamePtr, std::size(vehicleNameBuffer), itemNameId, nullptr);
}
else
{
format_string(groupNamePtr, Util::CountOf(groupNameBuffer), itemNameId, nullptr);
format_string(groupNamePtr, std::size(groupNameBuffer), itemNameId, nullptr);
vehicleNamePtr = nullptr;
}

View File

@ -12,10 +12,10 @@
#include "../interface/Window.h"
#include "Window.h"
#include <iterator>
#include <openrct2/Context.h>
#include <openrct2/OpenRCT2.h>
#include <openrct2/actions/ParkSetNameAction.hpp>
#include <openrct2/core/Util.hpp>
#include <openrct2/drawing/Drawing.h>
#include <openrct2/drawing/Font.h>
#include <openrct2/interface/Colour.h>
@ -775,11 +775,11 @@ static void window_editor_objective_options_main_textinput(rct_window* w, rct_wi
break;
}
case WIDX_SCENARIO_NAME:
safe_strcpy(gS6Info.name, text, Util::CountOf(gS6Info.name));
safe_strcpy(gS6Info.name, text, std::size(gS6Info.name));
window_invalidate(w);
break;
case WIDX_DETAILS:
safe_strcpy(gS6Info.details, text, Util::CountOf(gS6Info.details));
safe_strcpy(gS6Info.details, text, std::size(gS6Info.details));
window_invalidate(w);
break;
}

View File

@ -9,6 +9,7 @@
#include <algorithm>
#include <ctime>
#include <iterator>
#include <memory>
#include <openrct2-ui/interface/Widget.h>
#include <openrct2-ui/windows/Window.h>
@ -21,7 +22,6 @@
#include <openrct2/core/Guard.hpp>
#include <openrct2/core/Path.hpp>
#include <openrct2/core/String.hpp>
#include <openrct2/core/Util.hpp>
#include <openrct2/localisation/Localisation.h>
#include <openrct2/platform/Platform2.h>
#include <openrct2/platform/platform.h>
@ -813,12 +813,12 @@ static void window_loadsave_sort_list()
static void window_loadsave_populate_list(rct_window* w, int32_t includeNewItem, const char* directory, const char* extension)
{
utf8 absoluteDirectory[MAX_PATH];
Path::GetAbsolute(absoluteDirectory, Util::CountOf(absoluteDirectory), directory);
safe_strcpy(_directory, absoluteDirectory, Util::CountOf(_directory));
Path::GetAbsolute(absoluteDirectory, std::size(absoluteDirectory), directory);
safe_strcpy(_directory, absoluteDirectory, std::size(_directory));
// Note: This compares the pointers, not values
if (_extension != extension)
{
safe_strcpy(_extension, extension, Util::CountOf(_extension));
safe_strcpy(_extension, extension, std::size(_extension));
}
_shortenedDirectory[0] = '\0';
@ -850,7 +850,7 @@ static void window_loadsave_populate_list(rct_window* w, int32_t includeNewItem,
else
{
// Remove the separator at the end of the path, if present
safe_strcpy(_parentDirectory, absoluteDirectory, Util::CountOf(_parentDirectory));
safe_strcpy(_parentDirectory, absoluteDirectory, std::size(_parentDirectory));
if (_parentDirectory[strlen(_parentDirectory) - 1] == *PATH_SEPARATOR
|| _parentDirectory[strlen(_parentDirectory) - 1] == '/')
_parentDirectory[strlen(_parentDirectory) - 1] = '\0';
@ -902,14 +902,14 @@ static void window_loadsave_populate_list(rct_window* w, int32_t includeNewItem,
// List all files with the wanted extensions
char filter[MAX_PATH];
char extCopy[64];
safe_strcpy(extCopy, extension, Util::CountOf(extCopy));
safe_strcpy(extCopy, extension, std::size(extCopy));
bool showExtension = false;
char* extToken = strtok(extCopy, ";");
while (extToken != nullptr)
{
safe_strcpy(filter, directory, Util::CountOf(filter));
safe_strcat_path(filter, "*", Util::CountOf(filter));
path_append_extension(filter, extToken, Util::CountOf(filter));
safe_strcpy(filter, directory, std::size(filter));
safe_strcat_path(filter, "*", std::size(filter));
path_append_extension(filter, extToken, std::size(filter));
auto scanner = std::unique_ptr<IFileScanner>(Path::ScanDirectory(filter, false));
while (scanner->Next())

View File

@ -8,6 +8,7 @@
*****************************************************************************/
#include <algorithm>
#include <iterator>
#include <openrct2-ui/interface/LandTool.h>
#include <openrct2-ui/interface/Viewport.h>
#include <openrct2-ui/interface/Widget.h>
@ -18,7 +19,6 @@
#include <openrct2/Input.h>
#include <openrct2/OpenRCT2.h>
#include <openrct2/audio/audio.h>
#include <openrct2/core/Util.hpp>
#include <openrct2/localisation/Localisation.h>
#include <openrct2/ride/Track.h>
#include <openrct2/world/Entrance.h>
@ -842,7 +842,7 @@ static void window_map_paint(rct_window* w, rct_drawpixelinfo* dpi)
STR_MAP_INFO_KIOSK, STR_MAP_FIRST_AID, STR_MAP_CASH_MACHINE, STR_MAP_TOILET,
};
for (uint32_t i = 0; i < Util::CountOf(RideKeyColours); i++)
for (uint32_t i = 0; i < std::size(RideKeyColours); i++)
{
gfx_fill_rect(dpi, x, y + 2, x + 6, y + 8, RideKeyColours[i]);
gfx_draw_string_left(dpi, mapLabels[i], w, COLOUR_BLACK, x + LIST_ROW_HEIGHT, y);
@ -1549,7 +1549,7 @@ static uint16_t map_window_get_pixel_colour_peep(CoordsXY c)
if (!(tileElement->AsSurface()->GetOwnership() & OWNERSHIP_OWNED))
colour = MAP_COLOUR_UNOWNED(colour);
const int32_t maxSupportedTileElementType = (int32_t)Util::CountOf(ElementTypeAddColour);
const int32_t maxSupportedTileElementType = (int32_t)std::size(ElementTypeAddColour);
while (!(tileElement++)->IsLastForTile())
{
int32_t tileElementType = tileElement->GetType() >> 2;

View File

@ -7,9 +7,9 @@
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
#include <iterator>
#include <openrct2-ui/interface/Widget.h>
#include <openrct2-ui/windows/Window.h>
#include <openrct2/core/Util.hpp>
#include <openrct2/drawing/Drawing.h>
#include <openrct2/interface/Colour.h>
#include <openrct2/localisation/Localisation.h>
@ -161,7 +161,7 @@ static void window_music_credits_mouseup(rct_window* w, rct_widgetindex widgetIn
static void window_music_credits_scrollgetsize(rct_window* w, int32_t scrollIndex, int32_t* width, int32_t* height)
{
int32_t lineHeight = font_get_line_height(gCurrentFontSpriteBase);
*height = static_cast<int32_t>(Util::CountOf(music_credits) + Util::CountOf(music_credits_rct2)) * lineHeight + 12;
*height = static_cast<int32_t>(std::size(music_credits) + std::size(music_credits_rct2)) * lineHeight + 12;
}
/**
@ -184,7 +184,7 @@ static void window_music_credits_scrollpaint(rct_window* w, rct_drawpixelinfo* d
int32_t x = 245;
int32_t y = 2;
for (size_t i = 0; i < Util::CountOf(music_credits); i++)
for (size_t i = 0; i < std::size(music_credits); i++)
{
gfx_draw_string_centred(dpi, music_credits[i], x, y, COLOUR_BLACK, nullptr);
y += lineHeight;
@ -200,7 +200,7 @@ static void window_music_credits_scrollpaint(rct_window* w, rct_drawpixelinfo* d
gfx_fill_rect_inset(dpi, 4, y, 484, y + 1, w->colours[1], INSET_RECT_FLAG_BORDER_INSET);
y += lineHeight + 1;
for (size_t i = 0; i < Util::CountOf(music_credits_rct2); i++)
for (size_t i = 0; i < std::size(music_credits_rct2); i++)
{
gfx_draw_string_centred(dpi, music_credits_rct2[i], x, y, COLOUR_BLACK, nullptr);
y += lineHeight;

View File

@ -8,6 +8,7 @@
*****************************************************************************/
#include <algorithm>
#include <iterator>
#include <limits>
#include <openrct2-ui/interface/Widget.h>
#include <openrct2-ui/windows/Window.h>
@ -17,7 +18,6 @@
#include <openrct2/audio/audio.h>
#include <openrct2/config/Config.h>
#include <openrct2/core/String.hpp>
#include <openrct2/core/Util.hpp>
#include <openrct2/localisation/Localisation.h>
#include <openrct2/management/NewsItem.h>
#include <openrct2/management/Research.h>
@ -312,7 +312,7 @@ static void window_new_ride_populate_list()
ride_list_item* nextListItem = _windowNewRideListItems;
// For each ride type in the view order list
for (int32_t i = 0; i < (int32_t)Util::CountOf(RideTypeViewOrder); i++)
for (int32_t i = 0; i < (int32_t)std::size(RideTypeViewOrder); i++)
{
uint8_t rideType = RideTypeViewOrder[i];
if (rideType == RIDE_TYPE_NULL)
@ -443,7 +443,7 @@ static void window_new_ride_scroll_to_focused_ride(rct_window* w)
// Find row index of the focused ride type
rct_widget* listWidget = &window_new_ride_widgets[WIDX_RIDE_LIST];
assert(_windowNewRideCurrentTab < Util::CountOf(_windowNewRideHighlightedItem));
assert(_windowNewRideCurrentTab < std::size(_windowNewRideHighlightedItem));
int32_t focusRideType = _windowNewRideHighlightedItem[_windowNewRideCurrentTab].ride_type_and_entry;
int32_t count = 0, row = 0;
ride_list_item* listItem = _windowNewRideListItems;

View File

@ -8,10 +8,10 @@
*****************************************************************************/
#include <cstddef>
#include <iterator>
#include <openrct2-ui/interface/Widget.h>
#include <openrct2-ui/windows/Window.h>
#include <openrct2/config/Config.h>
#include <openrct2/core/Util.hpp>
#include <openrct2/drawing/Drawing.h>
#include <openrct2/localisation/Localisation.h>
#include <openrct2/sprites.h>
@ -161,7 +161,7 @@ static void window_news_options_mouseup(rct_window* w, rct_widgetindex widgetInd
if (checkBoxIndex >= 0)
{
int32_t matchIndex = 0;
for (size_t i = 0; i < Util::CountOf(NewsItemOptionDefinitions); i++)
for (size_t i = 0; i < std::size(NewsItemOptionDefinitions); i++)
{
const notification_def* ndef = &NewsItemOptionDefinitions[i];
if (ndef->category != w->page)
@ -206,7 +206,7 @@ static void window_news_options_invalidate(rct_window* w)
int32_t checkboxWidgetIndex = WIDX_CHECKBOX_0;
rct_widget* checkboxWidget = &w->widgets[checkboxWidgetIndex];
for (size_t i = 0; i < Util::CountOf(NewsItemOptionDefinitions); i++)
for (size_t i = 0; i < std::size(NewsItemOptionDefinitions); i++)
{
const notification_def* ndef = &NewsItemOptionDefinitions[i];
if (ndef->category != w->page)

View File

@ -11,6 +11,7 @@
#include <algorithm>
#include <cmath>
#include <iterator>
#include <limits>
#include <openrct2-ui/interface/Dropdown.h>
#include <openrct2-ui/interface/Viewport.h>
@ -23,7 +24,6 @@
#include <openrct2/OpenRCT2.h>
#include <openrct2/audio/audio.h>
#include <openrct2/config/Config.h>
#include <openrct2/core/Util.hpp>
#include <openrct2/localisation/Date.h>
#include <openrct2/localisation/Localisation.h>
#include <openrct2/localisation/LocalisationService.h>
@ -3880,7 +3880,7 @@ static void window_ride_maintenance_mousedown(rct_window* w, rct_widgetindex wid
gDropdownItemsArgs[0] = STR_DEBUG_FIX_RIDE;
for (int32_t i = 0; i < 8; i++)
{
assert(j < (int32_t)Util::CountOf(rideEntry->ride_type));
assert(j < (int32_t)std::size(rideEntry->ride_type));
if (RideAvailableBreakdowns[rideEntry->ride_type[j]] & (uint8_t)(1 << i))
{
if (i == BREAKDOWN_BRAKES_FAILURE
@ -4019,7 +4019,7 @@ static void window_ride_maintenance_dropdown(rct_window* w, rct_widgetindex widg
int32_t num_items = 1;
for (i = 0; i < BREAKDOWN_COUNT; i++)
{
assert(j < (int32_t)Util::CountOf(rideEntry->ride_type));
assert(j < (int32_t)std::size(rideEntry->ride_type));
if (RideAvailableBreakdowns[rideEntry->ride_type[j]] & (uint8_t)(1 << i))
{
if (i == BREAKDOWN_BRAKES_FAILURE
@ -4399,7 +4399,7 @@ static void window_ride_colour_mousedown(rct_window* w, rct_widgetindex widgetIn
break;
case WIDX_ENTRANCE_STYLE_DROPDOWN:
checkedIndex = -1;
for (i = 0; i < (int32_t)Util::CountOf(window_ride_entrance_style_list); i++)
for (i = 0; i < (int32_t)std::size(window_ride_entrance_style_list); i++)
{
gDropdownItemsFormat[i] = STR_DROPDOWN_MENU_LABEL;
gDropdownItemsArgs[i] = RideEntranceDefinitions[window_ride_entrance_style_list[i]].string_id;
@ -4412,7 +4412,7 @@ static void window_ride_colour_mousedown(rct_window* w, rct_widgetindex widgetIn
window_dropdown_show_text_custom_width(
w->x + dropdownWidget->left, w->y + dropdownWidget->top, dropdownWidget->bottom - dropdownWidget->top + 1,
w->colours[1], 0, DROPDOWN_FLAG_STAY_OPEN, Util::CountOf(window_ride_entrance_style_list),
w->colours[1], 0, DROPDOWN_FLAG_STAY_OPEN, std::size(window_ride_entrance_style_list),
widget->right - dropdownWidget->left);
if (checkedIndex != -1)
@ -5021,7 +5021,7 @@ static void window_ride_music_mousedown(rct_window* w, rct_widgetindex widgetInd
}
else
{
for (size_t n = 0; n < Util::CountOf(MusicStyleOrder); n++)
for (size_t n = 0; n < std::size(MusicStyleOrder); n++)
window_ride_current_music_style_order[numItems++] = MusicStyleOrder[n];
if (gRideMusicInfoList[36].length != 0)
@ -5136,7 +5136,7 @@ static void window_ride_music_paint(rct_window* w, rct_drawpixelinfo* dpi)
static rct_string_id get_rating_name(ride_rating rating)
{
int32_t index = std::clamp<int32_t>(rating >> 8, 0, (int32_t)Util::CountOf(RatingNames) - 1);
int32_t index = std::clamp<int32_t>(rating >> 8, 0, (int32_t)std::size(RatingNames) - 1);
return RatingNames[index];
}

View File

@ -19,7 +19,6 @@
#include <openrct2/Input.h>
#include <openrct2/audio/audio.h>
#include <openrct2/config/Config.h>
#include <openrct2/core/Util.hpp>
#include <openrct2/localisation/Localisation.h>
#include <openrct2/network/network.h>
#include <openrct2/ride/Ride.h>

View File

@ -9,13 +9,13 @@
#include "../interface/Theme.h"
#include <iterator>
#include <openrct2-ui/interface/Dropdown.h>
#include <openrct2-ui/interface/Widget.h>
#include <openrct2-ui/windows/Window.h>
#include <openrct2/Context.h>
#include <openrct2/Game.h>
#include <openrct2/config/Config.h>
#include <openrct2/core/Util.hpp>
#include <openrct2/drawing/Drawing.h>
#include <openrct2/interface/Colour.h>
#include <openrct2/localisation/Localisation.h>
@ -388,7 +388,7 @@ static void window_ride_list_dropdown(rct_window* w, rct_widgetindex widgetIndex
int32_t informationType = INFORMATION_TYPE_STATUS;
uint32_t arg = (uint32_t)gDropdownItemsArgs[dropdownIndex];
for (size_t i = 0; i < Util::CountOf(ride_info_type_string_mapping); i++)
for (size_t i = 0; i < std::size(ride_info_type_string_mapping); i++)
{
if (arg == ride_info_type_string_mapping[i])
{

View File

@ -7,6 +7,7 @@
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
#include <iterator>
#include <openrct2-ui/interface/Widget.h>
#include <openrct2-ui/windows/Window.h>
#include <openrct2/Context.h>
@ -14,7 +15,6 @@
#include <openrct2/OpenRCT2.h>
#include <openrct2/audio/audio.h>
#include <openrct2/config/Config.h>
#include <openrct2/core/Util.hpp>
#include <openrct2/localisation/Localisation.h>
#include <openrct2/scenario/Scenario.h>
#include <openrct2/windows/Intent.h>
@ -163,7 +163,7 @@ rct_window* window_save_prompt_open()
height = 54;
}
if (prompt_mode >= Util::CountOf(window_save_prompt_labels))
if (prompt_mode >= std::size(window_save_prompt_labels))
{
log_warning("Invalid save prompt mode %u", prompt_mode);
return nullptr;

View File

@ -15,12 +15,12 @@
*/
#include <algorithm>
#include <iterator>
#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/core/Util.hpp>
#include <openrct2/drawing/Drawing.h>
#include <openrct2/localisation/Localisation.h>
#include <openrct2/util/Util.h>
@ -99,7 +99,7 @@ void window_text_input_open(
rct_string_id existing_text, uintptr_t existing_args, int32_t maxLength)
{
// Get the raw string
utf8 buffer[Util::CountOf(text_input)]{};
utf8 buffer[std::size(text_input)]{};
if (existing_text != STR_NONE)
format_string(buffer, maxLength, existing_text, &existing_args);

View File

@ -8,6 +8,7 @@
*****************************************************************************/
#include <algorithm>
#include <iterator>
#include <openrct2-ui/interface/Dropdown.h>
#include <openrct2-ui/interface/Widget.h>
#include <openrct2-ui/windows/Window.h>
@ -15,7 +16,6 @@
#include <openrct2/Input.h>
#include <openrct2/common.h>
#include <openrct2/core/Guard.hpp>
#include <openrct2/core/Util.hpp>
#include <openrct2/localisation/Localisation.h>
#include <openrct2/localisation/StringIds.h>
#include <openrct2/ride/RideData.h>
@ -1759,7 +1759,7 @@ static void window_tile_inspector_paint(rct_window* w, rct_drawpixelinfo* dpi)
// Edge texture name
uint32_t idx = tileElement->AsSurface()->GetEdgeStyle();
openrct2_assert(
(uint32_t)idx < Util::CountOf(TerrainEdgeTypeStringIds),
(uint32_t)idx < std::size(TerrainEdgeTypeStringIds),
"Tried accessing invalid entry %d in terrainEdgeTypeStringIds", idx);
rct_string_id terrainEdgeNameId = TerrainEdgeTypeStringIds[tileElement->AsSurface()->GetEdgeStyle()];
gfx_draw_string_left(dpi, STR_TILE_INSPECTOR_SURFACE_EDGE, &terrainEdgeNameId, COLOUR_DARK_GREEN, x, y + 11);

View File

@ -9,6 +9,7 @@
#include "../interface/Theme.h"
#include <iterator>
#include <openrct2-ui/interface/Dropdown.h>
#include <openrct2-ui/interface/Viewport.h>
#include <openrct2-ui/interface/Widget.h>
@ -17,7 +18,6 @@
#include <openrct2/Input.h>
#include <openrct2/OpenRCT2.h>
#include <openrct2/core/Memory.hpp>
#include <openrct2/core/Util.hpp>
#include <openrct2/drawing/Drawing.h>
#include <openrct2/localisation/Localisation.h>
#include <openrct2/scenario/ScenarioRepository.h>
@ -48,7 +48,7 @@ static TITLE_COMMAND_ORDER _window_title_command_editor_orders[] = {
{ TITLE_SCRIPT_END, STR_TITLE_EDITOR_END, STR_NONE },
};
#define NUM_COMMANDS Util::CountOf(_window_title_command_editor_orders)
#define NUM_COMMANDS std::size(_window_title_command_editor_orders)
enum WINDOW_WATER_WIDGET_IDX {
WIDX_BACKGROUND,
@ -636,7 +636,7 @@ static void window_title_command_editor_tool_down(rct_window* w, rct_widgetindex
else if (spriteIdentifier == SPRITE_IDENTIFIER_LITTER)
{
rct_litter* litter = &(get_sprite(spriteIndex)->litter);
if (litter->type < Util::CountOf(litterNames))
if (litter->type < std::size(litterNames))
{
validSprite = true;
format_string(command.SpriteName, USER_STRING_MAX_LENGTH, litterNames[litter->type], nullptr);

View File

@ -11,6 +11,7 @@
#include "../interface/InGameConsole.h"
#include <algorithm>
#include <iterator>
#include <limits>
#include <openrct2-ui/interface/Dropdown.h>
#include <openrct2-ui/interface/LandTool.h>
@ -26,7 +27,6 @@
#include <openrct2/ParkImporter.h>
#include <openrct2/audio/audio.h>
#include <openrct2/config/Config.h>
#include <openrct2/core/Util.hpp>
#include <openrct2/interface/InteractiveConsole.h>
#include <openrct2/interface/Screenshot.h>
#include <openrct2/network/network.h>
@ -783,7 +783,7 @@ static void window_top_toolbar_invalidate(rct_window* w)
// Align left hand side toolbar buttons
firstAlignment = 1;
x = 0;
for (size_t i = 0; i < Util::CountOf(left_aligned_widgets_order); ++i)
for (size_t i = 0; i < std::size(left_aligned_widgets_order); ++i)
{
widgetIndex = left_aligned_widgets_order[i];
widget = &window_top_toolbar_widgets[widgetIndex];
@ -805,7 +805,7 @@ static void window_top_toolbar_invalidate(rct_window* w)
int32_t screenWidth = context_get_width();
firstAlignment = 1;
x = std::max(640, screenWidth);
for (size_t i = 0; i < Util::CountOf(right_aligned_widgets_order); ++i)
for (size_t i = 0; i < std::size(right_aligned_widgets_order); ++i)
{
widgetIndex = right_aligned_widgets_order[i];
widget = &window_top_toolbar_widgets[widgetIndex];

View File

@ -7,14 +7,10 @@
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
#include <algorithm>
#include <cmath>
#include <exception>
#include <memory>
#include <string>
#ifdef __EMSCRIPTEN__
# include <emscripten.h>
#endif // __EMSCRIPTEN__
#include "Context.h"
#include "Editor.h"
#include "FileClassifier.h"
@ -37,7 +33,6 @@
#include "core/MemoryStream.h"
#include "core/Path.hpp"
#include "core/String.hpp"
#include "core/Util.hpp"
#include "drawing/IDrawingEngine.h"
#include "drawing/LightFX.h"
#include "interface/Chat.h"
@ -65,6 +60,13 @@
#include "util/Util.h"
#include "world/Park.h"
#include <algorithm>
#include <cmath>
#include <exception>
#include <iterator>
#include <memory>
#include <string>
using namespace OpenRCT2;
using namespace OpenRCT2::Audio;
using namespace OpenRCT2::Drawing;
@ -513,8 +515,8 @@ namespace OpenRCT2
stream, info.Type == FILE_TYPE::SCENARIO, false, path.c_str());
_objectManager->LoadObjects(result.RequiredObjects.data(), result.RequiredObjects.size());
parkImporter->Import();
String::Set(gScenarioSavePath, Util::CountOf(gScenarioSavePath), path.c_str());
String::Set(gCurrentLoadedPath, Util::CountOf(gCurrentLoadedPath), path.c_str());
String::Set(gScenarioSavePath, std::size(gScenarioSavePath), path.c_str());
String::Set(gCurrentLoadedPath, std::size(gCurrentLoadedPath), path.c_str());
gFirstTimeSaving = true;
game_fix_save_vars();
sprite_position_tween_reset();

View File

@ -13,7 +13,6 @@
#include "Editor.h"
#include "Game.h"
#include "OpenRCT2.h"
#include "core/Util.hpp"
#include "localisation/Localisation.h"
#include "management/Research.h"
#include "object/DefaultObjects.h"
@ -25,6 +24,7 @@
#include "world/Footpath.h"
#include "world/LargeScenery.h"
#include <iterator>
#include <vector>
bool _maxObjectsWasHit;
@ -351,9 +351,7 @@ static void window_editor_object_selection_select_default_objects()
*/
static void window_editor_object_selection_select_required_objects()
{
int32_t i;
for (i = 0; i < (int32_t)Util::CountOf(RequiredSelectedObjects); i++)
for (size_t i = 0; i < std::size(RequiredSelectedObjects); i++)
window_editor_object_selection_select_object(0, 0xF, &RequiredSelectedObjects[i]);
}

View File

@ -19,7 +19,6 @@
#include "audio/audio.h"
#include "config/Config.h"
#include "core/FileScanner.h"
#include "core/Util.hpp"
#include "interface/Screenshot.h"
#include "interface/Viewport.h"
#include "interface/Window.h"
@ -61,6 +60,7 @@
#include "world/Water.h"
#include <algorithm>
#include <iterator>
#include <memory>
#define NUMBER_OF_AUTOSAVES_TO_KEEP 9
@ -109,7 +109,7 @@ using namespace OpenRCT2;
int32_t game_command_callback_get_index(GAME_COMMAND_CALLBACK_POINTER* callback)
{
for (uint32_t i = 0; i < Util::CountOf(game_command_callback_table); i++)
for (uint32_t i = 0; i < std::size(game_command_callback_table); i++)
{
if (game_command_callback_table[i] == callback)
{
@ -121,7 +121,7 @@ int32_t game_command_callback_get_index(GAME_COMMAND_CALLBACK_POINTER* callback)
GAME_COMMAND_CALLBACK_POINTER* game_command_callback_get_callback(uint32_t index)
{
if (index < Util::CountOf(game_command_callback_table))
if (index < std::size(game_command_callback_table))
{
return game_command_callback_table[index];
}
@ -379,7 +379,7 @@ int32_t game_do_command_p(
original_edi = *edi;
original_ebp = *ebp;
if (command >= Util::CountOf(new_game_command_table))
if (command >= std::size(new_game_command_table))
{
return MONEY32_UNDEFINED;
}
@ -768,7 +768,7 @@ void game_log_multiplayer_command(int command, const int* eax, const int* ebx, c
if (nameChunkOffset < 0)
nameChunkOffset = 2;
nameChunkOffset *= 12;
nameChunkOffset = std::min(nameChunkOffset, (int32_t)(Util::CountOf(banner_name) - 12));
nameChunkOffset = std::min(nameChunkOffset, (int32_t)(std::size(banner_name) - 12));
memcpy(banner_name + nameChunkOffset + 0, edx, 4);
memcpy(banner_name + nameChunkOffset + 4, ebp, 4);
memcpy(banner_name + nameChunkOffset + 8, edi, 4);

View File

@ -13,7 +13,6 @@
#include "../core/Guard.hpp"
#include "../core/Memory.hpp"
#include "../core/MemoryStream.h"
#include "../core/Util.hpp"
#include "../localisation/Localisation.h"
#include "../network/network.h"
#include "../platform/platform.h"
@ -21,6 +20,7 @@
#include "../world/Park.h"
#include <algorithm>
#include <iterator>
GameActionResult::GameActionResult(GA_ERROR error, rct_string_id message)
{
@ -49,7 +49,7 @@ namespace GameActions
GameActionFactory Register(uint32_t id, GameActionFactory factory)
{
Guard::Assert(id < Util::CountOf(_actions));
Guard::Assert(id < std::size(_actions));
Guard::ArgumentNotNull(factory);
_actions[id] = factory;
@ -72,7 +72,7 @@ namespace GameActions
Initialize();
GameAction* result = nullptr;
if (id < Util::CountOf(_actions))
if (id < std::size(_actions))
{
GameActionFactory factory = _actions[id];
if (factory != nullptr)

View File

@ -11,7 +11,6 @@
#include "../Context.h"
#include "../core/MemoryStream.h"
#include "../core/Util.hpp"
#include "../localisation/StringIds.h"
#include "../management/Finance.h"
#include "../management/Marketing.h"
@ -21,6 +20,8 @@
#include "../world/Park.h"
#include "GameAction.h"
#include <iterator>
struct ParkMarketingAction : public GameActionBase<GAME_COMMAND_START_MARKETING_CAMPAIGN, GameActionResult>
{
private:
@ -52,7 +53,7 @@ public:
GameActionResult::Ptr Query() const override
{
if ((size_t)_type >= Util::CountOf(AdvertisingCampaignPricePerWeek) || _numWeeks >= 256)
if ((size_t)_type >= std::size(AdvertisingCampaignPricePerWeek) || _numWeeks >= 256)
{
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_START_MARKETING_CAMPAIGN);
}

View File

@ -17,7 +17,6 @@
#include "../core/Memory.hpp"
#include "../core/Path.hpp"
#include "../core/String.hpp"
#include "../core/Util.hpp"
#include "../localisation/Language.h"
#include "../network/network.h"
#include "../object/ObjectRepository.h"
@ -26,6 +25,7 @@
#include "CommandLine.hpp"
#include <ctime>
#include <iterator>
#include <memory>
#ifdef USE_BREAKPAD
@ -197,34 +197,34 @@ exitcode_t CommandLine::HandleCommandDefault()
if (_userDataPath != nullptr)
{
utf8 absolutePath[MAX_PATH]{};
Path::GetAbsolute(absolutePath, Util::CountOf(absolutePath), _userDataPath);
String::Set(gCustomUserDataPath, Util::CountOf(gCustomUserDataPath), absolutePath);
Path::GetAbsolute(absolutePath, std::size(absolutePath), _userDataPath);
String::Set(gCustomUserDataPath, std::size(gCustomUserDataPath), absolutePath);
Memory::Free(_userDataPath);
}
if (_openrctDataPath != nullptr)
{
utf8 absolutePath[MAX_PATH]{};
Path::GetAbsolute(absolutePath, Util::CountOf(absolutePath), _openrctDataPath);
String::Set(gCustomOpenrctDataPath, Util::CountOf(gCustomOpenrctDataPath), absolutePath);
Path::GetAbsolute(absolutePath, std::size(absolutePath), _openrctDataPath);
String::Set(gCustomOpenrctDataPath, std::size(gCustomOpenrctDataPath), absolutePath);
Memory::Free(_openrctDataPath);
}
if (_rct1DataPath != nullptr)
{
String::Set(gCustomRCT1DataPath, Util::CountOf(gCustomRCT1DataPath), _rct1DataPath);
String::Set(gCustomRCT1DataPath, std::size(gCustomRCT1DataPath), _rct1DataPath);
Memory::Free(_rct1DataPath);
}
if (_rct2DataPath != nullptr)
{
String::Set(gCustomRCT2DataPath, Util::CountOf(gCustomRCT2DataPath), _rct2DataPath);
String::Set(gCustomRCT2DataPath, std::size(gCustomRCT2DataPath), _rct2DataPath);
Memory::Free(_rct2DataPath);
}
if (_password != nullptr)
{
String::Set(gCustomPassword, Util::CountOf(gCustomPassword), _password);
String::Set(gCustomPassword, std::size(gCustomPassword), _password);
Memory::Free(_password);
}

View File

@ -19,7 +19,8 @@
#include "Memory.hpp"
#include "Path.hpp"
#include "String.hpp"
#include "Util.hpp"
#include <iterator>
namespace Path
{
@ -172,7 +173,7 @@ namespace Path
#ifdef _WIN32
wchar_t* relativePathW = utf8_to_widechar(relativePath);
wchar_t absolutePathW[MAX_PATH];
DWORD length = GetFullPathNameW(relativePathW, (DWORD)Util::CountOf(absolutePathW), absolutePathW, nullptr);
DWORD length = GetFullPathNameW(relativePathW, (DWORD)std::size(absolutePathW), absolutePathW, nullptr);
Memory::Free(relativePathW);
if (length == 0)
{

View File

@ -1,28 +0,0 @@
/*****************************************************************************
* Copyright (c) 2014-2018 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.
*****************************************************************************/
#ifndef _UTIL_HPP_
#define _UTIL_HPP_
#include <cstdlib>
/**
* Common utility functions.
*/
namespace Util
{
// Based on http://www.g-truc.net/post-0708.html
template<typename T, size_t N> static constexpr size_t CountOf(T const (&)[N]) noexcept
{
return N;
}
} // namespace Util
#endif // _UTIL_HPP_

View File

@ -9,7 +9,6 @@
#include "Font.h"
#include "../core/Util.hpp"
#include "../localisation/FormatCodes.h"
#include "../localisation/Language.h"
#include "../localisation/LocalisationService.h"
@ -17,6 +16,7 @@
#include "Drawing.h"
#include "TTF.h"
#include <iterator>
#include <map>
static constexpr const int32_t SpriteFontLineHeight[FONT_SIZE_COUNT] = { 6, 10, 10 };
@ -255,7 +255,7 @@ int32_t font_sprite_get_codepoint_width(uint16_t fontSpriteBase, int32_t codepoi
{
glyphIndex = (SPR_CHAR_START + glyphIndex) - SPR_G2_CHAR_BEGIN;
if (glyphIndex >= (int32_t)Util::CountOf(_additionalSpriteFontCharacterWidth[baseFontIndex]))
if (glyphIndex >= (int32_t)std::size(_additionalSpriteFontCharacterWidth[baseFontIndex]))
{
log_warning("Invalid glyph index %u", glyphIndex);
glyphIndex = 0;

View File

@ -17,7 +17,6 @@
#include "../audio/audio.h"
#include "../config/Config.h"
#include "../core/Guard.hpp"
#include "../core/Util.hpp"
#include "../drawing/Drawing.h"
#include "../interface/Cursors.h"
#include "../localisation/Localisation.h"
@ -35,6 +34,7 @@
#include <algorithm>
#include <cmath>
#include <iterator>
std::vector<std::unique_ptr<rct_window>> g_window_list;
rct_window* gWindowAudioExclusive;
@ -912,7 +912,7 @@ void window_scroll_to_location(rct_window* w, int32_t x, int32_t y, int32_t z)
}
}
}
if (i >= (int32_t)Util::CountOf(window_scroll_locations))
if (i >= (int32_t)std::size(window_scroll_locations))
{
i = 0;
found = true;

View File

@ -9,10 +9,10 @@
#include "ConversionTables.h"
#include "../core/Util.hpp"
#include "FormatCodes.h"
#include <cstdlib>
#include <iterator>
// clang-format off
const encoding_convert_entry RCT2ToUnicodeTable[] =
@ -117,7 +117,7 @@ static wchar_t encoding_convert_x_to_unicode(wchar_t code, const encoding_conver
wchar_t encoding_convert_rct2_to_unicode(wchar_t rct2str)
{
return encoding_convert_x_to_unicode(rct2str, RCT2ToUnicodeTable, Util::CountOf(RCT2ToUnicodeTable));
return encoding_convert_x_to_unicode(rct2str, RCT2ToUnicodeTable, std::size(RCT2ToUnicodeTable));
}
uint32_t encoding_convert_unicode_to_rct2(uint32_t unicode)

View File

@ -8,7 +8,6 @@
*****************************************************************************/
#include "../core/String.hpp"
#include "../core/Util.hpp"
#include "ConversionTables.h"
#include "Language.h"

View File

@ -10,9 +10,10 @@
#include "FormatCodes.h"
#include "../common.h"
#include "../core/Util.hpp"
#include "Localisation.h"
#include <iterator>
#pragma region Format codes
struct format_code_token
@ -77,7 +78,7 @@ static constexpr const format_code_token format_code_tokens[] = {
uint32_t format_get_code(const char* token)
{
for (uint32_t i = 0; i < Util::CountOf(format_code_tokens); i++)
for (uint32_t i = 0; i < std::size(format_code_tokens); i++)
{
if (_strcmpi(token, format_code_tokens[i].token) == 0)
return format_code_tokens[i].code;
@ -87,7 +88,7 @@ uint32_t format_get_code(const char* token)
const char* format_get_token(uint32_t code)
{
for (uint32_t i = 0; i < Util::CountOf(format_code_tokens); i++)
for (uint32_t i = 0; i < std::size(format_code_tokens); i++)
{
if (code == format_code_tokens[i].code)
return format_code_tokens[i].token;

View File

@ -7,11 +7,6 @@
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
#include <algorithm>
#include <cstring>
#include <ctype.h>
#include <limits.h>
#ifdef _WIN32
# include <windows.h>
#elif defined(__ANDROID__)
@ -28,13 +23,18 @@
#include "../config/Config.h"
#include "../core/Guard.hpp"
#include "../core/String.hpp"
#include "../core/Util.hpp"
#include "../management/Marketing.h"
#include "../ride/Ride.h"
#include "../util/Util.h"
#include "Date.h"
#include "Localisation.h"
#include <algorithm>
#include <cstring>
#include <ctype.h>
#include <iterator>
#include <limits.h>
char gCommonStringFormatBuffer[512];
uint8_t gCommonFormatArgs[80];
uint8_t gMapTooltipFormatArgs[40];
@ -1259,11 +1259,11 @@ static void format_string_part(utf8** dest, size_t* size, rct_string_id format,
// Real name
auto realNameIndex = format - REAL_NAME_START;
format_append_string(dest, size, real_names[realNameIndex % Util::CountOf(real_names)]);
format_append_string(dest, size, real_names[realNameIndex % std::size(real_names)]);
if ((*size) == 0)
return;
format_push_char(' ');
format_push_char(real_name_initials[(realNameIndex >> 10) % Util::CountOf(real_name_initials)]);
format_push_char(real_name_initials[(realNameIndex >> 10) % std::size(real_name_initials)]);
format_push_char('.');
*(*dest) = '\0';

View File

@ -10,7 +10,6 @@
#include "Award.h"
#include "../config/Config.h"
#include "../core/Util.hpp"
#include "../interface/Window.h"
#include "../localisation/StringIds.h"
#include "../peep/Peep.h"

View File

@ -12,7 +12,6 @@
#include "../Cheats.h"
#include "../Game.h"
#include "../config/Config.h"
#include "../core/Util.hpp"
#include "../interface/Window.h"
#include "../localisation/Localisation.h"
#include "../ride/Ride.h"

View File

@ -13,7 +13,6 @@
#include "../Input.h"
#include "../OpenRCT2.h"
#include "../audio/audio.h"
#include "../core/Util.hpp"
#include "../interface/Window.h"
#include "../localisation/Date.h"
#include "../localisation/Localisation.h"

View File

@ -15,7 +15,6 @@
#include "../config/Config.h"
#include "../core/Guard.hpp"
#include "../core/Memory.hpp"
#include "../core/Util.hpp"
#include "../interface/Window.h"
#include "../localisation/Date.h"
#include "../localisation/Localisation.h"
@ -34,6 +33,7 @@
#include "NewsItem.h"
#include <algorithm>
#include <iterator>
static constexpr const int32_t _researchRate[] = {
0,
@ -224,8 +224,7 @@ void research_finish_item(rct_research_item* researchItem)
ride_type_set_invented(base_ride_type);
openrct2_assert(
base_ride_type < Util::CountOf(RideTypePossibleTrackConfigurations), "Invalid base_ride_type = %d",
base_ride_type);
base_ride_type < std::size(RideTypePossibleTrackConfigurations), "Invalid base_ride_type = %d", base_ride_type);
ride_entry_set_invented(rideEntryIndex);
@ -644,7 +643,7 @@ void research_insert_scenery_group_entry(uint8_t entryIndex, bool researched)
bool ride_type_is_invented(uint32_t rideType)
{
Guard::Assert(rideType < Util::CountOf(_researchedRideTypes), GUARD_LINE);
Guard::Assert(rideType < std::size(_researchedRideTypes), GUARD_LINE);
return _researchedRideTypes[rideType];
}
@ -660,7 +659,7 @@ bool track_piece_is_available_for_ride_type(uint8_t rideType, int32_t trackType)
void ride_type_set_invented(uint32_t rideType)
{
Guard::Assert(rideType < Util::CountOf(_researchedRideTypes), GUARD_LINE);
Guard::Assert(rideType < std::size(_researchedRideTypes), GUARD_LINE);
_researchedRideTypes[rideType] = true;
}

View File

@ -21,6 +21,7 @@
#include "../world/Location.hpp"
#include <algorithm>
#include <iterator>
#include <stdexcept>
#define ACTION_COOLDOWN_TIME_PLACE_SCENERY 20
@ -49,7 +50,6 @@ static int32_t _pickup_peep_old_x = LOCATION_NULL;
# include "../core/Nullable.hpp"
# include "../core/Path.hpp"
# include "../core/String.hpp"
# include "../core/Util.hpp"
# include "../interface/Chat.h"
# include "../interface/Window.h"
# include "../localisation/Date.h"
@ -1017,10 +1017,10 @@ std::string Network::GenerateAdvertiseKey()
char key[17];
for (int32_t i = 0; i < 16; i++)
{
int32_t hexCharIndex = util_rand() % Util::CountOf(hexChars);
int32_t hexCharIndex = util_rand() % std::size(hexChars);
key[i] = hexChars[hexCharIndex];
}
key[Util::CountOf(key) - 1] = 0;
key[std::size(key) - 1] = 0;
return key;
}
@ -3435,7 +3435,7 @@ void game_command_modify_groups(
if (nameChunkIndex == 0)
nameChunkOffset = 2;
nameChunkOffset *= 12;
nameChunkOffset = (std::min)(nameChunkOffset, Util::CountOf(newName) - 12);
nameChunkOffset = (std::min)(nameChunkOffset, std::size(newName) - 12);
memcpy((void*)((uintptr_t)newName + (uintptr_t)nameChunkOffset + 0), edx, sizeof(uint32_t));
memcpy((void*)((uintptr_t)newName + (uintptr_t)nameChunkOffset + 4), ebp, sizeof(uint32_t));
memcpy((void*)((uintptr_t)newName + (uintptr_t)nameChunkOffset + 8), edi, sizeof(uint32_t));

View File

@ -15,7 +15,6 @@
# include "../core/Console.hpp"
# include "../core/Json.hpp"
# include "../core/String.hpp"
# include "../core/Util.hpp"
# include "../localisation/Date.h"
# include "../management/Finance.h"
# include "../peep/Peep.h"
@ -26,6 +25,7 @@
# include "Http.h"
# include "network.h"
# include <iterator>
# include <string>
# ifndef DISABLE_HTTP
@ -243,10 +243,10 @@ private:
char key[17];
for (int32_t i = 0; i < 16; i++)
{
int32_t hexCharIndex = util_rand() % Util::CountOf(hexChars);
int32_t hexCharIndex = util_rand() % std::size(hexChars);
key[i] = hexChars[hexCharIndex];
}
key[Util::CountOf(key) - 1] = 0;
key[std::size(key) - 1] = 0;
return key;
}

View File

@ -13,7 +13,6 @@
#include "../core/IStream.hpp"
#include "../core/Memory.hpp"
#include "../core/Util.hpp"
#include "../drawing/Drawing.h"
#include "../interface/Cursors.h"
#include "../localisation/Language.h"
@ -21,6 +20,7 @@
#include "ObjectJsonHelpers.h"
#include <algorithm>
#include <iterator>
void LargeSceneryObject::ReadLegacy(IReadObjectContext* context, IStream* stream)
{
@ -215,7 +215,7 @@ std::unique_ptr<rct_large_scenery_text> LargeSceneryObject::ReadJson3dFont(const
if (jOffsets != nullptr)
{
auto offsets = ReadJsonOffsets(jOffsets);
auto numOffsets = std::min(Util::CountOf(font->offset), offsets.size());
auto numOffsets = std::min(std::size(font->offset), offsets.size());
std::copy_n(offsets.data(), numOffsets, font->offset);
}
@ -232,7 +232,7 @@ std::unique_ptr<rct_large_scenery_text> LargeSceneryObject::ReadJson3dFont(const
if (jGlyphs != nullptr)
{
auto glyphs = ReadJsonGlyphs(jGlyphs);
auto numGlyphs = std::min(Util::CountOf(font->glyphs), glyphs.size());
auto numGlyphs = std::min(std::size(font->glyphs), glyphs.size());
std::copy_n(glyphs.data(), numGlyphs, font->glyphs);
}

View File

@ -11,7 +11,6 @@
#include "../Context.h"
#include "../Game.h"
#include "../core/Util.hpp"
#include "../object/Object.h"
#include "../util/SawyerCoding.h"
#include "../util/Util.h"

View File

@ -15,7 +15,6 @@
#include "../core/IStream.hpp"
#include "../core/Memory.hpp"
#include "../core/String.hpp"
#include "../core/Util.hpp"
#include "../drawing/Drawing.h"
#include "../localisation/Language.h"
#include "../rct2/RCT2.h"
@ -27,6 +26,7 @@
#include "ObjectRepository.h"
#include <algorithm>
#include <iterator>
#include <unordered_map>
using namespace OpenRCT2;
@ -698,7 +698,7 @@ void RideObject::ReadJsonVehicleInfo([[maybe_unused]] IReadObjectContext* contex
}
auto cars = ReadJsonCars(json_object_get(properties, "cars"));
auto numCars = std::min(Util::CountOf(_legacyType.vehicles), cars.size());
auto numCars = std::min(std::size(_legacyType.vehicles), cars.size());
for (size_t i = 0; i < numCars; i++)
{
_legacyType.vehicles[i] = cars[i];

View File

@ -9,7 +9,6 @@
#include "../../Game.h"
#include "../../config/Config.h"
#include "../../core/Util.hpp"
#include "../../interface/Viewport.h"
#include "../../localisation/Localisation.h"
#include "../../ride/Ride.h"
@ -23,6 +22,8 @@
#include "../Supports.h"
#include "Paint.TileElement.h"
#include <iterator>
// 6B8172:
static void large_scenery_paint_supports(
paint_session* session, uint8_t direction, uint16_t height, const TileElement* tileElement, uint32_t dword_F4387C,
@ -67,7 +68,7 @@ static void large_scenery_paint_supports(
static rct_large_scenery_text_glyph* large_scenery_sign_get_glyph(rct_large_scenery_text* text, uint32_t codepoint)
{
if (codepoint >= Util::CountOf(text->glyphs))
if (codepoint >= std::size(text->glyphs))
{
return &text->glyphs[(size_t)'?'];
}

View File

@ -13,7 +13,6 @@
#include "../../OpenRCT2.h"
#include "../../config/Config.h"
#include "../../core/Guard.hpp"
#include "../../core/Util.hpp"
#include "../../drawing/Drawing.h"
#include "../../interface/Colour.h"
#include "../../interface/Viewport.h"
@ -27,6 +26,7 @@
#include <algorithm>
#include <cstring>
#include <iterator>
// clang-format off
static constexpr const uint8_t byte_97B444[] =
@ -1119,7 +1119,7 @@ void surface_paint(paint_session* session, uint8_t direction, uint16_t height, c
}
}
assert(surfaceShape < Util::CountOf(byte_97B444));
assert(surfaceShape < std::size(byte_97B444));
const uint8_t image_offset = byte_97B444[surfaceShape];
int32_t image_id;
uint32_t ebp = terrain_type;
@ -1138,10 +1138,10 @@ void surface_paint(paint_session* session, uint8_t direction, uint16_t height, c
// loc_660C9F
if (rotation & 1)
{
assert(ebp < Util::CountOf(byte_97B84A));
assert(ebp < std::size(byte_97B84A));
ebp = byte_97B84A[ebp];
}
assert(ebp < Util::CountOf(dword_97B750));
assert(ebp < std::size(dword_97B750));
image_id = dword_97B750[ebp][showGridlines ? 1 : 0] + image_offset;
if (gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))
@ -1206,7 +1206,7 @@ void surface_paint(paint_session* session, uint8_t direction, uint16_t height, c
if (staff_is_patrol_area_set(200 + staffType, x, y))
{
assert(surfaceShape < Util::CountOf(byte_97B444));
assert(surfaceShape < std::size(byte_97B444));
image_id |= SPR_TERRAIN_SELECTION_PATROL_AREA + byte_97B444[surfaceShape];
image_id |= patrolColour << 19;
@ -1237,7 +1237,7 @@ void surface_paint(paint_session* session, uint8_t direction, uint16_t height, c
// loc_660E9A:
if (tileElement->AsSurface()->GetOwnership() & OWNERSHIP_OWNED)
{
assert(surfaceShape < Util::CountOf(byte_97B444));
assert(surfaceShape < std::size(byte_97B444));
paint_attach_to_previous_ps(session, SPR_TERRAIN_SELECTION_SQUARE + byte_97B444[surfaceShape], 0, 0);
}
else if (tileElement->AsSurface()->GetOwnership() & OWNERSHIP_AVAILABLE)
@ -1255,7 +1255,7 @@ void surface_paint(paint_session* session, uint8_t direction, uint16_t height, c
{
if (tileElement->AsSurface()->GetOwnership() & OWNERSHIP_CONSTRUCTION_RIGHTS_OWNED)
{
assert(surfaceShape < Util::CountOf(byte_97B444));
assert(surfaceShape < std::size(byte_97B444));
paint_attach_to_previous_ps(session, SPR_TERRAIN_SELECTION_DOTTED + byte_97B444[surfaceShape], 0, 0);
}
else if (tileElement->AsSurface()->GetOwnership() & OWNERSHIP_CONSTRUCTION_RIGHTS_AVAILABLE)

View File

@ -13,7 +13,6 @@
#include "../audio/audio.h"
#include "../config/Config.h"
#include "../core/Guard.hpp"
#include "../core/Util.hpp"
#include "../localisation/Localisation.h"
#include "../management/Finance.h"
#include "../management/Marketing.h"
@ -37,6 +36,7 @@
#include "Peep.h"
#include <algorithm>
#include <iterator>
// Locations of the spiral slide platform that a peep walks from the entrance of the ride to the
// entrance of the slide. Up to 4 waypoints for each 4 sides that an ride entrance can be located
@ -4169,7 +4169,7 @@ static void peep_update_ride_prepare_for_exit(rct_peep* peep)
{
Ride* ride = get_ride(peep->current_ride);
Guard::Assert(peep->current_ride_station < Util::CountOf(ride->exits), GUARD_LINE);
Guard::Assert(peep->current_ride_station < std::size(ride->exits), GUARD_LINE);
auto exit = ride_get_exit_location(peep->current_ride, peep->current_ride_station);
int16_t x = exit.x;
int16_t y = exit.y;
@ -6635,7 +6635,7 @@ void rct_peep::SetSpriteType(uint8_t new_sprite_type)
action = PEEP_ACTION_NONE_2;
peep_flags &= ~PEEP_FLAGS_SLOW_WALK;
Guard::Assert(new_sprite_type < Util::CountOf(gSpriteTypeToSlowWalkMap));
Guard::Assert(new_sprite_type < std::size(gSpriteTypeToSlowWalkMap));
if (gSpriteTypeToSlowWalkMap[new_sprite_type])
{
peep_flags |= PEEP_FLAGS_SLOW_WALK;

View File

@ -18,7 +18,6 @@
#include "../audio/audio.h"
#include "../config/Config.h"
#include "../core/Guard.hpp"
#include "../core/Util.hpp"
#include "../interface/Window.h"
#include "../localisation/Localisation.h"
#include "../management/Finance.h"
@ -47,6 +46,7 @@
#include "Staff.h"
#include <algorithm>
#include <iterator>
#include <limits>
#if defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1
@ -517,15 +517,14 @@ uint8_t rct_peep::GetActionSpriteType()
{ // PEEP_ACTION_NONE_1 or PEEP_ACTION_NONE_2
return PeepSpecialSpriteToSpriteTypeMap[special_sprite];
}
else if (action < Util::CountOf(PeepActionToSpriteTypeMap))
else if (action < std::size(PeepActionToSpriteTypeMap))
{
return PeepActionToSpriteTypeMap[action];
}
else
{
openrct2_assert(
action >= Util::CountOf(PeepActionToSpriteTypeMap) && action < PEEP_ACTION_NONE_1, "Invalid peep action %u",
action);
action >= std::size(PeepActionToSpriteTypeMap) && action < PEEP_ACTION_NONE_1, "Invalid peep action %u", action);
return 0;
}
}
@ -535,7 +534,7 @@ uint8_t rct_peep::GetActionSpriteType()
*/
void rct_peep::UpdateCurrentActionSpriteType()
{
if (sprite_type >= Util::CountOf(g_peep_animation_entries))
if (sprite_type >= std::size(g_peep_animation_entries))
{
return;
}
@ -1883,10 +1882,10 @@ rct_peep* peep_generate(int32_t x, int32_t y, int32_t z)
peep->angriness = 0;
peep->time_lost = 0;
uint8_t tshirt_colour = static_cast<uint8_t>(scenario_rand() % Util::CountOf(tshirt_colours));
uint8_t tshirt_colour = static_cast<uint8_t>(scenario_rand() % std::size(tshirt_colours));
peep->tshirt_colour = tshirt_colours[tshirt_colour];
uint8_t trousers_colour = static_cast<uint8_t>(scenario_rand() % Util::CountOf(trouser_colours));
uint8_t trousers_colour = static_cast<uint8_t>(scenario_rand() % std::size(trouser_colours));
peep->trousers_colour = trouser_colours[trousers_colour];
/* Minimum energy is capped at 32 and maximum at 128, so this initialises
@ -2233,7 +2232,7 @@ int32_t peep_get_easteregg_name_id(rct_peep* peep)
format_string(buffer, 256, peep->name_string_idx, &peep->id);
for (uint32_t i = 0; i < Util::CountOf(gPeepEasterEggNames); i++)
for (uint32_t i = 0; i < std::size(gPeepEasterEggNames); i++)
if (_stricmp(buffer, gPeepEasterEggNames[i]) == 0)
return static_cast<int32_t>(i);
@ -3468,7 +3467,7 @@ static void peep_give_real_name(rct_peep* peep)
uint16_t ax = (uint16_t)(peep->id + 0xF0B);
uint16_t dx = 0;
static constexpr uint16_t twiddlingBitOrder[] = { 4, 9, 3, 7, 5, 8, 2, 1, 6, 0, 12, 11, 13, 10 };
for (size_t i = 0; i < Util::CountOf(twiddlingBitOrder); i++)
for (size_t i = 0; i < std::size(twiddlingBitOrder); i++)
{
dx |= (ax & (1 << twiddlingBitOrder[i]) ? 1 : 0) << i;
}
@ -3512,13 +3511,13 @@ static int32_t peep_compare(const void* sprite_index_a, const void* sprite_index
rct_string_id peep_a_format = peep_a->name_string_idx + REAL_NAME_START;
rct_string_id peep_b_format = peep_b->name_string_idx + REAL_NAME_START;
uint16_t peep_a_name = (peep_a_format % Util::CountOf(real_names));
uint16_t peep_b_name = (peep_b_format % Util::CountOf(real_names));
uint16_t peep_a_name = (peep_a_format % std::size(real_names));
uint16_t peep_b_name = (peep_b_format % std::size(real_names));
if (peep_a_name == peep_b_name)
{
uint16_t peep_a_initial = ((peep_a_format >> 10) % Util::CountOf(real_name_initials));
uint16_t peep_b_initial = ((peep_b_format >> 10) % Util::CountOf(real_name_initials));
uint16_t peep_a_initial = ((peep_a_format >> 10) % std::size(real_name_initials));
uint16_t peep_b_initial = ((peep_b_format >> 10) % std::size(real_name_initials));
return peep_a_initial - peep_b_initial;
}
else

File diff suppressed because it is too large Load Diff

View File

@ -14,7 +14,6 @@
#include "../Input.h"
#include "../audio/audio.h"
#include "../config/Config.h"
#include "../core/Util.hpp"
#include "../interface/Viewport.h"
#include "../localisation/Date.h"
#include "../localisation/Localisation.h"
@ -37,6 +36,7 @@
#include "Peep.h"
#include <algorithm>
#include <iterator>
// clang-format off
const rct_string_id StaffCostumeNames[] = {
@ -419,7 +419,7 @@ void game_command_set_staff_order(
{ // change costume
uint8_t sprite_type = order_id & ~0x80;
sprite_type += 4;
if (sprite_type >= Util::CountOf(peep_slow_walking_types))
if (sprite_type >= std::size(peep_slow_walking_types))
{
log_error("Invalid change costume order for sprite_type %u", sprite_type);
*ebx = MONEY32_UNDEFINED;
@ -1662,7 +1662,7 @@ void rct_peep::UpdateMowing()
SwitchToSpecialSprite(2);
}
if (var_37 == Util::CountOf(_MowingWaypoints))
if (var_37 == std::size(_MowingWaypoints))
{
StateReset();
return;

View File

@ -23,7 +23,6 @@
# endif // __linux__
# include "../OpenRCT2.h"
# include "../core/Path.hpp"
# include "../core/Util.hpp"
# include "Platform2.h"
# include "platform.h"

View File

@ -28,10 +28,11 @@
# include "../OpenRCT2.h"
# include "../core/Path.hpp"
# include "../core/String.hpp"
# include "../core/Util.hpp"
# include "Platform2.h"
# include "platform.h"
# include <iterator>
namespace Platform
{
# ifdef __USE_SHGETKNOWNFOLDERPATH__
@ -51,8 +52,8 @@ namespace Platform
std::wstring result;
auto wname = String::ToUtf16(name);
wchar_t wvalue[256];
auto valueSize = GetEnvironmentVariableW(wname.c_str(), wvalue, (DWORD)Util::CountOf(wvalue));
if (valueSize < Util::CountOf(wvalue))
auto valueSize = GetEnvironmentVariableW(wname.c_str(), wvalue, (DWORD)std::size(wvalue));
if (valueSize < std::size(wvalue))
{
result = wvalue;
}

View File

@ -22,13 +22,13 @@
# include "../OpenRCT2.h"
# include "../Version.h"
# include "../config/Config.h"
# include "../core/Util.hpp"
# include "../localisation/Date.h"
# include "../localisation/Language.h"
# include "../rct2/RCT2.h"
# include "../util/Util.h"
# include "platform.h"
# include <iterator>
# include <lmcons.h>
# include <psapi.h>
# include <shlobj.h>
@ -410,8 +410,8 @@ uint8_t platform_get_locale_date_format()
wchar_t first[sizeof(dateFormat)];
wchar_t second[sizeof(dateFormat)];
if (swscanf_s(
dateFormat, L"%l[dyM]%*l[^dyM]%l[dyM]%*l[^dyM]%*l[dyM]", first, (uint32_t)Util::CountOf(first), second,
(uint32_t)Util::CountOf(second))
dateFormat, L"%l[dyM]%*l[^dyM]%l[dyM]%*l[^dyM]%*l[dyM]", first, (uint32_t)std::size(first), second,
(uint32_t)std::size(second))
!= 2)
{
return DATE_FORMAT_DAY_MONTH_YEAR;
@ -482,7 +482,7 @@ utf8* platform_get_absolute_path(const utf8* relativePath, const utf8* basePath)
wchar_t* pathW = utf8_to_widechar(path);
wchar_t fullPathW[MAX_PATH];
DWORD fullPathLen = GetFullPathNameW(pathW, (DWORD)Util::CountOf(fullPathW), fullPathW, nullptr);
DWORD fullPathLen = GetFullPathNameW(pathW, (DWORD)std::size(fullPathW), fullPathW, nullptr);
free(pathW);

View File

@ -22,7 +22,6 @@
#include "../core/Memory.hpp"
#include "../core/Path.hpp"
#include "../core/String.hpp"
#include "../core/Util.hpp"
#include "../interface/Window.h"
#include "../localisation/Date.h"
#include "../localisation/Localisation.h"
@ -55,6 +54,7 @@
#include "Tables.h"
#include <algorithm>
#include <iterator>
#include <memory>
#include <vector>
@ -541,7 +541,7 @@ private:
void AddAvailableEntriesFromRides()
{
for (size_t i = 0; i < Util::CountOf(_s4.rides); i++)
for (size_t i = 0; i < std::size(_s4.rides); i++)
{
rct1_ride* ride = &_s4.rides[i];
if (ride->type != RCT1_RIDE_TYPE_NULL)
@ -609,7 +609,7 @@ private:
void AddEntryForRideType(uint8_t rideType)
{
assert(rideType < Util::CountOf(_rideTypeToRideEntryMap));
assert(rideType < std::size(_rideTypeToRideEntryMap));
if (_rideTypeToRideEntryMap[rideType] == 255)
{
const char* entryName = RCT1::GetRideTypeObject(rideType);
@ -623,7 +623,7 @@ private:
void AddEntryForVehicleType(uint8_t rideType, uint8_t vehicleType)
{
assert(vehicleType < Util::CountOf(_vehicleTypeToRideEntryMap));
assert(vehicleType < std::size(_vehicleTypeToRideEntryMap));
if (_vehicleTypeToRideEntryMap[vehicleType] == 255)
{
const char* entryName = RCT1::GetVehicleObject(vehicleType);
@ -640,7 +640,7 @@ private:
void AddEntryForSmallScenery(uint8_t smallSceneryType)
{
assert(smallSceneryType < Util::CountOf(_smallSceneryTypeToEntryMap));
assert(smallSceneryType < std::size(_smallSceneryTypeToEntryMap));
if (_smallSceneryTypeToEntryMap[smallSceneryType] == 255)
{
const char* entryName = RCT1::GetSmallSceneryObject(smallSceneryType);
@ -652,7 +652,7 @@ private:
void AddEntryForLargeScenery(uint8_t largeSceneryType)
{
assert(largeSceneryType < Util::CountOf(_largeSceneryTypeToEntryMap));
assert(largeSceneryType < std::size(_largeSceneryTypeToEntryMap));
if (_largeSceneryTypeToEntryMap[largeSceneryType] == 255)
{
const char* entryName = RCT1::GetLargeSceneryObject(largeSceneryType);
@ -664,7 +664,7 @@ private:
void AddEntryForWall(uint8_t wallType)
{
assert(wallType < Util::CountOf(_wallTypeToEntryMap));
assert(wallType < std::size(_wallTypeToEntryMap));
if (_wallTypeToEntryMap[wallType] == 255)
{
const char* entryName = RCT1::GetWallObject(wallType);
@ -676,7 +676,7 @@ private:
void AddEntryForPath(uint8_t pathType)
{
assert(pathType < Util::CountOf(_pathTypeToEntryMap));
assert(pathType < std::size(_pathTypeToEntryMap));
if (_pathTypeToEntryMap[pathType] == 255)
{
const char* entryName = RCT1::GetPathObject(pathType);
@ -1087,7 +1087,7 @@ private:
Ride* ride;
FOR_ALL_RIDES (i, ride)
{
for (uint8_t j = 0; j < Util::CountOf(ride->vehicles); j++)
for (uint8_t j = 0; j < std::size(ride->vehicles); j++)
{
uint16_t originalIndex = ride->vehicles[j];
if (originalIndex != SPRITE_INDEX_NULL)
@ -2795,7 +2795,7 @@ private:
void FixEntrancePositions()
{
for (size_t i = 0; i < Util::CountOf(gParkEntrances); i++)
for (size_t i = 0; i < std::size(gParkEntrances); i++)
{
gParkEntrances[i].x = LOCATION_NULL;
}
@ -2852,12 +2852,12 @@ private:
// Loopy Landscapes stores research items in a different place
if (_gameVersion == FILE_VERSION_RCT1_LL)
{
*count = Util::CountOf(_s4.research_items_LL);
*count = std::size(_s4.research_items_LL);
return _s4.research_items_LL;
}
else
{
*count = Util::CountOf(_s4.research_items);
*count = std::size(_s4.research_items);
return _s4.research_items;
}
}

View File

@ -11,12 +11,13 @@
#include "../common.h"
#include "../core/Guard.hpp"
#include "../core/Util.hpp"
#include "../interface/Colour.h"
#include "../ride/Ride.h"
#include "../world/Surface.h"
#include "RCT1.h"
#include <iterator>
// clang-format off
namespace RCT1
{
@ -57,7 +58,7 @@ namespace RCT1
COLOUR_BRIGHT_YELLOW,
COLOUR_ICY_BLUE
};
if (colour >= Util::CountOf(map))
if (colour >= std::size(map))
{
log_warning("Unsupported RCT1 colour.");
return COLOUR_BLACK;
@ -105,7 +106,7 @@ namespace RCT1
PEEP_SPRITE_TYPE_CHICKEN, // 0x21
PEEP_SPRITE_TYPE_LEMONADE, // 0x22
};
if (rct1SpriteType >= Util::CountOf(map))
if (rct1SpriteType >= std::size(map))
{
log_warning("Unsupported RCT1 peep sprite type: %d.", rct1SpriteType);
return PEEP_SPRITE_TYPE_NORMAL;
@ -134,7 +135,7 @@ namespace RCT1
TERRAIN_GRID_BLUE,
TERRAIN_GRID_GREEN
};
Guard::ArgumentInRange<size_t>(terrain, 0, Util::CountOf(map), "Unsupported RCT1 terrain type.");
Guard::ArgumentInRange<size_t>(terrain, 0, std::size(map), "Unsupported RCT1 terrain type.");
return map[terrain];
}
@ -159,7 +160,7 @@ namespace RCT1
TERRAIN_EDGE_SKYSCRAPER_B,
TERRAIN_EDGE_ROCK // Unused
};
Guard::ArgumentInRange<size_t>(terrainEdge, 0, Util::CountOf(map), "Unsupported RCT1 terrain edge.");
Guard::ArgumentInRange<size_t>(terrainEdge, 0, std::size(map), "Unsupported RCT1 terrain edge.");
return map[terrainEdge];
}
@ -254,7 +255,7 @@ namespace RCT1
RIDE_TYPE_DRINK_STALL
};
Guard::ArgumentInRange<size_t>(rideType, 0, Util::CountOf(map), "Unsupported RCT1 ride type.");
Guard::ArgumentInRange<size_t>(rideType, 0, std::size(map), "Unsupported RCT1 ride type.");
return map[rideType];
}
@ -353,7 +354,7 @@ namespace RCT1
{ COPY_COLOUR_1, COPY_COLOUR_2, COLOUR_BLACK }, // RCT1_VEHICLE_TYPE_ENTERPRISE_WHEEL
};
Guard::ArgumentInRange<size_t>(vehicleType, 0, Util::CountOf(map), "Unsupported RCT1 vehicle type.");
Guard::ArgumentInRange<size_t>(vehicleType, 0, std::size(map), "Unsupported RCT1 vehicle type.");
return map[vehicleType];
}
@ -770,7 +771,7 @@ namespace RCT1
"LEMST ", // RCT1_RIDE_TYPE_LEMONADE_STALL
};
Guard::ArgumentInRange<size_t>(rideType, 0, Util::CountOf(map), "Unsupported RCT1 ride type.");
Guard::ArgumentInRange<size_t>(rideType, 0, std::size(map), "Unsupported RCT1 ride type.");
return map[rideType];
}
@ -869,7 +870,7 @@ namespace RCT1
"ENTERP ", // RCT1_VEHICLE_TYPE_ENTERPRISE_WHEEL
};
Guard::ArgumentInRange<size_t>(vehicleType, 0, Util::CountOf(map), "Unsupported RCT1 vehicle type.");
Guard::ArgumentInRange<size_t>(vehicleType, 0, std::size(map), "Unsupported RCT1 vehicle type.");
return map[vehicleType];
}

View File

@ -17,7 +17,6 @@
#include "../core/FileStream.hpp"
#include "../core/IStream.hpp"
#include "../core/String.hpp"
#include "../core/Util.hpp"
#include "../interface/Viewport.h"
#include "../interface/Window.h"
#include "../localisation/Date.h"
@ -49,6 +48,7 @@
#include <algorithm>
#include <cstring>
#include <functional>
#include <iterator>
S6Exporter::S6Exporter()
{
@ -227,7 +227,7 @@ void S6Exporter::Export()
ExportResearchedRideTypes();
ExportResearchedRideEntries();
// Not used by OpenRCT2 any more, but left in to keep RCT2 export working.
for (uint8_t i = 0; i < Util::CountOf(RideTypePossibleTrackConfigurations); i++)
for (uint8_t i = 0; i < std::size(RideTypePossibleTrackConfigurations); i++)
{
researchedTrackPiecesA[i] = (RideTypePossibleTrackConfigurations[i]) & 0xFFFFFFFFULL;
researchedTrackPiecesB[i] = (RideTypePossibleTrackConfigurations[i] >> 32ULL) & 0xFFFFFFFFULL;

View File

@ -12,7 +12,6 @@
#include "../Context.h"
#include "../audio/audio.h"
#include "../common.h"
#include "../core/Util.hpp"
#define MAKE_TUNEID_LIST(...) std::vector<uint8_t>({ __VA_ARGS__ })

View File

@ -20,7 +20,6 @@
#include "../common.h"
#include "../config/Config.h"
#include "../core/Guard.hpp"
#include "../core/Util.hpp"
#include "../interface/Window.h"
#include "../localisation/Date.h"
#include "../localisation/Localisation.h"
@ -59,6 +58,7 @@
#include <algorithm>
#include <climits>
#include <cstdlib>
#include <iterator>
#include <limits>
using namespace OpenRCT2;
@ -3712,7 +3712,7 @@ static int32_t ride_music_params_update_label_51(
if (a1 < gRideMusicInfoList[*tuneId].length)
{
rct_ride_music_params* ride_music_params = gRideMusicParamsListEnd;
if (ride_music_params < &gRideMusicParamsList[Util::CountOf(gRideMusicParamsList)])
if (ride_music_params < &gRideMusicParamsList[std::size(gRideMusicParamsList)])
{
ride_music_params->ride_id = rideIndex;
ride_music_params->tune_id = *tuneId;
@ -6451,7 +6451,7 @@ void game_command_set_ride_appearance(
switch (type)
{
case 0:
if (index >= Util::CountOf(ride->track_colour_main))
if (index >= std::size(ride->track_colour_main))
{
log_warning("Invalid game command, index %d out of bounds", index);
*ebx = MONEY32_UNDEFINED;
@ -6464,7 +6464,7 @@ void game_command_set_ride_appearance(
}
break;
case 1:
if (index >= Util::CountOf(ride->track_colour_additional))
if (index >= std::size(ride->track_colour_additional))
{
log_warning("Invalid game command, index %d out of bounds", index);
*ebx = MONEY32_UNDEFINED;
@ -6477,7 +6477,7 @@ void game_command_set_ride_appearance(
}
break;
case 2:
if (index >= Util::CountOf(ride->vehicle_colours))
if (index >= std::size(ride->vehicle_colours))
{
log_warning("Invalid game command, index %d out of bounds", index);
*ebx = MONEY32_UNDEFINED;
@ -6490,7 +6490,7 @@ void game_command_set_ride_appearance(
}
break;
case 3:
if (index >= Util::CountOf(ride->vehicle_colours))
if (index >= std::size(ride->vehicle_colours))
{
log_warning("Invalid game command, index %d out of bounds", index);
*ebx = MONEY32_UNDEFINED;
@ -6503,7 +6503,7 @@ void game_command_set_ride_appearance(
}
break;
case 4:
if (index >= Util::CountOf(ride->track_colour_supports))
if (index >= std::size(ride->track_colour_supports))
{
log_warning("Invalid game command, index %d out of bounds", index);
*ebx = MONEY32_UNDEFINED;
@ -6520,7 +6520,7 @@ void game_command_set_ride_appearance(
{
ride->colour_scheme_type &= ~(RIDE_COLOUR_SCHEME_DIFFERENT_PER_TRAIN | RIDE_COLOUR_SCHEME_DIFFERENT_PER_CAR);
ride->colour_scheme_type |= value;
for (uint32_t i = 1; i < Util::CountOf(ride->vehicle_colours); i++)
for (uint32_t i = 1; i < std::size(ride->vehicle_colours); i++)
{
ride->vehicle_colours[i] = ride->vehicle_colours[0];
ride->vehicle_colours_extended[i] = ride->vehicle_colours_extended[0];
@ -6537,7 +6537,7 @@ void game_command_set_ride_appearance(
}
break;
case 7:
if (index >= Util::CountOf(ride->vehicle_colours_extended))
if (index >= std::size(ride->vehicle_colours_extended))
{
log_warning("Invalid game command, index %d out of bounds", index);
*ebx = MONEY32_UNDEFINED;

View File

@ -20,7 +20,6 @@
#include "RideData.h"
#include "../audio/audio.h"
#include "../core/Util.hpp"
#include "../interface/Colour.h"
#include "../localisation/Localisation.h"
#include "../sprites.h"
@ -28,6 +27,8 @@
#include "ShopItem.h"
#include "Track.h"
#include <iterator>
// clang-format off
const bool hasRunningTrack[RIDE_TYPE_COUNT] = {
true, // 0 Spiral Roller coaster
@ -2349,7 +2350,7 @@ const uint8_t RideConstructionDefaultTrackType[] = {
TRACK_ELEM_END_STATION, // RIDE_TYPE_LIM_LAUNCHED_ROLLER_COASTER
};
#define TRACK_COLOUR_PRESETS(...) {static_cast<uint8_t>(Util::CountOf<track_colour>({__VA_ARGS__})), {__VA_ARGS__}}
#define TRACK_COLOUR_PRESETS(...) {static_cast<uint8_t>(std::size<track_colour>({__VA_ARGS__})), {__VA_ARGS__}}
#define DEFAULT_FLAT_RIDE_COLOUR_PRESET TRACK_COLOUR_PRESETS( { COLOUR_BRIGHT_RED, COLOUR_LIGHT_BLUE, COLOUR_YELLOW } )
#define DEFAULT_STALL_COLOUR_PRESET TRACK_COLOUR_PRESETS( { COLOUR_BRIGHT_RED, COLOUR_BRIGHT_RED, COLOUR_BRIGHT_RED } )

View File

@ -11,7 +11,6 @@
#include "../Cheats.h"
#include "../OpenRCT2.h"
#include "../core/Util.hpp"
#include "../interface/Window.h"
#include "../localisation/Date.h"
#include "../world/Footpath.h"
@ -23,6 +22,7 @@
#include "Track.h"
#include <algorithm>
#include <iterator>
enum
{
@ -774,11 +774,11 @@ static void ride_ratings_calculate_value(Ride* ride)
}
const row* age_table = age_table_new;
size_t table_size = Util::CountOf(age_table_new);
size_t table_size = std::size(age_table_new);
#ifdef ORIGINAL_RATINGS
age_table = age_table_old;
table_size = Util::CountOf(age_table_old);
table_size = std::size(age_table_old);
#endif
row last_row = age_table[table_size - 1];

View File

@ -9,10 +9,11 @@
#include "TrackData.h"
#include "../core/Util.hpp"
#include "Track.h"
#include "TrackPaint.h"
#include <iterator>
// clang-format off
const rct_track_coordinates FlatTrackCoordinates[] = {
{ 0, 0, 0, 0, 0, 0 },
@ -6482,7 +6483,7 @@ const track_descriptor gTrackDescriptors[142] = {
#define CREATE_VEHICLE_INFO(VAR, ...) \
static constexpr const rct_vehicle_info VAR##_data [] = __VA_ARGS__ ; \
static constexpr const rct_vehicle_info_list VAR = { static_cast<uint16_t>(Util::CountOf(VAR##_data)), VAR##_data };
static constexpr const rct_vehicle_info_list VAR = { static_cast<uint16_t>(std::size(VAR##_data)), VAR##_data };
CREATE_VEHICLE_INFO(TrackVehicleInfo_8BE57A, {
{ 31, 16, 0, 0, 0, 0 }, { 30, 16, 0, 0, 0, 0 }, { 29, 16, 0, 0, 0, 0 }, { 28, 16, 0, 0, 0, 0 }, { 27, 16, 0, 0, 0, 0 },

View File

@ -16,7 +16,6 @@
#include "../audio/audio.h"
#include "../core/File.h"
#include "../core/String.hpp"
#include "../core/Util.hpp"
#include "../localisation/Localisation.h"
#include "../localisation/StringIds.h"
#include "../management/Finance.h"
@ -41,6 +40,7 @@
#include "TrackDesignRepository.h"
#include <algorithm>
#include <iterator>
struct map_backup
{
@ -664,7 +664,7 @@ static void track_design_add_selection_tile(int16_t x, int16_t y)
{
LocationXY16* selectionTile = gMapSelectionTiles;
// Subtract 2 because the tile gets incremented later on
for (; (selectionTile < gMapSelectionTiles + Util::CountOf(gMapSelectionTiles) - 2) && (selectionTile->x != -1);
for (; (selectionTile < gMapSelectionTiles + std::size(gMapSelectionTiles) - 2) && (selectionTile->x != -1);
selectionTile++)
{
if (selectionTile->x == x && selectionTile->y == y)
@ -750,7 +750,7 @@ static int32_t track_design_place_scenery(
break;
}
// Need to subtract one because selectionTile in following block is incremented
if (selectionTile + 1 >= &gMapSelectionTiles[Util::CountOf(gMapSelectionTiles) - 1])
if (selectionTile + 1 >= &gMapSelectionTiles[std::size(gMapSelectionTiles) - 1])
{
new_tile = 0;
break;

View File

@ -17,7 +17,6 @@
#include "../audio/audio.h"
#include "../config/Config.h"
#include "../core/Memory.hpp"
#include "../core/Util.hpp"
#include "../interface/Viewport.h"
#include "../localisation/Localisation.h"
#include "../management/NewsItem.h"
@ -42,6 +41,7 @@
#include "VehicleData.h"
#include <algorithm>
#include <iterator>
static void vehicle_update(rct_vehicle* vehicle);
static void vehicle_update_crossings(const rct_vehicle* vehicle);
@ -762,7 +762,7 @@ static const struct
static bool vehicle_move_info_valid(int32_t cd, int32_t typeAndDirection, int32_t offset)
{
if (cd >= static_cast<int32_t>(Util::CountOf(gTrackVehicleInfo)))
if (cd >= static_cast<int32_t>(std::size(gTrackVehicleInfo)))
{
return false;
}
@ -912,10 +912,10 @@ static void vehicle_update_sound_params(rct_vehicle* vehicle)
soundParam < gVehicleSoundParamsListEnd && sound_priority <= soundParam->priority; soundParam++)
;
if (soundParam >= &gVehicleSoundParamsList[Util::CountOf(gVehicleSoundParamsList)])
if (soundParam >= &gVehicleSoundParamsList[std::size(gVehicleSoundParamsList)])
return;
if (gVehicleSoundParamsListEnd < &gVehicleSoundParamsList[Util::CountOf(gVehicleSoundParamsList)])
if (gVehicleSoundParamsListEnd < &gVehicleSoundParamsList[std::size(gVehicleSoundParamsList)])
{
gVehicleSoundParamsListEnd++;
}
@ -996,7 +996,7 @@ static int32_t vehicle_get_sound_priority_factor(rct_vehicle* vehicle)
{
vehicle_sound++;
if (vehicle_sound >= &gVehicleSoundList[Util::CountOf(gVehicleSoundList)])
if (vehicle_sound >= &gVehicleSoundList[std::size(gVehicleSoundList)])
{
return result;
}
@ -1082,16 +1082,16 @@ static rct_vehicle_sound* vehicle_sounds_update_get_vehicle_sound(rct_vehicle_so
{
// Search for already playing vehicle sound
rct_vehicle_sound* vehicleSound = &gVehicleSoundList[0];
for (; vehicleSound < &gVehicleSoundList[Util::CountOf(gVehicleSoundList)]; vehicleSound++)
for (; vehicleSound < &gVehicleSoundList[std::size(gVehicleSoundList)]; vehicleSound++)
{
if (vehicleSound->id == sound_params->id)
return vehicleSound;
}
// No sound already playing
if (vehicleSound >= &gVehicleSoundList[Util::CountOf(gVehicleSoundList)])
if (vehicleSound >= &gVehicleSoundList[std::size(gVehicleSoundList)])
{
for (vehicleSound = &gVehicleSoundList[0]; vehicleSound < &gVehicleSoundList[Util::CountOf(gVehicleSoundList)];
for (vehicleSound = &gVehicleSoundList[0]; vehicleSound < &gVehicleSoundList[std::size(gVehicleSoundList)];
vehicleSound++)
{
// Use free slot
@ -2205,7 +2205,7 @@ static int ride_get_train_index_from_vehicle(Ride* ride, uint16_t spriteIndex)
// track type to, e.g., Crooked House
break;
}
else if (trainIndex >= Util::CountOf(ride->vehicles))
else if (trainIndex >= std::size(ride->vehicles))
{
return VEHICLE_INVALID_ID;
}
@ -5559,7 +5559,7 @@ static void vehicle_update_sound(rct_vehicle* vehicle)
loc_6D7A97:
vehicle->scream_sound_id = 255;
if (ride->type < Util::CountOf(RideLiftData))
if (ride->type < std::size(RideLiftData))
{
// Get lift hill sound
screamId = RideLiftData[ride->type].sound_id;

View File

@ -9,7 +9,7 @@
#include "VehicleData.h"
#include "../core/Util.hpp"
#include <iterator>
// clang-format off
/** rct2: 0x0099F100 */
@ -793,7 +793,7 @@ const uint8_t MotionSimulatorTimeToSpriteMap[] = {
0xFF,
};
const int32_t MotionSimulatorTimeToSpriteMapCount = static_cast<int32_t>(Util::CountOf(MotionSimulatorTimeToSpriteMap));
const int32_t MotionSimulatorTimeToSpriteMapCount = static_cast<int32_t>(std::size(MotionSimulatorTimeToSpriteMap));
/** rct2: 0x009A2930 */
const int32_t dword_9A2930[] = {

View File

@ -10,7 +10,6 @@
#include "VehiclePaint.h"
#include "../Game.h"
#include "../core/Util.hpp"
#include "../drawing/Drawing.h"
#include "../drawing/LightFX.h"
#include "../interface/Viewport.h"
@ -19,6 +18,8 @@
#include "../world/Sprite.h"
#include "Track.h"
#include <iterator>
// clang-format off
// 0x0098E52C:
const vehicle_boundbox VehicleBoundboxes[16][224] = {
@ -892,7 +893,7 @@ static void vehicle_sprite_paint(
const rct_ride_entry_vehicle* vehicleEntry)
{
int32_t baseImage_id = ebx;
if (vehicleEntry->draw_order >= Util::CountOf(VehicleBoundboxes))
if (vehicleEntry->draw_order >= std::size(VehicleBoundboxes))
{
return;
}
@ -3105,7 +3106,7 @@ void vehicle_visual_default(
paint_session* session, int32_t imageDirection, int32_t z, const rct_vehicle* vehicle,
const rct_ride_entry_vehicle* vehicleEntry)
{
if (vehicle->vehicle_sprite_type < Util::CountOf(vehicle_sprite_funcs))
if (vehicle->vehicle_sprite_type < std::size(vehicle_sprite_funcs))
{
vehicle_sprite_funcs[vehicle->vehicle_sprite_type](session, vehicle, imageDirection, z, vehicleEntry);
}

View File

@ -8,7 +8,6 @@
*****************************************************************************/
#include "../../common.h"
#include "../../core/Util.hpp"
#include "../../interface/Viewport.h"
#include "../../paint/Paint.h"
#include "../../paint/Supports.h"

View File

@ -8,7 +8,6 @@
*****************************************************************************/
#include "../../config/Config.h"
#include "../../core/Util.hpp"
#include "../../interface/Viewport.h"
#include "../../paint/Paint.h"
#include "../../paint/Supports.h"
@ -20,6 +19,8 @@
#include "../TrackPaint.h"
#include "../VehiclePaint.h"
#include <iterator>
enum
{
SPR_MINI_GOLF_FLAT_SW_NE = 14404,
@ -182,26 +183,28 @@ enum
SPR_MINI_GOLF_HOLE_E_TRIM_PART_3_SW_NW = 14556,
};
static constexpr const uint32_t mini_golf_track_sprites_25_deg_up[][3] = { {
SPR_MINI_GOLF_25_DEG_UP_SW_NE,
SPR_MINI_GOLF_25_DEG_UP_FENCE_BACK_SW_NE,
SPR_MINI_GOLF_25_DEG_UP_FENCE_FRONT_SW_NE,
},
{
SPR_MINI_GOLF_25_DEG_UP_NW_SE,
SPR_MINI_GOLF_25_DEG_UP_FENCE_BACK_NW_SE,
SPR_MINI_GOLF_25_DEG_UP_FENCE_FRONT_NW_SE,
},
{
SPR_MINI_GOLF_25_DEG_UP_NE_SW,
SPR_MINI_GOLF_25_DEG_UP_FENCE_BACK_NE_SW,
SPR_MINI_GOLF_25_DEG_UP_FENCE_FRONT_NE_SW,
},
{
SPR_MINI_GOLF_25_DEG_UP_SE_NW,
SPR_MINI_GOLF_25_DEG_UP_FENCE_BACK_SE_NW,
SPR_MINI_GOLF_25_DEG_UP_FENCE_FRONT_SE_NW,
} };
static constexpr const uint32_t mini_golf_track_sprites_25_deg_up[][3] = {
{
SPR_MINI_GOLF_25_DEG_UP_SW_NE,
SPR_MINI_GOLF_25_DEG_UP_FENCE_BACK_SW_NE,
SPR_MINI_GOLF_25_DEG_UP_FENCE_FRONT_SW_NE,
},
{
SPR_MINI_GOLF_25_DEG_UP_NW_SE,
SPR_MINI_GOLF_25_DEG_UP_FENCE_BACK_NW_SE,
SPR_MINI_GOLF_25_DEG_UP_FENCE_FRONT_NW_SE,
},
{
SPR_MINI_GOLF_25_DEG_UP_NE_SW,
SPR_MINI_GOLF_25_DEG_UP_FENCE_BACK_NE_SW,
SPR_MINI_GOLF_25_DEG_UP_FENCE_FRONT_NE_SW,
},
{
SPR_MINI_GOLF_25_DEG_UP_SE_NW,
SPR_MINI_GOLF_25_DEG_UP_FENCE_BACK_SE_NW,
SPR_MINI_GOLF_25_DEG_UP_FENCE_FRONT_SE_NW,
},
};
static constexpr const uint32_t mini_golf_track_sprites_flat_to_25_deg_up[][3] = {
{
@ -223,7 +226,7 @@ static constexpr const uint32_t mini_golf_track_sprites_flat_to_25_deg_up[][3] =
SPR_MINI_GOLF_FLAT_TO_25_DEG_UP_SE_NW,
SPR_MINI_GOLF_FLAT_TO_25_DEG_UP_FENCE_BACK_SE_NW,
SPR_MINI_GOLF_FLAT_TO_25_DEG_UP_FENCE_FRONT_SE_NW,
}
},
};
static constexpr const uint32_t mini_golf_track_sprites_25_deg_up_to_flat[][3] = {
@ -246,7 +249,7 @@ static constexpr const uint32_t mini_golf_track_sprites_25_deg_up_to_flat[][3] =
SPR_MINI_GOLF_25_DEG_UP_TO_FLAT_SE_NW,
SPR_MINI_GOLF_25_DEG_UP_TO_FLAT_FENCE_BACK_SE_NW,
SPR_MINI_GOLF_25_DEG_UP_TO_FLAT_FENCE_FRONT_SE_NW,
}
},
};
static constexpr const uint32_t mini_golf_track_sprites_quarter_turn_1_tile[] = {
@ -264,117 +267,179 @@ static constexpr const uint32_t mini_golf_track_sprites_quarter_turn_1_tile_fenc
};
static constexpr const uint32_t mini_golf_track_sprites_hole_a[4][2][2] = {
{ { SPR_MINI_GOLF_HOLE_A_BASE_PART_1_SW_NE, SPR_MINI_GOLF_HOLE_A_TRIM_PART_1_SW_NE },
{ SPR_MINI_GOLF_HOLE_A_BASE_PART_2_SW_NE, SPR_MINI_GOLF_HOLE_A_TRIM_PART_2_SW_NE } },
{ { SPR_MINI_GOLF_HOLE_A_BASE_PART_1_NW_SE, SPR_MINI_GOLF_HOLE_A_TRIM_PART_1_NW_SE },
{ SPR_MINI_GOLF_HOLE_A_BASE_PART_2_NW_SE, SPR_MINI_GOLF_HOLE_A_TRIM_PART_2_NW_SE } },
{ { SPR_MINI_GOLF_HOLE_A_BASE_PART_1_NE_SW, SPR_MINI_GOLF_HOLE_A_TRIM_PART_1_NE_SW },
{ SPR_MINI_GOLF_HOLE_A_BASE_PART_2_NE_SW, SPR_MINI_GOLF_HOLE_A_TRIM_PART_2_NE_SW } },
{ { SPR_MINI_GOLF_HOLE_A_BASE_PART_1_SE_NW, SPR_MINI_GOLF_HOLE_A_TRIM_PART_1_SE_NW },
{ SPR_MINI_GOLF_HOLE_A_BASE_PART_2_SE_NW, SPR_MINI_GOLF_HOLE_A_TRIM_PART_2_SE_NW } },
{
{ SPR_MINI_GOLF_HOLE_A_BASE_PART_1_SW_NE, SPR_MINI_GOLF_HOLE_A_TRIM_PART_1_SW_NE },
{ SPR_MINI_GOLF_HOLE_A_BASE_PART_2_SW_NE, SPR_MINI_GOLF_HOLE_A_TRIM_PART_2_SW_NE },
},
{
{ SPR_MINI_GOLF_HOLE_A_BASE_PART_1_NW_SE, SPR_MINI_GOLF_HOLE_A_TRIM_PART_1_NW_SE },
{ SPR_MINI_GOLF_HOLE_A_BASE_PART_2_NW_SE, SPR_MINI_GOLF_HOLE_A_TRIM_PART_2_NW_SE },
},
{
{ SPR_MINI_GOLF_HOLE_A_BASE_PART_1_NE_SW, SPR_MINI_GOLF_HOLE_A_TRIM_PART_1_NE_SW },
{ SPR_MINI_GOLF_HOLE_A_BASE_PART_2_NE_SW, SPR_MINI_GOLF_HOLE_A_TRIM_PART_2_NE_SW },
},
{
{ SPR_MINI_GOLF_HOLE_A_BASE_PART_1_SE_NW, SPR_MINI_GOLF_HOLE_A_TRIM_PART_1_SE_NW },
{ SPR_MINI_GOLF_HOLE_A_BASE_PART_2_SE_NW, SPR_MINI_GOLF_HOLE_A_TRIM_PART_2_SE_NW },
},
};
static constexpr const uint32_t mini_golf_track_sprites_hole_b[4][2][2] = {
{ { SPR_MINI_GOLF_HOLE_B_BASE_PART_1_SW_NE, SPR_MINI_GOLF_HOLE_B_TRIM_PART_1_SW_NE },
{ SPR_MINI_GOLF_HOLE_B_BASE_PART_2_SW_NE, SPR_MINI_GOLF_HOLE_B_TRIM_PART_2_SW_NE } },
{ { SPR_MINI_GOLF_HOLE_B_BASE_PART_1_NW_SE, SPR_MINI_GOLF_HOLE_B_TRIM_PART_1_NW_SE },
{ SPR_MINI_GOLF_HOLE_B_BASE_PART_2_NW_SE, SPR_MINI_GOLF_HOLE_B_TRIM_PART_2_NW_SE } },
{ { SPR_MINI_GOLF_HOLE_B_BASE_PART_1_NE_SW, SPR_MINI_GOLF_HOLE_B_TRIM_PART_1_NE_SW },
{ SPR_MINI_GOLF_HOLE_B_BASE_PART_2_NE_SW, SPR_MINI_GOLF_HOLE_B_TRIM_PART_2_NE_SW } },
{ { SPR_MINI_GOLF_HOLE_B_BASE_PART_1_SE_NW, SPR_MINI_GOLF_HOLE_B_TRIM_PART_1_SE_NW },
{ SPR_MINI_GOLF_HOLE_B_BASE_PART_2_SE_NW, SPR_MINI_GOLF_HOLE_B_TRIM_PART_2_SE_NW } },
{
{ SPR_MINI_GOLF_HOLE_B_BASE_PART_1_SW_NE, SPR_MINI_GOLF_HOLE_B_TRIM_PART_1_SW_NE },
{ SPR_MINI_GOLF_HOLE_B_BASE_PART_2_SW_NE, SPR_MINI_GOLF_HOLE_B_TRIM_PART_2_SW_NE },
},
{
{ SPR_MINI_GOLF_HOLE_B_BASE_PART_1_NW_SE, SPR_MINI_GOLF_HOLE_B_TRIM_PART_1_NW_SE },
{ SPR_MINI_GOLF_HOLE_B_BASE_PART_2_NW_SE, SPR_MINI_GOLF_HOLE_B_TRIM_PART_2_NW_SE },
},
{
{ SPR_MINI_GOLF_HOLE_B_BASE_PART_1_NE_SW, SPR_MINI_GOLF_HOLE_B_TRIM_PART_1_NE_SW },
{ SPR_MINI_GOLF_HOLE_B_BASE_PART_2_NE_SW, SPR_MINI_GOLF_HOLE_B_TRIM_PART_2_NE_SW },
},
{
{ SPR_MINI_GOLF_HOLE_B_BASE_PART_1_SE_NW, SPR_MINI_GOLF_HOLE_B_TRIM_PART_1_SE_NW },
{ SPR_MINI_GOLF_HOLE_B_BASE_PART_2_SE_NW, SPR_MINI_GOLF_HOLE_B_TRIM_PART_2_SE_NW },
},
};
static constexpr const uint32_t mini_golf_track_sprites_hole_c[][2][2] = {
{ { SPR_MINI_GOLF_HOLE_C_BASE_PART_1_SW_NE, SPR_MINI_GOLF_HOLE_C_TRIM_PART_1_SW_NE },
{ SPR_MINI_GOLF_HOLE_C_BASE_PART_2_SW_NE, SPR_MINI_GOLF_HOLE_C_TRIM_PART_2_SW_NE } },
{ { SPR_MINI_GOLF_HOLE_C_BASE_PART_1_NW_SE, SPR_MINI_GOLF_HOLE_C_TRIM_PART_1_NW_SE },
{ SPR_MINI_GOLF_HOLE_C_BASE_PART_2_NW_SE, SPR_MINI_GOLF_HOLE_C_TRIM_PART_2_NW_SE } },
{ { SPR_MINI_GOLF_HOLE_C_BASE_PART_1_NE_SW, SPR_MINI_GOLF_HOLE_C_TRIM_PART_1_NE_SW },
{ SPR_MINI_GOLF_HOLE_C_BASE_PART_2_NE_SW, SPR_MINI_GOLF_HOLE_C_TRIM_PART_2_NE_SW } },
{ { SPR_MINI_GOLF_HOLE_C_BASE_PART_1_SE_NW, SPR_MINI_GOLF_HOLE_C_TRIM_PART_1_SE_NW },
{ SPR_MINI_GOLF_HOLE_C_BASE_PART_2_SE_NW, SPR_MINI_GOLF_HOLE_C_TRIM_PART_2_SE_NW } },
{
{ SPR_MINI_GOLF_HOLE_C_BASE_PART_1_SW_NE, SPR_MINI_GOLF_HOLE_C_TRIM_PART_1_SW_NE },
{ SPR_MINI_GOLF_HOLE_C_BASE_PART_2_SW_NE, SPR_MINI_GOLF_HOLE_C_TRIM_PART_2_SW_NE },
},
{
{ SPR_MINI_GOLF_HOLE_C_BASE_PART_1_NW_SE, SPR_MINI_GOLF_HOLE_C_TRIM_PART_1_NW_SE },
{ SPR_MINI_GOLF_HOLE_C_BASE_PART_2_NW_SE, SPR_MINI_GOLF_HOLE_C_TRIM_PART_2_NW_SE },
},
{
{ SPR_MINI_GOLF_HOLE_C_BASE_PART_1_NE_SW, SPR_MINI_GOLF_HOLE_C_TRIM_PART_1_NE_SW },
{ SPR_MINI_GOLF_HOLE_C_BASE_PART_2_NE_SW, SPR_MINI_GOLF_HOLE_C_TRIM_PART_2_NE_SW },
},
{
{ SPR_MINI_GOLF_HOLE_C_BASE_PART_1_SE_NW, SPR_MINI_GOLF_HOLE_C_TRIM_PART_1_SE_NW },
{ SPR_MINI_GOLF_HOLE_C_BASE_PART_2_SE_NW, SPR_MINI_GOLF_HOLE_C_TRIM_PART_2_SE_NW },
},
};
static constexpr const uint32_t mini_golf_track_sprites_hole_d[][3][2] = {
{ { SPR_MINI_GOLF_HOLE_D_BASE_PART_1_SW_SE, SPR_MINI_GOLF_HOLE_D_TRIM_PART_1_SW_SE },
{ SPR_MINI_GOLF_HOLE_D_BASE_PART_2_SW_SE, SPR_MINI_GOLF_HOLE_D_TRIM_PART_2_SW_SE },
{ SPR_MINI_GOLF_HOLE_D_BASE_PART_3_SW_SE, SPR_MINI_GOLF_HOLE_D_TRIM_PART_3_SW_SE } },
{ { SPR_MINI_GOLF_HOLE_D_BASE_PART_1_NW_SW, SPR_MINI_GOLF_HOLE_D_TRIM_PART_1_NW_SW },
{ SPR_MINI_GOLF_HOLE_D_BASE_PART_2_NW_SW, SPR_MINI_GOLF_HOLE_D_TRIM_PART_2_NW_SW },
{ SPR_MINI_GOLF_HOLE_D_BASE_PART_3_NW_SW, SPR_MINI_GOLF_HOLE_D_TRIM_PART_3_NW_SW } },
{ { SPR_MINI_GOLF_HOLE_D_BASE_PART_1_NE_NW, SPR_MINI_GOLF_HOLE_D_TRIM_PART_1_NE_NW },
{ SPR_MINI_GOLF_HOLE_D_BASE_PART_2_NE_NW, SPR_MINI_GOLF_HOLE_D_TRIM_PART_2_NE_NW },
{ SPR_MINI_GOLF_HOLE_D_BASE_PART_3_NE_NW, SPR_MINI_GOLF_HOLE_D_TRIM_PART_3_NE_NW } },
{ { SPR_MINI_GOLF_HOLE_D_BASE_PART_1_SE_NE, SPR_MINI_GOLF_HOLE_D_TRIM_PART_1_SE_NE },
{ SPR_MINI_GOLF_HOLE_D_BASE_PART_2_SE_NE, SPR_MINI_GOLF_HOLE_D_TRIM_PART_2_SE_NE },
{ SPR_MINI_GOLF_HOLE_D_BASE_PART_3_SE_NE, SPR_MINI_GOLF_HOLE_D_TRIM_PART_3_SE_NE } },
{
{ SPR_MINI_GOLF_HOLE_D_BASE_PART_1_SW_SE, SPR_MINI_GOLF_HOLE_D_TRIM_PART_1_SW_SE },
{ SPR_MINI_GOLF_HOLE_D_BASE_PART_2_SW_SE, SPR_MINI_GOLF_HOLE_D_TRIM_PART_2_SW_SE },
{ SPR_MINI_GOLF_HOLE_D_BASE_PART_3_SW_SE, SPR_MINI_GOLF_HOLE_D_TRIM_PART_3_SW_SE },
},
{
{ SPR_MINI_GOLF_HOLE_D_BASE_PART_1_NW_SW, SPR_MINI_GOLF_HOLE_D_TRIM_PART_1_NW_SW },
{ SPR_MINI_GOLF_HOLE_D_BASE_PART_2_NW_SW, SPR_MINI_GOLF_HOLE_D_TRIM_PART_2_NW_SW },
{ SPR_MINI_GOLF_HOLE_D_BASE_PART_3_NW_SW, SPR_MINI_GOLF_HOLE_D_TRIM_PART_3_NW_SW },
},
{
{ SPR_MINI_GOLF_HOLE_D_BASE_PART_1_NE_NW, SPR_MINI_GOLF_HOLE_D_TRIM_PART_1_NE_NW },
{ SPR_MINI_GOLF_HOLE_D_BASE_PART_2_NE_NW, SPR_MINI_GOLF_HOLE_D_TRIM_PART_2_NE_NW },
{ SPR_MINI_GOLF_HOLE_D_BASE_PART_3_NE_NW, SPR_MINI_GOLF_HOLE_D_TRIM_PART_3_NE_NW },
},
{
{ SPR_MINI_GOLF_HOLE_D_BASE_PART_1_SE_NE, SPR_MINI_GOLF_HOLE_D_TRIM_PART_1_SE_NE },
{ SPR_MINI_GOLF_HOLE_D_BASE_PART_2_SE_NE, SPR_MINI_GOLF_HOLE_D_TRIM_PART_2_SE_NE },
{ SPR_MINI_GOLF_HOLE_D_BASE_PART_3_SE_NE, SPR_MINI_GOLF_HOLE_D_TRIM_PART_3_SE_NE },
},
};
static constexpr const uint32_t mini_golf_track_sprites_hole_e[][3][2] = {
{ { SPR_MINI_GOLF_HOLE_E_BASE_PART_1_SW_NW, SPR_MINI_GOLF_HOLE_E_TRIM_PART_1_SW_NW },
{ SPR_MINI_GOLF_HOLE_E_BASE_PART_2_SW_NW, SPR_MINI_GOLF_HOLE_E_TRIM_PART_2_SW_NW },
{ SPR_MINI_GOLF_HOLE_E_BASE_PART_3_SW_NW, SPR_MINI_GOLF_HOLE_E_TRIM_PART_3_SW_NW } },
{ { SPR_MINI_GOLF_HOLE_E_BASE_PART_1_NW_NE, SPR_MINI_GOLF_HOLE_E_TRIM_PART_1_NW_NE },
{ SPR_MINI_GOLF_HOLE_E_BASE_PART_2_NW_NE, SPR_MINI_GOLF_HOLE_E_TRIM_PART_2_NW_NE },
{ SPR_MINI_GOLF_HOLE_E_BASE_PART_3_NW_NE, SPR_MINI_GOLF_HOLE_E_TRIM_PART_3_NW_NE } },
{ { SPR_MINI_GOLF_HOLE_E_BASE_PART_1_NE_SE, SPR_MINI_GOLF_HOLE_E_TRIM_PART_1_NE_SE },
{ SPR_MINI_GOLF_HOLE_E_BASE_PART_2_NE_SE, SPR_MINI_GOLF_HOLE_E_TRIM_PART_2_NE_SE },
{ SPR_MINI_GOLF_HOLE_E_BASE_PART_3_NE_SE, SPR_MINI_GOLF_HOLE_E_TRIM_PART_3_NE_SE } },
{ { SPR_MINI_GOLF_HOLE_E_BASE_PART_1_SE_SW, SPR_MINI_GOLF_HOLE_E_TRIM_PART_1_SE_SW },
{ SPR_MINI_GOLF_HOLE_E_BASE_PART_2_SE_SW, SPR_MINI_GOLF_HOLE_E_TRIM_PART_2_SE_SW },
{ SPR_MINI_GOLF_HOLE_E_BASE_PART_3_SE_SW, SPR_MINI_GOLF_HOLE_E_TRIM_PART_3_SE_SW } },
{
{ SPR_MINI_GOLF_HOLE_E_BASE_PART_1_SW_NW, SPR_MINI_GOLF_HOLE_E_TRIM_PART_1_SW_NW },
{ SPR_MINI_GOLF_HOLE_E_BASE_PART_2_SW_NW, SPR_MINI_GOLF_HOLE_E_TRIM_PART_2_SW_NW },
{ SPR_MINI_GOLF_HOLE_E_BASE_PART_3_SW_NW, SPR_MINI_GOLF_HOLE_E_TRIM_PART_3_SW_NW },
},
{
{ SPR_MINI_GOLF_HOLE_E_BASE_PART_1_NW_NE, SPR_MINI_GOLF_HOLE_E_TRIM_PART_1_NW_NE },
{ SPR_MINI_GOLF_HOLE_E_BASE_PART_2_NW_NE, SPR_MINI_GOLF_HOLE_E_TRIM_PART_2_NW_NE },
{ SPR_MINI_GOLF_HOLE_E_BASE_PART_3_NW_NE, SPR_MINI_GOLF_HOLE_E_TRIM_PART_3_NW_NE },
},
{
{ SPR_MINI_GOLF_HOLE_E_BASE_PART_1_NE_SE, SPR_MINI_GOLF_HOLE_E_TRIM_PART_1_NE_SE },
{ SPR_MINI_GOLF_HOLE_E_BASE_PART_2_NE_SE, SPR_MINI_GOLF_HOLE_E_TRIM_PART_2_NE_SE },
{ SPR_MINI_GOLF_HOLE_E_BASE_PART_3_NE_SE, SPR_MINI_GOLF_HOLE_E_TRIM_PART_3_NE_SE },
},
{
{ SPR_MINI_GOLF_HOLE_E_BASE_PART_1_SE_SW, SPR_MINI_GOLF_HOLE_E_TRIM_PART_1_SE_SW },
{ SPR_MINI_GOLF_HOLE_E_BASE_PART_2_SE_SW, SPR_MINI_GOLF_HOLE_E_TRIM_PART_2_SE_SW },
{ SPR_MINI_GOLF_HOLE_E_BASE_PART_3_SE_SW, SPR_MINI_GOLF_HOLE_E_TRIM_PART_3_SE_SW },
},
};
/** rct2: 0x00933471 */
static constexpr const uint8_t mini_golf_peep_animation_frames_walk[] = { 0, 1, 2, 3, 4, 5 };
// clang-format off
static constexpr const uint8_t mini_golf_peep_animation_frames_walk[] = {
0, 1, 2, 3, 4, 5,
};
/** rct2: 0x00933478 */
static constexpr const uint8_t mini_golf_peep_animation_frames_place_ball_downwards[] = { 12, 13, 14, 15 };
static constexpr const uint8_t mini_golf_peep_animation_frames_place_ball_downwards[] = {
12, 13, 14, 15,
};
/** rct2: 0x009334B5 */
static constexpr const uint8_t mini_golf_peep_animation_frames_swing[] = { 31, 31, 31, 31, 31, 31, 31, 31,
31, 32, 33, 33, 33, 33, 34 };
static constexpr const uint8_t mini_golf_peep_animation_frames_swing[] = {
31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 33, 33, 33, 33, 34,
};
/** rct2: 0x0093347D */
static constexpr const uint8_t mini_golf_peep_animation_frames_swing_left[] = { 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 8, 8, 8, 8, 9 };
static constexpr const uint8_t mini_golf_peep_animation_frames_swing_left[] = {
6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 8, 8, 8, 8, 9,
};
/** rct2: 0x0093348D */
static constexpr const uint8_t mini_golf_peep_animation_frames_place_ball_upwards[] = { 12, 13, 14, 15, 14, 13, 12 };
static constexpr const uint8_t mini_golf_peep_animation_frames_place_ball_upwards[] = {
12, 13, 14, 15, 14, 13, 12,
};
/** rct2: 0x00933495 */
static constexpr const uint8_t mini_golf_peep_animation_frames_jump[] = { 16, 17, 18, 19, 20, 21, 22, 23,
24, 25, 26, 27, 28, 29, 30 };
static constexpr const uint8_t mini_golf_peep_animation_frames_jump[] = {
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
};
/** rct2: 0x009334A5 */
static constexpr const uint8_t mini_golf_peep_animation_frames_pickup_ball[] = { 15, 14, 13, 12 };
static constexpr const uint8_t mini_golf_peep_animation_frames_pickup_ball[] = {
15, 14, 13, 12,
};
/** rct2: 0x009334C5 */
static constexpr const uint8_t mini_golf_peep_animation_frames_put[] = { 35, 36, 36, 36, 36, 36, 35, 35, 35, 35 };
static constexpr const uint8_t mini_golf_peep_animation_frames_put[] = {
35, 36, 36, 36, 36, 36, 35, 35, 35, 35,
};
/** rct2: 0x009334AA */
static constexpr const uint8_t mini_golf_peep_animation_frames_put_left[] = { 10, 11, 11, 11, 11, 11, 10, 10, 10, 10 };
static constexpr const uint8_t mini_golf_peep_animation_frames_put_left[] = {
10, 11, 11, 11, 11, 11, 10, 10, 10, 10,
};
/** rct2: 0x008B8F74 */
static constexpr const uint8_t* mini_golf_peep_animation_frames[] = {
mini_golf_peep_animation_frames_walk, mini_golf_peep_animation_frames_place_ball_downwards,
mini_golf_peep_animation_frames_swing_left, mini_golf_peep_animation_frames_place_ball_upwards,
mini_golf_peep_animation_frames_jump, mini_golf_peep_animation_frames_pickup_ball,
mini_golf_peep_animation_frames_put_left, mini_golf_peep_animation_frames_swing,
mini_golf_peep_animation_frames_walk,
mini_golf_peep_animation_frames_place_ball_downwards,
mini_golf_peep_animation_frames_swing_left,
mini_golf_peep_animation_frames_place_ball_upwards,
mini_golf_peep_animation_frames_jump,
mini_golf_peep_animation_frames_pickup_ball,
mini_golf_peep_animation_frames_put_left,
mini_golf_peep_animation_frames_swing,
mini_golf_peep_animation_frames_put,
};
const size_t mini_golf_peep_animation_lengths[] = {
Util::CountOf(mini_golf_peep_animation_frames_walk),
Util::CountOf(mini_golf_peep_animation_frames_place_ball_downwards),
Util::CountOf(mini_golf_peep_animation_frames_swing_left),
Util::CountOf(mini_golf_peep_animation_frames_place_ball_upwards),
Util::CountOf(mini_golf_peep_animation_frames_jump),
Util::CountOf(mini_golf_peep_animation_frames_pickup_ball),
Util::CountOf(mini_golf_peep_animation_frames_put_left),
Util::CountOf(mini_golf_peep_animation_frames_swing),
Util::CountOf(mini_golf_peep_animation_frames_put),
std::size(mini_golf_peep_animation_frames_walk),
std::size(mini_golf_peep_animation_frames_place_ball_downwards),
std::size(mini_golf_peep_animation_frames_swing_left),
std::size(mini_golf_peep_animation_frames_place_ball_upwards),
std::size(mini_golf_peep_animation_frames_jump),
std::size(mini_golf_peep_animation_frames_pickup_ball),
std::size(mini_golf_peep_animation_frames_put_left),
std::size(mini_golf_peep_animation_frames_swing),
std::size(mini_golf_peep_animation_frames_put),
};
// clang-format on
static paint_struct* mini_golf_paint_util_7c(
paint_session* session, uint8_t direction, uint32_t image_id, int8_t x_offset, int8_t y_offset, int16_t bound_box_length_x,

View File

@ -7,7 +7,6 @@
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
#include "../../core/Util.hpp"
#include "../../interface/Viewport.h"
#include "../../localisation/Localisation.h"
#include "../../paint/Paint.h"
@ -19,6 +18,8 @@
#include "../TrackData.h"
#include "../TrackPaint.h"
#include <iterator>
/** rct2: 0x014280BC */
static int16_t TopSpinSeatHeightOffset[] = {
-10, -10, -9, -7, -4, -1, 2, 6, 11, 16, 21, 26, 31, 37, 42, 47, 52, 57, 61, 64, 67, 70, 72, 73,
@ -140,7 +141,7 @@ static void top_spin_paint_vehicle(
LocationXYZ16 seatCoords = { al, cl, static_cast<int16_t>(height) };
if (armRotation >= static_cast<int8_t>(Util::CountOf(TopSpinSeatHeightOffset)))
if (armRotation >= static_cast<int8_t>(std::size(TopSpinSeatHeightOffset)))
{
return;
}

View File

@ -20,7 +20,6 @@
#include "../core/FileStream.hpp"
#include "../core/Path.hpp"
#include "../core/String.hpp"
#include "../core/Util.hpp"
#include "../localisation/Language.h"
#include "../localisation/Localisation.h"
#include "../localisation/LocalisationService.h"

View File

@ -11,9 +11,10 @@
#include "../core/Guard.hpp"
#include "../core/String.hpp"
#include "../core/Util.hpp"
#include "Scenario.h"
#include <iterator>
namespace ScenarioSources
{
struct ScenarioAlias
@ -302,7 +303,7 @@ namespace ScenarioSources
{ SC_UNIDENTIFIED, "Build your own Six Flags over Texas", SCENARIO_CATEGORY_BUILD_YOUR_OWN },
};
#define DEFINE_SCENARIO_TITLE_DESC_GROUP(x) { Util::CountOf(x), x }
#define DEFINE_SCENARIO_TITLE_DESC_GROUP(x) { std::size(x), x }
const struct {
size_t count;
const ScenarioTitleDescriptor * const titles;
@ -325,7 +326,7 @@ namespace ScenarioSources
Guard::ArgumentNotNull(outDesc, GUARD_LINE);
int32_t currentIndex = 0;
for (size_t i = 0; i < Util::CountOf(ScenarioTitlesBySource); i++)
for (size_t i = 0; i < std::size(ScenarioTitlesBySource); i++)
{
for (size_t j = 0; j < ScenarioTitlesBySource[i].count; j++)
{
@ -356,7 +357,7 @@ namespace ScenarioSources
Guard::ArgumentNotNull(outDesc, GUARD_LINE);
int32_t currentIndex = 0;
for (size_t i = 0; i < Util::CountOf(ScenarioTitlesBySource); i++)
for (size_t i = 0; i < std::size(ScenarioTitlesBySource); i++)
{
for (size_t j = 0; j < ScenarioTitlesBySource[i].count; j++)
{

View File

@ -15,12 +15,12 @@
#include "../core/Memory.hpp"
#include "../core/Path.hpp"
#include "../core/String.hpp"
#include "../core/Util.hpp"
#include "../localisation/Localisation.h"
#include "../platform/platform.h"
#include "TitleSequence.h"
#include <algorithm>
#include <iterator>
#include <vector>
namespace TitleSequenceManager
@ -172,7 +172,7 @@ namespace TitleSequenceManager
static size_t GetPredefinedIndex(const std::string& path)
{
const utf8* filename = Path::GetFileName(path.c_str());
for (size_t i = 0; i < Util::CountOf(PredefinedSequences); i++)
for (size_t i = 0; i < std::size(PredefinedSequences); i++)
{
if (String::Equals(filename, PredefinedSequences[i].Filename, true))
{

View File

@ -12,7 +12,6 @@
#include "../Game.h"
#include "../Input.h"
#include "../audio/audio.h"
#include "../core/Util.hpp"
#include "../interface/Viewport.h"
#include "../network/network.h"
#include "../paint/VirtualFloor.h"
@ -24,6 +23,7 @@
#include "../world/Sprite.h"
#include "Intent.h"
#include <iterator>
#include <tuple>
bool gDisableErrorWindowSound = false;
@ -251,7 +251,7 @@ static std::tuple<bool, uint8_t> window_ride_construction_update_state_get_track
if (curve <= 8)
{
for (uint32_t i = 0; i < Util::CountOf(gTrackDescriptors); i++)
for (uint32_t i = 0; i < std::size(gTrackDescriptors); i++)
{
const track_descriptor* trackDescriptor = &gTrackDescriptors[i];

View File

@ -13,7 +13,6 @@
#include "../Game.h"
#include "../core/Memory.hpp"
#include "../core/String.hpp"
#include "../core/Util.hpp"
#include "../interface/Window.h"
#include "../localisation/Localisation.h"
#include "../management/Finance.h"
@ -28,6 +27,7 @@
#include <algorithm>
#include <cstring>
#include <iterator>
#include <limits>
rct_banner gBanners[MAX_BANNERS];
@ -421,7 +421,7 @@ uint8_t banner_get_closest_ride_index(int32_t x, int32_t y, int32_t z)
{ 0, -32 }, { -32, +32 }, { +32, -32 },
{ +32, +32 }, { -32, +32 }, { 0, 0 } };
for (size_t i = 0; i < (int32_t)Util::CountOf(NeighbourCheckOrder); i++)
for (size_t i = 0; i < (int32_t)std::size(NeighbourCheckOrder); i++)
{
uint8_t rideIndex = banner_get_ride_index_at(x + NeighbourCheckOrder[i].x, y + NeighbourCheckOrder[i].y, z);
if (rideIndex != RIDE_ID_NULL)
@ -468,7 +468,7 @@ void banner_reset_broken_index()
void fix_duplicated_banners()
{
// For each banner in the map, check if the banner index is in use already, and if so, create a new entry for it
bool activeBanners[Util::CountOf(gBanners)]{};
bool activeBanners[std::size(gBanners)]{};
TileElement* tileElement;
for (int y = 0; y < MAXIMUM_MAP_SIZE_TECHNICAL; y++)
{

View File

@ -16,7 +16,6 @@
#include "../audio/AudioMixer.h"
#include "../audio/audio.h"
#include "../config/Config.h"
#include "../core/Util.hpp"
#include "../drawing/Drawing.h"
#include "../interface/Window.h"
#include "../localisation/Date.h"
@ -26,6 +25,7 @@
#include "../windows/Intent.h"
#include <algorithm>
#include <iterator>
constexpr int32_t MAX_THUNDER_INSTANCES = 2;
@ -221,7 +221,7 @@ FILTER_PALETTE_ID climate_get_weather_gloom_palette_id(const ClimateState& state
{
auto paletteId = PALETTE_NULL;
auto gloom = state.WeatherGloom;
if (gloom < Util::CountOf(ClimateWeatherGloomColours))
if (gloom < std::size(ClimateWeatherGloomColours))
{
paletteId = ClimateWeatherGloomColours[gloom];
}
@ -231,7 +231,7 @@ FILTER_PALETTE_ID climate_get_weather_gloom_palette_id(const ClimateState& state
uint32_t climate_get_weather_sprite_id(const ClimateState& state)
{
uint32_t spriteId = SPR_WEATHER_SUN;
if (state.Weather < Util::CountOf(ClimateWeatherData))
if (state.Weather < std::size(ClimateWeatherData))
{
spriteId = ClimateWeatherData[state.Weather].SpriteId;
}

View File

@ -9,7 +9,6 @@
#include "../Game.h"
#include "../audio/audio.h"
#include "../core/Util.hpp"
#include "../localisation/Date.h"
#include "../scenario/Scenario.h"
#include "../sprites.h"
@ -17,6 +16,7 @@
#include "Sprite.h"
#include <algorithm>
#include <iterator>
#include <limits>
// clang-format off
@ -110,7 +110,7 @@ void rct_duck::UpdateFlyToWater()
return;
frame++;
if (frame >= Util::CountOf(DuckAnimationFlyToWater))
if (frame >= std::size(DuckAnimationFlyToWater))
{
frame = 0;
}
@ -272,7 +272,7 @@ void rct_duck::UpdateFlyAway()
if ((gCurrentTicks & 3) == 0)
{
frame++;
if (frame >= Util::CountOf(DuckAnimationFlyAway))
if (frame >= std::size(DuckAnimationFlyAway))
{
frame = 0;
}

View File

@ -13,7 +13,6 @@
#include "../OpenRCT2.h"
#include "../actions/FootpathRemoveAction.hpp"
#include "../core/Guard.hpp"
#include "../core/Util.hpp"
#include "../localisation/Localisation.h"
#include "../management/Finance.h"
#include "../network/network.h"
@ -31,6 +30,7 @@
#include "Surface.h"
#include <algorithm>
#include <iterator>
void footpath_update_queue_entrance_banner(int32_t x, int32_t y, TileElement* tileElement);
@ -1206,7 +1206,7 @@ static void neighbour_list_init(rct_neighbour_list* neighbourList)
static void neighbour_list_push(
rct_neighbour_list* neighbourList, int32_t order, int32_t direction, uint8_t rideIndex, uint8_t entrance_index)
{
Guard::Assert(neighbourList->count < Util::CountOf(neighbourList->items));
Guard::Assert(neighbourList->count < std::size(neighbourList->items));
neighbourList->items[neighbourList->count].order = order;
neighbourList->items[neighbourList->count].direction = direction;
neighbourList->items[neighbourList->count].ride_index = rideIndex;
@ -1744,7 +1744,7 @@ void footpath_queue_chain_push(uint8_t rideIndex)
{
if (rideIndex != 255)
{
uint8_t* lastSlot = _footpathQueueChain + Util::CountOf(_footpathQueueChain) - 1;
uint8_t* lastSlot = _footpathQueueChain + std::size(_footpathQueueChain) - 1;
if (_footpathQueueChainNext <= lastSlot)
{
*_footpathQueueChainNext++ = rideIndex;

View File

@ -19,7 +19,6 @@
#include "../audio/audio.h"
#include "../config/Config.h"
#include "../core/Guard.hpp"
#include "../core/Util.hpp"
#include "../interface/Cursors.h"
#include "../interface/Window.h"
#include "../localisation/Date.h"
@ -46,6 +45,7 @@
#include "Wall.h"
#include <algorithm>
#include <iterator>
/**
* Replaces 0x00993CCC, 0x00993CCE
@ -1309,7 +1309,7 @@ static money32 map_change_surface_style(
// Prevent network-originated value of surfaceStyle from causing
// invalid access.
uint8_t style = surfaceStyle & 0x1F;
if (style >= Util::CountOf(TerrainPricing))
if (style >= std::size(TerrainPricing))
{
return MONEY32_UNDEFINED;
}
@ -4361,7 +4361,7 @@ void game_command_set_sign_style(
int32_t* ebp)
{
BannerIndex bannerId = *ecx & 0xFF;
if (bannerId > Util::CountOf(gBanners))
if (bannerId > std::size(gBanners))
{
log_warning("Invalid game command for setting sign style, banner id = %d", bannerId);
*ebx = MONEY32_UNDEFINED;

View File

@ -15,7 +15,6 @@
#include "../core/Guard.hpp"
#include "../core/Imaging.h"
#include "../core/String.hpp"
#include "../core/Util.hpp"
#include "../localisation/StringIds.h"
#include "../object/Object.h"
#include "../platform/platform.h"
@ -29,6 +28,7 @@
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iterator>
#include <vector>
#pragma region Height map struct
@ -144,7 +144,7 @@ void mapgen_generate(mapgen_settings* settings)
waterLevel = settings->water_level;
if (floorTexture == -1)
floorTexture = BaseTerrain[util_rand() % Util::CountOf(BaseTerrain)];
floorTexture = BaseTerrain[util_rand() % std::size(BaseTerrain)];
if (wallTexture == -1)
{
@ -258,9 +258,9 @@ static void mapgen_place_tree(int32_t type, int32_t x, int32_t y)
*/
static void mapgen_place_trees()
{
std::vector<int32_t> grassTreeIds(Util::CountOf(GrassTrees), 0);
std::vector<int32_t> desertTreeIds(Util::CountOf(DesertTrees), 0);
std::vector<int32_t> snowTreeIds(Util::CountOf(SnowTrees), 0);
std::vector<int32_t> grassTreeIds(std::size(GrassTrees), 0);
std::vector<int32_t> desertTreeIds(std::size(DesertTrees), 0);
std::vector<int32_t> snowTreeIds(std::size(SnowTrees), 0);
for (int32_t i = 0; i < object_entry_group_counts[OBJECT_TYPE_SMALL_SCENERY]; i++)
{
@ -271,34 +271,34 @@ static void mapgen_place_trees()
continue;
uint32_t j;
for (j = 0; j < Util::CountOf(GrassTrees); j++)
for (j = 0; j < std::size(GrassTrees); j++)
{
if (strncmp(GrassTrees[j], entry->name, 8) == 0)
break;
}
if (j != Util::CountOf(GrassTrees))
if (j != std::size(GrassTrees))
{
grassTreeIds.push_back(i);
continue;
}
for (j = 0; j < Util::CountOf(DesertTrees); j++)
for (j = 0; j < std::size(DesertTrees); j++)
{
if (strncmp(DesertTrees[j], entry->name, 8) == 0)
break;
}
if (j != Util::CountOf(DesertTrees))
if (j != std::size(DesertTrees))
{
desertTreeIds.push_back(i);
continue;
}
for (j = 0; j < Util::CountOf(SnowTrees); j++)
for (j = 0; j < std::size(SnowTrees); j++)
{
if (strncmp(SnowTrees[j], entry->name, 8) == 0)
break;
}
if (j != Util::CountOf(SnowTrees))
if (j != std::size(SnowTrees))
{
snowTreeIds.push_back(i);
continue;

View File

@ -17,7 +17,6 @@
#include "../OpenRCT2.h"
#include "../config/Config.h"
#include "../core/Memory.hpp"
#include "../core/Util.hpp"
#include "../interface/Colour.h"
#include "../interface/Window.h"
#include "../localisation/Localisation.h"

View File

@ -8,11 +8,12 @@
*****************************************************************************/
#include "../audio/audio.h"
#include "../core/Util.hpp"
#include "../paint/sprite/Paint.Sprite.h"
#include "../scenario/Scenario.h"
#include "Sprite.h"
#include <iterator>
/**
*
* rct2: 0x006735A1
@ -33,7 +34,7 @@ void crashed_vehicle_particle_create(rct_vehicle_colour colours, int32_t x, int3
sprite->frame = (scenario_rand() & 0xFF) * 12;
sprite->time_to_live = (scenario_rand() & 0x7F) + 140;
sprite->crashed_sprite_base = scenario_rand_max((uint32_t)Util::CountOf(vehicle_particle_base_sprites));
sprite->crashed_sprite_base = scenario_rand_max((uint32_t)std::size(vehicle_particle_base_sprites));
sprite->acceleration_x = ((int16_t)(scenario_rand() & 0xFFFF)) * 4;
sprite->acceleration_y = ((int16_t)(scenario_rand() & 0xFFFF)) * 4;
sprite->acceleration_z = (scenario_rand() & 0xFFFF) * 4 + 0x10000;

View File

@ -15,7 +15,6 @@
#include "../audio/audio.h"
#include "../core/Crypt.h"
#include "../core/Guard.hpp"
#include "../core/Util.hpp"
#include "../interface/Viewport.h"
#include "../localisation/Date.h"
#include "../localisation/Localisation.h"
@ -24,6 +23,7 @@
#include <algorithm>
#include <cmath>
#include <iterator>
uint16_t gSpriteListHead[6];
uint16_t gSpriteListCount[6];
@ -174,7 +174,7 @@ void reset_sprite_list()
*/
void reset_sprite_spatial_index()
{
std::fill_n(gSpriteSpatialIndex, Util::CountOf(gSpriteSpatialIndex), SPRITE_INDEX_NULL);
std::fill_n(gSpriteSpatialIndex, std::size(gSpriteSpatialIndex), SPRITE_INDEX_NULL);
for (size_t i = 0; i < MAX_SPRITES; i++)
{
rct_sprite* spr = get_sprite(i);

View File

@ -12,7 +12,7 @@
#include "FunctionCall.hpp"
#include "String.hpp"
#include <openrct2/core/Util.hpp>
#include <iterator>
#include <openrct2/sprites.h>
namespace Printer
@ -53,7 +53,7 @@ namespace Printer
std::string PrintFunctionCall(function_call call, uint16_t baseHeight)
{
std::string imageId = GetImageIdString(call.supports.colour_flags);
assert(call.function < Util::CountOf(functionNames));
assert(call.function < std::size(functionNames));
const char* functionName = functionNames[call.function];
std::string out = "";

View File

@ -11,7 +11,6 @@
#include "openrct2/config/ConfigEnum.hpp"
#include "openrct2/core/MemoryStream.h"
#include "openrct2/core/Util.hpp"
#include <gtest/gtest.h>
#include <limits>