Skip to content

Commit 4963188

Browse files
committed
Replace zero constants with nullptr
1 parent ec20c75 commit 4963188

100 files changed

Lines changed: 484 additions & 484 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/base/system.cpp

Lines changed: 50 additions & 50 deletions
Large diffs are not rendered by default.

src/base/unicode/confusables.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ static int str_utf8_skeleton(int ch, const int **skeleton, int *skeleton_len)
2323
break;
2424
}
2525
}
26-
*skeleton = NULL;
26+
*skeleton = nullptr;
2727
*skeleton_len = 1;
2828
return 0;
2929
}
@@ -37,7 +37,7 @@ struct SKELETON
3737

3838
static void str_utf8_skeleton_begin(struct SKELETON *skel, const char *str)
3939
{
40-
skel->skeleton = NULL;
40+
skel->skeleton = nullptr;
4141
skel->skeleton_len = 0;
4242
skel->str = str;
4343
}
@@ -55,7 +55,7 @@ static int str_utf8_skeleton_next(struct SKELETON *skel)
5555
str_utf8_skeleton(ch, &skel->skeleton, &skel->skeleton_len);
5656
}
5757
skel->skeleton_len--;
58-
if(skel->skeleton != NULL)
58+
if(skel->skeleton != nullptr)
5959
{
6060
ch = *skel->skeleton;
6161
skel->skeleton++;

src/base/unicode/tolower.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ int str_utf8_tolower(int code)
1616
key.upper = code;
1717
res = (UPPER_LOWER *)bsearch(&key, tolowermap, NUM_TOLOWER, sizeof(struct UPPER_LOWER), compul);
1818

19-
if(res == NULL)
19+
if(res == nullptr)
2020
return code;
2121
return res->lower;
2222
}

src/engine/client/backend_sdl.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ void CCommandProcessorFragment_SDL::Cmd_Init(const SCommand_Init *pCommand)
209209
void CCommandProcessorFragment_SDL::Cmd_Shutdown(const SCommand_Shutdown *pCommand)
210210
{
211211
if(m_GLContext)
212-
SDL_GL_MakeCurrent(NULL, NULL);
212+
SDL_GL_MakeCurrent(nullptr, nullptr);
213213
}
214214

