Skip to content

Commit 5903988

Browse files
committed
refactor: modernize NULL to nullptr across entire codebase
1 parent dcd010a commit 5903988

File tree

1,890 files changed

+28091
-27334
lines changed

Some content is hidden

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

1,890 files changed

+28091
-27334
lines changed

Core/GameEngine/Include/Common/ArchiveFileSystem.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
// Includes
5050
//----------------------------------------------------------------------------
5151

52+
#include <Utility/CppMacros.h>
5253
#include "Common/SubsystemInterface.h"
5354
#include "Common/AsciiString.h"
5455
#include "Common/FileSystem.h" // for typedefs, etc.
@@ -156,8 +157,8 @@ class ArchiveFileSystem : public SubsystemInterface
156157
protected:
157158
struct ArchivedDirectoryInfoResult
158159
{
159-
ArchivedDirectoryInfoResult() : dirInfo(NULL) {}
160-
Bool valid() const { return dirInfo != NULL; }
160+
ArchivedDirectoryInfoResult() : dirInfo(nullptr) {}
161+
Bool valid() const { return dirInfo != nullptr; }
161162

162163
ArchivedDirectoryInfo* dirInfo;
163164
AsciiString lastToken; ///< Synonymous for file name if the search directory was a file path

Core/GameEngine/Include/Common/AsciiString.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ class AsciiString
353353
token was found. (note that this modifies 'this' as well, stripping
354354
the token off!)
355355
*/
356-
Bool nextToken(AsciiString* token, const char* seps = NULL);
356+
Bool nextToken(AsciiString* token, const char* seps = nullptr);
357357

358358
/**
359359
return true iff the string is "NONE" (case-insensitive).
@@ -390,7 +390,7 @@ inline char* AsciiString::peek() const
390390
}
391391

392392
// -----------------------------------------------------
393-
inline AsciiString::AsciiString() : m_data(0)
393+
inline AsciiString::AsciiString() : m_data(nullptr)
394394
{
395395
validate();
396396
}
@@ -420,7 +420,7 @@ inline int AsciiString::getByteCount() const
420420
inline Bool AsciiString::isEmpty() const
421421
{
422422
validate();
423-
return m_data == NULL || peek()[0] == 0;
423+
return m_data == nullptr || peek()[0] == 0;
424424
}
425425

426426
// -----------------------------------------------------
@@ -501,14 +501,14 @@ inline int AsciiString::compare(const char* s) const
501501
inline int AsciiString::compareNoCase(const AsciiString& stringSrc) const
502502
{
503503
validate();
504-
return _stricmp(this->str(), stringSrc.str());
504+
return strcmp(this->str(), stringSrc.str());
505505
}
506506

507507
// -----------------------------------------------------
508508
inline int AsciiString::compareNoCase(const char* s) const
509509
{
510510
validate();
511-
return _stricmp(this->str(), s);
511+
return strcmp(this->str(), s);
512512
}
513513

514514
// -----------------------------------------------------

Core/GameEngine/Include/Common/AudioEventInfo.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
#pragma once
3030

31+
#include <Utility/CppMacros.h>
3132
#include "Common/AsciiString.h"
3233
#include "Common/GameMemory.h"
3334
#include "Common/STLTypedefs.h"
@@ -123,8 +124,8 @@ struct AudioEventInfo : public MemoryPoolObject
123124

124125
// DynamicAudioEventInfo interfacing functions
125126
virtual Bool isLevelSpecific() const { return false; } ///< If true, this sound is only defined on the current level and can be deleted when that level ends
126-
virtual DynamicAudioEventInfo * getDynamicAudioEventInfo() { return NULL; } ///< If this object is REALLY a DynamicAudioEventInfo, return a pointer to the derived class
127-
virtual const DynamicAudioEventInfo * getDynamicAudioEventInfo() const { return NULL; } ///< If this object is REALLY a DynamicAudioEventInfo, return a pointer to the derived class
127+
virtual DynamicAudioEventInfo * getDynamicAudioEventInfo() { return nullptr; } ///< If this object is REALLY a DynamicAudioEventInfo, return a pointer to the derived class
128+
virtual const DynamicAudioEventInfo * getDynamicAudioEventInfo() const { return nullptr; } ///< If this object is REALLY a DynamicAudioEventInfo, return a pointer to the derived class
128129

129130
/// Is this a permenant sound? That is, if I start this sound up, will it ever end
130131
/// "on its own" or only if I explicitly kill it?

Core/GameEngine/Include/Common/GameAudio.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ class AudioManagerDummy : public AudioManager
395395
virtual AsciiString getMusicTrackName() const { return ""; }
396396
virtual void openDevice() {}
397397
virtual void closeDevice() {}
398-
virtual void* getDevice() { return NULL; }
398+
virtual void* getDevice() { return nullptr; }
399399
virtual void notifyOfAudioCompletion(UnsignedInt audioCompleted, UnsignedInt flags) {}
400400
virtual UnsignedInt getProviderCount(void) const { return 0; };
401401
virtual AsciiString getProviderName(UnsignedInt providerNum) const { return ""; }
@@ -416,7 +416,7 @@ class AudioManagerDummy : public AudioManager
416416
virtual void removePlayingAudio(AsciiString eventName) {}
417417
virtual void removeAllDisabledAudio() {}
418418
virtual Bool has3DSensitiveStreamsPlaying(void) const { return false; }
419-
virtual void* getHandleForBink(void) { return NULL; }
419+
virtual void* getHandleForBink(void) { return nullptr; }
420420
virtual void releaseHandleForBink(void) {}
421421
virtual void friend_forcePlayAudioEventRTS(const AudioEventRTS* eventToPlay) {}
422422
virtual void setPreferredProvider(AsciiString providerNdx) {}

Core/GameEngine/Include/Common/GameMemory.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ class MemoryPoolFactory
545545
/// destroy the contents of all pools and dmas. (the pools and dma's are not destroyed, just reset)
546546
void reset();
547547

548-
void memoryPoolUsageReport( const char* filename, FILE *appendToFileInstead = NULL );
548+
void memoryPoolUsageReport( const char* filename, FILE *appendToFileInstead = nullptr );
549549

550550
#ifdef MEMORYPOOL_DEBUG
551551

@@ -743,7 +743,7 @@ class MemoryPoolObject
743743
virtual ~MemoryPoolObject() { }
744744

745745
protected:
746-
inline void *operator new(size_t s) { DEBUG_CRASH(("This should be impossible")); return 0; }
746+
inline void *operator new(size_t s) { DEBUG_CRASH(("This should be impossible")); return nullptr; }
747747
inline void operator delete(void *p) { DEBUG_CRASH(("This should be impossible")); }
748748

749749
protected:
@@ -902,9 +902,9 @@ class MemoryPoolObjectHolder
902902
private:
903903
MemoryPoolObject *m_mpo;
904904
public:
905-
MemoryPoolObjectHolder(MemoryPoolObject *mpo = NULL) : m_mpo(mpo) { }
905+
MemoryPoolObjectHolder(MemoryPoolObject *mpo = nullptr) : m_mpo(mpo) { }
906906
void hold(MemoryPoolObject *mpo) { DEBUG_ASSERTCRASH(!m_mpo, ("already holding")); m_mpo = mpo; }
907-
void release() { m_mpo = NULL; }
907+
void release() { m_mpo = nullptr; }
908908
~MemoryPoolObjectHolder() { deleteInstance(m_mpo); }
909909
};
910910

Core/GameEngine/Include/Common/LocalFile.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
// Includes
4848
//----------------------------------------------------------------------------
4949

50+
#include <Utility/CppMacros.h>
5051
#include "Common/file.h"
5152

5253
#if USE_BUFFERED_IO
@@ -103,7 +104,7 @@ class LocalFile : public File
103104
virtual Int writeChar( const WideChar* character ); ///< Write a wide character to the file
104105
virtual Int seek( Int new_pos, seekMode mode = CURRENT ); ///< Set file position: See File::seek
105106
virtual Bool flush(); ///< flush data to disk
106-
virtual void nextLine(Char *buf = NULL, Int bufSize = 0); ///< moves file position to after the next new-line
107+
virtual void nextLine(Char *buf = nullptr, Int bufSize = 0); ///< moves file position to after the next new-line
107108
virtual Bool scanInt(Int &newInt); ///< return what gets read in as an integer at the current file position.
108109
virtual Bool scanReal(Real &newReal); ///< return what gets read in as a float at the current file position.
109110
virtual Bool scanString(AsciiString &newString); ///< return what gets read in as a string at the current file position.

Core/GameEngine/Include/Common/RAMFile.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
// Includes
4848
//----------------------------------------------------------------------------
4949

50+
#include <Utility/CppMacros.h>
5051
#include "Common/file.h"
5152

5253
//----------------------------------------------------------------------------
@@ -94,7 +95,7 @@ class RAMFile : public File
9495
virtual Int writeChar( const WideChar* character ); ///< Write a wide character to the file
9596
virtual Int seek( Int new_pos, seekMode mode = CURRENT ); ///< Set file position: See File::seek
9697
virtual Bool flush(); ///< flush data to disk
97-
virtual void nextLine(Char *buf = NULL, Int bufSize = 0); ///< moves current position to after the next new-line
98+
virtual void nextLine(Char *buf = nullptr, Int bufSize = 0); ///< moves current position to after the next new-line
9899

99100
virtual Bool scanInt(Int &newInt); ///< return what gets read as an integer from the current memory position.
100101
virtual Bool scanReal(Real &newReal); ///< return what gets read as a float from the current memory position.

Core/GameEngine/Include/Common/Radar.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ static const char *const RadarPriorityNames[] =
143143
"UNIT", // unit level drawing priority
144144
"LOCAL_UNIT_ONLY", // unit priority, but only on the radar if controlled by the local player
145145

146-
NULL
146+
nullptr
147147
};
148148
static_assert(ARRAY_SIZE(RadarPriorityNames) == RADAR_PRIORITY_NUM_PRIORITIES + 1, "Incorrect array size");
149149
#endif // DEFINE_RADAR_PRIOTITY_NAMES
@@ -165,7 +165,7 @@ class Radar : public Snapshot,
165165
virtual void update( void ); ///< subsystem per frame update
166166

167167
// is the game window parameter the radar window
168-
Bool isRadarWindow( GameWindow *window ) { return (m_radarWindow == window) && (m_radarWindow != NULL); }
168+
Bool isRadarWindow( GameWindow *window ) { return (m_radarWindow == window) && (m_radarWindow != nullptr); }
169169

170170
Bool radarToWorld( const ICoord2D *radar, Coord3D *world ); ///< radar point to world point on terrain
171171
Bool radarToWorld2D( const ICoord2D *radar, Coord3D *world ); ///< radar point to world point (x,y only!)

Core/GameEngine/Include/Common/StreamingArchiveFile.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
// Includes
4848
//----------------------------------------------------------------------------
4949

50+
#include <Utility/CppMacros.h>
5051
#include "Common/RAMFile.h"
5152

5253
//----------------------------------------------------------------------------
@@ -90,7 +91,7 @@ class StreamingArchiveFile : public RAMFile
9091
virtual Int seek( Int new_pos, seekMode mode = CURRENT ); ///< Set file position: See File::seek
9192

9293
// Ini's should not be parsed with streaming files, that's just dumb.
93-
virtual void nextLine(Char *buf = NULL, Int bufSize = 0) { DEBUG_CRASH(("Should not call nextLine on a streaming file.")); }
94+
virtual void nextLine(Char *buf = nullptr, Int bufSize = 0) { DEBUG_CRASH(("Should not call nextLine on a streaming file.")); }
9495
virtual Bool scanInt(Int &newInt) { DEBUG_CRASH(("Should not call scanInt on a streaming file.")); return FALSE; }
9596
virtual Bool scanReal(Real &newReal) { DEBUG_CRASH(("Should not call scanReal on a streaming file.")); return FALSE; }
9697
virtual Bool scanString(AsciiString &newString) { DEBUG_CRASH(("Should not call scanString on a streaming file.")); return FALSE; }
@@ -99,7 +100,7 @@ class StreamingArchiveFile : public RAMFile
99100
virtual Bool openFromArchive(File *archiveFile, const AsciiString& filename, Int offset, Int size); ///< copy file data from the given file at the given offset for the given size.
100101
virtual Bool copyDataToFile(File *localFile) { DEBUG_CRASH(("Are you sure you meant to copyDataToFile on a streaming file?")); return FALSE; }
101102

102-
virtual char* readEntireAndClose() { DEBUG_CRASH(("Are you sure you meant to readEntireAndClose on a streaming file?")); return NULL; }
103+
virtual char* readEntireAndClose() { DEBUG_CRASH(("Are you sure you meant to readEntireAndClose on a streaming file?")); return nullptr; }
103104
virtual File* convertToRAMFile() { DEBUG_CRASH(("Are you sure you meant to readEntireAndClose on a streaming file?")); return this; }
104105
};
105106

Core/GameEngine/Include/Common/UnicodeString.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ inline WideChar* UnicodeString::peek() const
364364
}
365365

366366
// -----------------------------------------------------
367-
inline UnicodeString::UnicodeString() : m_data(0)
367+
inline UnicodeString::UnicodeString() : m_data(nullptr)
368368
{
369369
validate();
370370
}
@@ -394,7 +394,7 @@ inline int UnicodeString::getByteCount() const
394394
inline Bool UnicodeString::isEmpty() const
395395
{
396396
validate();
397-
return m_data == NULL || peek()[0] == 0;
397+
return m_data == nullptr || peek()[0] == 0;
398398
}
399399

400400
// -----------------------------------------------------
@@ -475,14 +475,14 @@ inline int UnicodeString::compare(const WideChar* s) const
475475
inline int UnicodeString::compareNoCase(const UnicodeString& stringSrc) const
476476
{
477477
validate();
478-
return _wcsicmp(this->str(), stringSrc.str());
478+
return strcasecmp(this->str(), stringSrc.str());
479479
}
480480

481481
// -----------------------------------------------------
482482
inline int UnicodeString::compareNoCase(const WideChar* s) const
483483
{
484484
validate();
485-
return _wcsicmp(this->str(), s);
485+
return strcasecmp(this->str(), s);
486486
}
487487

488488
// -----------------------------------------------------

0 commit comments

Comments
 (0)