From f904aef176b7bde38f27cc9b4f23c55dc13d2ce5 Mon Sep 17 00:00:00 2001 From: Rubidium Date: Wed, 16 Jun 2021 21:12:08 +0200 Subject: [PATCH] Cleanup: use nullptr instead of 0 or NULL --- src/main_gui.cpp | 2 +- src/network/core/tcp_connect.cpp | 2 +- src/network/network_command.cpp | 2 +- src/newgrf_commons.h | 2 +- src/os/unix/font_unix.cpp | 4 ++-- src/os/unix/unix.cpp | 2 +- src/video/opengl.cpp | 2 +- src/video/sdl2_v.cpp | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main_gui.cpp b/src/main_gui.cpp index 559040f378..79960d51bb 100644 --- a/src/main_gui.cpp +++ b/src/main_gui.cpp @@ -309,7 +309,7 @@ struct MainWindow : Window case GHK_REFRESH_SCREEN: MarkWholeScreenDirty(); break; case GHK_CRASH: // Crash the game - *(volatile byte *)0 = 0; + *(volatile byte *)nullptr = 0; break; case GHK_MONEY: // Gimme money diff --git a/src/network/core/tcp_connect.cpp b/src/network/core/tcp_connect.cpp index f251f02884..c4f5415b04 100644 --- a/src/network/core/tcp_connect.cpp +++ b/src/network/core/tcp_connect.cpp @@ -268,7 +268,7 @@ bool TCPConnecter::CheckActivity() timeval tv; tv.tv_usec = 0; tv.tv_sec = 0; - int n = select(FD_SETSIZE, NULL, &write_fd, NULL, &tv); + int n = select(FD_SETSIZE, nullptr, &write_fd, nullptr, &tv); /* select() failed; hopefully next try it doesn't. */ if (n < 0) { /* select() normally never fails; so hopefully it works next try! */ diff --git a/src/network/network_command.cpp b/src/network/network_command.cpp index 1a9849a346..6d03aaaa13 100644 --- a/src/network/network_command.cpp +++ b/src/network/network_command.cpp @@ -179,7 +179,7 @@ void NetworkSyncCommandQueue(NetworkClientSocket *cs) { for (CommandPacket *p = _local_execution_queue.Peek(); p != nullptr; p = p->next) { CommandPacket c = *p; - c.callback = 0; + c.callback = nullptr; cs->outgoing_queue.Append(&c); } } diff --git a/src/newgrf_commons.h b/src/newgrf_commons.h index ed18aaa9e2..ff241369a2 100644 --- a/src/newgrf_commons.h +++ b/src/newgrf_commons.h @@ -309,7 +309,7 @@ bool Convert8bitBooleanCallback(const struct GRFFile *grffile, uint16 cbid, uint */ template struct GRFFilePropsBase { - GRFFilePropsBase() : local_id(0), grffile(0) + GRFFilePropsBase() : local_id(0), grffile(nullptr) { /* The lack of some compilers to provide default constructors complying to the specs * requires us to zero the stuff ourself. */ diff --git a/src/os/unix/font_unix.cpp b/src/os/unix/font_unix.cpp index f8cf96a48b..246d65e63f 100644 --- a/src/os/unix/font_unix.cpp +++ b/src/os/unix/font_unix.cpp @@ -51,10 +51,10 @@ FT_Error GetFontByFaceName(const char *font_name, FT_Face *face) /* Resolve the name and populate the information structure */ pat = FcNameParse((FcChar8 *)font_family); if (font_style != nullptr) FcPatternAddString(pat, FC_STYLE, (FcChar8 *)font_style); - FcConfigSubstitute(0, pat, FcMatchPattern); + FcConfigSubstitute(nullptr, pat, FcMatchPattern); FcDefaultSubstitute(pat); fs = FcFontSetCreate(); - match = FcFontMatch(0, pat, &result); + match = FcFontMatch(nullptr, pat, &result); if (fs != nullptr && match != nullptr) { int i; diff --git a/src/os/unix/unix.cpp b/src/os/unix/unix.cpp index f696f817f4..95d6fa1fa5 100644 --- a/src/os/unix/unix.cpp +++ b/src/os/unix/unix.cpp @@ -277,7 +277,7 @@ bool GetClipboardContents(char *buffer, const char *last) } char *clip = SDL_GetClipboardText(); - if (clip != NULL) { + if (clip != nullptr) { strecpy(buffer, clip, last); SDL_free(clip); return true; diff --git a/src/video/opengl.cpp b/src/video/opengl.cpp index 576bdd78bf..2014d1cf95 100644 --- a/src/video/opengl.cpp +++ b/src/video/opengl.cpp @@ -1309,7 +1309,7 @@ void OpenGLBackend::RenderOglSprite(OpenGLSprite *gl_sprite, PaletteID pal, int _glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); _glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, 256, GetNonSprite(GB(pal, 0, PALETTE_WIDTH), ST_RECOLOUR) + 1); - _glTexSubImage1D(GL_TEXTURE_1D, 0, 0, 256, GL_RED, GL_UNSIGNED_BYTE, 0); + _glTexSubImage1D(GL_TEXTURE_1D, 0, 0, 256, GL_RED, GL_UNSIGNED_BYTE, nullptr); _glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); diff --git a/src/video/sdl2_v.cpp b/src/video/sdl2_v.cpp index 66bea5d8c3..98c04fd85c 100644 --- a/src/video/sdl2_v.cpp +++ b/src/video/sdl2_v.cpp @@ -593,7 +593,7 @@ void VideoDriver_SDL_Base::Stop() void VideoDriver_SDL_Base::InputLoop() { uint32 mod = SDL_GetModState(); - const Uint8 *keys = SDL_GetKeyboardState(NULL); + const Uint8 *keys = SDL_GetKeyboardState(nullptr); bool old_ctrl_pressed = _ctrl_pressed;