215215
void CCommandProcessorFragment_SDL::Cmd_Swap(const CCommandBuffer::SCommand_Swap *pCommand)
@@ -909,8 +909,8 @@ void CGraphicsBackend_SDL_GL::GetVideoModes(CVideoMode *pModes, int MaxModes, in
909909

910910
// Only collect fullscreen modes when requested, that makes sure in windowed mode no refresh rates are shown that aren't supported without
911911
// fullscreen anyway(except fullscreen desktop)
912-
bool IsFullscreenDestkop = m_pWindow != NULL && (((SDL_GetWindowFlags(m_pWindow) & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) || g_Config.m_GfxFullscreen == 3);
913-
bool CollectFullscreenModes = m_pWindow == NULL || ((SDL_GetWindowFlags(m_pWindow) & SDL_WINDOW_FULLSCREEN) != 0 && !IsFullscreenDestkop);
912+
bool IsFullscreenDestkop = m_pWindow != nullptr && (((SDL_GetWindowFlags(m_pWindow) & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) || g_Config.m_GfxFullscreen == 3);
913+
bool CollectFullscreenModes = m_pWindow == nullptr || ((SDL_GetWindowFlags(m_pWindow) & SDL_WINDOW_FULLSCREEN) != 0 && !IsFullscreenDestkop);
914914

915915
if(SDL_GetDesktopDisplayMode(ScreenId, &DesktopMode) < 0)
916916
{
@@ -1203,7 +1203,7 @@ int CGraphicsBackend_SDL_GL::Init(const char *pName, int *pScreen, int *pWidth,
12031203
SdlFlags);
12041204

12051205
// set caption
1206-
if(m_pWindow == NULL)
1206+
if(m_pWindow == nullptr)
12071207
{
12081208
dbg_msg("gfx", "unable to create window: %s", SDL_GetError());
12091209
if(m_BackendType == BACKEND_TYPE_VULKAN)
@@ -1220,7 +1220,7 @@ int CGraphicsBackend_SDL_GL::Init(const char *pName, int *pScreen, int *pWidth,
12201220
{
12211221
m_GLContext = SDL_GL_CreateContext(m_pWindow);
12221222

1223-
if(m_GLContext == NULL)
1223+
if(m_GLContext == nullptr)
12241224
{
12251225
SDL_DestroyWindow(m_pWindow);
12261226
m_pWindow = nullptr;
@@ -1238,7 +1238,7 @@ int CGraphicsBackend_SDL_GL::Init(const char *pName, int *pScreen, int *pWidth,
12381238
}
12391239

12401240
int InitError = 0;
1241-
const char *pErrorStr = NULL;
1241+
const char *pErrorStr = nullptr;
12421242

12431243
InitError = IsVersionSupportedGlew(m_BackendType, g_Config.m_GfxGLMajor, g_Config.m_GfxGLMinor, g_Config.m_GfxGLPatch, GlewMajor, GlewMinor, GlewPatch);
12441244

@@ -1251,7 +1251,7 @@ int CGraphicsBackend_SDL_GL::Init(const char *pName, int *pScreen, int *pWidth,
12511251
if(IsOpenGLFamilyBackend)
12521252
{
12531253
SDL_GL_SetSwapInterval(Flags & IGraphicsBackend::INITFLAG_VSYNC ? 1 : 0);
1254-
SDL_GL_MakeCurrent(NULL, NULL);
1254+
SDL_GL_MakeCurrent(nullptr, nullptr);
12551255
}
12561256

12571257
if(InitError != 0)
@@ -1372,7 +1372,7 @@ int CGraphicsBackend_SDL_GL::Init(const char *pName, int *pScreen, int *pWidth,
13721372
g_Config.m_GfxGLPatch = m_Capabilites.m_ContextPatch;
13731373
}
13741374

1375-
if(pErrorStr != NULL)
1375+
if(pErrorStr != nullptr)
13761376
{
13771377
str_copy(m_aErrorString, pErrorStr);
13781378
}

src/engine/client/backend_sdl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ class CGraphicsBackend_SDL_GL : public CGraphicsBackend_Threaded
279279
if(m_aErrorString[0] != '\0')
280280
return m_aErrorString;
281281

282-
return NULL;
282+
return nullptr;
283283
}
284284

285285
const char *GetVendorString() override

src/engine/client/blocklist_driver.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ static SBackEndDriverBlockList gs_aBlockList[] = {
5555

5656
const char *ParseBlocklistDriverVersions(const char *pVendorStr, const char *pVersionStr, int &BlocklistMajor, int &BlocklistMinor, int &BlocklistPatch, bool &RequiresWarning)
5757
{
58-
if(str_find_nocase(pVendorStr, "Intel") == NULL)
59-
return NULL;
58+
if(str_find_nocase(pVendorStr, "Intel") == nullptr)
59+
return nullptr;
6060

6161
const char *pVersionStrStart = str_find_nocase(pVersionStr, "Build ");
62-
if(pVersionStrStart == NULL)
63-
return NULL;
62+
if(pVersionStrStart == nullptr)
63+
return nullptr;
6464

6565
// ignore "Build ", after that, it should directly start with the driver version
6666
pVersionStrStart += (ptrdiff_t)str_length("Build ");
@@ -71,8 +71,8 @@ const char *ParseBlocklistDriverVersions(const char *pVendorStr, const char *pVe
7171
for(int &VersionPart : Version.m_aParts)
7272
{
7373
pVersionStrStart = str_next_token(pVersionStrStart, ".", aVersionStrHelper, sizeof(aVersionStrHelper));
74-
if(pVersionStrStart == NULL)
75-
return NULL;
74+
if(pVersionStrStart == nullptr)
75+
return nullptr;
7676

7777
VersionPart = str_toint(aVersionStrHelper);
7878
}
@@ -84,7 +84,7 @@ const char *ParseBlocklistDriverVersions(const char *pVendorStr, const char *pVe
8484
bool DriverBlocked = false;
8585
if(BlockListItem.m_BlockListType == BACKEND_DRIVER_BLOCKLIST_TYPE_VENDOR)
8686
{
87-
if(str_find_nocase(pVendorStr, BlockListItem.m_pVendorName) != NULL)
87+
if(str_find_nocase(pVendorStr, BlockListItem.m_pVendorName) != nullptr)
8888
{
8989
DriverBlocked = true;
9090
}
@@ -108,5 +108,5 @@ const char *ParseBlocklistDriverVersions(const char *pVendorStr, const char *pVe
108108
}
109109
}
110110

111-
return NULL;
111+
return nullptr;
112112
}

src/engine/client/client.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ int *CClient::GetInput(int Tick, int IsDummy) const
396396

397397
if(Best != -1)
398398
return (int *)m_aInputs[d][Best].m_aData;
399-
return 0;
399+
return nullptr;
400400
}
401401

402402
// ------ state handling -----
@@ -695,8 +695,8 @@ void CClient::DisconnectWithReason(const char *pReason)
695695
mem_zero(&m_CurrentServerInfo, sizeof(m_CurrentServerInfo));
696696

697697
// clear snapshots
698-
m_aapSnapshots[0][SNAP_CURRENT] = 0;
699-
m_aapSnapshots[0][SNAP_PREV] = 0;
698+
m_aapSnapshots[0][SNAP_CURRENT] = nullptr;
699+
m_aapSnapshots[0][SNAP_PREV] = nullptr;
700700
m_aReceivedSnapshots[0] = 0;
701701
m_LastDummy = false;
702702

@@ -782,8 +782,8 @@ void CClient::DummyDisconnect(const char *pReason)
782782
g_Config.m_ClDummy = 0;
783783

784784
m_aRconAuthed[1] = 0;
785-
m_aapSnapshots[1][SNAP_CURRENT] = 0;
786-
m_aapSnapshots[1][SNAP_PREV] = 0;
785+
m_aapSnapshots[1][SNAP_CURRENT] = nullptr;
786+
m_aapSnapshots[1][SNAP_PREV] = nullptr;
787787
m_aReceivedSnapshots[1] = 0;
788788
m_DummyConnected = false;
789789
m_DummyConnecting = false;
@@ -1018,7 +1018,7 @@ const char *CClient::DummyName()
10181018
{
10191019
return g_Config.m_ClDummyName;
10201020
}
1021-
const char *pBase = 0;
1021+
const char *pBase = nullptr;
10221022
if(g_Config.m_PlayerName[0])
10231023
{
10241024
pBase = g_Config.m_PlayerName;
@@ -1106,7 +1106,7 @@ const char *CClient::LoadMap(const char *pName, const char *pFilename, SHA256_DI
11061106
str_copy(m_aCurrentMap, pName);
11071107
str_copy(m_aCurrentMapPath, pFilename);
11081108

1109-
return 0;
1109+
return nullptr;
11101110
}
11111111

11121112
static void FormatMapDownloadFilename(const char *pName, const SHA256_DIGEST *pSha256, int Crc, bool Temp, char *pBuffer, int BufferSize)
@@ -1162,7 +1162,7 @@ const char *CClient::LoadMapSearch(const char *pMapName, SHA256_DIGEST *pWantedS
11621162
// backward compatibility with old names
11631163
if(pWantedSha256)
11641164
{
1165-
FormatMapDownloadFilename(pMapName, 0, WantedCrc, false, aBuf, sizeof(aBuf));
1165+
FormatMapDownloadFilename(pMapName, nullptr, WantedCrc, false, aBuf, sizeof(aBuf));
11661166
pError = LoadMap(pMapName, aBuf, pWantedSha256, WantedCrc);
11671167
if(!pError)
11681168
return nullptr;
@@ -1559,7 +1559,7 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket, int Conn, bool Dummy)
15591559

15601560
if(m_DummyConnected && !m_DummyReconnectOnReload)
15611561
{
1562-
DummyDisconnect(0);
1562+
DummyDisconnect(nullptr);
15631563
}
15641564

15651565
ResetMapDownload(true);
@@ -1657,7 +1657,7 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket, int Conn, bool Dummy)
16571657
if(m_MapdownloadFileTemp)
16581658
{
16591659
io_close(m_MapdownloadFileTemp);
1660-
m_MapdownloadFileTemp = 0;
1660+
m_MapdownloadFileTemp = nullptr;
16611661
}
16621662
FinishMapDownload();
16631663
}
@@ -2326,7 +2326,7 @@ void CClient::ResetMapDownload(bool ResetActive)
23262326
if(m_MapdownloadFileTemp)
23272327
{
23282328
io_close(m_MapdownloadFileTemp);
2329-
m_MapdownloadFileTemp = 0;
2329+
m_MapdownloadFileTemp = nullptr;
23302330
}
23312331

23322332
if(Storage()->FileExists(m_aMapdownloadFilenameTemp, IStorage::TYPE_SAVE))
@@ -2389,7 +2389,7 @@ void CClient::ResetDDNetInfoTask()
23892389
if(m_pDDNetInfoTask)
23902390
{
23912391
m_pDDNetInfoTask->Abort();
2392-
m_pDDNetInfoTask = NULL;
2392+
m_pDDNetInfoTask = nullptr;
23932393
}
23942394
}
23952395

@@ -2407,7 +2407,7 @@ TVersion ToVersion(char *pStr)
24072407
return gs_InvalidVersion;
24082408

24092409
aVersion[i] = str_toint(p);
2410-
p = strtok(NULL, ".");
2410+
p = strtok(nullptr, ".");
24112411
}
24122412

24132413
if(p)
@@ -3273,7 +3273,7 @@ void CClient::Run()
32733273
if(time_get() > m_BenchmarkStopTime)
32743274
{
32753275
io_close(m_BenchmarkFile);
3276-
m_BenchmarkFile = 0;
3276+
m_BenchmarkFile = nullptr;
32773277
Quit();
32783278
}
32793279
}
@@ -3567,7 +3567,7 @@ void CClient::AutoCSV_Cleanup()
35673567
void CClient::Con_Screenshot(IConsole::IResult *pResult, void *pUserData)
35683568
{
35693569
CClient *pSelf = (CClient *)pUserData;
3570-
pSelf->Graphics()->TakeScreenshot(0);
3570+
pSelf->Graphics()->TakeScreenshot(nullptr);
35713571
}
35723572

35733573
#if defined(CONF_VIDEORECORDER)
@@ -3928,7 +3928,7 @@ const char *CClient::DemoPlayer_Play(const char *pFilename, int StorageType)
39283928
m_DemoPlayer.Play();
39293929
GameClient()->OnEnterGame();
39303930

3931-
return 0;
3931+
return nullptr;
39323932
}
39333933

39343934
#if defined(CONF_VIDEORECORDER)
@@ -4009,7 +4009,7 @@ void CClient::DemoRecorder_Start(const char *pFilename, bool WithTimestamp, int
40094009
m_pMap->Crc(),
40104010
"client",
40114011
m_pMap->MapSize(),
4012-
0,
4012+
nullptr,
40134013
m_pMap->File(),
40144014
nullptr,
40154015
nullptr);
@@ -5013,7 +5013,7 @@ void CClient::RaceRecord_Start(const char *pFilename)
50135013
m_pMap->Crc(),
50145014
"client",
50155015
m_pMap->MapSize(),
5016-
0,
5016+
nullptr,
50175017
m_pMap->File(),
50185018
nullptr,
50195019
nullptr);

src/engine/client/client.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ class CClient : public IClient, public CDemoPlayer::IListener
150150
char m_aMapdownloadFilename[256] = "";
151151
char m_aMapdownloadFilenameTemp[256] = "";
152152
char m_aMapdownloadName[256] = "";
153-
IOHANDLE m_MapdownloadFileTemp = 0;
153+
IOHANDLE m_MapdownloadFileTemp = nullptr;
154154
int m_MapdownloadChunk = 0;
155155
int m_MapdownloadCrc = 0;
156156
int m_MapdownloadAmount = -1;
@@ -245,12 +245,12 @@ class CClient : public IClient, public CDemoPlayer::IListener
245245

246246
CFifo m_Fifo;
247247

248-
IOHANDLE m_BenchmarkFile = 0;
248+
IOHANDLE m_BenchmarkFile = nullptr;
249249
int64_t m_BenchmarkStopTime = 0;
250250

251251
CChecksum m_Checksum;
252252
int64_t m_OwnExecutableSize = 0;
253-
IOHANDLE m_OwnExecutable = 0;
253+
IOHANDLE m_OwnExecutable = nullptr;
254254

255255
// favorite command handling
256256
bool m_FavoritesGroup = false;

src/engine/client/demoedit.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ CDemoEdit::CDemoEdit(const char *pNetVersion, class CSnapshotDelta *pSnapshotDel
1414
m_EndTick = EndTick;
1515

1616
// Init the demoeditor
17-
m_DemoEditor.Init(&m_SnapshotDelta, NULL, pStorage);
17+
m_DemoEditor.Init(&m_SnapshotDelta, nullptr, pStorage);
1818
}
1919

2020
void CDemoEdit::Run()
2121
{
2222
// Slice the current demo
23-
m_Success = m_DemoEditor.Slice(m_aDemo, m_aDst, m_StartTick, m_EndTick, NULL, 0);
23+
m_Success = m_DemoEditor.Slice(m_aDemo, m_aDst, m_StartTick, m_EndTick, nullptr, nullptr);
2424
// We remove the temporary demo file if slicing is successful
2525
if(m_Success)
2626
m_pStorage->RemoveFile(m_aDemo, IStorage::TYPE_SAVE);

src/engine/client/discord.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ IDiscord *CreateDiscordImpl()
100100
#else
101101
IDiscord *CreateDiscordImpl()
102102
{
103-
return 0;
103+
return nullptr;
104104
}
105105
#endif
106106

0 commit comments

Comments
 (0)