diff --git a/src/openrct2-ui/WindowManager.cpp b/src/openrct2-ui/WindowManager.cpp index c24cdecf3f..d5e07643b6 100644 --- a/src/openrct2-ui/WindowManager.cpp +++ b/src/openrct2-ui/WindowManager.cpp @@ -330,7 +330,7 @@ public: case INTENT_ACTION_REFRESH_STAFF_LIST: { auto w = window_find_by_class(WC_STAFF_LIST); - if (w != NULL) + if (w != nullptr) { w->no_list_items = 0; } diff --git a/src/openrct2-ui/input/MouseInput.cpp b/src/openrct2-ui/input/MouseInput.cpp index e731298b2c..d4389ea955 100644 --- a/src/openrct2-ui/input/MouseInput.cpp +++ b/src/openrct2-ui/input/MouseInput.cpp @@ -678,7 +678,7 @@ static void input_scroll_continue(rct_window * w, rct_widgetindex widgetIndex, s sint32 scroll_part, scroll_id; sint32 x2, y2; - assert(w != NULL); + assert(w != nullptr); widget = &w->widgets[widgetIndex]; if (w->classification != gPressedWidget.window_classification || w->number != gPressedWidget.window_number || @@ -785,7 +785,7 @@ static void input_scroll_part_update_hthumb(rct_window * w, rct_widgetindex widg */ static void input_scroll_part_update_vthumb(rct_window * w, rct_widgetindex widgetIndex, sint32 y, sint32 scroll_id) { - assert(w != NULL); + assert(w != nullptr); rct_widget * widget = &w->widgets[widgetIndex]; if (window_find_by_number(w->classification, w->number)) @@ -824,7 +824,7 @@ static void input_scroll_part_update_vthumb(rct_window * w, rct_widgetindex widg */ static void input_scroll_part_update_hleft(rct_window * w, rct_widgetindex widgetIndex, sint32 scroll_id) { - assert(w != NULL); + assert(w != nullptr); if (window_find_by_number(w->classification, w->number)) { w->scrolls[scroll_id].flags |= HSCROLLBAR_LEFT_PRESSED; @@ -841,7 +841,7 @@ static void input_scroll_part_update_hleft(rct_window * w, rct_widgetindex widge */ static void input_scroll_part_update_hright(rct_window * w, rct_widgetindex widgetIndex, sint32 scroll_id) { - assert(w != NULL); + assert(w != nullptr); rct_widget * widget = &w->widgets[widgetIndex]; if (window_find_by_number(w->classification, w->number)) { @@ -867,7 +867,7 @@ static void input_scroll_part_update_hright(rct_window * w, rct_widgetindex widg */ static void input_scroll_part_update_vtop(rct_window * w, rct_widgetindex widgetIndex, sint32 scroll_id) { - assert(w != NULL); + assert(w != nullptr); if (window_find_by_number(w->classification, w->number)) { w->scrolls[scroll_id].flags |= VSCROLLBAR_UP_PRESSED; @@ -884,7 +884,7 @@ static void input_scroll_part_update_vtop(rct_window * w, rct_widgetindex widget */ static void input_scroll_part_update_vbottom(rct_window * w, rct_widgetindex widgetIndex, sint32 scroll_id) { - assert(w != NULL); + assert(w != nullptr); rct_widget * widget = &w->widgets[widgetIndex]; if (window_find_by_number(w->classification, w->number)) { diff --git a/src/openrct2/actions/PlaceParkEntranceAction.hpp b/src/openrct2/actions/PlaceParkEntranceAction.hpp index 105811b9e8..cdf138eea0 100644 --- a/src/openrct2/actions/PlaceParkEntranceAction.hpp +++ b/src/openrct2/actions/PlaceParkEntranceAction.hpp @@ -120,7 +120,7 @@ public: // Check that entrance element does not already exist at this location rct_tile_element* entranceElement = map_get_park_entrance_element_at(entranceLoc.x, entranceLoc.y, zLow, false); - if (entranceElement != NULL) + if (entranceElement != nullptr) { return std::make_unique(GA_ERROR::ITEM_ALREADY_PLACED, STR_CANT_BUILD_PARK_ENTRANCE_HERE, STR_NONE); } @@ -179,7 +179,7 @@ public: } rct_tile_element* newElement = tile_element_insert(entranceLoc.x / 32, entranceLoc.y / 32, zLow, 0xF); - Guard::Assert(newElement != NULL); + Guard::Assert(newElement != nullptr); newElement->clearance_height = zHigh; if (flags & GAME_COMMAND_FLAG_GHOST) diff --git a/src/openrct2/common.h b/src/openrct2/common.h index 5427de05fc..84880dbc33 100644 --- a/src/openrct2/common.h +++ b/src/openrct2/common.h @@ -193,7 +193,7 @@ typedef fixed64_1dp money64; typedef void (EMPTY_ARGS_VOID_POINTER)(); typedef uint16 rct_string_id; -#define SafeFree(x) do { free(x); (x) = NULL; } while (false) +#define SafeFree(x) do { free(x); (x) = nullptr; } while (false) #define SafeDelete(x) do { delete (x); (x) = nullptr; } while (false) #define SafeDeleteArray(x) do { delete[] (x); (x) = nullptr; } while (false) diff --git a/src/openrct2/interface/Window.cpp b/src/openrct2/interface/Window.cpp index be86c4c02f..d647623486 100644 --- a/src/openrct2/interface/Window.cpp +++ b/src/openrct2/interface/Window.cpp @@ -561,7 +561,7 @@ rct_window *window_create_auto_pos(sint32 width, sint32 height, rct_window_event // if (cls & 0x80) { // cls &= ~0x80; // rct_window *w = window_find_by_number(0, 0); - // if (w != NULL) { + // if (w != nullptr) { // if (w->x > -60 && w->x < screenWidth - 20) { // if (w->y < screenHeight - 20) { // sint32 x = w->x; @@ -984,7 +984,7 @@ void widget_invalidate(rct_window *w, rct_widgetindex widgetIndex) { rct_widget* widget; - assert(w != NULL); + assert(w != nullptr); #ifdef DEBUG for (sint32 i = 0; i <= widgetIndex; i++) { assert(w->widgets[i].type != WWT_LAST); @@ -1084,7 +1084,7 @@ void window_update_scroll_widgets(rct_window *w) widgetIndex = 0; scrollIndex = 0; - assert(w != NULL); + assert(w != nullptr); for (widget = w->widgets; widget->type != WWT_LAST; widget++, widgetIndex++) { if (widget->type != WWT_SCROLL) continue; @@ -1126,7 +1126,7 @@ sint32 window_get_scroll_data_index(rct_window *w, rct_widgetindex widget_index) sint32 i, result; result = 0; - assert(w != NULL); + assert(w != nullptr); for (i = 0; i < widget_index; i++) { if (w->widgets[i].type == WWT_SCROLL) result++; @@ -1307,7 +1307,7 @@ void window_scroll_to_viewport(rct_window *w) { sint32 x, y, z; rct_window *mainWindow; - assert(w != NULL); + assert(w != nullptr); // In original checked to make sure x and y were not -1 as well. if (w->viewport == nullptr || w->viewport_focus_coordinates.y == -1) return; @@ -1350,7 +1350,7 @@ void window_scroll_to_location(rct_window *w, sint32 x, sint32 y, sint32 z) /* .z = */ (sint16)z }; - assert(w != NULL); + assert(w != nullptr); window_unfollow_sprite(w); diff --git a/src/openrct2/localisation/Localisation.cpp b/src/openrct2/localisation/Localisation.cpp index 1dc960d701..00940fa57b 100644 --- a/src/openrct2/localisation/Localisation.cpp +++ b/src/openrct2/localisation/Localisation.cpp @@ -1338,14 +1338,14 @@ sint32 win1252_to_utf8(utf8string dst, const char *src, size_t srcLength, size_t { #ifdef _WIN32 utf16 stackBuffer[256]; - utf16 *heapBuffer = NULL; + utf16 *heapBuffer = nullptr; utf16 *intermediateBuffer = stackBuffer; size_t bufferCount = Util::CountOf(stackBuffer); if (maxBufferLength > bufferCount) { if (srcLength > bufferCount) { bufferCount = srcLength + 4; heapBuffer = (utf16 *)malloc(bufferCount * sizeof(utf16)); - assert(heapBuffer != NULL); + assert(heapBuffer != nullptr); intermediateBuffer = heapBuffer; } } diff --git a/src/openrct2/peep/Peep.h b/src/openrct2/peep/Peep.h index cbcb155c6c..57bf3dbcbb 100644 --- a/src/openrct2/peep/Peep.h +++ b/src/openrct2/peep/Peep.h @@ -710,7 +710,7 @@ enum */ #define FOR_ALL_PEEPS(sprite_index, peep) \ for ((sprite_index) = gSpriteListHead[SPRITE_LIST_PEEP]; (sprite_index) != SPRITE_INDEX_NULL; (sprite_index) = peep->next) \ - if (((peep) = GET_PEEP(sprite_index)) != NULL || 1) + if (((peep) = GET_PEEP(sprite_index)) != nullptr || 1) #define FOR_ALL_GUESTS(sprite_index, peep) \ FOR_ALL_PEEPS(sprite_index, peep) \ diff --git a/src/openrct2/platform/Linux.cpp b/src/openrct2/platform/Linux.cpp index 8b2cd88d45..00e3024860 100644 --- a/src/openrct2/platform/Linux.cpp +++ b/src/openrct2/platform/Linux.cpp @@ -67,7 +67,7 @@ void platform_get_exe_path(utf8 *outPath, size_t outSize) #error "Platform does not support full path exe retrieval" #endif char *exeDelimiter = strrchr(exePath, *PATH_SEPARATOR); - if (exeDelimiter == NULL) + if (exeDelimiter == nullptr) { log_error("should never happen here"); outPath[0] = '\0'; @@ -110,7 +110,7 @@ void platform_posix_sub_resolve_openrct_data_path(utf8 *out, size_t size) { uint16 platform_get_locale_language(){ const char *langString = setlocale(LC_MESSAGES, ""); - if(langString != NULL){ + if(langString != nullptr){ // The locale has the following form: // language[_territory[.codeset]][@modifier] // (see https://www.gnu.org/software/libc/manual/html_node/Locale-Names.html) @@ -130,7 +130,7 @@ uint16 platform_get_locale_language(){ pattern[length] = '\0'; //find _ if present const char *strip = strchr(pattern, '_'); - if(strip != NULL){ + if(strip != nullptr){ // could also use '-', but '?' is more flexible. Maybe LanguagesDescriptors will change. // pattern is now "language?territory" pattern[strip - pattern] = '?'; @@ -155,7 +155,7 @@ uint16 platform_get_locale_language(){ } //no exact match found trying only language part - if(strip != NULL){ + if(strip != nullptr){ pattern[strip - pattern] = '*'; pattern[strip - pattern +1] = '\0'; // pattern is now "language*" for(sint32 i = 1; i < LANGUAGE_COUNT; ++i){ @@ -171,7 +171,7 @@ uint16 platform_get_locale_language(){ uint8 platform_get_locale_currency(){ char *langstring = setlocale(LC_MONETARY, ""); - if (langstring == NULL) { + if (langstring == nullptr) { return platform_get_currency_value(NULL); } @@ -188,7 +188,7 @@ uint8 platform_get_locale_measurement_format(){ const char *langstring = setlocale(LC_ALL, ""); #endif - if(langstring != NULL){ + if(langstring != nullptr){ //using https://en.wikipedia.org/wiki/Metrication#Chronology_and_status_of_conversion_by_country as reference if(!fnmatch("*_US*", langstring, 0) || !fnmatch("*_MM*", langstring, 0) || !fnmatch("*_LR*", langstring, 0)){ return MEASUREMENT_FORMAT_IMPERIAL; @@ -200,7 +200,7 @@ uint8 platform_get_locale_measurement_format(){ bool platform_get_steam_path(utf8 * outPath, size_t outSize) { const char * steamRoot = getenv("STEAMROOT"); - if (steamRoot != NULL) + if (steamRoot != nullptr) { safe_strcpy(outPath, steamRoot, outSize); safe_strcat_path(outPath, "steamapps/common", outSize); @@ -209,7 +209,7 @@ bool platform_get_steam_path(utf8 * outPath, size_t outSize) char steamPath[1024] = { 0 }; const char * localSharePath = getenv("XDG_DATA_HOME"); - if (localSharePath != NULL) + if (localSharePath != nullptr) { safe_strcpy(steamPath, localSharePath, sizeof(steamPath)); safe_strcat_path(steamPath, "Steam/steamapps/common", sizeof(steamPath)); @@ -221,7 +221,7 @@ bool platform_get_steam_path(utf8 * outPath, size_t outSize) } const char * homeDir = getpwuid(getuid())->pw_dir; - if (homeDir != NULL) + if (homeDir != nullptr) { safe_strcpy(steamPath, homeDir, sizeof(steamPath)); safe_strcat_path(steamPath, ".local/share/Steam/steamapps/common", sizeof(steamPath)); @@ -246,8 +246,8 @@ bool platform_get_steam_path(utf8 * outPath, size_t outSize) #ifndef NO_TTF bool platform_get_font_path(TTFFontDescriptor *font, utf8 *buffer, size_t size) { - assert(buffer != NULL); - assert(font != NULL); + assert(buffer != nullptr); + assert(font != nullptr); log_verbose("Looking for font %s with FontConfig.", font->font_name); FcConfig* config = FcInitLoadConfigAndFonts(); @@ -276,7 +276,7 @@ bool platform_get_font_path(TTFFontDescriptor *font, utf8 *buffer, size_t size) // to unrendered characters (tofu) when trying to render e.g. CJK characters using a // Western (sans-)serif font. We therefore ignore substitutions FontConfig provides, // and instead rely on exact matches on the fonts predefined for each font family. - FcChar8* matched_font_face = NULL; + FcChar8* matched_font_face = nullptr; if (FcPatternGetString(match, FC_FULLNAME, 0, &matched_font_face) == FcResultMatch && strcmp(font->font_name, (const char *) matched_font_face) != 0) { @@ -284,7 +284,7 @@ bool platform_get_font_path(TTFFontDescriptor *font, utf8 *buffer, size_t size) is_substitute = true; } - FcChar8* filename = NULL; + FcChar8* filename = nullptr; if (!is_substitute && FcPatternGetString(match, FC_FILE, 0, &filename) == FcResultMatch) { found = true; diff --git a/src/openrct2/platform/Posix.cpp b/src/openrct2/platform/Posix.cpp index 9a5b2930f3..0b80c82ecc 100644 --- a/src/openrct2/platform/Posix.cpp +++ b/src/openrct2/platform/Posix.cpp @@ -52,7 +52,7 @@ static utf8 _openrctDataDirectoryPath[MAX_PATH] = { 0 }; void platform_get_date_utc(rct2_date *out_date) { - assert(out_date != NULL); + assert(out_date != nullptr); time_t rawtime; struct tm * timeinfo; time(&rawtime); @@ -65,7 +65,7 @@ void platform_get_date_utc(rct2_date *out_date) void platform_get_time_utc(rct2_time *out_time) { - assert(out_time != NULL); + assert(out_time != nullptr); time_t rawtime; struct tm * timeinfo; time(&rawtime); @@ -77,7 +77,7 @@ void platform_get_time_utc(rct2_time *out_time) void platform_get_date_local(rct2_date *out_date) { - assert(out_date != NULL); + assert(out_date != nullptr); time_t rawtime; struct tm * timeinfo; time(&rawtime); @@ -90,7 +90,7 @@ void platform_get_date_local(rct2_date *out_date) void platform_get_time_local(rct2_time *out_time) { - assert(out_time != NULL); + assert(out_time != nullptr); time_t rawtime; struct tm * timeinfo; time(&rawtime); @@ -207,14 +207,14 @@ bool platform_directory_delete(const utf8 *path) char* ourPath = _strdup(path); utf8* const patharray[2] = {ourPath, NULL}; - if ((ftsp = fts_open(patharray, FTS_COMFOLLOW | FTS_LOGICAL | FTS_NOCHDIR, NULL)) == NULL) { + if ((ftsp = fts_open(patharray, FTS_COMFOLLOW | FTS_LOGICAL | FTS_NOCHDIR, NULL)) == nullptr) { log_error("fts_open returned NULL"); free(ourPath); return false; } chp = fts_children(ftsp, 0); - if (chp == NULL) { + if (chp == nullptr) { log_verbose("No files to traverse, deleting directory %s", path); if (remove(path) != 0) { @@ -224,7 +224,7 @@ bool platform_directory_delete(const utf8 *path) return true; // No files to traverse } - while ((p = fts_read(ftsp)) != NULL) { + while ((p = fts_read(ftsp)) != nullptr) { switch (p->fts_info) { case FTS_DP: // Directory postorder, which means // the directory is empty @@ -258,7 +258,7 @@ utf8 * platform_get_absolute_path(const utf8 * relative_path, const utf8 * base_ { utf8 path[MAX_PATH]; - if (base_path != NULL) + if (base_path != nullptr) { snprintf(path, MAX_PATH, "%s/%s", base_path, relative_path); } @@ -325,7 +325,7 @@ bool platform_file_copy(const utf8 *srcPath, const utf8 *dstPath, bool overwrite dstFile = fopen(dstPath, "wbx"); } - if (dstFile == NULL) { + if (dstFile == nullptr) { if (errno == EEXIST) { log_warning("platform_file_copy: Not overwriting %s, because overwrite flag == false", dstPath); return false; @@ -337,7 +337,7 @@ bool platform_file_copy(const utf8 *srcPath, const utf8 *dstPath, bool overwrite // Open both files and check whether they are opened correctly FILE *srcFile = fopen(srcPath, "rb"); - if (srcFile == NULL) { + if (srcFile == nullptr) { fclose(dstFile); log_error("Could not open source file %s for copying", srcPath); return false; @@ -418,7 +418,7 @@ void platform_resolve_openrct_data_path() // since our `MAX_PATH` macro is set to some other value, pass NULL to have `realpath` return // a `malloc`ed buffer. char *resolved_path = realpath(gCustomOpenrctDataPath, NULL); - if (resolved_path == NULL) { + if (resolved_path == nullptr) { log_error("Could not resolve path \"%s\", errno = %d", gCustomOpenrctDataPath, errno); return; } else { @@ -463,7 +463,7 @@ uint8 platform_get_locale_temperature_format(){ const char *langstring = setlocale(LC_ALL, ""); #endif - if(langstring != NULL){ + if(langstring != nullptr){ if (!fnmatch("*_US*", langstring, 0) || !fnmatch("*_BS*", langstring, 0) || !fnmatch("*_BZ*", langstring, 0) || @@ -500,7 +500,7 @@ utf8* platform_get_username() { if (pw) { return pw->pw_name; } else { - return NULL; + return nullptr; } } diff --git a/src/openrct2/platform/Shared.cpp b/src/openrct2/platform/Shared.cpp index ac167812f5..9bab992046 100644 --- a/src/openrct2/platform/Shared.cpp +++ b/src/openrct2/platform/Shared.cpp @@ -58,9 +58,9 @@ char * strndup(const char * src, size_t size) size_t len = strnlen(src, size); char * dst = (char *)malloc(len + 1); - if (dst == NULL) + if (dst == nullptr) { - return NULL; + return nullptr; } dst = (char *)memcpy(dst, src, len); @@ -193,7 +193,7 @@ void platform_sleep(uint32 ms) uint8 platform_get_currency_value(const char * currCode) { - if (currCode == NULL || strlen(currCode) < 3) + if (currCode == nullptr || strlen(currCode) < 3) { return CURRENCY_POUNDS; } diff --git a/src/openrct2/platform/Windows.cpp b/src/openrct2/platform/Windows.cpp index c816d0f9c1..1a20891c94 100644 --- a/src/openrct2/platform/Windows.cpp +++ b/src/openrct2/platform/Windows.cpp @@ -57,11 +57,11 @@ static utf8 _openrctDataDirectoryPath[MAX_PATH] = { 0 }; #define OPENRCT2_DLL_MODULE_NAME "openrct2.dll" -static HMODULE _dllModule = NULL; +static HMODULE _dllModule = nullptr; static HMODULE plaform_get_dll_module() { - if (_dllModule == NULL) { + if (_dllModule == nullptr) { _dllModule = GetModuleHandle(NULL); } return _dllModule; @@ -69,7 +69,7 @@ static HMODULE plaform_get_dll_module() void platform_get_date_local(rct2_date *out_date) { - assert(out_date != NULL); + assert(out_date != nullptr); SYSTEMTIME systime; GetLocalTime(&systime); @@ -81,7 +81,7 @@ void platform_get_date_local(rct2_date *out_date) void platform_get_time_local(rct2_time *out_time) { - assert(out_time != NULL); + assert(out_time != nullptr); SYSTEMTIME systime; GetLocalTime(&systime); out_time->hour = systime.wHour; @@ -138,15 +138,15 @@ bool platform_directory_delete(const utf8 *path) free(wPath); SHFILEOPSTRUCTW fileop; - fileop.hwnd = NULL; // no status display + fileop.hwnd = nullptr; // no status display fileop.wFunc = FO_DELETE; // delete operation fileop.pFrom = pszFrom; // source file name as double null terminated string - fileop.pTo = NULL; // no destination needed + fileop.pTo = nullptr; // no destination needed fileop.fFlags = FOF_NOCONFIRMATION | FOF_SILENT; // do not prompt the user fileop.fAnyOperationsAborted = FALSE; - fileop.lpszProgressTitle = NULL; - fileop.hNameMappings = NULL; + fileop.lpszProgressTitle = nullptr; + fileop.hNameMappings = nullptr; sint32 ret = SHFileOperationW(&fileop); return (ret == 0); @@ -158,10 +158,10 @@ bool platform_lock_single_instance() // Check if operating system mutex exists mutex = OpenMutex(MUTEX_ALL_ACCESS, FALSE, SINGLE_INSTANCE_MUTEX_NAME); - if (mutex == NULL) { + if (mutex == nullptr) { // Create new mutex status = CreateMutex(NULL, FALSE, SINGLE_INSTANCE_MUTEX_NAME); - if (status == NULL) + if (status == nullptr) log_error("unable to create mutex\n"); return true; @@ -545,7 +545,7 @@ utf8 * platform_get_absolute_path(const utf8 * relativePath, const utf8 * basePa if (fullPathLen == 0) { - return NULL; + return nullptr; } return widechar_to_utf8(fullPathW); @@ -570,7 +570,7 @@ utf8* platform_get_username() DWORD usernameLength = UNLEN + 1; if (!GetUserName(username, &usernameLength)) { - return NULL; + return nullptr; } return username; @@ -579,7 +579,7 @@ utf8* platform_get_username() bool platform_process_is_elevated() { BOOL isElevated = FALSE; - HANDLE hToken = NULL; + HANDLE hToken = nullptr; if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken)) { TOKEN_ELEVATION Elevation; DWORD tokenSize = sizeof(TOKEN_ELEVATION); @@ -635,8 +635,8 @@ static bool windows_setup_file_association( get_progIdName(progIdNameW, extension); bool result = false; - HKEY hKey = NULL; - HKEY hRootKey = NULL; + HKEY hKey = nullptr; + HKEY hRootKey = nullptr; // [HKEY_CURRENT_USER\Software\Classes] if (RegOpenKeyW(HKEY_CURRENT_USER, SOFTWARE_CLASSES, &hRootKey) != ERROR_SUCCESS) { diff --git a/src/openrct2/ride/RideRatings.cpp b/src/openrct2/ride/RideRatings.cpp index 876387efa1..477eed658c 100644 --- a/src/openrct2/ride/RideRatings.cpp +++ b/src/openrct2/ride/RideRatings.cpp @@ -634,7 +634,7 @@ static void ride_ratings_score_close_proximity(rct_tile_element *inputTileElemen static void ride_ratings_calculate(Ride *ride) { auto calcFunc = ride_ratings_get_calculate_func(ride->type); - if (calcFunc != NULL) { + if (calcFunc != nullptr) { calcFunc(ride); } @@ -828,7 +828,7 @@ static void ride_ratings_apply_adjustments(Ride *ride, rating_tuple *ratings) { rct_ride_entry *rideEntry = get_ride_entry(ride->subtype); - if (rideEntry == NULL) + if (rideEntry == nullptr) { return; } @@ -975,7 +975,7 @@ static sint32 get_num_of_sheltered_eighths(Ride *ride) sint32 dh = numShelteredEighths; rct_ride_entry *rideType = get_ride_entry(ride->subtype); - if (rideType == NULL) + if (rideType == nullptr) { return 0; } diff --git a/src/openrct2/ride/TrackDesignSave.cpp b/src/openrct2/ride/TrackDesignSave.cpp index 58b6d94ffa..9a09ef9034 100644 --- a/src/openrct2/ride/TrackDesignSave.cpp +++ b/src/openrct2/ride/TrackDesignSave.cpp @@ -164,7 +164,7 @@ bool track_design_save(uint8 rideIndex) } _trackDesign = track_design_save_to_td6(rideIndex); - if (_trackDesign == NULL) { + if (_trackDesign == nullptr) { context_show_error(STR_CANT_SAVE_TRACK_DESIGN, gGameCommandErrorText); return false; } @@ -322,7 +322,7 @@ static void track_design_save_add_large_scenery(sint32 x, sint32 y, rct_tile_ele y = y0 + offsetY; z = (z0 + tile->z_offset) / 8; tileElement = map_get_large_scenery_segment(x, y, z, direction, sequence); - if (tileElement != NULL) + if (tileElement != nullptr) { if (sequence == 0) { @@ -423,7 +423,7 @@ static void track_design_save_pop_tile_element(sint32 x, sint32 y, rct_tile_elem ); } _trackSavedTileElementsCount--; - _trackSavedTileElements[_trackSavedTileElementsCount] = NULL; + _trackSavedTileElements[_trackSavedTileElementsCount] = nullptr; } } @@ -503,7 +503,7 @@ static void track_design_save_remove_large_scenery(sint32 x, sint32 y, rct_tile_ y = y0 + offsetY; z = (z0 + tile->z_offset) / 8; tileElement = map_get_large_scenery_segment(x, y, z, direction, sequence); - if (tileElement != NULL) + if (tileElement != nullptr) { if (sequence == 0) { @@ -789,7 +789,7 @@ static rct_track_td6 *track_design_save_to_td6(uint8 rideIndex) if (!result) { track_design_dispose(td6); - td6 = NULL; + td6 = nullptr; } return td6; } @@ -800,7 +800,7 @@ static rct_track_td6 *track_design_save_to_td6(uint8 rideIndex) */ static bool track_design_save_to_td6_for_maze(uint8 rideIndex, rct_track_td6 *td6) { - rct_tile_element *tileElement = NULL; + rct_tile_element *tileElement = nullptr; bool mapFound = false; sint16 startX = 0; sint16 startY = 0; @@ -1172,7 +1172,7 @@ static size_t track_design_get_scenery_elements_count(rct_track_td6 *td6) { size_t count = 0; rct_td6_scenery_element *sceneryElement = td6->scenery_elements; - if (sceneryElement != NULL) { + if (sceneryElement != nullptr) { while (sceneryElement->scenery_object.end_flag != 0xFF) { count++; sceneryElement++; @@ -1232,7 +1232,7 @@ bool track_design_save_to_file(const utf8 *path) // Encode TD6 data uint8 *encodedData = (uint8 *)malloc(0x8000); - assert(td6Buffer.ptr != NULL); + assert(td6Buffer.ptr != nullptr); size_t encodedDataLength = sawyercoding_encode_td6((uint8*)td6Buffer.ptr, encodedData, td6Buffer.length); // Save encoded TD6 data to file diff --git a/src/openrct2/ride/TrackPaint.cpp b/src/openrct2/ride/TrackPaint.cpp index 1be9426f91..2c0792273c 100644 --- a/src/openrct2/ride/TrackPaint.cpp +++ b/src/openrct2/ride/TrackPaint.cpp @@ -994,9 +994,9 @@ void track_paint_util_right_helix_up_small_quarter_tiles_paint(paint_session * s if (sprites[direction][index][0] != 0) { uint32 imageId = sprites[direction][index][0] | colourFlags; - LocationXY16 offset = (offsets == NULL ? LocationXY16{ 0, 0 } : offsets[direction][index][0]); + LocationXY16 offset = (offsets == nullptr ? LocationXY16{ 0, 0 } : offsets[direction][index][0]); LocationXY16 boundsLength = boundsLengths[direction][index][0]; - LocationXYZ16 boundsOffset = (boundsOffsets == NULL ? LocationXYZ16{ offset.x, offset.y, 0 } + LocationXYZ16 boundsOffset = (boundsOffsets == nullptr ? LocationXYZ16{ offset.x, offset.y, 0 } : boundsOffsets[direction][index][0]); sub_98197C(session, imageId, (sint8)offset.x, (sint8)offset.y, boundsLength.x, boundsLength.y, thickness[0], height, @@ -1005,9 +1005,9 @@ void track_paint_util_right_helix_up_small_quarter_tiles_paint(paint_session * s if (sprites[direction][index][1] != 0) { uint32 imageId = sprites[direction][index][1] | colourFlags; - LocationXY16 offset = (offsets == NULL ? LocationXY16{ 0, 0 } : offsets[direction][index][1]); + LocationXY16 offset = (offsets == nullptr ? LocationXY16{ 0, 0 } : offsets[direction][index][1]); LocationXY16 boundsLength = boundsLengths[direction][index][1]; - LocationXYZ16 boundsOffset = (boundsOffsets == NULL ? LocationXYZ16{ offset.x, offset.y, 0 } + LocationXYZ16 boundsOffset = (boundsOffsets == nullptr ? LocationXYZ16{ offset.x, offset.y, 0 } : boundsOffsets[direction][index][1]); sub_98197C(session, imageId, (sint8)offset.x, (sint8)offset.y, boundsLength.x, boundsLength.y, thickness[1], height, @@ -1096,9 +1096,9 @@ void track_paint_util_right_helix_up_large_quarter_tiles_paint(paint_session * s if (sprites[direction][index][0] != 0) { uint32 imageId = sprites[direction][index][0] | colourFlags; - LocationXY16 offset = (offsets == NULL ? LocationXY16{ 0, 0 } : offsets[direction][index][0]); + LocationXY16 offset = (offsets == nullptr ? LocationXY16{ 0, 0 } : offsets[direction][index][0]); LocationXY16 boundsLength = boundsLengths[direction][index][0]; - LocationXYZ16 boundsOffset = (boundsOffsets == NULL ? LocationXYZ16{ offset.x, offset.y, 0 } + LocationXYZ16 boundsOffset = (boundsOffsets == nullptr ? LocationXYZ16{ offset.x, offset.y, 0 } : boundsOffsets[direction][index][0]); sub_98197C(session, imageId, (sint8)offset.x, (sint8)offset.y, boundsLength.x, boundsLength.y, thickness[0], height, @@ -1107,9 +1107,9 @@ void track_paint_util_right_helix_up_large_quarter_tiles_paint(paint_session * s if (sprites[direction][index][1] != 0) { uint32 imageId = sprites[direction][index][1] | colourFlags; - LocationXY16 offset = (offsets == NULL ? LocationXY16{ 0, 0 } : offsets[direction][index][1]); + LocationXY16 offset = (offsets == nullptr ? LocationXY16{ 0, 0 } : offsets[direction][index][1]); LocationXY16 boundsLength = boundsLengths[direction][index][1]; - LocationXYZ16 boundsOffset = (boundsOffsets == NULL ? LocationXYZ16{ offset.x, offset.y, 0 } + LocationXYZ16 boundsOffset = (boundsOffsets == nullptr ? LocationXYZ16{ offset.x, offset.y, 0 } : boundsOffsets[direction][index][1]); sub_98197C(session, imageId, (sint8)offset.x, (sint8)offset.y, boundsLength.x, boundsLength.y, thickness[1], height, @@ -1270,10 +1270,10 @@ void track_paint_util_eighth_to_diag_tiles_paint(paint_session * session, const } uint32 imageId = sprites[direction][index] | colourFlags; - LocationXY16 offset = (offsets == NULL ? LocationXY16{ 0, 0 } : offsets[direction][index]); + LocationXY16 offset = (offsets == nullptr ? LocationXY16{ 0, 0 } : offsets[direction][index]); LocationXY16 boundsLength = boundsLengths[direction][index]; LocationXYZ16 boundsOffset = - (boundsOffsets == NULL ? LocationXYZ16{ offset.x, offset.y, 0 } : boundsOffsets[direction][index]); + (boundsOffsets == nullptr ? LocationXYZ16{ offset.x, offset.y, 0 } : boundsOffsets[direction][index]); sub_98197C(session, imageId, (sint8)offset.x, (sint8)offset.y, boundsLength.x, boundsLength.y, thickness[direction][index], height, boundsOffset.x, boundsOffset.y, height + boundsOffset.z, rotation); @@ -1312,10 +1312,10 @@ void track_paint_util_diag_tiles_paint(paint_session * session, sint8 thickness, } uint32 imageId = sprites[direction] | colourFlags; - LocationXY16 offset = (offsets == NULL ? LocationXY16{ 0, 0 } : offsets[direction]); + LocationXY16 offset = (offsets == nullptr ? LocationXY16{ 0, 0 } : offsets[direction]); LocationXY16 boundsLength = boundsLengths[direction]; LocationXYZ16 boundsOffset = - (boundsOffsets == NULL ? LocationXYZ16{ offset.x, offset.y, 0 } : boundsOffsets[direction]); + (boundsOffsets == nullptr ? LocationXYZ16{ offset.x, offset.y, 0 } : boundsOffsets[direction]); sub_98197C(session, imageId, (sint8)offset.x, (sint8)offset.y, boundsLength.x, boundsLength.y, thickness, height, boundsOffset.x, boundsOffset.y, height + boundsOffset.z, rotation); @@ -1432,10 +1432,10 @@ void track_paint_util_right_quarter_turn_5_tiles_paint(paint_sessi } uint32 imageId = sprites[direction][index] | colourFlags; - LocationXY16 offset = (offsets == NULL ? LocationXY16{ 0, 0 } : offsets[direction][index]); + LocationXY16 offset = (offsets == nullptr ? LocationXY16{ 0, 0 } : offsets[direction][index]); LocationXY16 boundsLength = boundsLengths[direction][index]; LocationXYZ16 boundsOffset = - (boundsOffsets == NULL ? LocationXYZ16{ offset.x, offset.y, 0 } : boundsOffsets[direction][index]); + (boundsOffsets == nullptr ? LocationXYZ16{ offset.x, offset.y, 0 } : boundsOffsets[direction][index]); sub_98197C(session, imageId, (sint8)offset.x, (sint8)offset.y, boundsLength.x, boundsLength.y, thickness, height, boundsOffset.x, boundsOffset.y, height + boundsOffset.z, rotation); @@ -1598,10 +1598,10 @@ void track_paint_util_right_quarter_turn_3_tiles_paint(paint_sessi } uint32 imageId = sprites[direction][index] | colourFlags; - LocationXY16 offset = (offsets == NULL ? LocationXY16{ 0, 0 } : offsets[direction][index]); + LocationXY16 offset = (offsets == nullptr ? LocationXY16{ 0, 0 } : offsets[direction][index]); LocationXY16 boundsLength = boundsLengths[direction][index]; LocationXYZ16 boundsOffset = - (boundsOffsets == NULL ? LocationXYZ16{ offset.x, offset.y, 0 } : boundsOffsets[direction][index]); + (boundsOffsets == nullptr ? LocationXYZ16{ offset.x, offset.y, 0 } : boundsOffsets[direction][index]); sub_98197C(session, imageId, (sint8)offset.x, (sint8)offset.y, boundsLength.x, boundsLength.y, thickness, height, boundsOffset.x, boundsOffset.y, height + boundsOffset.z, rotation); @@ -2186,10 +2186,10 @@ void track_paint(paint_session * session, uint8 direction, sint32 height, rct_ti } TRACK_PAINT_FUNCTION_GETTER paintFunctionGetter = RideTypeTrackPaintFunctions[ride->type]; - if (paintFunctionGetter != NULL) + if (paintFunctionGetter != nullptr) { TRACK_PAINT_FUNCTION paintFunction = paintFunctionGetter(trackType, direction); - if (paintFunction != NULL) + if (paintFunction != nullptr) { paintFunction(session, rideIndex, trackSequence, direction, height, tileElement); } diff --git a/src/openrct2/ride/VehiclePaint.cpp b/src/openrct2/ride/VehiclePaint.cpp index 6e243db3b7..b24e7a820d 100644 --- a/src/openrct2/ride/VehiclePaint.cpp +++ b/src/openrct2/ride/VehiclePaint.cpp @@ -916,7 +916,7 @@ static void vehicle_sprite_paint(paint_session * session, rct_vehicle * vehicle, baseImage_id | (vehicle->colours.body_colour << 19) | (vehicle->colours.trim_colour << 24) | IMAGE_TYPE_REMAP_2_PLUS; paint_struct * ps = sub_98197C(session, image_id, 0, 0, bb.length_x, bb.length_y, bb.length_z, z, bb.offset_x, bb.offset_y, bb.offset_z + z, rotation); - if (ps != NULL) + if (ps != nullptr) { ps->tertiary_colour = vehicle->colours_extended; } @@ -3047,7 +3047,7 @@ void vehicle_paint(paint_session * session, rct_vehicle * vehicle, sint32 imageD else { rideEntry = get_ride_entry(vehicle->ride_subtype); - if (rideEntry == NULL) + if (rideEntry == nullptr) { return; } diff --git a/src/openrct2/scenario/Scenario.cpp b/src/openrct2/scenario/Scenario.cpp index ce2434f263..b4c8f1b5c1 100644 --- a/src/openrct2/scenario/Scenario.cpp +++ b/src/openrct2/scenario/Scenario.cpp @@ -478,7 +478,7 @@ static sint32 scenario_create_ducks() #ifndef DEBUG_DESYNC uint32 scenario_rand() #else -static FILE *fp = NULL; +static FILE *fp = nullptr; static const char *realm = "LC"; uint32 dbg_scenario_rand(const char *file, const char *function, const uint32 line, const void *data) @@ -489,7 +489,7 @@ uint32 dbg_scenario_rand(const char *file, const char *function, const uint32 li gScenarioSrand1 = ror32(originalSrand0, 3); #ifdef DEBUG_DESYNC - if (fp == NULL) + if (fp == nullptr) { if (network_get_mode() == NETWORK_MODE_SERVER) { @@ -505,7 +505,7 @@ uint32 dbg_scenario_rand(const char *file, const char *function, const uint32 li { if (fp) fclose(fp); - fp = NULL; + fp = nullptr; realm = "LC"; } } @@ -525,7 +525,7 @@ uint32 dbg_scenario_rand(const char *file, const char *function, const uint32 li #ifdef DEBUG_DESYNC void dbg_report_desync(uint32 tick, uint32 srand0, uint32 server_srand0, const char *clientHash, const char *serverHash) { - if (fp == NULL) + if (fp == nullptr) { if (network_get_mode() == NETWORK_MODE_SERVER) { diff --git a/src/openrct2/util/Util.cpp b/src/openrct2/util/Util.cpp index ae4e94c3f8..597bec9474 100644 --- a/src/openrct2/util/Util.cpp +++ b/src/openrct2/util/Util.cpp @@ -321,7 +321,7 @@ sint32 strlogicalcmp(char const *a, char const *b) { utf8 * safe_strtrunc(utf8 * text, size_t size) { - assert(text != NULL); + assert(text != nullptr); if (size == 0) return text; @@ -343,8 +343,8 @@ utf8 * safe_strtrunc(utf8 * text, size_t size) char *safe_strcpy(char * destination, const char * source, size_t size) { - assert(destination != NULL); - assert(source != NULL); + assert(destination != nullptr); + assert(source != nullptr); if (size == 0) return destination; @@ -371,8 +371,8 @@ char *safe_strcpy(char * destination, const char * source, size_t size) char *safe_strcat(char *destination, const char *source, size_t size) { - assert(destination != NULL); - assert(source != NULL); + assert(destination != nullptr); + assert(source != nullptr); if (size == 0) { return destination; diff --git a/src/openrct2/world/Footpath.cpp b/src/openrct2/world/Footpath.cpp index b88c68cd2c..59847463aa 100644 --- a/src/openrct2/world/Footpath.cpp +++ b/src/openrct2/world/Footpath.cpp @@ -131,7 +131,7 @@ static rct_tile_element *map_get_footpath_element(sint32 x, sint32 y, sint32 z) return tileElement; } while (!tile_element_is_last_for_tile(tileElement++)); - return NULL; + return nullptr; } static rct_tile_element *map_get_footpath_element_slope(sint32 x, sint32 y, sint32 z, sint32 slope) @@ -149,7 +149,7 @@ static rct_tile_element *map_get_footpath_element_slope(sint32 x, sint32 y, sint } } while (!tile_element_is_last_for_tile(tileElement++)); - return NULL; + return nullptr; } static void loc_6A6620(sint32 flags, sint32 x, sint32 y, rct_tile_element *tileElement) @@ -200,7 +200,7 @@ static money32 footpath_element_insert(sint32 type, sint32 x, sint32 y, sint32 z entranceElement = map_get_park_entrance_element_at(x, y, z, false); // Make sure the entrance part is the middle - if (entranceElement != NULL && (entranceElement->properties.entrance.index & 0x0F) == 0) + if (entranceElement != nullptr && (entranceElement->properties.entrance.index & 0x0F) == 0) { entrancePath = true; // Make the price the same as replacing a path @@ -239,7 +239,7 @@ static money32 footpath_element_insert(sint32 type, sint32 x, sint32 y, sint32 z else { tileElement = tile_element_insert(x / 32, y / 32, z, 0x0F); - assert(tileElement != NULL); + assert(tileElement != nullptr); tileElement->type = TILE_ELEMENT_TYPE_PATH; tileElement->clearance_height = z + 4 + ((slope & TILE_ELEMENT_SLOPE_NE_SIDE_UP) ? 2 : 0); footpath_element_set_type(tileElement, type); @@ -445,7 +445,7 @@ static money32 footpath_place_real(sint32 type, sint32 x, sint32 y, sint32 z, si footpath_provisional_remove(); tileElement = map_get_footpath_element_slope((x / 32), (y / 32), z, slope); - if (tileElement == NULL) { + if (tileElement == nullptr) { return footpath_element_insert(type, x, y, z, slope, flags, pathItemType); } else { return footpath_element_update(x, y, tileElement, type, flags, pathItemType); @@ -469,7 +469,7 @@ static void remove_banners_at_element(sint32 x, sint32 y, rct_tile_element* tile money32 footpath_remove_real(sint32 x, sint32 y, sint32 z, sint32 flags) { rct_tile_element *tileElement; - rct_tile_element *footpathElement = NULL; + rct_tile_element *footpathElement = nullptr; gCommandExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING; gCommandPosition.x = x + 16; @@ -490,7 +490,7 @@ money32 footpath_remove_real(sint32 x, sint32 y, sint32 z, sint32 flags) return MONEY32_UNDEFINED; tileElement = map_get_footpath_element(x / 32, y / 32, z); - if (tileElement != NULL && (flags & GAME_COMMAND_FLAG_APPLY)) { + if (tileElement != nullptr && (flags & GAME_COMMAND_FLAG_APPLY)) { if (gGameCommandNestLevel == 1 && !(flags & GAME_COMMAND_FLAG_GHOST)) { LocationXYZ16 coord; coord.x = x + 16; @@ -513,7 +513,7 @@ money32 footpath_remove_real(sint32 x, sint32 y, sint32 z, sint32 flags) footpathElement = tileElement; } - if (footpathElement != NULL) { + if (footpathElement != nullptr) { footpath_queue_chain_reset(); remove_banners_at_element(x, y, footpathElement); footpath_remove_edges_at(x, y, footpathElement); @@ -527,7 +527,7 @@ money32 footpath_remove_real(sint32 x, sint32 y, sint32 z, sint32 flags) bool isNotOwnedByPark = (flags & GAME_COMMAND_FLAG_5); bool moneyDisabled = (gParkFlags & PARK_FLAGS_NO_MONEY); - bool isGhost = (footpathElement == NULL) || (tile_element_is_ghost(footpathElement)); + bool isGhost = (footpathElement == nullptr) || (tile_element_is_ghost(footpathElement)); if (isNotOwnedByPark || moneyDisabled || isGhost) { cost = 0; @@ -609,7 +609,7 @@ static money32 footpath_place_from_track(sint32 type, sint32 x, sint32 y, sint32 entranceElement = map_get_park_entrance_element_at(x, y, z, false); // Make sure the entrance part is the middle - if (entranceElement != NULL && (entranceElement->properties.entrance.index & 0x0F) == 0) + if (entranceElement != nullptr && (entranceElement->properties.entrance.index & 0x0F) == 0) { entrancePath = true; // Make the price the same as replacing a path @@ -656,7 +656,7 @@ static money32 footpath_place_from_track(sint32 type, sint32 x, sint32 y, sint32 else { tileElement = tile_element_insert(x / 32, y / 32, z, 0x0F); - assert(tileElement != NULL); + assert(tileElement != nullptr); tileElement->type = TILE_ELEMENT_TYPE_PATH; tileElement->clearance_height = z + 4 + ((slope & TILE_ELEMENT_SLOPE_S_CORNER_UP) ? 2 : 0); tileElement->properties.path.type = (type << 4) | (slope & TILE_ELEMENT_SLOPE_W_CORNER_DN); @@ -833,7 +833,7 @@ void footpath_get_coordinates_from_pos(sint32 screenX, sint32 screenY, sint32 *x if (interactionType != VIEWPORT_INTERACTION_ITEM_FOOTPATH || !(viewport->flags & (VIEWPORT_FLAG_UNDERGROUND_INSIDE | VIEWPORT_FLAG_HIDE_BASE | VIEWPORT_FLAG_HIDE_VERTICAL))) { get_map_coordinates_from_pos(screenX, screenY, VIEWPORT_INTERACTION_MASK_FOOTPATH & VIEWPORT_INTERACTION_MASK_TERRAIN, &position.x, &position.y, &interactionType, &myTileElement, &viewport); if (interactionType == VIEWPORT_INTERACTION_ITEM_NONE) { - if (x != NULL) *x = LOCATION_NULL; + if (x != nullptr) *x = LOCATION_NULL; return; } } @@ -879,10 +879,10 @@ void footpath_get_coordinates_from_pos(sint32 screenX, sint32 screenY, sint32 *x } } - if (x != NULL) *x = position.x & ~0x1F; - if (y != NULL) *y = position.y & ~0x1F; - if (direction != NULL) *direction = myDirection; - if (tileElement != NULL) *tileElement = myTileElement; + if (x != nullptr) *x = position.x & ~0x1F; + if (y != nullptr) *y = position.y & ~0x1F; + if (direction != nullptr) *direction = myDirection; + if (tileElement != nullptr) *tileElement = myTileElement; } /** @@ -915,7 +915,7 @@ void footpath_bridge_get_info_from_pos(sint32 screenX, sint32 screenY, sint32 *x sint32 bx = bitscanforward(directions); bx += (*tileElement)->type; bx &= 3; - if (direction != NULL) *direction = bx; + if (direction != nullptr) *direction = bx; return; } } @@ -927,7 +927,7 @@ void footpath_bridge_get_info_from_pos(sint32 screenX, sint32 screenY, sint32 *x sint32 directions = entrance_get_directions(*tileElement); if (directions & 0x0F) { sint32 bx = tile_element_get_direction_with_offset(*tileElement, bitscanforward(directions)); - if (direction != NULL) *direction = bx; + if (direction != nullptr) *direction = bx; return; } } @@ -993,7 +993,7 @@ bool fence_in_the_way(sint32 x, sint32 y, sint32 z0, sint32 z1, sint32 direction rct_tile_element *tileElement; tileElement = map_get_first_element_at(x >> 5, y >> 5); - if (tileElement == NULL) + if (tileElement == nullptr) return false; do { if (tile_element_get_type(tileElement) != TILE_ELEMENT_TYPE_WALL) @@ -1037,7 +1037,7 @@ static rct_tile_element *footpath_connect_corners_get_neighbour(sint32 x, sint32 return tileElement; } while (!tile_element_is_last_for_tile(tileElement++)); - return NULL; + return nullptr; } /** @@ -1067,14 +1067,14 @@ static void footpath_connect_corners(sint32 initialX, sint32 initialY, rct_tile_ x += TileDirectionDelta[direction].x; y += TileDirectionDelta[direction].y; tileElement[1] = footpath_connect_corners_get_neighbour(x, y, z, (1 << (direction ^ 2))); - if (tileElement[1] == NULL) + if (tileElement[1] == nullptr) continue; direction = (direction + 1) & 3; x += TileDirectionDelta[direction].x; y += TileDirectionDelta[direction].y; tileElement[2] = footpath_connect_corners_get_neighbour(x, y, z, (1 << (direction ^ 2))); - if (tileElement[2] == NULL) + if (tileElement[2] == nullptr) continue; direction = (direction + 1) & 3; @@ -1082,11 +1082,11 @@ static void footpath_connect_corners(sint32 initialX, sint32 initialY, rct_tile_ y += TileDirectionDelta[direction].y; // First check link to previous tile tileElement[3] = footpath_connect_corners_get_neighbour(x, y, z, (1 << (direction ^ 2))); - if (tileElement[3] == NULL) + if (tileElement[3] == nullptr) continue; // Second check link to initial tile tileElement[3] = footpath_connect_corners_get_neighbour(x, y, z, (1 << ((direction + 1) & 3))); - if (tileElement[3] == NULL) + if (tileElement[3] == nullptr) continue; direction = (direction + 1) & 3; @@ -1203,7 +1203,7 @@ static rct_tile_element *footpath_get_element(sint32 x, sint32 y, sint32 z0, sin return tileElement; } } while (!tile_element_is_last_for_tile(tileElement++)); - return NULL; + return nullptr; } static bool sub_footpath_disconnect_queue_from_path(sint32 x, sint32 y, rct_tile_element *tileElement, sint32 action, sint32 direction) { @@ -1216,7 +1216,7 @@ static bool sub_footpath_disconnect_queue_from_path(sint32 x, sint32 y, rct_tile sint32 y1 = y + TileDirectionDelta[direction].y; sint32 z = tileElement->base_height; rct_tile_element *otherTileElement = footpath_get_element(x1, y1, z - 2, z, direction); - if (otherTileElement != NULL && !footpath_element_is_queue(otherTileElement)) { + if (otherTileElement != nullptr && !footpath_element_is_queue(otherTileElement)) { tileElement->properties.path.type &= ~FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK; if (action > 0) { tileElement->properties.path.edges &= ~(1 << direction); @@ -1474,8 +1474,8 @@ void footpath_chain_ride_queue(sint32 rideIndex, sint32 entranceIndex, sint32 x, rct_tile_element *lastPathElement, *lastQueuePathElement; sint32 lastPathX = x, lastPathY = y, lastPathDirection = direction; - lastPathElement = NULL; - lastQueuePathElement = NULL; + lastPathElement = nullptr; + lastQueuePathElement = nullptr; sint32 z = tileElement->base_height; for (;;) { if (tile_element_get_type(tileElement) == TILE_ELEMENT_TYPE_PATH) { @@ -1539,7 +1539,7 @@ void footpath_chain_ride_queue(sint32 rideIndex, sint32 entranceIndex, sint32 x, map_invalidate_element(x, y, tileElement); - if (lastQueuePathElement == NULL) { + if (lastQueuePathElement == nullptr) { lastQueuePathElement = tileElement; } @@ -1557,7 +1557,7 @@ void footpath_chain_ride_queue(sint32 rideIndex, sint32 entranceIndex, sint32 x, break; } - if (rideIndex != 255 && lastPathElement != NULL) { + if (rideIndex != 255 && lastPathElement != nullptr) { if (footpath_element_is_queue(lastPathElement)) { lastPathElement->properties.path.type |= (1 << 3); // Set the ride sign flag lastPathElement->type &= 0x3F; // Clear the ride sign direction @@ -1637,7 +1637,7 @@ static void footpath_fix_ownership(sint32 x, sint32 y, rct_tile_element *pathEle uint16 ownership; // Unlikely to be NULL unless deliberate. - if (surfaceElement != NULL) + if (surfaceElement != nullptr) { // If the tile is not safe to own construction rights of, erase them. if (check_max_allowable_land_rights_for_tile(x >> 5, y >> 5, surfaceElement->base_height) == OWNERSHIP_UNOWNED) @@ -1930,7 +1930,7 @@ static rct_tile_element* footpath_can_be_wide(sint32 x, sint32 y, uint8 height) return tileElement; } while (!tile_element_is_last_for_tile(tileElement++)); - return NULL; + return nullptr; } @@ -2010,7 +2010,7 @@ void footpath_update_path_wide_flags(sint32 x, sint32 y) uint8 F3EFA5 = 0; if (tileElement->properties.path.edges & EDGE_NW) { F3EFA5 |= 0x80; - if (pathList[7] != NULL) { + if (pathList[7] != nullptr) { if (footpath_element_is_wide(pathList[7])) { F3EFA5 &= ~0x80; } @@ -2019,7 +2019,7 @@ void footpath_update_path_wide_flags(sint32 x, sint32 y) if (tileElement->properties.path.edges & EDGE_NE) { F3EFA5 |= 0x2; - if (pathList[1] != NULL) { + if (pathList[1] != nullptr) { if (footpath_element_is_wide(pathList[1])) { F3EFA5 &= ~0x2; } @@ -2033,7 +2033,7 @@ void footpath_update_path_wide_flags(sint32 x, sint32 y) * is always false due to the tile update order * in combination with reset tiles. * Commented out since it will never occur. */ - //if (pathList[3] != NULL) { + //if (pathList[3] != nullptr) { // if (footpath_element_is_wide(pathList[3])) { // F3EFA5 &= ~0x8; // } @@ -2047,18 +2047,18 @@ void footpath_update_path_wide_flags(sint32 x, sint32 y) * is always false due to the tile update order * in combination with reset tiles. * Commented out since it will never occur. */ - //if (pathList[5] != NULL) { + //if (pathList[5] != nullptr) { // if (footpath_element_is_wide(pathList[5])) { // F3EFA5 &= ~0x20; // } //} } - if ((F3EFA5 & 0x80) && (pathList[7] != NULL) && !(footpath_element_is_wide(pathList[7]))) { + if ((F3EFA5 & 0x80) && (pathList[7] != nullptr) && !(footpath_element_is_wide(pathList[7]))) { if ((F3EFA5 & 2) && - (pathList[0] != NULL) && (!footpath_element_is_wide(pathList[0])) && + (pathList[0] != nullptr) && (!footpath_element_is_wide(pathList[0])) && ((pathList[0]->properties.path.edges & 6) == 6) && // N E - (pathList[1] != NULL) && (!footpath_element_is_wide(pathList[1]))) { + (pathList[1] != nullptr) && (!footpath_element_is_wide(pathList[1]))) { F3EFA5 |= 0x1; } @@ -2068,9 +2068,9 @@ void footpath_update_path_wide_flags(sint32 x, sint32 y) * in combination with reset tiles. * Short circuit the logic appropriately. */ if ((F3EFA5 & 0x20) && - (pathList[6] != NULL) && (!footpath_element_is_wide(pathList[6])) && + (pathList[6] != nullptr) && (!footpath_element_is_wide(pathList[6])) && ((pathList[6]->properties.path.edges & 3) == 3) && // N W - (pathList[5] != NULL) && (true || !footpath_element_is_wide(pathList[5]))) { + (pathList[5] != nullptr) && (true || !footpath_element_is_wide(pathList[5]))) { F3EFA5 |= 0x40; } } @@ -2082,11 +2082,11 @@ void footpath_update_path_wide_flags(sint32 x, sint32 y) * are always false due to the tile update order * in combination with reset tiles. * Short circuit the logic appropriately. */ - if ((F3EFA5 & 0x8) && (pathList[3] != NULL) && (true || !footpath_element_is_wide(pathList[3]))) { + if ((F3EFA5 & 0x8) && (pathList[3] != nullptr) && (true || !footpath_element_is_wide(pathList[3]))) { if ((F3EFA5 & 2) && - (pathList[2] != NULL) && (true || !footpath_element_is_wide(pathList[2])) && + (pathList[2] != nullptr) && (true || !footpath_element_is_wide(pathList[2])) && ((pathList[2]->properties.path.edges & 0xC) == 0xC) && - (pathList[1] != NULL) && (!footpath_element_is_wide(pathList[1]))) { + (pathList[1] != nullptr) && (!footpath_element_is_wide(pathList[1]))) { F3EFA5 |= 0x4; } @@ -2097,9 +2097,9 @@ void footpath_update_path_wide_flags(sint32 x, sint32 y) * in combination with reset tiles. * Short circuit the logic appropriately. */ if ((F3EFA5 & 0x20) && - (pathList[4] != NULL) && (true || !footpath_element_is_wide(pathList[4])) && + (pathList[4] != nullptr) && (true || !footpath_element_is_wide(pathList[4])) && ((pathList[4]->properties.path.edges & 9) == 9) && - (pathList[5] != NULL) && (true || !footpath_element_is_wide(pathList[5]))) { + (pathList[5] != nullptr) && (true || !footpath_element_is_wide(pathList[5]))) { F3EFA5 |= 0x10; } } diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index 25f9128367..794d2d318d 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -2870,7 +2870,7 @@ void game_command_place_large_scenery(sint32* eax, sint32* ebx, sint32* ecx, sin } rct_tile_element *new_tile_element = tile_element_insert(curTile.x / 32, curTile.y / 32, zLow, F43887); - assert(new_tile_element != NULL); + assert(new_tile_element != nullptr); map_animation_create(MAP_ANIMATION_TYPE_LARGE_SCENERY, curTile.x, curTile.y, zLow); new_tile_element->clearance_height = zHigh; diff --git a/src/openrct2/world/MapAnimation.cpp b/src/openrct2/world/MapAnimation.cpp index 42ca624665..88bb137947 100644 --- a/src/openrct2/world/MapAnimation.cpp +++ b/src/openrct2/world/MapAnimation.cpp @@ -305,7 +305,7 @@ static bool map_animation_invalidate_track_onridephoto(sint32 x, sint32 y, sint3 tileElement = map_get_first_element_at(x >> 5, y >> 5); do { - if (tileElement == NULL) + if (tileElement == nullptr) break; if (tileElement->base_height != baseZ) continue; diff --git a/src/openrct2/world/Scenery.cpp b/src/openrct2/world/Scenery.cpp index 65191f6cbc..6e6c3901e7 100644 --- a/src/openrct2/world/Scenery.cpp +++ b/src/openrct2/world/Scenery.cpp @@ -95,7 +95,7 @@ void scenery_update_tile(sint32 x, sint32 y) } else if (tile_element_get_type(tileElement) == TILE_ELEMENT_TYPE_PATH) { if (footpath_element_has_path_scenery(tileElement) && !footpath_element_path_scenery_is_ghost(tileElement)) { rct_scenery_entry *sceneryEntry = get_footpath_item_entry(footpath_element_get_path_scenery_index(tileElement)); - if (sceneryEntry != NULL) { + if (sceneryEntry != nullptr) { if (sceneryEntry->path_bit.flags & PATH_BIT_FLAG_JUMPING_FOUNTAIN_WATER) { jumping_fountain_begin(JUMPING_FOUNTAIN_TYPE_WATER, x, y, tileElement); } @@ -118,7 +118,7 @@ void scenery_update_age(sint32 x, sint32 y, rct_tile_element *tileElement) rct_scenery_entry *sceneryEntry; sceneryEntry = get_small_scenery_entry(tileElement->properties.scenery.type); - if (sceneryEntry == NULL) + if (sceneryEntry == nullptr) { return; } @@ -280,7 +280,7 @@ void scenery_remove_ghost_tool_placement(){ rct_scenery_entry *get_small_scenery_entry(sint32 entryIndex) { if (entryIndex >= object_entry_group_counts[OBJECT_TYPE_SMALL_SCENERY]) { - return NULL; + return nullptr; } return (rct_scenery_entry*)gSmallSceneryEntries[entryIndex]; } @@ -288,7 +288,7 @@ rct_scenery_entry *get_small_scenery_entry(sint32 entryIndex) rct_scenery_entry *get_large_scenery_entry(sint32 entryIndex) { if (entryIndex >= object_entry_group_counts[OBJECT_TYPE_LARGE_SCENERY]) { - return NULL; + return nullptr; } return (rct_scenery_entry*)gLargeSceneryEntries[entryIndex]; } @@ -296,7 +296,7 @@ rct_scenery_entry *get_large_scenery_entry(sint32 entryIndex) rct_scenery_entry *get_wall_entry(sint32 entryIndex) { if (entryIndex >= object_entry_group_counts[OBJECT_TYPE_WALLS]) { - return NULL; + return nullptr; } return (rct_scenery_entry*)gWallSceneryEntries[entryIndex]; } @@ -304,7 +304,7 @@ rct_scenery_entry *get_wall_entry(sint32 entryIndex) rct_scenery_entry *get_banner_entry(sint32 entryIndex) { if (entryIndex >= object_entry_group_counts[OBJECT_TYPE_BANNERS]) { - return NULL; + return nullptr; } return (rct_scenery_entry*)gBannerSceneryEntries[entryIndex]; } @@ -312,7 +312,7 @@ rct_scenery_entry *get_banner_entry(sint32 entryIndex) rct_scenery_entry *get_footpath_item_entry(sint32 entryIndex) { if (entryIndex >= object_entry_group_counts[OBJECT_TYPE_PATH_BITS]) { - return NULL; + return nullptr; } return (rct_scenery_entry*)gFootpathAdditionEntries[entryIndex]; } @@ -320,7 +320,7 @@ rct_scenery_entry *get_footpath_item_entry(sint32 entryIndex) rct_scenery_group_entry *get_scenery_group_entry(sint32 entryIndex) { if (entryIndex >= object_entry_group_counts[OBJECT_TYPE_SCENERY_GROUP]) { - return NULL; + return nullptr; } return (rct_scenery_group_entry*)gSceneryGroupEntries[entryIndex]; } diff --git a/src/openrct2/world/Sprite.cpp b/src/openrct2/world/Sprite.cpp index 788fffbc7c..1a4f51d17f 100644 --- a/src/openrct2/world/Sprite.cpp +++ b/src/openrct2/world/Sprite.cpp @@ -58,7 +58,7 @@ static size_t GetSpatialIndexOffset(sint32 x, sint32 y); rct_sprite *try_get_sprite(size_t spriteIndex) { - rct_sprite * sprite = NULL; + rct_sprite * sprite = nullptr; if (spriteIndex < MAX_SPRITES) { sprite = &_spriteList[spriteIndex]; @@ -250,7 +250,7 @@ const char * sprite_checksum() const char * sprite_checksum() { - return NULL; + return nullptr; } #endif // DISABLE_NETWORK @@ -315,11 +315,11 @@ rct_sprite *create_sprite(uint8 bl) // 69EC96; uint16 cx = 0x12C - gSpriteListCount[SPRITE_LIST_MISC]; if (cx >= gSpriteListCount[SPRITE_LIST_NULL]) { - return NULL; + return nullptr; } linkedListTypeOffset = SPRITE_LIST_MISC * 2; } else if (gSpriteListCount[SPRITE_LIST_NULL] == 0) { - return NULL; + return nullptr; } rct_unk_sprite *sprite = &(get_sprite(gSpriteListHead[SPRITE_LIST_NULL]))->unknown; @@ -429,7 +429,7 @@ static void sprite_steam_particle_update(rct_steam_particle *steam) void sprite_misc_explosion_cloud_create(sint32 x, sint32 y, sint32 z) { rct_unk_sprite *sprite = (rct_unk_sprite*)create_sprite(2); - if (sprite != NULL) { + if (sprite != nullptr) { sprite->sprite_width = 44; sprite->sprite_height_negative = 32; sprite->sprite_height_positive = 34; @@ -460,7 +460,7 @@ static void sprite_misc_explosion_cloud_update(rct_sprite * sprite) void sprite_misc_explosion_flare_create(sint32 x, sint32 y, sint32 z) { rct_unk_sprite *sprite = (rct_unk_sprite*)create_sprite(2); - if (sprite != NULL) { + if (sprite != nullptr) { sprite->sprite_width = 25; sprite->sprite_height_negative = 85; sprite->sprite_height_positive = 8; @@ -675,7 +675,7 @@ void litter_create(sint32 x, sint32 y, sint32 z, sint32 direction, sint32 type) return; if (gSpriteListCount[SPRITE_LIST_LITTER] >= 500) { - rct_litter *newestLitter = NULL; + rct_litter *newestLitter = nullptr; uint32 newestLitterCreationTick = 0; for (uint16 nextSpriteIndex, spriteIndex = gSpriteListHead[SPRITE_LIST_LITTER]; spriteIndex != SPRITE_INDEX_NULL; spriteIndex = nextSpriteIndex) { rct_litter *litter = &get_sprite(spriteIndex)->litter; @@ -686,14 +686,14 @@ void litter_create(sint32 x, sint32 y, sint32 z, sint32 direction, sint32 type) } } - if (newestLitter != NULL) { + if (newestLitter != nullptr) { invalidate_sprite_0((rct_sprite*)newestLitter); sprite_remove((rct_sprite*)newestLitter); } } rct_litter *litter = (rct_litter*)create_sprite(1); - if (litter == NULL) + if (litter == nullptr) return; move_sprite_to_list((rct_sprite*)litter, SPRITE_LIST_LITTER * 2); @@ -841,7 +841,7 @@ static rct_sprite * find_sprite_list_cycle(uint16 sprite_idx) const rct_sprite * fast = get_sprite(sprite_idx); const rct_sprite * slow = fast; bool increment_slow = false; - rct_sprite * cycle_start = NULL; + rct_sprite * cycle_start = nullptr; while (fast->unknown.sprite_index != SPRITE_INDEX_NULL) { // increment fast every time, unless reached the end @@ -876,7 +876,7 @@ static rct_sprite * find_sprite_quadrant_cycle(uint16 sprite_idx) const rct_sprite * fast = get_sprite(sprite_idx); const rct_sprite * slow = fast; bool increment_slow = false; - rct_sprite * cycle_start = NULL; + rct_sprite * cycle_start = nullptr; while (fast->unknown.sprite_index != SPRITE_INDEX_NULL) { // increment fast every time, unless reached the end @@ -920,7 +920,7 @@ sint32 check_for_sprite_list_cycles(bool fix) { for (sint32 i = 0; i < NUM_SPRITE_LISTS; i++) { rct_sprite * cycle_start = find_sprite_list_cycle(gSpriteListHead[i]); - if (cycle_start != NULL) + if (cycle_start != nullptr) { if (fix) { @@ -964,7 +964,7 @@ sint32 fix_disjoint_sprites() // Find reachable sprites bool reachable[MAX_SPRITES] = { false }; uint16 sprite_idx = gSpriteListHead[SPRITE_LIST_NULL]; - rct_sprite * null_list_tail = NULL; + rct_sprite * null_list_tail = nullptr; while (sprite_idx != SPRITE_INDEX_NULL) { reachable[sprite_idx] = true; @@ -981,7 +981,7 @@ sint32 fix_disjoint_sprites() rct_sprite * spr = get_sprite(sprite_idx); if (spr->unknown.sprite_identifier == SPRITE_IDENTIFIER_NULL) { - openrct2_assert(null_list_tail != NULL, "Null list is empty, yet found null sprites"); + openrct2_assert(null_list_tail != nullptr, "Null list is empty, yet found null sprites"); spr->unknown.sprite_index = sprite_idx; if (!reachable[sprite_idx]) { @@ -1002,7 +1002,7 @@ sint32 check_for_spatial_index_cycles(bool fix) { for (sint32 i = 0; i < SPATIAL_INDEX_LOCATION_NULL; i++) { rct_sprite * cycle_start = find_sprite_quadrant_cycle(gSpriteSpatialIndex[i]); - if (cycle_start != NULL) + if (cycle_start != nullptr) { if (fix) { diff --git a/test/testpaint/Compat.cpp b/test/testpaint/Compat.cpp index 3c22b28b55..edf7ae8e1f 100644 --- a/test/testpaint/Compat.cpp +++ b/test/testpaint/Compat.cpp @@ -92,7 +92,7 @@ void large_scenery_paint(paint_session * session, uint8 direction, uint16 height Ride *get_ride(int index) { if (index < 0 || index >= MAX_RIDES) { log_error("invalid index %d for ride", index); - return NULL; + return nullptr; } return &gRideList[index]; } @@ -100,7 +100,7 @@ Ride *get_ride(int index) { rct_ride_entry *get_ride_entry(int index) { if (index < 0 || index >= object_entry_group_counts[OBJECT_TYPE_RIDE]) { log_error("invalid index %d for ride type", index); - return NULL; + return nullptr; } return gRideEntries[index]; @@ -108,7 +108,7 @@ rct_ride_entry *get_ride_entry(int index) { rct_ride_entry *get_ride_entry_by_ride(Ride *ride) { rct_ride_entry * type = get_ride_entry(ride->subtype); - if (type == NULL) { + if (type == nullptr) { log_error("Invalid ride subtype for ride"); } return type; @@ -138,7 +138,7 @@ int tile_element_get_direction_with_offset(const rct_tile_element *element, uint rct_tile_element *map_get_first_element_at(int x, int y) { if (x < 0 || y < 0 || x > 255 || y > 255) { log_error("Trying to access element outside of range"); - return NULL; + return nullptr; } return gTileElementTilePointers[x + y * 256]; } diff --git a/test/testpaint/Utils.cpp b/test/testpaint/Utils.cpp index f44712891a..6bf2467ff3 100644 --- a/test/testpaint/Utils.cpp +++ b/test/testpaint/Utils.cpp @@ -45,11 +45,11 @@ namespace Utils { bool rideSupportsTrackType(uint8 rideType, uint8 trackType) { TRACK_PAINT_FUNCTION_GETTER newPaintGetter = RideTypeTrackPaintFunctions[rideType]; - if (newPaintGetter == NULL) { + if (newPaintGetter == nullptr) { return false; } - if (newPaintGetter(trackType, 0) == NULL) { + if (newPaintGetter(trackType, 0) == nullptr) { return false; } diff --git a/test/testpaint/generate.cpp b/test/testpaint/generate.cpp index 8572c4c211..1d1e0dfdd9 100644 --- a/test/testpaint/generate.cpp +++ b/test/testpaint/generate.cpp @@ -1046,7 +1046,7 @@ private: } } WriteLine(1, "}"); - WriteLine(1, "return NULL;"); + WriteLine(1, "return nullptr;"); WriteLine(0, "}"); } diff --git a/test/testpaint/main.cpp b/test/testpaint/main.cpp index cffb3d8b17..d7a5129d9c 100644 --- a/test/testpaint/main.cpp +++ b/test/testpaint/main.cpp @@ -101,7 +101,7 @@ static const char* GetAnsiColorCode(CLIColour color) { case GREEN: return "2"; case YELLOW: return "3"; - default: return NULL; + default: return nullptr; }; } @@ -189,7 +189,7 @@ int main(int argc, char *argv[]); #define OPENRCT2_DLL_MODULE_NAME "openrct2.dll" -static HMODULE _dllModule = NULL; +static HMODULE _dllModule = nullptr; utf8 *utf8_write_codepoint(utf8 *dst, uint32 codepoint) { @@ -256,7 +256,7 @@ BOOL APIENTRY DllMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved) __declspec(dllexport) int StartOpenRCT(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { - if (_dllModule == NULL) { + if (_dllModule == nullptr) { _dllModule = GetModuleHandleA(OPENRCT2_DLL_MODULE_NAME); }