From 0762fcb6016433f76c5255f3eb65d1627badd439 Mon Sep 17 00:00:00 2001 From: Hielke Morsink Date: Wed, 18 Jan 2023 22:42:16 +0100 Subject: [PATCH] Rename snake_case functions in OpenRCT2/util folder --- src/openrct2-ui/interface/Widget.cpp | 4 +- src/openrct2-ui/scripting/CustomListView.cpp | 2 +- src/openrct2-ui/windows/Cheats.cpp | 4 +- src/openrct2-ui/windows/CustomCurrency.cpp | 2 +- .../windows/EditorObjectSelection.cpp | 6 +- src/openrct2-ui/windows/Guest.cpp | 6 +- src/openrct2-ui/windows/GuestList.cpp | 6 +- src/openrct2-ui/windows/LoadSave.cpp | 18 ++-- src/openrct2-ui/windows/MapGen.cpp | 4 +- src/openrct2-ui/windows/NewCampaign.cpp | 2 +- src/openrct2-ui/windows/Park.cpp | 2 +- src/openrct2-ui/windows/RideConstruction.cpp | 6 +- src/openrct2-ui/windows/RideList.cpp | 2 +- src/openrct2-ui/windows/ScenarioSelect.cpp | 6 +- src/openrct2-ui/windows/ServerList.cpp | 4 +- src/openrct2-ui/windows/ServerStart.cpp | 16 ++-- src/openrct2-ui/windows/Staff.cpp | 4 +- src/openrct2-ui/windows/StaffList.cpp | 2 +- src/openrct2-ui/windows/TextInput.cpp | 4 +- src/openrct2-ui/windows/TopToolbar.cpp | 12 +-- src/openrct2/FileClassifier.cpp | 6 +- src/openrct2/Game.cpp | 2 +- src/openrct2/actions/CheatSetAction.cpp | 2 +- src/openrct2/actions/LandSetRightsAction.cpp | 2 +- .../actions/SmallSceneryPlaceAction.cpp | 4 +- src/openrct2/actions/TrackPlaceAction.cpp | 12 +-- src/openrct2/audio/Audio.cpp | 2 +- src/openrct2/core/String.cpp | 4 +- src/openrct2/drawing/Drawing.String.cpp | 8 +- src/openrct2/drawing/Drawing.cpp | 10 +-- src/openrct2/drawing/LightFX.cpp | 12 +-- src/openrct2/entity/Guest.cpp | 14 +-- src/openrct2/entity/Peep.cpp | 2 +- src/openrct2/entity/Staff.cpp | 4 +- src/openrct2/interface/Chat.cpp | 2 +- src/openrct2/interface/InteractiveConsole.cpp | 6 +- src/openrct2/interface/Viewport.cpp | 8 +- src/openrct2/localisation/Currency.cpp | 2 +- src/openrct2/localisation/Formatting.cpp | 6 +- .../localisation/Localisation.Date.cpp | 2 +- src/openrct2/management/Finance.cpp | 2 +- src/openrct2/network/NetworkBase.cpp | 2 +- src/openrct2/object/ObjectRepository.cpp | 2 +- src/openrct2/object/RideObject.cpp | 4 +- src/openrct2/paint/Paint.cpp | 10 +-- src/openrct2/paint/Supports.cpp | 12 +-- .../paint/tile_element/Paint.LargeScenery.cpp | 2 +- .../paint/tile_element/Paint.SmallScenery.cpp | 2 +- src/openrct2/peep/GuestPathfinding.cpp | 20 ++--- src/openrct2/platform/Crash.cpp | 2 +- src/openrct2/platform/Platform.Posix.cpp | 2 +- src/openrct2/platform/Shared.cpp | 2 +- src/openrct2/rct1/S4Importer.cpp | 8 +- src/openrct2/rct12/SawyerChunkWriter.cpp | 2 +- src/openrct2/ride/CableLift.cpp | 2 +- src/openrct2/ride/Ride.cpp | 14 +-- src/openrct2/ride/TrackDesign.cpp | 2 +- src/openrct2/ride/TrackDesignRepository.cpp | 2 +- src/openrct2/ride/Vehicle.cpp | 6 +- src/openrct2/ride/thrill/Enterprise.cpp | 2 +- src/openrct2/scenario/Scenario.cpp | 2 +- src/openrct2/title/TitleScreen.cpp | 2 +- src/openrct2/title/TitleSequence.cpp | 4 +- src/openrct2/util/Math.hpp | 14 +-- src/openrct2/util/SawyerCoding.cpp | 62 ++++++------- src/openrct2/util/SawyerCoding.h | 20 ++--- src/openrct2/util/Util.cpp | 86 +++++++++---------- src/openrct2/util/Util.h | 54 ++++++------ src/openrct2/world/Climate.cpp | 6 +- src/openrct2/world/Footpath.cpp | 8 +- src/openrct2/world/Location.hpp | 6 +- src/openrct2/world/MapGen.cpp | 24 +++--- src/openrct2/world/Park.cpp | 2 +- test/tests/SawyerCodingTest.cpp | 4 +- test/tests/StringTest.cpp | 30 +++---- 75 files changed, 323 insertions(+), 323 deletions(-) diff --git a/src/openrct2-ui/interface/Widget.cpp b/src/openrct2-ui/interface/Widget.cpp index 2c7c35891b..70eb2e54d1 100644 --- a/src/openrct2-ui/interface/Widget.cpp +++ b/src/openrct2-ui/interface/Widget.cpp @@ -1149,14 +1149,14 @@ static void WidgetTextBoxDraw(rct_drawpixelinfo* dpi, rct_window& w, WidgetIndex { if (widget.text != 0) { - safe_strcpy(wrapped_string, widget.string, 512); + SafeStrCpy(wrapped_string, widget.string, 512); GfxWrapString(wrapped_string, bottomRight.x - topLeft.x - 5, FontStyle::Medium, &no_lines); GfxDrawStringNoFormatting(dpi, { topLeft.x + 2, topLeft.y }, wrapped_string, { w.colours[1], FontStyle::Medium }); } return; } - safe_strcpy(wrapped_string, gTextBoxInput, TEXT_INPUT_SIZE); + SafeStrCpy(wrapped_string, gTextBoxInput, TEXT_INPUT_SIZE); // String length needs to add 12 either side of box // +13 for cursor when max length. diff --git a/src/openrct2-ui/scripting/CustomListView.cpp b/src/openrct2-ui/scripting/CustomListView.cpp index 4ddc0af7af..7273c0ee1f 100644 --- a/src/openrct2-ui/scripting/CustomListView.cpp +++ b/src/openrct2-ui/scripting/CustomListView.cpp @@ -293,7 +293,7 @@ bool CustomListView::SortItem(size_t indexA, size_t indexB, int32_t column) { const auto& cellA = Items[indexA].Cells[column]; const auto& cellB = Items[indexB].Cells[column]; - return strlogicalcmp(cellA.c_str(), cellB.c_str()) < 0; + return StrLogicalCmp(cellA.c_str(), cellB.c_str()) < 0; } void CustomListView::SortItems(int32_t column) diff --git a/src/openrct2-ui/windows/Cheats.cpp b/src/openrct2-ui/windows/Cheats.cpp index e167122349..12caf8f041 100644 --- a/src/openrct2-ui/windows/Cheats.cpp +++ b/src/openrct2-ui/windows/Cheats.cpp @@ -699,12 +699,12 @@ private: switch (widgetIndex) { case WIDX_MONEY_SPINNER_INCREMENT: - _moneySpinnerValue = add_clamp_money32( + _moneySpinnerValue = AddClamp_money32( CHEATS_MONEY_INCREMENT_DIV * (_moneySpinnerValue / CHEATS_MONEY_INCREMENT_DIV), CHEATS_MONEY_INCREMENT_DIV); InvalidateWidget(WIDX_MONEY_SPINNER); break; case WIDX_MONEY_SPINNER_DECREMENT: - _moneySpinnerValue = add_clamp_money32( + _moneySpinnerValue = AddClamp_money32( CHEATS_MONEY_INCREMENT_DIV * (_moneySpinnerValue / CHEATS_MONEY_INCREMENT_DIV), -CHEATS_MONEY_INCREMENT_DIV); InvalidateWidget(WIDX_MONEY_SPINNER); diff --git a/src/openrct2-ui/windows/CustomCurrency.cpp b/src/openrct2-ui/windows/CustomCurrency.cpp index 078c67c0b9..888cabc9d4 100644 --- a/src/openrct2-ui/windows/CustomCurrency.cpp +++ b/src/openrct2-ui/windows/CustomCurrency.cpp @@ -160,7 +160,7 @@ public: switch (widgetIndex) { case WIDX_SYMBOL_TEXT: - safe_strcpy( + SafeStrCpy( CurrencyDescriptors[EnumValue(CurrencyType::Custom)].symbol_unicode, std::string(text).c_str(), CURRENCY_SYMBOL_MAX_SIZE); diff --git a/src/openrct2-ui/windows/EditorObjectSelection.cpp b/src/openrct2-ui/windows/EditorObjectSelection.cpp index 42ab0194b0..fb7746f9c9 100644 --- a/src/openrct2-ui/windows/EditorObjectSelection.cpp +++ b/src/openrct2-ui/windows/EditorObjectSelection.cpp @@ -750,7 +750,7 @@ public: width_limit /= 2; // Draw ride type StringId rideTypeStringId = GetRideTypeStringId(listItem.repositoryItem); - safe_strcpy(buffer, LanguageGetString(rideTypeStringId), 256 - (buffer - bufferWithColour)); + SafeStrCpy(buffer, LanguageGetString(rideTypeStringId), 256 - (buffer - bufferWithColour)); auto ft = Formatter(); ft.Add(gCommonStringFormatBuffer); DrawTextEllipsised( @@ -759,7 +759,7 @@ public: } // Draw text - safe_strcpy(buffer, listItem.repositoryItem->Name.c_str(), 256 - (buffer - bufferWithColour)); + SafeStrCpy(buffer, listItem.repositoryItem->Name.c_str(), 256 - (buffer - bufferWithColour)); if (gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER) { while (*buffer != 0 && *buffer != 9) @@ -801,7 +801,7 @@ public: if (strcmp(_filter_string, c) == 0) return; - safe_strcpy(_filter_string, c, sizeof(_filter_string)); + SafeStrCpy(_filter_string, c, sizeof(_filter_string)); FilterUpdateCounts(); diff --git a/src/openrct2-ui/windows/Guest.cpp b/src/openrct2-ui/windows/Guest.cpp index 50fda4bd84..77c4efb932 100644 --- a/src/openrct2-ui/windows/Guest.cpp +++ b/src/openrct2-ui/windows/Guest.cpp @@ -881,7 +881,7 @@ private: { if (!(_beingWatchedTimer & 0x3FF)) { - int32_t random = util_rand() & 0xFFFF; + int32_t random = UtilRand() & 0xFFFF; if (random <= 0x2AAA) { peep->InsertNewThought(PeepThoughtType::Watched); @@ -1855,14 +1855,14 @@ private: if (peep->GetNextIsSurface()) { OpenRCT2::FormatStringLegacy(buffer2, sizeof(buffer2), STR_PEEP_DEBUG_NEXT_SURFACE, nullptr); - safe_strcat(buffer, buffer2, sizeof(buffer)); + SafeStrCat(buffer, buffer2, sizeof(buffer)); } if (peep->GetNextIsSloped()) { auto ft2 = Formatter(); ft2.Add(peep->GetNextDirection()); OpenRCT2::FormatStringLegacy(buffer2, sizeof(buffer2), STR_PEEP_DEBUG_NEXT_SLOPE, ft2.Data()); - safe_strcat(buffer, buffer2, sizeof(buffer)); + SafeStrCat(buffer, buffer2, sizeof(buffer)); } GfxDrawString(&dpi, screenCoords, buffer, {}); } diff --git a/src/openrct2-ui/windows/GuestList.cpp b/src/openrct2-ui/windows/GuestList.cpp index 7b40a48065..5d93f2cae4 100644 --- a/src/openrct2-ui/windows/GuestList.cpp +++ b/src/openrct2-ui/windows/GuestList.cpp @@ -808,7 +808,7 @@ private: bool IsRefreshOfGroupsRequired() { - uint32_t tick256 = floor2(gCurrentTicks, 256); + uint32_t tick256 = Floor2(gCurrentTicks, 256); if (_selectedView == _lastFindGroupsSelectedView) { if (_lastFindGroupsWait != 0 || _lastFindGroupsTick == tick256) @@ -835,7 +835,7 @@ private: void RefreshGroups() { - _lastFindGroupsTick = floor2(gCurrentTicks, 256); + _lastFindGroupsTick = Floor2(gCurrentTicks, 256); _lastFindGroupsSelectedView = _selectedView; _lastFindGroupsWait = 320; _groups.clear(); @@ -946,7 +946,7 @@ private: } } } - return strlogicalcmp(a.Name, b.Name) < 0; + return StrLogicalCmp(a.Name, b.Name) < 0; } static GuestItem::CompareFunc GetGuestCompareFunc() diff --git a/src/openrct2-ui/windows/LoadSave.cpp b/src/openrct2-ui/windows/LoadSave.cpp index a313b3a50b..0046b62cf1 100644 --- a/src/openrct2-ui/windows/LoadSave.cpp +++ b/src/openrct2-ui/windows/LoadSave.cpp @@ -120,15 +120,15 @@ static bool ListItemSort(LoadSaveListItem& a, LoadSaveListItem& b) switch (gConfigGeneral.LoadSaveSort) { case Sort::NameAscending: - return strlogicalcmp(a.name.c_str(), b.name.c_str()) < 0; + return StrLogicalCmp(a.name.c_str(), b.name.c_str()) < 0; case Sort::NameDescending: - return -strlogicalcmp(a.name.c_str(), b.name.c_str()) < 0; + return -StrLogicalCmp(a.name.c_str(), b.name.c_str()) < 0; case Sort::DateDescending: return -difftime(a.date_modified, b.date_modified) < 0; case Sort::DateAscending: return difftime(a.date_modified, b.date_modified) < 0; } - return strlogicalcmp(a.name.c_str(), b.name.c_str()) < 0; + return StrLogicalCmp(a.name.c_str(), b.name.c_str()) < 0; } static void SetAndSaveConfigPath(u8string& config_str, u8string_view path) @@ -263,7 +263,7 @@ static void Select(const char* path) } char pathBuffer[MAX_PATH]; - safe_strcpy(pathBuffer, path, sizeof(pathBuffer)); + SafeStrCpy(pathBuffer, path, sizeof(pathBuffer)); switch (_type & 0x0F) { @@ -529,7 +529,7 @@ public: void PopulateList(int32_t includeNewItem, const u8string& directory, std::string_view extensionPattern) { const auto absoluteDirectory = Path::GetAbsolute(directory); - safe_strcpy(_directory, absoluteDirectory.c_str(), std::size(_directory)); + SafeStrCpy(_directory, absoluteDirectory.c_str(), std::size(_directory)); // Note: This compares the pointers, not values _extensionPattern = extensionPattern; _shortenedDirectory[0] = '\0'; @@ -563,7 +563,7 @@ public: else { // Remove the separator at the end of the path, if present - safe_strcpy(_parentDirectory, absoluteDirectory.c_str(), std::size(_parentDirectory)); + SafeStrCpy(_parentDirectory, absoluteDirectory.c_str(), std::size(_parentDirectory)); if (_parentDirectory[strlen(_parentDirectory) - 1] == *PATH_SEPARATOR || _parentDirectory[strlen(_parentDirectory) - 1] == '/') _parentDirectory[strlen(_parentDirectory) - 1] = '\0'; @@ -955,7 +955,7 @@ public: includeNewItem = (_type & 1) == LOADSAVETYPE_SAVE; char directory[MAX_PATH]; - safe_strcpy(directory, _listItems[selectedItem].path.c_str(), sizeof(directory)); + SafeStrCpy(directory, _listItems[selectedItem].path.c_str(), sizeof(directory)); PopulateList(includeNewItem, directory, _extensionPattern); InitScrollWidgets(); @@ -1143,8 +1143,8 @@ static rct_window* WindowOverwritePromptOpen(const char* name, const char* path) w->flags |= WF_TRANSPARENT; w->colours[0] = TRANSLUCENT(COLOUR_BORDEAUX_RED); - safe_strcpy(_window_overwrite_prompt_name, name, sizeof(_window_overwrite_prompt_name)); - safe_strcpy(_window_overwrite_prompt_path, path, sizeof(_window_overwrite_prompt_path)); + SafeStrCpy(_window_overwrite_prompt_name, name, sizeof(_window_overwrite_prompt_name)); + SafeStrCpy(_window_overwrite_prompt_path, path, sizeof(_window_overwrite_prompt_path)); return w; } diff --git a/src/openrct2-ui/windows/MapGen.cpp b/src/openrct2-ui/windows/MapGen.cpp index f1e2797b70..8605b791e4 100644 --- a/src/openrct2-ui/windows/MapGen.cpp +++ b/src/openrct2-ui/windows/MapGen.cpp @@ -783,8 +783,8 @@ static void WindowMapgenRandomMouseup(rct_window* w, WidgetIndex widgetIndex) mapgenSettings.wall = _randomTerrain ? -1 : _wallTexture; mapgenSettings.trees = _placeTrees; - mapgenSettings.simplex_low = util_rand() % 4; - mapgenSettings.simplex_high = 12 + (util_rand() % (32 - 12)); + mapgenSettings.simplex_low = UtilRand() % 4; + mapgenSettings.simplex_high = 12 + (UtilRand() % (32 - 12)); mapgenSettings.simplex_base_freq = 1.75f; mapgenSettings.simplex_octaves = 6; diff --git a/src/openrct2-ui/windows/NewCampaign.cpp b/src/openrct2-ui/windows/NewCampaign.cpp index 7a402b61a1..39ec89cafc 100644 --- a/src/openrct2-ui/windows/NewCampaign.cpp +++ b/src/openrct2-ui/windows/NewCampaign.cpp @@ -89,7 +89,7 @@ private: if (rideB != nullptr) rideBName = rideB->GetName(); - return strlogicalcmp(rideAName.c_str(), rideBName.c_str()) < 0; + return StrLogicalCmp(rideAName.c_str(), rideBName.c_str()) < 0; } /** diff --git a/src/openrct2-ui/windows/Park.cpp b/src/openrct2-ui/windows/Park.cpp index 6049cad502..da8416164f 100644 --- a/src/openrct2-ui/windows/Park.cpp +++ b/src/openrct2-ui/windows/Park.cpp @@ -966,7 +966,7 @@ private: if (gConfigGeneral.MeasurementFormat == MeasurementFormat::Imperial) { stringIndex = STR_PARK_SIZE_IMPERIAL_LABEL; - parkSize = squaredmetres_to_squaredfeet(parkSize); + parkSize = SquaredMetresToSquaredFeet(parkSize); } auto ft = Formatter(); ft.Add(parkSize); diff --git a/src/openrct2-ui/windows/RideConstruction.cpp b/src/openrct2-ui/windows/RideConstruction.cpp index dc32e5f1b4..bd8c74b604 100644 --- a/src/openrct2-ui/windows/RideConstruction.cpp +++ b/src/openrct2-ui/windows/RideConstruction.cpp @@ -2966,7 +2966,7 @@ static std::optional RideGetPlacePositionFromScreenPosition(ScreenCoor { _trackPlaceShiftZ = mainWnd->viewport->zoom.ApplyTo(_trackPlaceShiftZ); } - _trackPlaceShiftZ = floor2(_trackPlaceShiftZ, 8); + _trackPlaceShiftZ = Floor2(_trackPlaceShiftZ, 8); // Clamp to maximum possible value of base_height can offer. _trackPlaceShiftZ = std::min(_trackPlaceShiftZ, maxHeight); @@ -2991,7 +2991,7 @@ static std::optional RideGetPlacePositionFromScreenPosition(ScreenCoor auto surfaceElement = MapGetSurfaceElementAt(mapCoords); if (surfaceElement == nullptr) return std::nullopt; - auto mapZ = floor2(surfaceElement->GetBaseZ(), 16); + auto mapZ = Floor2(surfaceElement->GetBaseZ(), 16); mapZ += _trackPlaceShiftZ; mapZ = std::max(mapZ, 16); _trackPlaceZ = mapZ; @@ -4548,7 +4548,7 @@ static void WindowRideConstructionMouseUpDemolishNextPiece(const CoordsXYZD& pie { if (_gotoStartPlacementMode) { - _currentTrackBegin.z = floor2(piecePos.z, COORDS_Z_STEP); + _currentTrackBegin.z = Floor2(piecePos.z, COORDS_Z_STEP); _rideConstructionState = RideConstructionState::Front; _currentTrackSelectionFlags = 0; _currentTrackPieceDirection = piecePos.direction & 3; diff --git a/src/openrct2-ui/windows/RideList.cpp b/src/openrct2-ui/windows/RideList.cpp index 440c143cfb..92cc06fdaa 100644 --- a/src/openrct2-ui/windows/RideList.cpp +++ b/src/openrct2-ui/windows/RideList.cpp @@ -810,7 +810,7 @@ private: case INFORMATION_TYPE_STATUS: currentListPosition = SortList( currentListPosition, rideRef, [](const Ride& thisRide, const Ride& otherRide) -> bool { - return 0 <= strlogicalcmp(thisRide.GetName().c_str(), otherRide.GetName().c_str()); + return 0 <= StrLogicalCmp(thisRide.GetName().c_str(), otherRide.GetName().c_str()); }); break; case INFORMATION_TYPE_POPULARITY: diff --git a/src/openrct2-ui/windows/ScenarioSelect.cpp b/src/openrct2-ui/windows/ScenarioSelect.cpp index f9086c5668..60d35f4970 100644 --- a/src/openrct2-ui/windows/ScenarioSelect.cpp +++ b/src/openrct2-ui/windows/ScenarioSelect.cpp @@ -231,7 +231,7 @@ static void WindowScenarioselectInitTabs(rct_window* w) } else { - int32_t firstPage = bitscanforward(showPages); + int32_t firstPage = UtilBitScanForward(showPages); if (firstPage != -1) { w->selected_tab = firstPage; @@ -602,7 +602,7 @@ static void WindowScenarioselectScrollpaint(rct_window* w, rct_drawpixelinfo* dp // Draw scenario name char buffer[64]; - safe_strcpy(buffer, scenario->name, sizeof(buffer)); + SafeStrCpy(buffer, scenario->name, sizeof(buffer)); StringId format = isDisabled ? static_cast(STR_STRINGID) : (isHighlighted ? highlighted_format : unhighlighted_format); auto ft = Formatter(); @@ -629,7 +629,7 @@ static void WindowScenarioselectScrollpaint(rct_window* w, rct_drawpixelinfo* dp { completedByName = scenario->highscore->name; } - safe_strcpy(buffer, completedByName, 64); + SafeStrCpy(buffer, completedByName, 64); ft = Formatter(); ft.Add(STR_COMPLETED_BY); ft.Add(STR_STRING); diff --git a/src/openrct2-ui/windows/ServerList.cpp b/src/openrct2-ui/windows/ServerList.cpp index 702ef33fd0..e0d5b818b0 100644 --- a/src/openrct2-ui/windows/ServerList.cpp +++ b/src/openrct2-ui/windows/ServerList.cpp @@ -144,7 +144,7 @@ rct_window* WindowServerListOpen() WindowSetResize(*window, WWIDTH_MIN, WHEIGHT_MIN, WWIDTH_MAX, WHEIGHT_MAX); - safe_strcpy(_playerName, gConfigNetwork.PlayerName.c_str(), sizeof(_playerName)); + SafeStrCpy(_playerName, gConfigNetwork.PlayerName.c_str(), sizeof(_playerName)); window->no_list_items = static_cast(_serverList.GetCount()); @@ -317,7 +317,7 @@ static void WindowServerListTextinput(rct_window* w, WidgetIndex widgetIndex, ch std::fill_n(_playerName, sizeof(_playerName), 0x00); if (text[0] != '\0') { - safe_strcpy(_playerName, text, sizeof(_playerName)); + SafeStrCpy(_playerName, text, sizeof(_playerName)); } if (_playerName[0] != '\0') diff --git a/src/openrct2-ui/windows/ServerStart.cpp b/src/openrct2-ui/windows/ServerStart.cpp index 8bafbd0116..5bc95b4a0d 100644 --- a/src/openrct2-ui/windows/ServerStart.cpp +++ b/src/openrct2-ui/windows/ServerStart.cpp @@ -85,9 +85,9 @@ public: list_information_type = 0; snprintf(_port, 7, "%u", gConfigNetwork.DefaultPort); - safe_strcpy(_name, gConfigNetwork.ServerName.c_str(), sizeof(_name)); - safe_strcpy(_description, gConfigNetwork.ServerDescription.c_str(), sizeof(_description)); - safe_strcpy(_greeting, gConfigNetwork.ServerGreeting.c_str(), sizeof(_greeting)); + SafeStrCpy(_name, gConfigNetwork.ServerName.c_str(), sizeof(_name)); + SafeStrCpy(_description, gConfigNetwork.ServerDescription.c_str(), sizeof(_description)); + SafeStrCpy(_greeting, gConfigNetwork.ServerGreeting.c_str(), sizeof(_greeting)); } void OnMouseUp(WidgetIndex widgetIndex) override { @@ -181,7 +181,7 @@ public: std::fill_n(_port, sizeof(_port), 0x00); if (text[0] != '\0') { - safe_strcpy(_port, temp.c_str(), sizeof(_port)); + SafeStrCpy(_port, temp.c_str(), sizeof(_port)); } gConfigNetwork.DefaultPort = atoi(_port); @@ -196,7 +196,7 @@ public: std::fill_n(_name, sizeof(_name), 0x00); if (text[0] != '\0') { - safe_strcpy(_name, temp.c_str(), sizeof(_name)); + SafeStrCpy(_name, temp.c_str(), sizeof(_name)); } if (_name[0] != '\0') @@ -214,7 +214,7 @@ public: std::fill_n(_description, sizeof(_description), 0x00); if (text[0] != '\0') { - safe_strcpy(_description, temp.c_str(), sizeof(_description)); + SafeStrCpy(_description, temp.c_str(), sizeof(_description)); } if (_description[0] != '\0') @@ -232,7 +232,7 @@ public: std::fill_n(_greeting, sizeof(_greeting), 0x00); if (text[0] != '\0') { - safe_strcpy(_greeting, temp.c_str(), sizeof(_greeting)); + SafeStrCpy(_greeting, temp.c_str(), sizeof(_greeting)); } if (_greeting[0] != '\0') @@ -250,7 +250,7 @@ public: std::fill_n(_password, sizeof(_password), 0x00); if (text[0] != '\0') { - safe_strcpy(_password, temp.c_str(), sizeof(_password)); + SafeStrCpy(_password, temp.c_str(), sizeof(_password)); } WidgetInvalidate(*this, WIDX_PASSWORD_INPUT); diff --git a/src/openrct2-ui/windows/Staff.cpp b/src/openrct2-ui/windows/Staff.cpp index 20671616d9..0ebcab88d5 100644 --- a/src/openrct2-ui/windows/Staff.cpp +++ b/src/openrct2-ui/windows/Staff.cpp @@ -577,7 +577,7 @@ private: if (page == WINDOW_STAFF_OVERVIEW) { offset = _tabAnimationOffset; - offset = floor2(offset, 4); + offset = Floor2(offset, 4); } imageIndex += offset; @@ -871,7 +871,7 @@ private: auto staffOrders = staff->StaffOrders; - for (auto index = bitscanforward(staffOrders); index != -1; index = bitscanforward(staffOrders)) + for (auto index = UtilBitScanForward(staffOrders); index != -1; index = UtilBitScanForward(staffOrders)) { staffOrders &= ~(1 << index); SetCheckboxValue(WIDX_CHECKBOX_1 + index, true); diff --git a/src/openrct2-ui/windows/StaffList.cpp b/src/openrct2-ui/windows/StaffList.cpp index baf7ada3b3..468c76e749 100644 --- a/src/openrct2-ui/windows/StaffList.cpp +++ b/src/openrct2-ui/windows/StaffList.cpp @@ -636,7 +636,7 @@ private: int32_t numCostumes = StaffGetAvailableEntertainerCostumeList(costumeList); if (numCostumes > 0) { - int32_t index = util_rand() % numCostumes; + int32_t index = UtilRand() % numCostumes; result = costumeList[index]; } return result; diff --git a/src/openrct2-ui/windows/TextInput.cpp b/src/openrct2-ui/windows/TextInput.cpp index 63521e0d60..53b9b2aae8 100644 --- a/src/openrct2-ui/windows/TextInput.cpp +++ b/src/openrct2-ui/windows/TextInput.cpp @@ -109,7 +109,7 @@ public: void SetText(std::string_view text, size_t maxLength) { _buffer.resize(maxLength); - safe_strcpy(_buffer.data(), std::string(text).c_str(), maxLength); + SafeStrCpy(_buffer.data(), std::string(text).c_str(), maxLength); _maxInputLength = maxLength; gTextInput = ContextStartTextInput(_buffer.data(), maxLength); } @@ -219,7 +219,7 @@ public: screenCoords.y += 25; char wrapped_string[TEXT_INPUT_SIZE]; - safe_strcpy(wrapped_string, _buffer.data(), _buffer.size()); + SafeStrCpy(wrapped_string, _buffer.data(), _buffer.size()); // String length needs to add 12 either side of box // +13 for cursor when max length. diff --git a/src/openrct2-ui/windows/TopToolbar.cpp b/src/openrct2-ui/windows/TopToolbar.cpp index 5195cca66f..72d5e1d605 100644 --- a/src/openrct2-ui/windows/TopToolbar.cpp +++ b/src/openrct2-ui/windows/TopToolbar.cpp @@ -1216,7 +1216,7 @@ static void Sub6E1F34UpdateScreenCoordsAndButtonsPressed(bool canRaiseItem, Scre { gSceneryShiftPressZOffset = mainWnd->viewport->zoom.ApplyTo(gSceneryShiftPressZOffset); } - gSceneryShiftPressZOffset = floor2(gSceneryShiftPressZOffset, 8); + gSceneryShiftPressZOffset = Floor2(gSceneryShiftPressZOffset, 8); screenPos.x = gSceneryShiftPressX; screenPos.y = gSceneryShiftPressY; @@ -1328,7 +1328,7 @@ static void Sub6E1F34SmallScenery( if (!sceneryEntry->HasFlag(SMALL_SCENERY_FLAG_ROTATABLE)) { - rotation = util_rand() & 0xFF; + rotation = UtilRand() & 0xFF; } rotation -= GetCurrentRotation(); @@ -1412,7 +1412,7 @@ static void Sub6E1F34SmallScenery( if (!sceneryEntry->HasFlag(SMALL_SCENERY_FLAG_ROTATABLE)) { - rotation = util_rand() & 0xFF; + rotation = UtilRand() & 0xFF; } rotation -= GetCurrentRotation(); @@ -1767,11 +1767,11 @@ static void WindowTopToolbarSceneryToolDown(const ScreenCoordsXY& windowPos, rct { if (!sceneryEntry->HasFlag(SMALL_SCENERY_FLAG_FULL_TILE)) { - quadrant = util_rand() & 3; + quadrant = UtilRand() & 3; } - int16_t grid_x_offset = (util_rand() % gWindowSceneryScatterSize) - (gWindowSceneryScatterSize / 2); - int16_t grid_y_offset = (util_rand() % gWindowSceneryScatterSize) - (gWindowSceneryScatterSize / 2); + int16_t grid_x_offset = (UtilRand() % gWindowSceneryScatterSize) - (gWindowSceneryScatterSize / 2); + int16_t grid_y_offset = (UtilRand() % gWindowSceneryScatterSize) - (gWindowSceneryScatterSize / 2); if (gWindowSceneryScatterSize % 2 == 0) { grid_x_offset += 1; diff --git a/src/openrct2/FileClassifier.cpp b/src/openrct2/FileClassifier.cpp index 2ae0fc88c4..1b68ee5422 100644 --- a/src/openrct2/FileClassifier.cpp +++ b/src/openrct2/FileClassifier.cpp @@ -131,7 +131,7 @@ static bool TryClassifyAsS4(OpenRCT2::IStream* stream, ClassifiedFileInfo* resul size_t dataLength = static_cast(stream->GetLength()); auto data = stream->ReadArray(dataLength); stream->SetPosition(originalPosition); - int32_t fileTypeVersion = sawyercoding_detect_file_type(data.get(), dataLength); + int32_t fileTypeVersion = SawyerCodingDetectFileType(data.get(), dataLength); int32_t type = fileTypeVersion & FILE_TYPE_MASK; int32_t version = fileTypeVersion & FILE_VERSION_MASK; @@ -169,11 +169,11 @@ static bool TryClassifyAsTD4_TD6(OpenRCT2::IStream* stream, ClassifiedFileInfo* auto data = stream->ReadArray(dataLength); stream->SetPosition(originalPosition); - if (sawyercoding_validate_track_checksum(data.get(), dataLength)) + if (SawyerCodingValidateTrackChecksum(data.get(), dataLength)) { std::unique_ptr)> td6data( Memory::Allocate(0x10000), &Memory::Free); - size_t td6len = sawyercoding_decode_td6(data.get(), td6data.get(), dataLength); + size_t td6len = SawyerCodingDecodeTD6(data.get(), td6data.get(), dataLength); if (td6data != nullptr && td6len >= 8) { uint8_t version = (td6data.get()[7] >> 2) & 3; diff --git a/src/openrct2/Game.cpp b/src/openrct2/Game.cpp index 0278b932bd..daa3db434e 100644 --- a/src/openrct2/Game.cpp +++ b/src/openrct2/Game.cpp @@ -335,7 +335,7 @@ void RCT2StringToUTF8Self(char* buffer, size_t length) if (length > 0) { auto temp = RCT2StringToUTF8(buffer, RCT2LanguageId::EnglishUK); - safe_strcpy(buffer, temp.data(), length); + SafeStrCpy(buffer, temp.data(), length); } } diff --git a/src/openrct2/actions/CheatSetAction.cpp b/src/openrct2/actions/CheatSetAction.cpp index a8d651e779..45fce32180 100644 --- a/src/openrct2/actions/CheatSetAction.cpp +++ b/src/openrct2/actions/CheatSetAction.cpp @@ -532,7 +532,7 @@ void CheatSetAction::SetMoney(money64 amount) const void CheatSetAction::AddMoney(money64 amount) const { - gCash = add_clamp_money64(gCash, amount); + gCash = AddClamp_money64(gCash, amount); WindowInvalidateByClass(WindowClass::Finances); WindowInvalidateByClass(WindowClass::BottomToolbar); diff --git a/src/openrct2/actions/LandSetRightsAction.cpp b/src/openrct2/actions/LandSetRightsAction.cpp index d6e81a7ba7..10e032c45c 100644 --- a/src/openrct2/actions/LandSetRightsAction.cpp +++ b/src/openrct2/actions/LandSetRightsAction.cpp @@ -191,7 +191,7 @@ GameActions::Result LandSetRightsAction::MapBuyLandRightsForTile(const CoordsXY& std::remove_if( gPeepSpawns.begin(), gPeepSpawns.end(), [x = loc.x, y = loc.y](const auto& spawn) { - return floor2(spawn.x, 32) == x && floor2(spawn.y, 32) == y; + return Floor2(spawn.x, 32) == x && Floor2(spawn.y, 32) == y; }), gPeepSpawns.end()); } diff --git a/src/openrct2/actions/SmallSceneryPlaceAction.cpp b/src/openrct2/actions/SmallSceneryPlaceAction.cpp index dbdfc8342f..f1691c5a29 100644 --- a/src/openrct2/actions/SmallSceneryPlaceAction.cpp +++ b/src/openrct2/actions/SmallSceneryPlaceAction.cpp @@ -221,7 +221,7 @@ GameActions::Result SmallSceneryPlaceAction::Query() const } int32_t zLow = targetHeight; - int32_t zHigh = zLow + ceil2(sceneryEntry->height, COORDS_Z_STEP); + int32_t zHigh = zLow + Ceil2(sceneryEntry->height, COORDS_Z_STEP); uint8_t collisionQuadrants = 0b1111; auto quadRotation{ 0 }; if (!(sceneryEntry->HasFlag(SMALL_SCENERY_FLAG_FULL_TILE))) @@ -358,7 +358,7 @@ GameActions::Result SmallSceneryPlaceAction::Execute() const } int32_t zLow = targetHeight; - int32_t zHigh = zLow + ceil2(sceneryEntry->height, 8); + int32_t zHigh = zLow + Ceil2(sceneryEntry->height, 8); uint8_t collisionQuadrants = 0b1111; auto quadRotation{ 0 }; if (!(sceneryEntry->HasFlag(SMALL_SCENERY_FLAG_FULL_TILE))) diff --git a/src/openrct2/actions/TrackPlaceAction.cpp b/src/openrct2/actions/TrackPlaceAction.cpp index 7ad39598e4..5fda1b4064 100644 --- a/src/openrct2/actions/TrackPlaceAction.cpp +++ b/src/openrct2/actions/TrackPlaceAction.cpp @@ -224,7 +224,7 @@ GameActions::Result TrackPlaceAction::Query() const GameActions::Status::InvalidParameters, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_TOO_LOW); } - int32_t baseZ = floor2(mapLoc.z, COORDS_Z_STEP); + int32_t baseZ = Floor2(mapLoc.z, COORDS_Z_STEP); int32_t clearanceZ = trackBlock->var_07; if (trackBlock->flags & RCT_PREVIEW_TRACK_FLAG_IS_VERTICAL @@ -237,7 +237,7 @@ GameActions::Result TrackPlaceAction::Query() const clearanceZ += ride->GetRideTypeDescriptor().Heights.ClearanceHeight; } - clearanceZ = floor2(clearanceZ, COORDS_Z_STEP) + baseZ; + clearanceZ = Floor2(clearanceZ, COORDS_Z_STEP) + baseZ; if (clearanceZ > MAX_TRACK_HEIGHT) { @@ -448,7 +448,7 @@ GameActions::Result TrackPlaceAction::Execute() const auto quarterTile = trackBlock->var_08.Rotate(_origin.direction); - int32_t baseZ = floor2(mapLoc.z, COORDS_Z_STEP); + int32_t baseZ = Floor2(mapLoc.z, COORDS_Z_STEP); int32_t clearanceZ = trackBlock->var_07; if (trackBlock->flags & RCT_PREVIEW_TRACK_FLAG_IS_VERTICAL && ride->GetRideTypeDescriptor().Heights.ClearanceHeight > 24) @@ -460,7 +460,7 @@ GameActions::Result TrackPlaceAction::Execute() const clearanceZ += ride->GetRideTypeDescriptor().Heights.ClearanceHeight; } - clearanceZ = floor2(clearanceZ, COORDS_Z_STEP) + baseZ; + clearanceZ = Floor2(clearanceZ, COORDS_Z_STEP) + baseZ; const auto mapLocWithClearance = CoordsXYRangedZ(mapLoc, baseZ, clearanceZ); uint8_t crossingMode = (ride->GetRideTypeDescriptor().HasFlag(RIDE_TYPE_FLAG_SUPPORTS_LEVEL_CROSSINGS) @@ -654,8 +654,8 @@ GameActions::Result TrackPlaceAction::Execute() const { if (!(GetFlags() & GAME_COMMAND_FLAG_GHOST) && !gCheatsDisableClearanceChecks) { - for (int32_t chosenDirection = bitscanforward(availableDirections); chosenDirection != -1; - chosenDirection = bitscanforward(availableDirections)) + for (int32_t chosenDirection = UtilBitScanForward(availableDirections); chosenDirection != -1; + chosenDirection = UtilBitScanForward(availableDirections)) { availableDirections &= ~(1 << chosenDirection); CoordsXY tempLoc{ mapLoc.x, mapLoc.y }; diff --git a/src/openrct2/audio/Audio.cpp b/src/openrct2/audio/Audio.cpp index f842a12a81..e45d5c51ea 100644 --- a/src/openrct2/audio/Audio.cpp +++ b/src/openrct2/audio/Audio.cpp @@ -282,7 +282,7 @@ namespace OpenRCT2::Audio case TitleMusicKind::Random: return ObjectEntryDescriptor( ObjectType::Audio, - (util_rand() & 1) ? AudioObjectIdentifiers::Rct1Title : AudioObjectIdentifiers::Rct2Title); + (UtilRand() & 1) ? AudioObjectIdentifiers::Rct1Title : AudioObjectIdentifiers::Rct2Title); } } diff --git a/src/openrct2/core/String.cpp b/src/openrct2/core/String.cpp index a1d812f425..8bb306a563 100644 --- a/src/openrct2/core/String.cpp +++ b/src/openrct2/core/String.cpp @@ -307,7 +307,7 @@ namespace String utf8* Set(utf8* buffer, size_t bufferSize, const utf8* src) { - return safe_strcpy(buffer, src, bufferSize); + return SafeStrCpy(buffer, src, bufferSize); } utf8* Set(utf8* buffer, size_t bufferSize, const utf8* src, size_t srcSize) @@ -327,7 +327,7 @@ namespace String utf8* Append(utf8* buffer, size_t bufferSize, const utf8* src) { - return safe_strcat(buffer, src, bufferSize); + return SafeStrCat(buffer, src, bufferSize); } utf8* Format(utf8* buffer, size_t bufferSize, const utf8* format, ...) diff --git a/src/openrct2/drawing/Drawing.String.cpp b/src/openrct2/drawing/Drawing.String.cpp index 4510d3b446..6d4f86afbb 100644 --- a/src/openrct2/drawing/Drawing.String.cpp +++ b/src/openrct2/drawing/Drawing.String.cpp @@ -1078,7 +1078,7 @@ void ShortenPath(utf8* buffer, size_t bufferSize, const utf8* path, int32_t avai // Return full string if it fits if (GfxGetStringWidth(const_cast(path), fontStyle) <= availableWidth) { - safe_strcpy(buffer, path, bufferSize); + SafeStrCpy(buffer, path, bufferSize); return; } @@ -1093,7 +1093,7 @@ void ShortenPath(utf8* buffer, size_t bufferSize, const utf8* path, int32_t avai } // TODO: Replace with unicode ellipsis when supported - safe_strcpy(buffer, "...", bufferSize); + SafeStrCpy(buffer, "...", bufferSize); // Abbreviate beginning with xth separator int32_t begin = -1; @@ -1104,12 +1104,12 @@ void ShortenPath(utf8* buffer, size_t bufferSize, const utf8* path, int32_t avai begin++; } while (path[begin] != *PATH_SEPARATOR && path[begin] != '/'); - safe_strcpy(buffer + 3, path + begin, bufferSize - 3); + SafeStrCpy(buffer + 3, path + begin, bufferSize - 3); if (GfxGetStringWidth(buffer, fontStyle) <= availableWidth) { return; } } - safe_strcpy(buffer, path, bufferSize); + SafeStrCpy(buffer, path, bufferSize); } diff --git a/src/openrct2/drawing/Drawing.cpp b/src/openrct2/drawing/Drawing.cpp index 0774772479..be9946f048 100644 --- a/src/openrct2/drawing/Drawing.cpp +++ b/src/openrct2/drawing/Drawing.cpp @@ -561,12 +561,12 @@ void (*MaskFn)( void MaskInit() { - if (avx2_available()) + if (AVX2Available()) { LOG_VERBOSE("registering AVX2 mask function"); MaskFn = MaskAvx2; } - else if (sse41_available()) + else if (SSE41Available()) { LOG_VERBOSE("registering SSE4.1 mask function"); MaskFn = MaskSse4_1; @@ -814,9 +814,9 @@ void UpdatePalette(const uint8_t* colours, int32_t start_index, int32_t num_colo float night = gDayNightCycle; if (night >= 0 && gClimateLightningFlash == 0) { - r = lerp(r, soft_light(r, 8), night); - g = lerp(g, soft_light(g, 8), night); - b = lerp(b, soft_light(b, 128), night); + r = Lerp(r, SoftLight(r, 8), night); + g = Lerp(g, SoftLight(g, 8), night); + b = Lerp(b, SoftLight(b, 128), night); } } diff --git a/src/openrct2/drawing/LightFX.cpp b/src/openrct2/drawing/LightFX.cpp index ca6152793d..28008fa154 100644 --- a/src/openrct2/drawing/LightFX.cpp +++ b/src/openrct2/drawing/LightFX.cpp @@ -855,9 +855,9 @@ void LightFXApplyPaletteFilter(uint8_t i, uint8_t* r, uint8_t* g, uint8_t* b) float sunLight = std::max(0.0f, std::min(1.0f, 2.0f - night * 3.0f)); // Night version - natLightR = flerp(natLightR * 4.0f, 0.635f, (std::pow(night, 0.035f + sunLight * 10.50f))); - natLightG = flerp(natLightG * 4.0f, 0.650f, (std::pow(night, 0.100f + sunLight * 5.50f))); - natLightB = flerp(natLightB * 4.0f, 0.850f, (std::pow(night, 0.200f + sunLight * 1.5f))); + natLightR = FLerp(natLightR * 4.0f, 0.635f, (std::pow(night, 0.035f + sunLight * 10.50f))); + natLightG = FLerp(natLightG * 4.0f, 0.650f, (std::pow(night, 0.100f + sunLight * 5.50f))); + natLightB = FLerp(natLightB * 4.0f, 0.850f, (std::pow(night, 0.200f + sunLight * 1.5f))); float overExpose = 0.0f; float lightAvg = (natLightR + natLightG + natLightB) / 3.0f; @@ -953,9 +953,9 @@ void LightFXApplyPaletteFilter(uint8_t i, uint8_t* r, uint8_t* g, uint8_t* b) if (night >= 0 && gClimateLightningFlash != 1) { - *r = lerp(*r, soft_light(*r, 8), night); - *g = lerp(*g, soft_light(*g, 8), night); - *b = lerp(*b, soft_light(*b, 128), night); + *r = Lerp(*r, SoftLight(*r, 8), night); + *g = Lerp(*g, SoftLight(*g, 8), night); + *b = Lerp(*b, SoftLight(*b, 128), night); // if (i == 32) // boost = 300000.0f; diff --git a/src/openrct2/entity/Guest.cpp b/src/openrct2/entity/Guest.cpp index 374a8bbf14..0356572325 100644 --- a/src/openrct2/entity/Guest.cpp +++ b/src/openrct2/entity/Guest.cpp @@ -804,7 +804,7 @@ void Guest::Loc68FA89() if (TimeToConsume == 0) { - int32_t chosen_food = bitscanforward(GetFoodOrDrinkFlags()); + int32_t chosen_food = UtilBitScanForward(GetFoodOrDrinkFlags()); if (chosen_food != -1) { ShopItem food = ShopItem(chosen_food); @@ -1485,7 +1485,7 @@ bool Guest::DecideAndBuyItem(Ride& ride, ShopItem shopItem, money32 price) if (GetShopItemDescriptor(shopItem).IsFoodOrDrink()) { - int32_t food = bitscanforward(GetFoodOrDrinkFlags()); + int32_t food = UtilBitScanForward(GetFoodOrDrinkFlags()); if (food != -1) { InsertNewThought(PeepThoughtType::HaventFinished, static_cast(food)); @@ -1874,8 +1874,8 @@ OpenRCT2::BitSet Guest::FindRidesToGoOn() { // Take nearby rides into consideration constexpr auto radius = 10 * 32; - int32_t cx = floor2(x, 32); - int32_t cy = floor2(y, 32); + int32_t cx = Floor2(x, 32); + int32_t cy = Floor2(y, 32); for (int32_t tileX = cx - radius; tileX <= cx + radius; tileX += COORDS_XY_STEP) { for (int32_t tileY = cy - radius; tileY <= cy + radius; tileY += COORDS_XY_STEP) @@ -3151,8 +3151,8 @@ template static void PeepHeadForNearestRide(Guest* peep, bool consid { // Take nearby rides into consideration constexpr auto searchRadius = 10 * 32; - int32_t cx = floor2(peep->x, 32); - int32_t cy = floor2(peep->y, 32); + int32_t cx = Floor2(peep->x, 32); + int32_t cy = Floor2(peep->y, 32); for (auto x = cx - searchRadius; x <= cx + searchRadius; x += COORDS_XY_STEP) { for (auto y = cy - searchRadius; y <= cy + searchRadius; y += COORDS_XY_STEP) @@ -5273,7 +5273,7 @@ void Guest::UpdateWalking() if ((!GetNextIsSurface()) && (static_cast(sprite_index.ToUnderlying() & 0x1FF) == (gCurrentTicks & 0x1FF)) && ((0xFFFF & ScenarioRand()) <= 4096)) { - int32_t container = bitscanforward(GetEmptyContainerFlags()); + int32_t container = UtilBitScanForward(GetEmptyContainerFlags()); auto litterType = Litter::Type::Vomit; if (container != -1) diff --git a/src/openrct2/entity/Peep.cpp b/src/openrct2/entity/Peep.cpp index 6b3ba6a798..fc6a7a7377 100644 --- a/src/openrct2/entity/Peep.cpp +++ b/src/openrct2/entity/Peep.cpp @@ -2609,7 +2609,7 @@ int32_t PeepCompare(const EntityId sprite_index_a, const EntityId sprite_index_b ft.Rewind(); peep_b->FormatNameTo(ft); OpenRCT2::FormatStringLegacy(nameB, sizeof(nameB), STR_STRINGID, ft.Data()); - return strlogicalcmp(nameA, nameB); + return StrLogicalCmp(nameA, nameB); } /** diff --git a/src/openrct2/entity/Staff.cpp b/src/openrct2/entity/Staff.cpp index 5d37e88bfc..179e49bebe 100644 --- a/src/openrct2/entity/Staff.cpp +++ b/src/openrct2/entity/Staff.cpp @@ -675,7 +675,7 @@ Direction Staff::MechanicDirectionPath(uint8_t validDirections, PathElement* pat pathDirections |= (1 << DirectionReverse(PeepDirection)); } - Direction direction = bitscanforward(pathDirections); + Direction direction = UtilBitScanForward(pathDirections); pathDirections &= ~(1 << direction); if (pathDirections == 0) { @@ -807,7 +807,7 @@ Direction Staff::DirectionPath(uint8_t validDirections, PathElement* pathElement pathDirections |= (1 << DirectionReverse(PeepDirection)); } - Direction direction = bitscanforward(pathDirections); + Direction direction = UtilBitScanForward(pathDirections); // If this is the only direction they can go, then go if (pathDirections == (1 << direction)) { diff --git a/src/openrct2/interface/Chat.cpp b/src/openrct2/interface/Chat.cpp index 5ae9add8f6..832441c4d1 100644 --- a/src/openrct2/interface/Chat.cpp +++ b/src/openrct2/interface/Chat.cpp @@ -216,7 +216,7 @@ void ChatAddHistory(std::string_view s) time(&timer); auto tmInfo = localtime(&timer); char timeBuffer[64]{}; - strcatftime(timeBuffer, sizeof(timeBuffer), "[%H:%M] ", tmInfo); + StrCatfTime(timeBuffer, sizeof(timeBuffer), "[%H:%M] ", tmInfo); std::string buffer = timeBuffer; buffer += s; diff --git a/src/openrct2/interface/InteractiveConsole.cpp b/src/openrct2/interface/InteractiveConsole.cpp index 5a5f3243f6..f2975ed12e 100644 --- a/src/openrct2/interface/InteractiveConsole.cpp +++ b/src/openrct2/interface/InteractiveConsole.cpp @@ -1763,8 +1763,8 @@ static int32_t ConsoleCommandMpDesync(InteractiveConsole& console, const argumen { auto* guest = guests[0]; if (guests.size() > 1) - guest = guests[util_rand() % guests.size() - 1]; - guest->TshirtColour = util_rand() & 0xFF; + guest = guests[UtilRand() % guests.size() - 1]; + guest->TshirtColour = UtilRand() & 0xFF; guest->Invalidate(); } break; @@ -1779,7 +1779,7 @@ static int32_t ConsoleCommandMpDesync(InteractiveConsole& console, const argumen { auto* guest = guests[0]; if (guests.size() > 1) - guest = guests[util_rand() % guests.size() - 1]; + guest = guests[UtilRand() % guests.size() - 1]; guest->Remove(); } break; diff --git a/src/openrct2/interface/Viewport.cpp b/src/openrct2/interface/Viewport.cpp index 97cc922ab8..a5a86fb875 100644 --- a/src/openrct2/interface/Viewport.cpp +++ b/src/openrct2/interface/Viewport.cpp @@ -1001,7 +1001,7 @@ void ViewportPaint( // make sure, the compare operation is done in int32_t to avoid the loop becoming an infinite loop. // this as well as the [x += 32] in the loop causes signed integer overflow -> undefined behaviour. auto rightBorder = dpi1.x + dpi1.width; - auto alignedX = floor2(dpi1.x, 32); + auto alignedX = Floor2(dpi1.x, 32); _paintColumns.clear(); @@ -1633,7 +1633,7 @@ static bool IsPixelPresentRLE(const uint8_t* esi, int32_t x_start_point, int32_t if (round > 1) { // This matches the original implementation, but allows empty lines to cause false positives on zoom 0 - if (ceil2(no_pixels, round) == 0) + if (Ceil2(no_pixels, round) == 0) continue; } @@ -1722,7 +1722,7 @@ static bool IsSpriteInteractedWithPaletteSet( } } - origin.y = floor2(origin.y, round); + origin.y = Floor2(origin.y, round); int32_t yEndPoint = height; origin.y -= dpi->y; if (origin.y < 0) @@ -1752,7 +1752,7 @@ static bool IsSpriteInteractedWithPaletteSet( int32_t xEndPoint = g1->width; origin.x += g1->x_offset; - origin.x = floor2(origin.x, round); + origin.x = Floor2(origin.x, round); origin.x -= dpi->x; if (origin.x < 0) { diff --git a/src/openrct2/localisation/Currency.cpp b/src/openrct2/localisation/Currency.cpp index ac9a1c0b2c..202755e28c 100644 --- a/src/openrct2/localisation/Currency.cpp +++ b/src/openrct2/localisation/Currency.cpp @@ -42,7 +42,7 @@ void CurrencyLoadCustomCurrencyConfig() CurrencyDescriptors[EnumValue(CurrencyType::Custom)].affix_unicode = gConfigGeneral.CustomCurrencyAffix; if (!gConfigGeneral.CustomCurrencySymbol.empty()) { - safe_strcpy( + SafeStrCpy( CurrencyDescriptors[EnumValue(CurrencyType::Custom)].symbol_unicode, gConfigGeneral.CustomCurrencySymbol.c_str(), CURRENCY_SYMBOL_MAX_SIZE); } diff --git a/src/openrct2/localisation/Formatting.cpp b/src/openrct2/localisation/Formatting.cpp index 9278fab88f..4cc0dab90e 100644 --- a/src/openrct2/localisation/Formatting.cpp +++ b/src/openrct2/localisation/Formatting.cpp @@ -540,10 +540,10 @@ namespace OpenRCT2 FormatStringID(ss, STR_UNIT_SUFFIX_MILES_PER_HOUR, arg); break; case MeasurementFormat::Metric: - FormatStringID(ss, STR_UNIT_SUFFIX_KILOMETRES_PER_HOUR, mph_to_kmph(arg)); + FormatStringID(ss, STR_UNIT_SUFFIX_KILOMETRES_PER_HOUR, MphToKmph(arg)); break; case MeasurementFormat::SI: - FormatStringID(ss, STR_UNIT_SUFFIX_METRES_PER_SECOND, mph_to_dmps(arg)); + FormatStringID(ss, STR_UNIT_SUFFIX_METRES_PER_SECOND, MphToDmps(arg)); break; } } @@ -567,7 +567,7 @@ namespace OpenRCT2 { default: case MeasurementFormat::Imperial: - FormatStringID(ss, STR_UNIT_SUFFIX_FEET, metres_to_feet(arg)); + FormatStringID(ss, STR_UNIT_SUFFIX_FEET, MetresToFeet(arg)); break; case MeasurementFormat::Metric: case MeasurementFormat::SI: diff --git a/src/openrct2/localisation/Localisation.Date.cpp b/src/openrct2/localisation/Localisation.Date.cpp index dcd8a155fb..be3599f503 100644 --- a/src/openrct2/localisation/Localisation.Date.cpp +++ b/src/openrct2/localisation/Localisation.Date.cpp @@ -87,7 +87,7 @@ void DateUpdate() } else { - gDateMonthTicks = floor2(static_cast(monthTicks), 4); + gDateMonthTicks = Floor2(static_cast(monthTicks), 4); } } diff --git a/src/openrct2/management/Finance.cpp b/src/openrct2/management/Finance.cpp index c8247dbb79..6ed3cffd37 100644 --- a/src/openrct2/management/Finance.cpp +++ b/src/openrct2/management/Finance.cpp @@ -87,7 +87,7 @@ bool FinanceCheckAffordability(money64 cost, uint32_t flags) void FinancePayment(money64 amount, ExpenditureType type) { // overflow check - gCash = add_clamp_money64(gCash, -amount); + gCash = AddClamp_money64(gCash, -amount); gExpenditureTable[0][static_cast(type)] -= amount; if (dword_988E60[static_cast(type)] & 1) diff --git a/src/openrct2/network/NetworkBase.cpp b/src/openrct2/network/NetworkBase.cpp index cf9423e913..4bc1312ca1 100644 --- a/src/openrct2/network/NetworkBase.cpp +++ b/src/openrct2/network/NetworkBase.cpp @@ -858,7 +858,7 @@ std::string NetworkBase::GenerateAdvertiseKey() char key[17]; for (int32_t i = 0; i < 16; i++) { - int32_t hexCharIndex = util_rand() % std::size(hexChars); + int32_t hexCharIndex = UtilRand() % std::size(hexChars); key[i] = hexChars[hexCharIndex]; } key[std::size(key) - 1] = 0; diff --git a/src/openrct2/object/ObjectRepository.cpp b/src/openrct2/object/ObjectRepository.cpp index d80807afc7..19d190ca14 100644 --- a/src/openrct2/object/ObjectRepository.cpp +++ b/src/openrct2/object/ObjectRepository.cpp @@ -525,7 +525,7 @@ private: chunkHeader.encoding = object_entry_group_encoding[EnumValue(objectType)]; chunkHeader.length = static_cast(dataSize); uint8_t* encodedDataBuffer = Memory::Allocate(0x600000); - size_t encodedDataSize = sawyercoding_write_chunk_buffer( + size_t encodedDataSize = SawyerCodingWriteChunkBuffer( encodedDataBuffer, reinterpret_cast(data), chunkHeader); // Save to file diff --git a/src/openrct2/object/RideObject.cpp b/src/openrct2/object/RideObject.cpp index a0c3186822..b01ebb4e64 100644 --- a/src/openrct2/object/RideObject.cpp +++ b/src/openrct2/object/RideObject.cpp @@ -48,7 +48,7 @@ static constexpr SpritePrecision PrecisionFromNumFrames(uint8_t numRotationFrame if (numRotationFrames == 0) return SpritePrecision::None; else - return static_cast(bitscanforward(numRotationFrames) + 1); + return static_cast(UtilBitScanForward(numRotationFrames) + 1); } static void RideObjectUpdateRideType(rct_ride_entry& rideEntry) @@ -774,7 +774,7 @@ CarEntry RideObject::ReadJsonCar([[maybe_unused]] IReadObjectContext* context, j auto numRotationFrames = Json::GetNumber(jRotationCount[SpriteGroupNames[i]], 0); if (numRotationFrames != 0) { - if (!is_power_of_2(numRotationFrames)) + if (!IsPowerOf2(numRotationFrames)) { context->LogError(ObjectError::InvalidProperty, "spriteGroups values must be powers of 2"); continue; diff --git a/src/openrct2/paint/Paint.cpp b/src/openrct2/paint/Paint.cpp index 9d2b89816d..25bcf23838 100644 --- a/src/openrct2/paint/Paint.cpp +++ b/src/openrct2/paint/Paint.cpp @@ -201,7 +201,7 @@ static PaintStruct* CreateNormalPaintStruct( template void PaintSessionGenerateRotate(PaintSession& session) { // Optimised modified version of ViewportPosToMapPos - ScreenCoordsXY screenCoord = { floor2(session.DPI.x, 32), floor2((session.DPI.y - 16), 32) }; + ScreenCoordsXY screenCoord = { Floor2(session.DPI.x, 32), Floor2((session.DPI.y - 16), 32) }; CoordsXY mapTile = { screenCoord.y - screenCoord.x / 2, screenCoord.y + screenCoord.x / 2 }; mapTile = mapTile.Rotate(direction); @@ -493,12 +493,12 @@ static void PaintDrawStruct(PaintSession& session, PaintStruct* ps) { if (dpi->zoom_level >= ZoomLevel{ 1 }) { - x = floor2(x, 2); - y = floor2(y, 2); + x = Floor2(x, 2); + y = Floor2(y, 2); if (dpi->zoom_level >= ZoomLevel{ 2 }) { - x = floor2(x, 4); - y = floor2(y, 4); + x = Floor2(x, 4); + y = Floor2(y, 4); } } } diff --git a/src/openrct2/paint/Supports.cpp b/src/openrct2/paint/Supports.cpp index 8929aa3fe5..052cf812d5 100644 --- a/src/openrct2/paint/Supports.cpp +++ b/src/openrct2/paint/Supports.cpp @@ -473,7 +473,7 @@ bool WoodenASupportsPaintSetup( imageTemplate = ImageId().WithTransparency(FilterPaletteID::PaletteDarken1); } - int32_t z = floor2(session.Support.height + 15, 16); + int32_t z = Floor2(session.Support.height + 15, 16); height -= z; if (height < 0) { @@ -634,7 +634,7 @@ bool WoodenBSupportsPaintSetup( imageTemplate = ImageId().WithTransparency(FilterPaletteID::PaletteDarken1); } - uint16_t baseHeight = ceil2(session.Support.height, 16); + uint16_t baseHeight = Ceil2(session.Support.height, 16); int16_t supportLength = height - baseHeight; if (supportLength < 0) @@ -878,7 +878,7 @@ bool MetalASupportsPaintSetup( // Work out if a small support segment required to bring support to normal // size (aka floor2(x, 16)) - int16_t heightDiff = floor2(height + 16, 16); + int16_t heightDiff = Floor2(height + 16, 16); if (heightDiff > si) { heightDiff = si; @@ -1073,7 +1073,7 @@ bool MetalBSupportsPaintSetup( baseHeight = supportSegments[segment].height + 6; } - int16_t heightDiff = floor2(baseHeight + 16, 16); + int16_t heightDiff = Floor2(baseHeight + 16, 16); if (heightDiff > si) { heightDiff = si; @@ -1192,7 +1192,7 @@ bool PathASupportsPaintSetup( imageTemplate = ImageId().WithTransparency(FilterPaletteID::PaletteDarken1); } - uint16_t baseHeight = ceil2(session.Support.height, 16); + uint16_t baseHeight = Ceil2(session.Support.height, 16); int32_t supportLength = height - baseHeight; if (supportLength < 0) { @@ -1370,7 +1370,7 @@ bool PathBSupportsPaintSetup( // si = height // dx = baseHeight - int16_t heightDiff = floor2(baseHeight + 16, 16); + int16_t heightDiff = Floor2(baseHeight + 16, 16); if (heightDiff > height) { heightDiff = height; diff --git a/src/openrct2/paint/tile_element/Paint.LargeScenery.cpp b/src/openrct2/paint/tile_element/Paint.LargeScenery.cpp index 8d9950c92a..dbef35f686 100644 --- a/src/openrct2/paint/tile_element/Paint.LargeScenery.cpp +++ b/src/openrct2/paint/tile_element/Paint.LargeScenery.cpp @@ -72,7 +72,7 @@ static void PaintLargeScenerySupports( WoodenBSupportsPaintSetup(session, (direction & 1), special, supportHeight, imageTemplate); - int32_t clearanceHeight = ceil2(tileElement.GetClearanceZ() + 15, 16); + int32_t clearanceHeight = Ceil2(tileElement.GetClearanceZ() + 15, 16); if (tile.flags & LARGE_SCENERY_TILE_FLAG_ALLOW_SUPPORTS_ABOVE) { PaintUtilSetSegmentSupportHeight(session, SEGMENTS_ALL, clearanceHeight, 0x20); diff --git a/src/openrct2/paint/tile_element/Paint.SmallScenery.cpp b/src/openrct2/paint/tile_element/Paint.SmallScenery.cpp index 4af8373a94..a50275980e 100644 --- a/src/openrct2/paint/tile_element/Paint.SmallScenery.cpp +++ b/src/openrct2/paint/tile_element/Paint.SmallScenery.cpp @@ -69,7 +69,7 @@ static void SetSupportHeights( { height += sceneryEntry.height; - PaintUtilSetGeneralSupportHeight(session, ceil2(height, 8), 0x20); + PaintUtilSetGeneralSupportHeight(session, Ceil2(height, 8), 0x20); if (sceneryEntry.HasFlag(SMALL_SCENERY_FLAG_BUILD_DIRECTLY_ONTOP)) { if (sceneryEntry.HasFlag(SMALL_SCENERY_FLAG_FULL_TILE)) diff --git a/src/openrct2/peep/GuestPathfinding.cpp b/src/openrct2/peep/GuestPathfinding.cpp index fa547fe2f9..38b9cd7c70 100644 --- a/src/openrct2/peep/GuestPathfinding.cpp +++ b/src/openrct2/peep/GuestPathfinding.cpp @@ -532,7 +532,7 @@ static bool path_is_thin_junction(PathElement* path, const TileCoordsXYZ& loc) uint8_t edges = path->GetEdges(); - int32_t test_edge = bitscanforward(edges); + int32_t test_edge = UtilBitScanForward(edges); if (test_edge == -1) return false; @@ -556,7 +556,7 @@ static bool path_is_thin_junction(PathElement* path, const TileCoordsXYZ& loc) break; } edges &= ~(1 << test_edge); - } while ((test_edge = bitscanforward(edges)) != -1); + } while ((test_edge = UtilBitScanForward(edges)) != -1); return thin_junction; } @@ -843,7 +843,7 @@ static void peep_pathfind_heuristic_search( searchResult = PATH_SEARCH_THIN; - uint8_t numEdges = bitcount(tileElement->AsPath()->GetEdges()); + uint8_t numEdges = BitCount(tileElement->AsPath()->GetEdges()); if (numEdges < 2) { @@ -1007,7 +1007,7 @@ static void peep_pathfind_heuristic_search( /* Remove the reverse edge (i.e. the edge back to the previous map element.) */ edges &= ~(1 << DirectionReverse(test_edge)); - int32_t next_test_edge = bitscanforward(edges); + int32_t next_test_edge = UtilBitScanForward(edges); /* If there are no other edges the current search ends here. * Continue to the next map element without updating the parameters (best result so far). */ @@ -1228,7 +1228,7 @@ static void peep_pathfind_heuristic_search( *endScore); } #endif // defined(DEBUG_LEVEL_2) && DEBUG_LEVEL_2 - } while ((next_test_edge = bitscanforward(edges)) != -1); + } while ((next_test_edge = UtilBitScanForward(edges)) != -1); } while (!(tileElement++)->IsLastForTile()); @@ -1426,7 +1426,7 @@ Direction OriginalPathfinding::ChooseDirection(const TileCoordsXYZ& loc, Peep& p if (edges == 0) return INVALID_DIRECTION; - int32_t chosen_edge = bitscanforward(edges); + int32_t chosen_edge = UtilBitScanForward(edges); // Peep has multiple edges still to try. if (edges & ~(1 << chosen_edge)) @@ -1450,8 +1450,8 @@ Direction OriginalPathfinding::ChooseDirection(const TileCoordsXYZ& loc, Peep& p * edge that gives the best (i.e. smallest) value (best_score) * or for different edges with equal value, the edge with the * least steps (best_sub). */ - int32_t numEdges = bitcount(edges); - for (int32_t test_edge = chosen_edge; test_edge != -1; test_edge = bitscanforward(edges)) + int32_t numEdges = BitCount(edges); + for (int32_t test_edge = chosen_edge; test_edge != -1; test_edge = UtilBitScanForward(edges)) { edges &= ~(1 << test_edge); uint8_t height = loc.z; @@ -2040,7 +2040,7 @@ int32_t OriginalPathfinding::CalculateNextDestination(Guest& peep) edges &= ~(1 << direction); } - direction = bitscanforward(edges); + direction = UtilBitScanForward(edges); // IF only one edge to choose from if ((edges & ~(1 << direction)) == 0) { @@ -2116,7 +2116,7 @@ int32_t OriginalPathfinding::CalculateNextDestination(Guest& peep) if (peep.HasItem(ShopItem::Map)) { // If at least 2 directions consult map - if (bitcount(edges) >= 2) + if (BitCount(edges) >= 2) { uint16_t probability = 1638; if (peep.HeadingForRideOrParkExit()) diff --git a/src/openrct2/platform/Crash.cpp b/src/openrct2/platform/Crash.cpp index 7ad1ef3c60..1b8cd91d48 100644 --- a/src/openrct2/platform/Crash.cpp +++ b/src/openrct2/platform/Crash.cpp @@ -138,7 +138,7 @@ static bool OnCrash( FILE* input = _wfopen(dumpFilePath, L"rb"); FILE* dest = _wfopen(dumpFilePathGZIP, L"wb"); - if (util_gzip_compress(input, dest)) + if (UtilGzipCompress(input, dest)) { // TODO: enable upload of gzip-compressed dumps once supported on // backtrace.io (uncomment the line below). For now leave compression diff --git a/src/openrct2/platform/Platform.Posix.cpp b/src/openrct2/platform/Platform.Posix.cpp index bc85d3b1b3..f0420831e6 100644 --- a/src/openrct2/platform/Platform.Posix.cpp +++ b/src/openrct2/platform/Platform.Posix.cpp @@ -320,7 +320,7 @@ namespace Platform { mode_t mask = openrct2_getumask(); char buffer[MAX_PATH]; - safe_strcpy(buffer, u8string(path).c_str(), sizeof(buffer)); + SafeStrCpy(buffer, u8string(path).c_str(), sizeof(buffer)); LOG_VERBOSE("Create directory: %s", buffer); for (char* p = buffer + 1; *p != '\0'; p++) diff --git a/src/openrct2/platform/Shared.cpp b/src/openrct2/platform/Shared.cpp index 7bdf913281..28aad51214 100644 --- a/src/openrct2/platform/Shared.cpp +++ b/src/openrct2/platform/Shared.cpp @@ -46,7 +46,7 @@ namespace Platform #endif // __ANDROID__ InitTicks(); - bitcount_init(); + BitCountInit(); MaskInit(); } } diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 85034982b4..b4ce90e840 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -163,7 +163,7 @@ namespace RCT1 _s4 = *ReadAndDecodeS4(stream, isScenario); _s4Path = path; _isScenario = isScenario; - _gameVersion = sawyercoding_detect_rct1_version(_s4.game_version) & FILE_VERSION_MASK; + _gameVersion = SawyerCodingDetectRCT1Version(_s4.game_version) & FILE_VERSION_MASK; // Only determine what objects we required to import this saved game InitialiseEntryMaps(); @@ -296,14 +296,14 @@ namespace RCT1 auto decodedData = std::make_unique(sizeof(S4)); size_t decodedSize; - int32_t fileType = sawyercoding_detect_file_type(data.get(), dataSize); + int32_t fileType = SawyerCodingDetectFileType(data.get(), dataSize); if (isScenario && (fileType & FILE_VERSION_MASK) != FILE_VERSION_RCT1) { - decodedSize = sawyercoding_decode_sc4(data.get(), decodedData.get(), dataSize, sizeof(S4)); + decodedSize = SawyerCodingDecodeSC4(data.get(), decodedData.get(), dataSize, sizeof(S4)); } else { - decodedSize = sawyercoding_decode_sv4(data.get(), decodedData.get(), dataSize, sizeof(S4)); + decodedSize = SawyerCodingDecodeSV4(data.get(), decodedData.get(), dataSize, sizeof(S4)); } if (decodedSize == sizeof(S4)) diff --git a/src/openrct2/rct12/SawyerChunkWriter.cpp b/src/openrct2/rct12/SawyerChunkWriter.cpp index dc6d12b3d5..ac5eb57357 100644 --- a/src/openrct2/rct12/SawyerChunkWriter.cpp +++ b/src/openrct2/rct12/SawyerChunkWriter.cpp @@ -33,7 +33,7 @@ void SawyerChunkWriter::WriteChunk(const void* src, size_t length, SAWYER_ENCODI header.length = static_cast(length); auto data = std::make_unique(MAX_COMPRESSED_CHUNK_SIZE); - size_t dataLength = sawyercoding_write_chunk_buffer(data.get(), static_cast(src), header); + size_t dataLength = SawyerCodingWriteChunkBuffer(data.get(), static_cast(src), header); _stream->Write(data.get(), dataLength); } diff --git a/src/openrct2/ride/CableLift.cpp b/src/openrct2/ride/CableLift.cpp index 72c037622b..9fd3e84390 100644 --- a/src/openrct2/ride/CableLift.cpp +++ b/src/openrct2/ride/CableLift.cpp @@ -447,7 +447,7 @@ int32_t Vehicle::CableLiftUpdateTrackMotion() vehicleCount++; massTotal += vehicle->mass; - accelerationTotal = add_clamp_int32_t(accelerationTotal, vehicle->acceleration); + accelerationTotal = AddClamp_int32_t(accelerationTotal, vehicle->acceleration); } int32_t newAcceleration = (accelerationTotal / vehicleCount) >> 9; diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index 8237c66f2a..ad0449d88f 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -1409,7 +1409,7 @@ static int32_t ride_get_new_breakdown_problem(const Ride& ride) problemBits = availableBreakdownProblems; while (problemBits != 0) { - breakdownProblem = bitscanforward(problemBits); + breakdownProblem = UtilBitScanForward(problemBits); problemBits &= ~(1 << breakdownProblem); totalProbability += _breakdownProblemProbabilities[breakdownProblem]; } @@ -1423,7 +1423,7 @@ static int32_t ride_get_new_breakdown_problem(const Ride& ride) problemBits = availableBreakdownProblems; do { - breakdownProblem = bitscanforward(problemBits); + breakdownProblem = UtilBitScanForward(problemBits); problemBits &= ~(1 << breakdownProblem); randomProbability -= _breakdownProblemProbabilities[breakdownProblem]; } while (randomProbability >= 0); @@ -1913,7 +1913,7 @@ void DefaultMusicUpdate(Ride& ride) if (musicObj != nullptr) { auto numTracks = musicObj->GetTrackCount(); - ride.music_tune_id = static_cast(util_rand() % numTracks); + ride.music_tune_id = static_cast(UtilRand() % numTracks); ride.music_position = 0; } return; @@ -2173,10 +2173,10 @@ int32_t RideGetUnusedPresetVehicleColour(ObjectEntryIndex subType) // If all presets have been used, just go with a random preset if (unused.size() == 0) - return util_rand() % colourPresets->count; + return UtilRand() % colourPresets->count; // Choose a random preset from the list of unused presets - auto unusedIndex = util_rand() % unused.size(); + auto unusedIndex = UtilRand() % unused.size(); return unused[unusedIndex]; } @@ -4145,10 +4145,10 @@ int32_t RideGetRandomColourPresetIndex(ride_type_t rideType) // If all presets have been used, just go with a random preset if (unused.size() == 0) - return util_rand() % colourPresets.count; + return UtilRand() % colourPresets.count; // Choose a random preset from the list of unused presets - auto unusedIndex = util_rand() % unused.size(); + auto unusedIndex = UtilRand() % unused.size(); return unused[unusedIndex]; } diff --git a/src/openrct2/ride/TrackDesign.cpp b/src/openrct2/ride/TrackDesign.cpp index 5a073c8445..6752ddca34 100644 --- a/src/openrct2/ride/TrackDesign.cpp +++ b/src/openrct2/ride/TrackDesign.cpp @@ -923,7 +923,7 @@ static void TrackDesignMirrorMaze(TrackDesign* td6) uint16_t maze_entry = maze.maze_entry; uint16_t new_entry = 0; - for (uint8_t position = bitscanforward(maze_entry); position != 0xFF; position = bitscanforward(maze_entry)) + for (uint8_t position = UtilBitScanForward(maze_entry); position != 0xFF; position = UtilBitScanForward(maze_entry)) { maze_entry &= ~(1 << position); new_entry |= (1 << maze_segment_mirror_map[position]); diff --git a/src/openrct2/ride/TrackDesignRepository.cpp b/src/openrct2/ride/TrackDesignRepository.cpp index 3be8ace9a6..ea7fa3064f 100644 --- a/src/openrct2/ride/TrackDesignRepository.cpp +++ b/src/openrct2/ride/TrackDesignRepository.cpp @@ -284,7 +284,7 @@ private: { return a.RideType < b.RideType; } - return strlogicalcmp(a.Name.c_str(), b.Name.c_str()) < 0; + return StrLogicalCmp(a.Name.c_str(), b.Name.c_str()) < 0; }); } diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index 5fdb85fee7..2970fda025 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -1485,14 +1485,14 @@ void Vehicle::UpdateMeasurements() if (curRide->average_speed_test_timeout == 0 && absVelocity > 0x8000) { - curRide->average_speed = add_clamp_int32_t(curRide->average_speed, absVelocity); + curRide->average_speed = AddClamp_int32_t(curRide->average_speed, absVelocity); stationForTestSegment.SegmentTime++; } int32_t distance = abs(((velocity + acceleration) >> 10) * 42); if (NumLaps == 0) { - stationForTestSegment.SegmentLength = add_clamp_int32_t(stationForTestSegment.SegmentLength, distance); + stationForTestSegment.SegmentLength = AddClamp_int32_t(stationForTestSegment.SegmentLength, distance); } if (curRide->GetRideTypeDescriptor().HasFlag(RIDE_TYPE_FLAG_HAS_G_FORCES)) @@ -1801,7 +1801,7 @@ void Vehicle::UpdateMeasurements() if (distance < 0) return; - curRide->sheltered_length = add_clamp_int32_t(curRide->sheltered_length, distance); + curRide->sheltered_length = AddClamp_int32_t(curRide->sheltered_length, distance); } struct SoundIdVolume diff --git a/src/openrct2/ride/thrill/Enterprise.cpp b/src/openrct2/ride/thrill/Enterprise.cpp index 8542d47d33..3d77df341c 100644 --- a/src/openrct2/ride/thrill/Enterprise.cpp +++ b/src/openrct2/ride/thrill/Enterprise.cpp @@ -35,7 +35,7 @@ static void PaintEnterpriseRiders( break; auto frameOffset1 = ((imageOffset % 4) * 4 + (i * 4) % 15) & 0x0F; - auto frameOffset2 = floor2(imageOffset, 4) * 4; + auto frameOffset2 = Floor2(imageOffset, 4) * 4; auto imageTemplate = ImageId(0, vehicle.peep_tshirt_colours[i]); auto imageId = imageTemplate.WithIndex(baseImageIndex + 196 + frameOffset1 + frameOffset2); PaintAddImageAsChild(session, imageId, offset, bb); diff --git a/src/openrct2/scenario/Scenario.cpp b/src/openrct2/scenario/Scenario.cpp index e8e8a6e802..e72e993fd1 100644 --- a/src/openrct2/scenario/Scenario.cpp +++ b/src/openrct2/scenario/Scenario.cpp @@ -242,7 +242,7 @@ void ScenarioSuccessSubmitName(const char* name) */ static void ScenarioCheckEntranceFeeTooHigh() { - const auto max_fee = add_clamp_money16(gTotalRideValueForMoney, gTotalRideValueForMoney / 2); + const auto max_fee = AddClamp_money16(gTotalRideValueForMoney, gTotalRideValueForMoney / 2); if ((gParkFlags & PARK_FLAGS_PARK_OPEN) && ParkGetEntranceFee() > max_fee) { diff --git a/src/openrct2/title/TitleScreen.cpp b/src/openrct2/title/TitleScreen.cpp index 9e40eae782..17025ff5ed 100644 --- a/src/openrct2/title/TitleScreen.cpp +++ b/src/openrct2/title/TitleScreen.cpp @@ -266,7 +266,7 @@ void TitleScreen::TitleInitialise() while (!safeSequence) { size_t total = TitleSequenceManager::GetCount(); - random = util_rand() % static_cast(total); + random = UtilRand() % static_cast(total); const utf8* scName = TitleSequenceManagerGetName(random); safeSequence = true; if (scName == RCT1String) diff --git a/src/openrct2/title/TitleSequence.cpp b/src/openrct2/title/TitleSequence.cpp index 3a44b24389..864f0bba44 100644 --- a/src/openrct2/title/TitleSequence.cpp +++ b/src/openrct2/title/TitleSequence.cpp @@ -382,7 +382,7 @@ namespace OpenRCT2::Title { auto entityID = EntityId::FromUnderlying(atoi(parts[1].data()) & 0xFFFF); auto followCommand = FollowEntityCommand{ entityID }; - safe_strcpy(followCommand.Follow.SpriteName, parts[2].data(), USER_STRING_MAX_LENGTH); + SafeStrCpy(followCommand.Follow.SpriteName, parts[2].data(), USER_STRING_MAX_LENGTH); command = followCommand; } else if (_stricmp(token, "WAIT") == 0) @@ -401,7 +401,7 @@ namespace OpenRCT2::Title else if (_stricmp(token, "LOADSC") == 0) { auto loadScenarioCommand = LoadScenarioCommand{}; - safe_strcpy(loadScenarioCommand.Scenario, parts[1].data(), sizeof(loadScenarioCommand.Scenario)); + SafeStrCpy(loadScenarioCommand.Scenario, parts[1].data(), sizeof(loadScenarioCommand.Scenario)); command = loadScenarioCommand; } } diff --git a/src/openrct2/util/Math.hpp b/src/openrct2/util/Math.hpp index 42d5237b12..c507ca2c40 100644 --- a/src/openrct2/util/Math.hpp +++ b/src/openrct2/util/Math.hpp @@ -14,24 +14,24 @@ namespace { - [[maybe_unused]] constexpr bool is_power_of_2(int v) + [[maybe_unused]] constexpr bool IsPowerOf2(int v) { return v && ((v & (v - 1)) == 0); } // Rounds an integer down to the given power of 2. y must be a power of 2. - [[maybe_unused]] constexpr int floor2(const int x, const int y) + [[maybe_unused]] constexpr int Floor2(const int x, const int y) { - if (!is_power_of_2(y)) - throw std::logic_error("floor2 should only operate on power of 2"); + if (!IsPowerOf2(y)) + throw std::logic_error("Floor2 should only operate on power of 2"); return x & ~(y - 1); } // Rounds an integer up to the given power of 2. y must be a power of 2. - [[maybe_unused]] constexpr int ceil2(const int x, const int y) + [[maybe_unused]] constexpr int Ceil2(const int x, const int y) { - if (!is_power_of_2(y)) - throw std::logic_error("ceil2 should only operate on power of 2"); + if (!IsPowerOf2(y)) + throw std::logic_error("Ceil2 should only operate on power of 2"); return (x + y - 1) & ~(y - 1); } } // namespace diff --git a/src/openrct2/util/SawyerCoding.cpp b/src/openrct2/util/SawyerCoding.cpp index 0bbc3ddf67..46b97ca5b6 100644 --- a/src/openrct2/util/SawyerCoding.cpp +++ b/src/openrct2/util/SawyerCoding.cpp @@ -18,14 +18,14 @@ #include #include -static size_t decode_chunk_rle(const uint8_t* src_buffer, uint8_t* dst_buffer, size_t length); -static size_t decode_chunk_rle_with_size(const uint8_t* src_buffer, uint8_t* dst_buffer, size_t length, size_t dstSize); +static size_t DecodeChunkRLE(const uint8_t* src_buffer, uint8_t* dst_buffer, size_t length); +static size_t DecodeChunkRLEWithWize(const uint8_t* src_buffer, uint8_t* dst_buffer, size_t length, size_t dstSize); -static size_t encode_chunk_rle(const uint8_t* src_buffer, uint8_t* dst_buffer, size_t length); -static size_t encode_chunk_repeat(const uint8_t* src_buffer, uint8_t* dst_buffer, size_t length); -static void encode_chunk_rotate(uint8_t* buffer, size_t length); +static size_t EncodeChunkRLE(const uint8_t* src_buffer, uint8_t* dst_buffer, size_t length); +static size_t EncodeChunkRepeat(const uint8_t* src_buffer, uint8_t* dst_buffer, size_t length); +static void EncodeChunkRotate(uint8_t* buffer, size_t length); -uint32_t sawyercoding_calculate_checksum(const uint8_t* buffer, size_t length) +uint32_t SawyerCodingCalculateChecksum(const uint8_t* buffer, size_t length) { uint32_t checksum = 0; for (size_t i = 0; i < length; i++) @@ -39,7 +39,7 @@ uint32_t sawyercoding_calculate_checksum(const uint8_t* buffer, size_t length) * rct2: 0x006762E1 * */ -size_t sawyercoding_write_chunk_buffer(uint8_t* dst_file, const uint8_t* buffer, sawyercoding_chunk_header chunkHeader) +size_t SawyerCodingWriteChunkBuffer(uint8_t* dst_file, const uint8_t* buffer, sawyercoding_chunk_header chunkHeader) { uint8_t *encode_buffer, *encode_buffer2; @@ -54,7 +54,7 @@ size_t sawyercoding_write_chunk_buffer(uint8_t* dst_file, const uint8_t* buffer, break; case CHUNK_ENCODING_RLE: encode_buffer = static_cast(malloc(0x600000)); - chunkHeader.length = static_cast(encode_chunk_rle(buffer, encode_buffer, chunkHeader.length)); + chunkHeader.length = static_cast(EncodeChunkRLE(buffer, encode_buffer, chunkHeader.length)); std::memcpy(dst_file, &chunkHeader, sizeof(sawyercoding_chunk_header)); dst_file += sizeof(sawyercoding_chunk_header); std::memcpy(dst_file, encode_buffer, chunkHeader.length); @@ -64,8 +64,8 @@ size_t sawyercoding_write_chunk_buffer(uint8_t* dst_file, const uint8_t* buffer, case CHUNK_ENCODING_RLECOMPRESSED: encode_buffer = static_cast(malloc(chunkHeader.length * 2)); encode_buffer2 = static_cast(malloc(0x600000)); - chunkHeader.length = static_cast(encode_chunk_repeat(buffer, encode_buffer, chunkHeader.length)); - chunkHeader.length = static_cast(encode_chunk_rle(encode_buffer, encode_buffer2, chunkHeader.length)); + chunkHeader.length = static_cast(EncodeChunkRepeat(buffer, encode_buffer, chunkHeader.length)); + chunkHeader.length = static_cast(EncodeChunkRLE(encode_buffer, encode_buffer2, chunkHeader.length)); std::memcpy(dst_file, &chunkHeader, sizeof(sawyercoding_chunk_header)); dst_file += sizeof(sawyercoding_chunk_header); std::memcpy(dst_file, encode_buffer2, chunkHeader.length); @@ -76,7 +76,7 @@ size_t sawyercoding_write_chunk_buffer(uint8_t* dst_file, const uint8_t* buffer, case CHUNK_ENCODING_ROTATE: encode_buffer = static_cast(malloc(chunkHeader.length)); std::memcpy(encode_buffer, buffer, chunkHeader.length); - encode_chunk_rotate(encode_buffer, chunkHeader.length); + EncodeChunkRotate(encode_buffer, chunkHeader.length); std::memcpy(dst_file, &chunkHeader, sizeof(sawyercoding_chunk_header)); dst_file += sizeof(sawyercoding_chunk_header); std::memcpy(dst_file, encode_buffer, chunkHeader.length); @@ -88,17 +88,17 @@ size_t sawyercoding_write_chunk_buffer(uint8_t* dst_file, const uint8_t* buffer, return chunkHeader.length + sizeof(sawyercoding_chunk_header); } -size_t sawyercoding_decode_sv4(const uint8_t* src, uint8_t* dst, size_t length, size_t bufferLength) +size_t SawyerCodingDecodeSV4(const uint8_t* src, uint8_t* dst, size_t length, size_t bufferLength) { // (0 to length - 4): RLE chunk // (length - 4 to length): checksum - return decode_chunk_rle_with_size(src, dst, length - 4, bufferLength); + return DecodeChunkRLEWithWize(src, dst, length - 4, bufferLength); } -size_t sawyercoding_decode_sc4(const uint8_t* src, uint8_t* dst, size_t length, size_t bufferLength) +size_t SawyerCodingDecodeSC4(const uint8_t* src, uint8_t* dst, size_t length, size_t bufferLength) { // Uncompress - size_t decodedLength = decode_chunk_rle_with_size(src, dst, length - 4, bufferLength); + size_t decodedLength = DecodeChunkRLEWithWize(src, dst, length - 4, bufferLength); // Decode for (size_t i = 0x60018; i <= std::min(decodedLength - 1, static_cast(0x1F8353)); i++) @@ -115,26 +115,26 @@ size_t sawyercoding_decode_sc4(const uint8_t* src, uint8_t* dst, size_t length, return decodedLength; } -size_t sawyercoding_encode_sv4(const uint8_t* src, uint8_t* dst, size_t length) +size_t SawyerCodingEencodeSV4(const uint8_t* src, uint8_t* dst, size_t length) { // Encode - size_t encodedLength = encode_chunk_rle(src, dst, length); + size_t encodedLength = EncodeChunkRLE(src, dst, length); // Append checksum - uint32_t checksum = sawyercoding_calculate_checksum(dst, encodedLength); + uint32_t checksum = SawyerCodingCalculateChecksum(dst, encodedLength); *(reinterpret_cast(&dst[encodedLength])) = checksum; return encodedLength + 4; } -size_t sawyercoding_decode_td6(const uint8_t* src, uint8_t* dst, size_t length) +size_t SawyerCodingDecodeTD6(const uint8_t* src, uint8_t* dst, size_t length) { - return decode_chunk_rle(src, dst, length - 4); + return DecodeChunkRLE(src, dst, length - 4); } -size_t sawyercoding_encode_td6(const uint8_t* src, uint8_t* dst, size_t length) +size_t SawyerCodingEncodeTD6(const uint8_t* src, uint8_t* dst, size_t length) { - size_t output_length = encode_chunk_rle(src, dst, length); + size_t output_length = EncodeChunkRLE(src, dst, length); uint32_t checksum = 0; for (size_t i = 0; i < output_length; i++) @@ -151,7 +151,7 @@ size_t sawyercoding_encode_td6(const uint8_t* src, uint8_t* dst, size_t length) } /* Based off of rct2: 0x006770C1 */ -int32_t sawyercoding_validate_track_checksum(const uint8_t* src, size_t length) +int32_t SawyerCodingValidateTrackChecksum(const uint8_t* src, size_t length) { if (length < 4) return 0; @@ -182,7 +182,7 @@ int32_t sawyercoding_validate_track_checksum(const uint8_t* src, size_t length) * * rct2: 0x0067693A */ -static size_t decode_chunk_rle(const uint8_t* src_buffer, uint8_t* dst_buffer, size_t length) +static size_t DecodeChunkRLE(const uint8_t* src_buffer, uint8_t* dst_buffer, size_t length) { size_t count; uint8_t *dst, rleCodeByte; @@ -215,7 +215,7 @@ static size_t decode_chunk_rle(const uint8_t* src_buffer, uint8_t* dst_buffer, s * * rct2: 0x0067693A */ -static size_t decode_chunk_rle_with_size(const uint8_t* src_buffer, uint8_t* dst_buffer, size_t length, size_t dstSize) +static size_t DecodeChunkRLEWithWize(const uint8_t* src_buffer, uint8_t* dst_buffer, size_t length, size_t dstSize) { size_t count; uint8_t *dst, rleCodeByte; @@ -258,7 +258,7 @@ static size_t decode_chunk_rle_with_size(const uint8_t* src_buffer, uint8_t* dst * Ensure dst_buffer is bigger than src_buffer then resize afterwards * returns length of dst_buffer */ -static size_t encode_chunk_rle(const uint8_t* src_buffer, uint8_t* dst_buffer, size_t length) +static size_t EncodeChunkRLE(const uint8_t* src_buffer, uint8_t* dst_buffer, size_t length) { const uint8_t* src = src_buffer; uint8_t* dst = dst_buffer; @@ -306,7 +306,7 @@ static size_t encode_chunk_rle(const uint8_t* src_buffer, uint8_t* dst_buffer, s return dst - dst_buffer; } -static size_t encode_chunk_repeat(const uint8_t* src_buffer, uint8_t* dst_buffer, size_t length) +static size_t EncodeChunkRepeat(const uint8_t* src_buffer, uint8_t* dst_buffer, size_t length) { if (length == 0) return 0; @@ -373,7 +373,7 @@ static size_t encode_chunk_repeat(const uint8_t* src_buffer, uint8_t* dst_buffer return outLength; } -static void encode_chunk_rotate(uint8_t* buffer, size_t length) +static void EncodeChunkRotate(uint8_t* buffer, size_t length) { size_t i; uint8_t code = 1; @@ -386,7 +386,7 @@ static void encode_chunk_rotate(uint8_t* buffer, size_t length) #pragma endregion -int32_t sawyercoding_detect_file_type(const uint8_t* src, size_t length) +int32_t SawyerCodingDetectFileType(const uint8_t* src, size_t length) { if (length < 4) { @@ -405,10 +405,10 @@ int32_t sawyercoding_detect_file_type(const uint8_t* src, size_t length) actualChecksum = Numerics::rol32(actualChecksum, 3); } - return sawyercoding_detect_rct1_version(checksum - actualChecksum); + return SawyerCodingDetectRCT1Version(checksum - actualChecksum); } -int32_t sawyercoding_detect_rct1_version(int32_t gameVersion) +int32_t SawyerCodingDetectRCT1Version(int32_t gameVersion) { int32_t fileType = (gameVersion) > 0 ? FILE_TYPE_SV4 : FILE_TYPE_SC4; gameVersion = abs(gameVersion); diff --git a/src/openrct2/util/SawyerCoding.h b/src/openrct2/util/SawyerCoding.h index 3394bc013b..e5bce4adf5 100644 --- a/src/openrct2/util/SawyerCoding.h +++ b/src/openrct2/util/SawyerCoding.h @@ -41,14 +41,14 @@ enum FILE_TYPE_SC4 = (2 << 2) }; -uint32_t sawyercoding_calculate_checksum(const uint8_t* buffer, size_t length); -size_t sawyercoding_write_chunk_buffer(uint8_t* dst_file, const uint8_t* src_buffer, sawyercoding_chunk_header chunkHeader); -size_t sawyercoding_decode_sv4(const uint8_t* src, uint8_t* dst, size_t length, size_t bufferLength); -size_t sawyercoding_decode_sc4(const uint8_t* src, uint8_t* dst, size_t length, size_t bufferLength); -size_t sawyercoding_encode_sv4(const uint8_t* src, uint8_t* dst, size_t length); -size_t sawyercoding_decode_td6(const uint8_t* src, uint8_t* dst, size_t length); -size_t sawyercoding_encode_td6(const uint8_t* src, uint8_t* dst, size_t length); -int32_t sawyercoding_validate_track_checksum(const uint8_t* src, size_t length); +uint32_t SawyerCodingCalculateChecksum(const uint8_t* buffer, size_t length); +size_t SawyerCodingWriteChunkBuffer(uint8_t* dst_file, const uint8_t* src_buffer, sawyercoding_chunk_header chunkHeader); +size_t SawyerCodingDecodeSV4(const uint8_t* src, uint8_t* dst, size_t length, size_t bufferLength); +size_t SawyerCodingDecodeSC4(const uint8_t* src, uint8_t* dst, size_t length, size_t bufferLength); +size_t SawyerCodingEencodeSV4(const uint8_t* src, uint8_t* dst, size_t length); +size_t SawyerCodingDecodeTD6(const uint8_t* src, uint8_t* dst, size_t length); +size_t SawyerCodingEncodeTD6(const uint8_t* src, uint8_t* dst, size_t length); +int32_t SawyerCodingValidateTrackChecksum(const uint8_t* src, size_t length); -int32_t sawyercoding_detect_file_type(const uint8_t* src, size_t length); -int32_t sawyercoding_detect_rct1_version(int32_t gameVersion); +int32_t SawyerCodingDetectFileType(const uint8_t* src, size_t length); +int32_t SawyerCodingDetectRCT1Version(int32_t gameVersion); diff --git a/src/openrct2/util/Util.cpp b/src/openrct2/util/Util.cpp index 827d7c9e70..219688d789 100644 --- a/src/openrct2/util/Util.cpp +++ b/src/openrct2/util/Util.cpp @@ -24,34 +24,34 @@ #include #include -int32_t squaredmetres_to_squaredfeet(int32_t squaredMetres) +int32_t SquaredMetresToSquaredFeet(int32_t squaredMetres) { // 1 metre squared = 10.7639104 feet squared // RCT2 approximates as 11 return squaredMetres * 11; } -int32_t metres_to_feet(int32_t metres) +int32_t MetresToFeet(int32_t metres) { // 1 metre = 3.2808399 feet // RCT2 approximates as 3.28125 return (metres * 840) / 256; } -int32_t mph_to_kmph(int32_t mph) +int32_t MphToKmph(int32_t mph) { // 1 mph = 1.60934 kmph // RCT2 approximates as 1.609375 return (mph * 1648) >> 10; } -int32_t mph_to_dmps(int32_t mph) +int32_t MphToDmps(int32_t mph) { // 1 mph = 4.4704 decimeters/s return (mph * 73243) >> 14; } -int32_t bitscanforward(int32_t source) +int32_t UtilBitScanForward(int32_t source) { #if defined(_MSC_VER) && (_MSC_VER >= 1400) // Visual Studio 2005 DWORD i; @@ -73,7 +73,7 @@ int32_t bitscanforward(int32_t source) #endif } -int32_t bitscanforward(int64_t source) +int32_t UtilBitScanForward(int64_t source) { #if defined(_MSC_VER) && (_MSC_VER >= 1400) && defined(_M_X64) // Visual Studio 2005 DWORD i; @@ -105,7 +105,7 @@ int32_t bitscanforward(int64_t source) #endif #ifdef OPENRCT2_X86 -static bool cpuid_x86(uint32_t* cpuid_outdata, int32_t eax) +static bool CPUIDX86(uint32_t* cpuid_outdata, int32_t eax) { # if defined(OpenRCT2_CPUID_GNUC_X86) int ret = __get_cpuid(eax, &cpuid_outdata[0], &cpuid_outdata[1], &cpuid_outdata[2], &cpuid_outdata[3]); @@ -119,12 +119,12 @@ static bool cpuid_x86(uint32_t* cpuid_outdata, int32_t eax) } #endif // OPENRCT2_X86 -bool sse41_available() +bool SSE41Available() { #ifdef OPENRCT2_X86 // SSE4.1 support is declared as the 19th bit of ECX with CPUID(EAX = 1). uint32_t regs[4] = { 0 }; - if (cpuid_x86(regs, 1)) + if (CPUIDX86(regs, 1)) { return (regs[2] & (1 << 19)); } @@ -132,7 +132,7 @@ bool sse41_available() return false; } -bool avx2_available() +bool AVX2Available() { #ifdef OPENRCT2_X86 // For GCC and similar use the builtin function, as cpuid changed its semantics in @@ -144,7 +144,7 @@ bool avx2_available() # else // AVX2 support is declared as the 5th bit of EBX with CPUID(EAX = 7, ECX = 0). uint32_t regs[4] = { 0 }; - if (cpuid_x86(regs, 7)) + if (CPUIDX86(regs, 7)) { bool avxCPUSupport = (regs[1] & (1 << 5)) != 0; if (avxCPUSupport) @@ -161,12 +161,12 @@ bool avx2_available() return false; } -static bool bitcount_popcnt_available() +static bool BitcountPopcntAvailable() { #ifdef OPENRCT2_X86 // POPCNT support is declared as the 23rd bit of ECX with CPUID(EAX = 1). uint32_t regs[4] = { 0 }; - if (cpuid_x86(regs, 1)) + if (CPUIDX86(regs, 1)) { return (regs[2] & (1 << 23)); } @@ -174,7 +174,7 @@ static bool bitcount_popcnt_available() return false; } -static int32_t bitcount_popcnt(uint32_t source) +static int32_t BitcountPopcnt(uint32_t source) { // Use CPUID defines to figure out calling style #if defined(OpenRCT2_CPUID_GNUC_X86) @@ -191,7 +191,7 @@ static int32_t bitcount_popcnt(uint32_t source) #endif } -static int32_t bitcount_lut(uint32_t source) +static int32_t BitcountLut(uint32_t source) { // https://graphics.stanford.edu/~seander/bithacks.html static constexpr const uint8_t BitsSetTable256[256] = { @@ -206,12 +206,12 @@ static int32_t bitcount_lut(uint32_t source) static int32_t (*bitcount_fn)(uint32_t); -void bitcount_init() +void BitCountInit() { - bitcount_fn = bitcount_popcnt_available() ? bitcount_popcnt : bitcount_lut; + bitcount_fn = BitcountPopcntAvailable() ? BitcountPopcnt : BitcountLut; } -int32_t bitcount(uint32_t source) +int32_t BitCount(uint32_t source) { return bitcount_fn(source); } @@ -223,7 +223,7 @@ int32_t bitcount(uint32_t source) // - Guest 100 // - John v2.0 // - John v2.1 -int32_t strlogicalcmp(const char* s1, const char* s2) +int32_t StrLogicalCmp(const char* s1, const char* s2) { for (;;) { @@ -255,7 +255,7 @@ int32_t strlogicalcmp(const char* s1, const char* s2) } } -char* safe_strcpy(char* destination, const char* source, size_t size) +char* SafeStrCpy(char* destination, const char* source, size_t size) { assert(destination != nullptr); assert(source != nullptr); @@ -289,7 +289,7 @@ char* safe_strcpy(char* destination, const char* source, size_t size) return result; } -char* safe_strcat(char* destination, const char* source, size_t size) +char* SafeStrCat(char* destination, const char* source, size_t size) { assert(destination != nullptr); assert(source != nullptr); @@ -336,7 +336,7 @@ char* safe_strcat(char* destination, const char* source, size_t size) return result; } -uint32_t util_rand() +uint32_t UtilRand() { thread_local std::mt19937 _prng(std::random_device{}()); return _prng(); @@ -344,7 +344,7 @@ uint32_t util_rand() // Returns a random floating point number from the Standard Normal Distribution; mean of 0 and standard deviation of 1. // TODO: In C++20 this can be templated, where the standard deviation is passed as a value template argument. -float util_rand_normal_distributed() +float UtilRandNormalDistributed() { thread_local std::mt19937 _prng{ std::random_device{}() }; thread_local std::normal_distribution _distributor{ 0.0f, 1.0f }; @@ -355,7 +355,7 @@ constexpr size_t CHUNK = 128 * 1024; // Compress the source to gzip-compatible stream, write to dest. // Mainly used for compressing the crashdumps -bool util_gzip_compress(FILE* source, FILE* dest) +bool UtilGzipCompress(FILE* source, FILE* dest) { if (source == nullptr || dest == nullptr) { @@ -508,7 +508,7 @@ std::vector Ungzip(const void* data, const size_t dataLen) } // Type-independent code left as macro to reduce duplicate code. -#define add_clamp_body(value, value_to_add, min_cap, max_cap) \ +#define ADD_CLAMP_BODY(value, value_to_add, min_cap, max_cap) \ if ((value_to_add > 0) && (value > (max_cap - (value_to_add)))) \ { \ value = max_cap; \ @@ -522,57 +522,57 @@ std::vector Ungzip(const void* data, const size_t dataLen) value += value_to_add; \ } -int8_t add_clamp_int8_t(int8_t value, int8_t value_to_add) +int8_t AddClamp_int8_t(int8_t value, int8_t value_to_add) { - add_clamp_body(value, value_to_add, INT8_MIN, INT8_MAX); + ADD_CLAMP_BODY(value, value_to_add, INT8_MIN, INT8_MAX); return value; } -int16_t add_clamp_int16_t(int16_t value, int16_t value_to_add) +int16_t AddClamp_int16_t(int16_t value, int16_t value_to_add) { - add_clamp_body(value, value_to_add, INT16_MIN, INT16_MAX); + ADD_CLAMP_BODY(value, value_to_add, INT16_MIN, INT16_MAX); return value; } -int32_t add_clamp_int32_t(int32_t value, int32_t value_to_add) +int32_t AddClamp_int32_t(int32_t value, int32_t value_to_add) { - add_clamp_body(value, value_to_add, INT32_MIN, INT32_MAX); + ADD_CLAMP_BODY(value, value_to_add, INT32_MIN, INT32_MAX); return value; } -int64_t add_clamp_int64_t(int64_t value, int64_t value_to_add) +int64_t AddClamp_int64_t(int64_t value, int64_t value_to_add) { - add_clamp_body(value, value_to_add, INT64_MIN, INT64_MAX); + ADD_CLAMP_BODY(value, value_to_add, INT64_MIN, INT64_MAX); return value; } -money16 add_clamp_money16(money16 value, money16 value_to_add) +money16 AddClamp_money16(money16 value, money16 value_to_add) { // This function is intended only for clarity, as money16 // is technically the same as int16_t assert_struct_size(money16, sizeof(int16_t)); - return add_clamp_int16_t(value, value_to_add); + return AddClamp_int16_t(value, value_to_add); } -money32 add_clamp_money32(money32 value, money32 value_to_add) +money32 AddClamp_money32(money32 value, money32 value_to_add) { // This function is intended only for clarity, as money32 // is technically the same as int32_t assert_struct_size(money32, sizeof(int32_t)); - return add_clamp_int32_t(value, value_to_add); + return AddClamp_int32_t(value, value_to_add); } -money64 add_clamp_money64(money64 value, money64 value_to_add) +money64 AddClamp_money64(money64 value, money64 value_to_add) { // This function is intended only for clarity, as money64 // is technically the same as int64_t assert_struct_size(money64, sizeof(int64_t)); - return add_clamp_int64_t(value, value_to_add); + return AddClamp_int64_t(value, value_to_add); } #undef add_clamp_body -uint8_t lerp(uint8_t a, uint8_t b, float t) +uint8_t Lerp(uint8_t a, uint8_t b, float t) { if (t <= 0) return a; @@ -584,12 +584,12 @@ uint8_t lerp(uint8_t a, uint8_t b, float t) return static_cast(a + amount); } -float flerp(float a, float b, float f) +float FLerp(float a, float b, float f) { return (a * (1.0f - f)) + (b * f); } -uint8_t soft_light(uint8_t a, uint8_t b) +uint8_t SoftLight(uint8_t a, uint8_t b) { float fa = a / 255.0f; float fb = b / 255.0f; @@ -608,7 +608,7 @@ uint8_t soft_light(uint8_t a, uint8_t b) /** * strftime wrapper which appends to an existing string. */ -size_t strcatftime(char* buffer, size_t bufferSize, const char* format, const struct tm* tp) +size_t StrCatfTime(char* buffer, size_t bufferSize, const char* format, const struct tm* tp) { size_t stringLen = strnlen(buffer, bufferSize); if (stringLen < bufferSize) diff --git a/src/openrct2/util/Util.h b/src/openrct2/util/Util.h index 0db2bf3fd8..9e1e460aa1 100644 --- a/src/openrct2/util/Util.h +++ b/src/openrct2/util/Util.h @@ -18,42 +18,42 @@ #include #include -int32_t squaredmetres_to_squaredfeet(int32_t squaredMetres); -int32_t metres_to_feet(int32_t metres); -int32_t mph_to_kmph(int32_t mph); -int32_t mph_to_dmps(int32_t mph); +int32_t SquaredMetresToSquaredFeet(int32_t squaredMetres); +int32_t MetresToFeet(int32_t metres); +int32_t MphToKmph(int32_t mph); +int32_t MphToDmps(int32_t mph); -bool sse41_available(); -bool avx2_available(); +bool SSE41Available(); +bool AVX2Available(); -int32_t bitscanforward(int32_t source); -int32_t bitscanforward(int64_t source); -void bitcount_init(); -int32_t bitcount(uint32_t source); -int32_t strlogicalcmp(char const* a, char const* b); -char* safe_strcpy(char* destination, const char* source, size_t num); -char* safe_strcat(char* destination, const char* source, size_t size); +int32_t UtilBitScanForward(int32_t source); +int32_t UtilBitScanForward(int64_t source); +void BitCountInit(); +int32_t BitCount(uint32_t source); +int32_t StrLogicalCmp(char const* a, char const* b); +char* SafeStrCpy(char* destination, const char* source, size_t num); +char* SafeStrCat(char* destination, const char* source, size_t size); -uint32_t util_rand(); -float util_rand_normal_distributed(); +uint32_t UtilRand(); +float UtilRandNormalDistributed(); -bool util_gzip_compress(FILE* source, FILE* dest); +bool UtilGzipCompress(FILE* source, FILE* dest); std::vector Gzip(const void* data, const size_t dataLen); std::vector Ungzip(const void* data, const size_t dataLen); -int8_t add_clamp_int8_t(int8_t value, int8_t value_to_add); -int16_t add_clamp_int16_t(int16_t value, int16_t value_to_add); -int32_t add_clamp_int32_t(int32_t value, int32_t value_to_add); -int64_t add_clamp_int64_t(int64_t value, int64_t value_to_add); -money16 add_clamp_money16(money16 value, money16 value_to_add); -money32 add_clamp_money32(money32 value, money32 value_to_add); -money64 add_clamp_money64(money64 value, money64 value_to_add); +int8_t AddClamp_int8_t(int8_t value, int8_t value_to_add); +int16_t AddClamp_int16_t(int16_t value, int16_t value_to_add); +int32_t AddClamp_int32_t(int32_t value, int32_t value_to_add); +int64_t AddClamp_int64_t(int64_t value, int64_t value_to_add); +money16 AddClamp_money16(money16 value, money16 value_to_add); +money32 AddClamp_money32(money32 value, money32 value_to_add); +money64 AddClamp_money64(money64 value, money64 value_to_add); -uint8_t lerp(uint8_t a, uint8_t b, float t); -float flerp(float a, float b, float t); -uint8_t soft_light(uint8_t a, uint8_t b); +uint8_t Lerp(uint8_t a, uint8_t b, float t); +float FLerp(float a, float b, float t); +uint8_t SoftLight(uint8_t a, uint8_t b); -size_t strcatftime(char* buffer, size_t bufferSize, const char* format, const struct tm* tp); +size_t StrCatfTime(char* buffer, size_t bufferSize, const char* format, const struct tm* tp); template [[nodiscard]] constexpr uint64_t EnumToFlag(T v) { diff --git a/src/openrct2/world/Climate.cpp b/src/openrct2/world/Climate.cpp index 07a7f266de..12f96a7ebb 100644 --- a/src/openrct2/world/Climate.cpp +++ b/src/openrct2/world/Climate.cpp @@ -185,7 +185,7 @@ void ClimateUpdate() || gClimateCurrent.WeatherEffect == WeatherEffectType::Blizzard) { // Create new thunder and lightning - uint32_t randomNumber = util_rand(); + uint32_t randomNumber = UtilRand(); if ((randomNumber & 0xFFFF) <= 0x1B4) { randomNumber >>= 16; @@ -399,7 +399,7 @@ static void ClimateUpdateLightning() _lightningTimer--; if (gClimateLightningFlash == 0) { - if ((util_rand() & 0xFFFF) <= 0x2000) + if ((UtilRand() & 0xFFFF) <= 0x2000) { gClimateLightningFlash = 1; } @@ -411,7 +411,7 @@ static void ClimateUpdateThunder() _thunderTimer--; if (_thunderTimer == 0) { - uint32_t randomNumber = util_rand(); + uint32_t randomNumber = UtilRand(); if (randomNumber & 0x10000) { if (_thunderStatus[0] == THUNDER_STATUS::NONE && _thunderStatus[1] == THUNDER_STATUS::NONE) diff --git a/src/openrct2/world/Footpath.cpp b/src/openrct2/world/Footpath.cpp index c348083ca8..1a679a1808 100644 --- a/src/openrct2/world/Footpath.cpp +++ b/src/openrct2/world/Footpath.cpp @@ -356,7 +356,7 @@ CoordsXY FootpathBridgeGetInfoFromPos(const ScreenCoordsXY& screenCoords, int32_ int32_t directions = (*tileElement)->AsEntrance()->GetDirections(); if (directions & 0x0F) { - int32_t bx = bitscanforward(directions); + int32_t bx = UtilBitScanForward(directions); bx += (*tileElement)->AsEntrance()->GetDirection(); bx &= 3; if (direction != nullptr) @@ -373,7 +373,7 @@ CoordsXY FootpathBridgeGetInfoFromPos(const ScreenCoordsXY& screenCoords, int32_ int32_t directions = (*tileElement)->AsEntrance()->GetDirections(); if (directions & 0x0F) { - int32_t bx = (*tileElement)->GetDirectionWithOffset(bitscanforward(directions)); + int32_t bx = (*tileElement)->GetDirectionWithOffset(UtilBitScanForward(directions)); if (direction != nullptr) *direction = bx; return info.Loc; @@ -1132,7 +1132,7 @@ void FootpathChainRideQueue( // Fix #2051: Stop queue paths that are already connected to two other tiles // from connecting to the tile we are coming from. int32_t edges = tileElement->AsPath()->GetEdges(); - int32_t numEdges = bitcount(edges); + int32_t numEdges = BitCount(edges); if (numEdges >= 2) { int32_t requiredEdgeMask = 1 << DirectionReverse(direction); @@ -1281,7 +1281,7 @@ static void FootpathFixOwnership(const CoordsXY& mapPos) static bool GetNextDirection(int32_t edges, int32_t* direction) { - int32_t index = bitscanforward(edges); + int32_t index = UtilBitScanForward(edges); if (index == -1) return false; diff --git a/src/openrct2/world/Location.hpp b/src/openrct2/world/Location.hpp index b8ad922e3e..2ec90a7311 100644 --- a/src/openrct2/world/Location.hpp +++ b/src/openrct2/world/Location.hpp @@ -228,7 +228,7 @@ struct CoordsXY constexpr CoordsXY ToTileStart() const { - return { floor2(x, COORDS_XY_STEP), floor2(y, COORDS_XY_STEP) }; + return { Floor2(x, COORDS_XY_STEP), Floor2(y, COORDS_XY_STEP) }; } constexpr bool IsNull() const @@ -277,7 +277,7 @@ struct CoordsXYZ : public CoordsXY constexpr CoordsXYZ ToTileStart() const { - return { floor2(x, COORDS_XY_STEP), floor2(y, COORDS_XY_STEP), z }; + return { Floor2(x, COORDS_XY_STEP), Floor2(y, COORDS_XY_STEP), z }; } constexpr CoordsXYZ ToTileCentre() const @@ -662,7 +662,7 @@ struct CoordsXYZD : public CoordsXYZ constexpr CoordsXYZD ToTileStart() const { - return { floor2(x, COORDS_XY_STEP), floor2(y, COORDS_XY_STEP), z, direction }; + return { Floor2(x, COORDS_XY_STEP), Floor2(y, COORDS_XY_STEP), z, direction }; } constexpr CoordsXYZD ToTileCentre() const diff --git a/src/openrct2/world/MapGen.cpp b/src/openrct2/world/MapGen.cpp index 6dda548bdd..d96ff59e18 100644 --- a/src/openrct2/world/MapGen.cpp +++ b/src/openrct2/world/MapGen.cpp @@ -160,7 +160,7 @@ void MapGenGenerate(mapgen_settings* settings) // Fall back to the first available surface texture that is available in the park floorTexture = TerrainSurfaceObject::GetById(0)->GetIdentifier(); else - floorTexture = availableTerrains[util_rand() % availableTerrains.size()]; + floorTexture = availableTerrains[UtilRand() % availableTerrains.size()]; } if (edgeTexture.empty()) @@ -206,7 +206,7 @@ void MapGenGenerate(mapgen_settings* settings) std::fill_n(_height, _heightSize.y * _heightSize.x, 0x00); MapGenSimplex(settings); - MapGenSmoothHeight(2 + (util_rand() % 6)); + MapGenSmoothHeight(2 + (UtilRand() % 6)); // Set the game map to the height map MapGenSetHeight(settings); @@ -222,7 +222,7 @@ void MapGenGenerate(mapgen_settings* settings) // Add sandy beaches std::string_view beachTexture = floorTexture; - if (settings->floor == -1 && floorTexture == "rct2.terrain_surface.grass" && (util_rand() & 1)) + if (settings->floor == -1 && floorTexture == "rct2.terrain_surface.grass" && (UtilRand() & 1)) { std::vector availableBeachTextures; if (objectManager.GetLoadedObject(ObjectEntryDescriptor("rct2.terrain_surface.sand")) != nullptr) @@ -231,7 +231,7 @@ void MapGenGenerate(mapgen_settings* settings) availableBeachTextures.push_back("rct2.terrain_surface.sand_brown"); if (!availableBeachTextures.empty()) - beachTexture = availableBeachTextures[util_rand() % availableBeachTextures.size()]; + beachTexture = availableBeachTextures[UtilRand() % availableBeachTextures.size()]; } auto beachTextureId = objectManager.GetLoadedObjectEntryIndex(ObjectEntryDescriptor(beachTexture)); @@ -265,7 +265,7 @@ static void MapGenPlaceTree(ObjectEntryIndex type, const CoordsXY& loc) Guard::Assert(sceneryElement != nullptr); sceneryElement->SetClearanceZ(surfaceZ + sceneryEntry->height); - sceneryElement->SetDirection(util_rand() & 3); + sceneryElement->SetDirection(UtilRand() & 3); sceneryElement->SetEntryIndex(type); sceneryElement->SetAge(0); sceneryElement->SetPrimaryColour(COLOUR_YELLOW); @@ -333,7 +333,7 @@ static void MapGenPlaceTrees() // Place trees CoordsXY pos; - float treeToLandRatio = (10 + (util_rand() % 30)) / 100.0f; + float treeToLandRatio = (10 + (UtilRand() % 30)) / 100.0f; for (int32_t y = 1; y < gMapSize.y - 1; y++) { for (int32_t x = 1; x < gMapSize.x - 1; x++) @@ -380,27 +380,27 @@ static void MapGenPlaceTrees() // Use tree:land ratio except when near an oasis constexpr static auto randModulo = 0xFFFF; - if (static_cast(util_rand() & randModulo) / randModulo > std::max(treeToLandRatio, oasisScore)) + if (static_cast(UtilRand() & randModulo) / randModulo > std::max(treeToLandRatio, oasisScore)) continue; // Use fractal noise to group tiles that are likely to spawn trees together float noiseValue = FractalNoise(x, y, 0.025f, 2, 2.0f, 0.65f); // Reduces the range to rarely stray further than 0.5 from the mean. - float noiseOffset = util_rand_normal_distributed() * 0.25f; + float noiseOffset = UtilRandNormalDistributed() * 0.25f; if (noiseValue + oasisScore < noiseOffset) continue; if (!grassTreeIds.empty() && MapGenSurfaceTakesGrassTrees(surfaceStyleObject)) { - treeObjectEntryIndex = grassTreeIds[util_rand() % grassTreeIds.size()]; + treeObjectEntryIndex = grassTreeIds[UtilRand() % grassTreeIds.size()]; } else if (!desertTreeIds.empty() && MapGenSurfaceTakesSandTrees(surfaceStyleObject)) { - treeObjectEntryIndex = desertTreeIds[util_rand() % desertTreeIds.size()]; + treeObjectEntryIndex = desertTreeIds[UtilRand() % desertTreeIds.size()]; } else if (!snowTreeIds.empty() && MapGenSurfaceTakesSnowTrees(surfaceStyleObject)) { - treeObjectEntryIndex = snowTreeIds[util_rand() % snowTreeIds.size()]; + treeObjectEntryIndex = snowTreeIds[UtilRand() % snowTreeIds.size()]; } if (treeObjectEntryIndex != OBJECT_ENTRY_INDEX_NULL) @@ -525,7 +525,7 @@ static void NoiseRand() { for (auto& i : perm) { - i = util_rand() & 0xFF; + i = UtilRand() & 0xFF; } } diff --git a/src/openrct2/world/Park.cpp b/src/openrct2/world/Park.cpp index b823d04160..e5bde73546 100644 --- a/src/openrct2/world/Park.cpp +++ b/src/openrct2/world/Park.cpp @@ -511,7 +511,7 @@ money64 Park::CalculateCompanyValue() const auto result = gParkValue - gBankLoan; // Clamp addition to prevent overflow - result = add_clamp_money64(result, FinanceGetCurrentCash()); + result = AddClamp_money64(result, FinanceGetCurrentCash()); return result; } diff --git a/test/tests/SawyerCodingTest.cpp b/test/tests/SawyerCodingTest.cpp index 246f7c7ae8..fa7dc628d5 100644 --- a/test/tests/SawyerCodingTest.cpp +++ b/test/tests/SawyerCodingTest.cpp @@ -38,7 +38,7 @@ protected: chdr_in.encoding = encoding_type; chdr_in.length = sizeof(randomdata); uint8_t* encodedDataBuffer = new uint8_t[BUFFER_SIZE]; - size_t encodedDataSize = sawyercoding_write_chunk_buffer( + size_t encodedDataSize = SawyerCodingWriteChunkBuffer( encodedDataBuffer, reinterpret_cast(randomdata), chdr_in); ASSERT_GT(encodedDataSize, sizeof(sawyercoding_chunk_header)); @@ -99,7 +99,7 @@ TEST_F(SawyerCodingTest, decode_chunk_none) TestDecode(nonedata, sizeof(nonedata)); } -TEST_F(SawyerCodingTest, decode_chunk_rle) +TEST_F(SawyerCodingTest, DecodeChunkRLE) { TestDecode(rledata, sizeof(rledata)); } diff --git a/test/tests/StringTest.cpp b/test/tests/StringTest.cpp index e6f90edf14..fd14d93052 100644 --- a/test/tests/StringTest.cpp +++ b/test/tests/StringTest.cpp @@ -141,10 +141,10 @@ TEST_F(StringTest, ToUpper_Japanese) ASSERT_STREQ(actual.c_str(), u8"日本語で大文字がなし"); } -TEST_F(StringTest, strlogicalcmp) +TEST_F(StringTest, StrLogicalCmp) { - auto res_logical_1 = strlogicalcmp("foo1", "foo1_2"); - auto res_logical_2 = strlogicalcmp("foo1_2", "foo1"); + auto res_logical_1 = StrLogicalCmp("foo1", "foo1_2"); + auto res_logical_2 = StrLogicalCmp("foo1_2", "foo1"); auto res_1 = strcmp("foo1", "foo1_2"); auto res_2 = strcmp("foo1_2", "foo1"); // We only care if sign is correct, actual values might not be. @@ -152,22 +152,22 @@ TEST_F(StringTest, strlogicalcmp) EXPECT_GE(res_2 * res_logical_2, 1); EXPECT_NE(res_logical_1, res_logical_2); - EXPECT_GT(strlogicalcmp("foo12", "foo1"), 0); - EXPECT_LT(strlogicalcmp("foo12", "foo13"), 0); - EXPECT_EQ(strlogicalcmp("foo13", "foo13"), 0); + EXPECT_GT(StrLogicalCmp("foo12", "foo1"), 0); + EXPECT_LT(StrLogicalCmp("foo12", "foo13"), 0); + EXPECT_EQ(StrLogicalCmp("foo13", "foo13"), 0); - EXPECT_EQ(strlogicalcmp("foo13", "FOO13"), 0); + EXPECT_EQ(StrLogicalCmp("foo13", "FOO13"), 0); - EXPECT_LT(strlogicalcmp("A", "b"), 0); - EXPECT_LT(strlogicalcmp("a", "B"), 0); - EXPECT_GT(strlogicalcmp("B", "a"), 0); - EXPECT_GT(strlogicalcmp("b", "A"), 0); + EXPECT_LT(StrLogicalCmp("A", "b"), 0); + EXPECT_LT(StrLogicalCmp("a", "B"), 0); + EXPECT_GT(StrLogicalCmp("B", "a"), 0); + EXPECT_GT(StrLogicalCmp("b", "A"), 0); // ^ is used at the start of a ride name to move it to the end of the list - EXPECT_LT(strlogicalcmp("A", "^"), 0); - EXPECT_LT(strlogicalcmp("a", "^"), 0); - EXPECT_LT(strlogicalcmp("!", "A"), 0); - EXPECT_LT(strlogicalcmp("!", "a"), 0); + EXPECT_LT(StrLogicalCmp("A", "^"), 0); + EXPECT_LT(StrLogicalCmp("a", "^"), 0); + EXPECT_LT(StrLogicalCmp("!", "A"), 0); + EXPECT_LT(StrLogicalCmp("!", "a"), 0); } class CodepointViewTest : public testing::Test