diff --git a/src/openrct2/object/ObjectFactory.cpp b/src/openrct2/object/ObjectFactory.cpp index fd4fcafb70..88b2ad0127 100644 --- a/src/openrct2/object/ObjectFactory.cpp +++ b/src/openrct2/object/ObjectFactory.cpp @@ -374,9 +374,9 @@ namespace ObjectFactory auto originalName = originalId; if (originalId.length() == 8 + 1 + 8 + 1 + 8) { - entry.flags = std::stoul(originalId.substr(0, 8), 0, 16); + entry.flags = std::stoul(originalId.substr(0, 8), nullptr, 16); originalName = originalId.substr(9, 8); - entry.checksum = std::stoul(originalId.substr(18, 8), 0, 16); + entry.checksum = std::stoul(originalId.substr(18, 8), nullptr, 16); } auto minLength = std::min(8, originalName.length()); memcpy(entry.name, originalName.c_str(), minLength); diff --git a/src/openrct2/platform/Windows.cpp b/src/openrct2/platform/Windows.cpp index 04c8cffb33..e7718db912 100644 --- a/src/openrct2/platform/Windows.cpp +++ b/src/openrct2/platform/Windows.cpp @@ -53,7 +53,7 @@ static HMODULE plaform_get_dll_module() { if (_dllModule == nullptr) { - _dllModule = GetModuleHandle(NULL); + _dllModule = GetModuleHandle(nullptr); } return _dllModule; } @@ -112,7 +112,7 @@ bool platform_ensure_directory_exists(const utf8* path) return 1; wchar_t* wPath = utf8_to_widechar(path); - BOOL success = CreateDirectoryW(wPath, NULL); + BOOL success = CreateDirectoryW(wPath, nullptr); free(wPath); return success == TRUE; } @@ -152,7 +152,7 @@ bool platform_lock_single_instance() if (mutex == nullptr) { // Create new mutex - status = CreateMutex(NULL, FALSE, SINGLE_INSTANCE_MUTEX_NAME); + status = CreateMutex(nullptr, FALSE, SINGLE_INSTANCE_MUTEX_NAME); if (status == nullptr) log_error("unable to create mutex\n"); @@ -210,14 +210,14 @@ bool platform_get_steam_path(utf8* outPath, size_t outSize) return false; // Get the size of the path first - if (RegQueryValueExW(hKey, L"SteamPath", 0, &type, NULL, &size) != ERROR_SUCCESS) + if (RegQueryValueExW(hKey, L"SteamPath", nullptr, &type, nullptr, &size) != ERROR_SUCCESS) { RegCloseKey(hKey); return false; } wSteamPath = (wchar_t*)malloc(size); - result = RegQueryValueExW(hKey, L"SteamPath", 0, &type, (LPBYTE)wSteamPath, &size); + result = RegQueryValueExW(hKey, L"SteamPath", nullptr, &type, (LPBYTE)wSteamPath, &size); if (result == ERROR_SUCCESS) { utf8* utf8SteamPath = widechar_to_utf8(wSteamPath); @@ -329,7 +329,7 @@ uint8_t platform_get_locale_currency() CHAR currCode[4]; if (GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SINTLSYMBOL, (LPSTR)&currCode, sizeof(currCode)) == 0) { - return platform_get_currency_value(NULL); + return platform_get_currency_value(nullptr); } return platform_get_currency_value(currCode); @@ -429,7 +429,7 @@ bool platform_get_font_path(TTFFontDescriptor* font, utf8* buffer, size_t size) # if !defined(__MINGW32__) \ && ((NTDDI_VERSION >= NTDDI_VISTA) && !defined(_USING_V110_SDK71_) && !defined(_ATL_XP_TARGETING)) wchar_t* fontFolder; - if (SUCCEEDED(SHGetKnownFolderPath(FOLDERID_Fonts, 0, NULL, &fontFolder))) + if (SUCCEEDED(SHGetKnownFolderPath(FOLDERID_Fonts, 0, nullptr, &fontFolder))) { // Convert wchar to utf8, then copy the font folder path to the buffer. utf8* outPathTemp = widechar_to_utf8(fontFolder); @@ -463,7 +463,7 @@ utf8* platform_get_absolute_path(const utf8* relativePath, const utf8* basePath) wchar_t* pathW = utf8_to_widechar(path); wchar_t fullPathW[MAX_PATH]; - DWORD fullPathLen = GetFullPathNameW(pathW, (DWORD)Util::CountOf(fullPathW), fullPathW, NULL); + DWORD fullPathLen = GetFullPathNameW(pathW, (DWORD)Util::CountOf(fullPathW), fullPathW, nullptr); free(pathW); @@ -547,7 +547,7 @@ static bool windows_setup_file_association( [[maybe_unused]] int32_t printResult; - GetModuleFileNameW(NULL, exePathW, sizeof(exePathW)); + GetModuleFileNameW(nullptr, exePathW, sizeof(exePathW)); GetModuleFileNameW(plaform_get_dll_module(), dllPathW, sizeof(dllPathW)); wchar_t* extensionW = utf8_to_widechar(extension); @@ -580,7 +580,7 @@ static bool windows_setup_file_association( } // [hRootKey\OpenRCT2.ext] - if (RegSetValueW(hKey, NULL, REG_SZ, fileTypeTextW, 0) != ERROR_SUCCESS) + if (RegSetValueW(hKey, nullptr, REG_SZ, fileTypeTextW, 0) != ERROR_SUCCESS) { goto fail; } @@ -654,7 +654,7 @@ void platform_setup_file_associations() windows_setup_file_association(".td6", "RCT2 Track Design (.td6)", "Install", "\"%1\"", 0); // Refresh explorer - SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL); + SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, nullptr, nullptr); } void platform_remove_file_associations() @@ -668,7 +668,7 @@ void platform_remove_file_associations() windows_remove_file_association(".td6"); // Refresh explorer - SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL); + SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, nullptr, nullptr); } /////////////////////////////////////////////////////////////////////////////// @@ -689,13 +689,13 @@ bool platform_setup_uri_protocol() HKEY hClassKey; if (RegCreateKeyA(hRootKey, "openrct2", &hClassKey) == ERROR_SUCCESS) { - if (RegSetValueA(hClassKey, NULL, REG_SZ, "URL:openrct2", 0) == ERROR_SUCCESS) + if (RegSetValueA(hClassKey, nullptr, REG_SZ, "URL:openrct2", 0) == ERROR_SUCCESS) { - if (RegSetKeyValueA(hClassKey, NULL, "URL Protocol", REG_SZ, "", 0) == ERROR_SUCCESS) + if (RegSetKeyValueA(hClassKey, nullptr, "URL Protocol", REG_SZ, "", 0) == ERROR_SUCCESS) { // [hRootKey\openrct2\shell\open\command] wchar_t exePath[MAX_PATH]; - GetModuleFileNameW(NULL, exePath, MAX_PATH); + GetModuleFileNameW(nullptr, exePath, MAX_PATH); wchar_t buffer[512]; swprintf_s(buffer, sizeof(buffer), L"\"%s\" handle-uri \"%%1\"", exePath); @@ -710,7 +710,7 @@ bool platform_setup_uri_protocol() // mingw-w64 used to define RegSetKeyValueW's signature incorrectly // You need at least mingw-w64 5.0 including this commit: // https://sourceforge.net/p/mingw-w64/mingw-w64/ci/da9341980a4b70be3563ac09b5927539e7da21f7/ - RegSetKeyValueW(hMuiCacheKey, NULL, buffer, REG_SZ, L"OpenRCT2", sizeof(L"OpenRCT2") + 1); + RegSetKeyValueW(hMuiCacheKey, nullptr, buffer, REG_SZ, L"OpenRCT2", sizeof(L"OpenRCT2") + 1); } log_verbose("URI protocol setup successful"); diff --git a/src/openrct2/ride/RideRatings.cpp b/src/openrct2/ride/RideRatings.cpp index bbe3b880c3..548f7b8f97 100644 --- a/src/openrct2/ride/RideRatings.cpp +++ b/src/openrct2/ride/RideRatings.cpp @@ -231,7 +231,7 @@ static void ride_ratings_update_state_2() /* .element = */ tileElement, }; CoordsXYE nextTrackElement; - if (!track_block_get_next(&trackElement, &nextTrackElement, NULL, NULL)) + if (!track_block_get_next(&trackElement, &nextTrackElement, nullptr, nullptr)) { gRideRatingsCalcData.state = RIDE_RATINGS_STATE_4; return; @@ -4440,16 +4440,16 @@ static const ride_ratings_calculation ride_ratings_calculate_func_table[RIDE_TYP ride_ratings_calculate_magic_carpet, // MAGIC_CARPET ride_ratings_calculate_submarine_ride, // SUBMARINE_RIDE ride_ratings_calculate_river_rafts, // RIVER_RAFTS - NULL, // 50 + nullptr, // 50 ride_ratings_calculate_enterprise, // ENTERPRISE - NULL, // 52 - NULL, // 53 - NULL, // 54 - NULL, // 55 + nullptr, // 52 + nullptr, // 53 + nullptr, // 54 + nullptr, // 55 ride_ratings_calculate_inverted_impulse_coaster, // INVERTED_IMPULSE_COASTER ride_ratings_calculate_mini_roller_coaster, // MINI_ROLLER_COASTER ride_ratings_calculate_mine_ride, // MINE_RIDE - NULL, // 59 + nullptr, // 59 ride_ratings_calculate_lim_launched_roller_coaster, // LIM_LAUNCHED_ROLLER_COASTER }; diff --git a/src/openrct2/ride/TrackDesignSave.cpp b/src/openrct2/ride/TrackDesignSave.cpp index 1c19a6595d..a025e8c9fc 100644 --- a/src/openrct2/ride/TrackDesignSave.cpp +++ b/src/openrct2/ride/TrackDesignSave.cpp @@ -319,7 +319,7 @@ static void track_design_save_add_large_scenery(int32_t x, int32_t y, rct_tile_e direction = tileElement->type & 3; sequence = scenery_large_get_sequence(tileElement); - if (!map_large_scenery_get_origin(x, y, z, direction, sequence, &x0, &y0, &z0, NULL)) + if (!map_large_scenery_get_origin(x, y, z, direction, sequence, &x0, &y0, &z0, nullptr)) { return; } @@ -510,7 +510,7 @@ static void track_design_save_remove_large_scenery(int32_t x, int32_t y, rct_til direction = tileElement->type & 3; sequence = scenery_large_get_sequence(tileElement); - if (!map_large_scenery_get_origin(x, y, z, direction, sequence, &x0, &y0, &z0, NULL)) + if (!map_large_scenery_get_origin(x, y, z, direction, sequence, &x0, &y0, &z0, nullptr)) { return; } @@ -1066,7 +1066,7 @@ static bool track_design_save_to_td6_for_tracked_ride(uint8_t rideIndex, rct_tra track++; numTrackElements++; - if (!track_block_get_next(&trackElement, &trackElement, NULL, NULL)) + if (!track_block_get_next(&trackElement, &trackElement, nullptr, nullptr)) { break; } diff --git a/src/openrct2/ride/TrackPaint.cpp b/src/openrct2/ride/TrackPaint.cpp index d81805f73f..5fd79941c3 100644 --- a/src/openrct2/ride/TrackPaint.cpp +++ b/src/openrct2/ride/TrackPaint.cpp @@ -1509,7 +1509,7 @@ void track_paint_util_right_quarter_turn_5_tiles_wooden_supports( { 1, 0xFF, 3, 5, 0xFF, 3, 0 }, }; uint8_t supportType = supportTypes[direction][trackSequence]; - wooden_a_supports_paint_setup(session, supportType, 0, height, session->TrackColours[SCHEME_SUPPORTS], NULL); + wooden_a_supports_paint_setup(session, supportType, 0, height, session->TrackColours[SCHEME_SUPPORTS], nullptr); } } diff --git a/src/openrct2/ride/VehiclePaint.cpp b/src/openrct2/ride/VehiclePaint.cpp index e75d351de9..c87c0e642e 100644 --- a/src/openrct2/ride/VehiclePaint.cpp +++ b/src/openrct2/ride/VehiclePaint.cpp @@ -3117,7 +3117,7 @@ void vehicle_visual_default( */ void vehicle_paint(paint_session* session, const rct_vehicle* vehicle, int32_t imageDirection) { - rct_ride_entry* rideEntry = 0; + rct_ride_entry* rideEntry = nullptr; const rct_ride_entry_vehicle* vehicleEntry; int32_t x = vehicle->x; diff --git a/src/openrct2/util/Util.cpp b/src/openrct2/util/Util.cpp index 3921932151..1c0e571e7f 100644 --- a/src/openrct2/util/Util.cpp +++ b/src/openrct2/util/Util.cpp @@ -484,20 +484,20 @@ char* strcasestr(const char* haystack, const char* needle) { const char* p1 = haystack; const char* p2 = needle; - const char* r = *p2 == 0 ? haystack : 0; + const char* r = *p2 == 0 ? haystack : nullptr; while (*p1 != 0 && *p2 != 0) { if (tolower((unsigned char)*p1) == tolower((unsigned char)*p2)) { - if (r == 0) + if (r == nullptr) r = p1; p2++; } else { p2 = needle; - if (r != 0) + if (r != nullptr) p1 = r + 1; if (tolower((unsigned char)*p1) == tolower((unsigned char)*p2)) @@ -507,14 +507,14 @@ char* strcasestr(const char* haystack, const char* needle) } else { - r = 0; + r = nullptr; } } p1++; } - return *p2 == 0 ? (char*)r : 0; + return *p2 == 0 ? (char*)r : nullptr; } #endif diff --git a/src/openrct2/windows/_legacy.cpp b/src/openrct2/windows/_legacy.cpp index 474dcd90c5..076374a0e6 100644 --- a/src/openrct2/windows/_legacy.cpp +++ b/src/openrct2/windows/_legacy.cpp @@ -485,21 +485,21 @@ bool window_ride_construction_update_state( properties = _currentSeatRotationAngle << 12; } - if (_trackType != NULL) + if (_trackType != nullptr) *_trackType = trackType; - if (_trackDirection != NULL) + if (_trackDirection != nullptr) *_trackDirection = trackDirection; - if (_rideIndex != NULL) + if (_rideIndex != nullptr) *_rideIndex = rideIndex; - if (_liftHillAndAlternativeState != NULL) + if (_liftHillAndAlternativeState != nullptr) *_liftHillAndAlternativeState = liftHillAndAlternativeState; - if (_x != NULL) + if (_x != nullptr) *_x = x; - if (_y != NULL) + if (_y != nullptr) *_y = y; - if (_z != NULL) + if (_z != nullptr) *_z = z; - if (_properties != NULL) + if (_properties != nullptr) *_properties = properties; return false; @@ -510,7 +510,7 @@ void window_ride_construction_do_entrance_exit_check() rct_window* w = window_find_by_class(WC_RIDE_CONSTRUCTION); Ride* ride = get_ride(_currentRideIndex); - if (w == NULL || ride == NULL) + if (w == nullptr || ride == nullptr) { return; } @@ -518,7 +518,7 @@ void window_ride_construction_do_entrance_exit_check() if (_rideConstructionState == RIDE_CONSTRUCTION_STATE_0) { w = window_find_by_class(WC_RIDE_CONSTRUCTION); - if (w != NULL) + if (w != nullptr) { if (!ride_are_all_possible_entrances_and_exits_built(ride)) { @@ -535,7 +535,7 @@ void window_ride_construction_do_entrance_exit_check() void window_ride_construction_do_station_check() { Ride* ride = get_ride(_currentRideIndex); - if (ride != NULL) + if (ride != nullptr) { _stationConstructed = ride->num_stations != 0; } @@ -560,7 +560,7 @@ void window_ride_construction_mouseup_demolish_next_piece(int32_t x, int32_t y, int32_t b4 = _currentTrackLiftHill; ride_construction_set_default_next_piece(); window_ride_construction_update_active_elements(); - if (!ride_try_get_origin_element(_currentRideIndex, NULL)) + if (!ride_try_get_origin_element(_currentRideIndex, nullptr)) { ride_initialise_construction_window(_currentRideIndex); _currentTrackPieceDirection = direction & 3; diff --git a/src/openrct2/world/Footpath.cpp b/src/openrct2/world/Footpath.cpp index 156486af2b..ff4dc143e2 100644 --- a/src/openrct2/world/Footpath.cpp +++ b/src/openrct2/world/Footpath.cpp @@ -1663,7 +1663,7 @@ void footpath_connect_edges(int32_t x, int32_t y, rct_tile_element* tileElement, while (neighbour_list_pop(&neighbourList, &neighbour)) { - loc_6A6C85(x, y, neighbour.direction, tileElement, flags, false, NULL); + loc_6A6C85(x, y, neighbour.direction, tileElement, flags, false, nullptr); } if (tileElement->GetType() == TILE_ELEMENT_TYPE_PATH) diff --git a/test/tests/helpers/StringHelpers.hpp b/test/tests/helpers/StringHelpers.hpp index 0fc13c6d41..14a6c59edc 100644 --- a/test/tests/helpers/StringHelpers.hpp +++ b/test/tests/helpers/StringHelpers.hpp @@ -19,7 +19,7 @@ inline std::string StringFromHex(const std::string_view& input) result.reserve(input.size() / 2); for (size_t i = 0; i < input.size(); i += 2) { - auto val = std::stoi(std::string(input.substr(i, 2)), 0, 16); + auto val = std::stoi(std::string(input.substr(i, 2)), nullptr, 16); result.push_back(val); } return result;