Skip to content

Commit 149474b

Browse files
committed
refactor(generals): modernize NULL to nullptr
1 parent 8826e20 commit 149474b

File tree

203 files changed

+4851
-4851
lines changed

Some content is hidden

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

203 files changed

+4851
-4851
lines changed

Generals/Code/GameEngine/Source/Common/Thing/ThingFactory.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
enum { TEMPLATE_HASH_SIZE = 12288 };
5353

5454
// PUBLIC DATA ////////////////////////////////////////////////////////////////////////////////////
55-
ThingFactory *TheThingFactory = NULL; ///< Thing manager singleton declaration
55+
ThingFactory *TheThingFactory = nullptr; ///< Thing manager singleton declaration
5656

5757
// STATIC FUNCTIONS ///////////////////////////////////////////////////////////////////////////////
5858

@@ -103,7 +103,7 @@ void ThingFactory::addTemplate( ThingTemplate *tmplate )
103103
//-------------------------------------------------------------------------------------------------
104104
ThingFactory::ThingFactory()
105105
{
106-
m_firstTemplate = NULL;
106+
m_firstTemplate = nullptr;
107107
m_nextTemplateID = 1; // not zero!
108108

109109
#ifdef USING_STLPORT
@@ -227,11 +227,11 @@ void ThingFactory::reset( void )
227227
AsciiString templateName = t->getName();
228228

229229
Overridable *stillValid = t->deleteOverrides();
230-
if (stillValid == NULL && possibleAdjustment) {
230+
if (stillValid == nullptr && possibleAdjustment) {
231231
m_firstTemplate = nextT;
232232
}
233233

234-
if (stillValid == NULL) {
234+
if (stillValid == nullptr) {
235235
// Also needs to be removed from the Hash map.
236236
m_templateHashMap.erase(templateName);
237237
}
@@ -259,7 +259,7 @@ const ThingTemplate *ThingFactory::findByTemplateID( UnsignedShort id )
259259
return tmpl;
260260
}
261261
DEBUG_CRASH(("template %d not found",(Int)id));
262-
return NULL;
262+
return nullptr;
263263
}
264264

265265
//-------------------------------------------------------------------------------------------------
@@ -293,22 +293,22 @@ ThingTemplate *ThingFactory::findTemplateInternal( const AsciiString& name )
293293
#endif
294294

295295
//DEBUG_LOG(("*** Object template %s not found",name.str()));
296-
return NULL;
296+
return nullptr;
297297

298298
}
299299

300300
//=============================================================================
301301
Object *ThingFactory::newObject( const ThingTemplate *tmplate, Team *team, ObjectStatusMaskType statusBits )
302302
{
303-
if (tmplate == NULL)
303+
if (tmplate == nullptr)
304304
throw ERROR_BAD_ARG;
305305

306306
const std::vector<AsciiString>& asv = tmplate->getBuildVariations();
307307
if (!asv.empty())
308308
{
309309
Int which = GameLogicRandomValue(0, asv.size()-1);
310310
const ThingTemplate* tmp = findTemplate( asv[which] );
311-
if (tmp != NULL)
311+
if (tmp != nullptr)
312312
tmplate = tmp;
313313
}
314314

@@ -345,7 +345,7 @@ Object *ThingFactory::newObject( const ThingTemplate *tmplate, Team *team, Objec
345345
//=============================================================================
346346
Drawable *ThingFactory::newDrawable(const ThingTemplate *tmplate, DrawableStatusBits statusBits)
347347
{
348-
if (tmplate == NULL)
348+
if (tmplate == nullptr)
349349
throw ERROR_BAD_ARG;
350350

351351
Drawable *draw = TheGameClient->friend_createDrawable( tmplate, statusBits );

Generals/Code/GameEngine/Source/Common/Thing/ThingTemplate.cpp

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

Generals/Code/GameEngine/Source/Common/UserPreferences.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ Bool UserPreferences::load(AsciiString fname)
126126
if (fp)
127127
{
128128
char buf[LINE_LEN];
129-
while( fgets( buf, LINE_LEN, fp ) != NULL )
129+
while( fgets( buf, LINE_LEN, fp ) != nullptr )
130130
{
131131
AsciiString line = buf;
132132
line.trim();
@@ -700,7 +700,7 @@ Money CustomMatchPreferences::getStartingCash(void) const
700700
}
701701

702702
Money money;
703-
money.deposit( strtoul( it->second.str(), NULL, 10 ), FALSE, FALSE );
703+
money.deposit( strtoul( it->second.str(), nullptr, 10 ), FALSE, FALSE );
704704

705705
return money;
706706
}

Generals/Code/GameEngine/Source/Common/version.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
#include "gitinfo.h"
3535

36-
Version *TheVersion = NULL; ///< The Version singleton
36+
Version *TheVersion = nullptr; ///< The Version singleton
3737

3838
Version::Version()
3939
{

Generals/Code/GameEngine/Source/GameClient/ClientInstance.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
namespace rts
2424
{
25-
HANDLE ClientInstance::s_mutexHandle = NULL;
25+
HANDLE ClientInstance::s_mutexHandle = nullptr;
2626
UnsignedInt ClientInstance::s_instanceIndex = 0;
2727

2828
#if defined(RTS_MULTI_INSTANCE)
@@ -52,13 +52,13 @@ bool ClientInstance::initialize()
5252
guidStr.push_back('-');
5353
guidStr.append(idStr);
5454
}
55-
s_mutexHandle = CreateMutex(NULL, FALSE, guidStr.c_str());
55+
s_mutexHandle = CreateMutex(nullptr, FALSE, guidStr.c_str());
5656
if (GetLastError() == ERROR_ALREADY_EXISTS)
5757
{
58-
if (s_mutexHandle != NULL)
58+
if (s_mutexHandle != nullptr)
5959
{
6060
CloseHandle(s_mutexHandle);
61-
s_mutexHandle = NULL;
61+
s_mutexHandle = nullptr;
6262
}
6363
// Try again with a new instance.
6464
++s_instanceIndex;
@@ -67,13 +67,13 @@ bool ClientInstance::initialize()
6767
}
6868
else
6969
{
70-
s_mutexHandle = CreateMutex(NULL, FALSE, getFirstInstanceName());
70+
s_mutexHandle = CreateMutex(nullptr, FALSE, getFirstInstanceName());
7171
if (GetLastError() == ERROR_ALREADY_EXISTS)
7272
{
73-
if (s_mutexHandle != NULL)
73+
if (s_mutexHandle != nullptr)
7474
{
7575
CloseHandle(s_mutexHandle);
76-
s_mutexHandle = NULL;
76+
s_mutexHandle = nullptr;
7777
}
7878
return false;
7979
}
@@ -86,7 +86,7 @@ bool ClientInstance::initialize()
8686

8787
bool ClientInstance::isInitialized()
8888
{
89-
return s_mutexHandle != NULL;
89+
return s_mutexHandle != nullptr;
9090
}
9191

9292
bool ClientInstance::isMultiInstance()

Generals/Code/GameEngine/Source/GameClient/Credits.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -61,22 +61,22 @@
6161
//-----------------------------------------------------------------------------
6262
// DEFINES ////////////////////////////////////////////////////////////////////
6363
//-----------------------------------------------------------------------------
64-
CreditsManager *TheCredits = NULL;
64+
CreditsManager *TheCredits = nullptr;
6565

6666
const FieldParse CreditsManager::m_creditsFieldParseTable[] =
6767
{
6868

69-
{ "ScrollRate", INI::parseInt, NULL, offsetof( CreditsManager, m_scrollRate ) },
70-
{ "ScrollRateEveryFrames", INI::parseInt, NULL, offsetof( CreditsManager, m_scrollRatePerFrames ) },
71-
{ "ScrollDown", INI::parseBool, NULL, offsetof( CreditsManager, m_scrollDown ) },
72-
{ "TitleColor", INI::parseColorInt, NULL, offsetof( CreditsManager, m_titleColor ) },
73-
{ "MinorTitleColor", INI::parseColorInt, NULL, offsetof( CreditsManager, m_positionColor ) },
74-
{ "NormalColor", INI::parseColorInt, NULL, offsetof( CreditsManager, m_normalColor ) },
69+
{ "ScrollRate", INI::parseInt, nullptr, offsetof( CreditsManager, m_scrollRate ) },
70+
{ "ScrollRateEveryFrames", INI::parseInt, nullptr, offsetof( CreditsManager, m_scrollRatePerFrames ) },
71+
{ "ScrollDown", INI::parseBool, nullptr, offsetof( CreditsManager, m_scrollDown ) },
72+
{ "TitleColor", INI::parseColorInt, nullptr, offsetof( CreditsManager, m_titleColor ) },
73+
{ "MinorTitleColor", INI::parseColorInt, nullptr, offsetof( CreditsManager, m_positionColor ) },
74+
{ "NormalColor", INI::parseColorInt, nullptr, offsetof( CreditsManager, m_normalColor ) },
7575
{ "Style", INI::parseLookupList, CreditStyleNames, offsetof( CreditsManager, m_currentStyle ) },
76-
{ "Blank", CreditsManager::parseBlank, NULL, NULL },
77-
{ "Text", CreditsManager::parseText, NULL, NULL },
76+
{ "Blank", CreditsManager::parseBlank, nullptr, NULL },
77+
{ "Text", CreditsManager::parseText, nullptr, NULL },
7878

79-
{ NULL, NULL, NULL, 0 }
79+
{ nullptr, nullptr, nullptr, 0 }
8080

8181
};
8282

@@ -102,8 +102,8 @@ CreditsLine::CreditsLine()
102102
m_useSecond = FALSE;
103103
m_done = FALSE;
104104
m_style = CREDIT_STYLE_BLANK;
105-
m_displayString = NULL;
106-
m_secondDisplayString = NULL;
105+
m_displayString = nullptr;
106+
m_secondDisplayString = nullptr;
107107
}
108108

109109
CreditsLine::~CreditsLine()
@@ -113,8 +113,8 @@ CreditsLine::~CreditsLine()
113113
if(m_secondDisplayString)
114114
TheDisplayStringManager->freeDisplayString(m_secondDisplayString);
115115

116-
m_displayString = NULL;
117-
m_secondDisplayString = NULL;
116+
m_displayString = nullptr;
117+
m_secondDisplayString = nullptr;
118118
}
119119

120120

@@ -155,7 +155,7 @@ void CreditsManager::load(void )
155155
{
156156
INI ini;
157157
// Read from INI all the ControlBarSchemes
158-
ini.loadFileDirectory( "Data\\INI\\Credits", INI_LOAD_OVERWRITE, NULL );
158+
ini.loadFileDirectory( "Data\\INI\\Credits", INI_LOAD_OVERWRITE, nullptr );
159159

160160
if(m_scrollRatePerFrames <=0)
161161
m_scrollRatePerFrames = 1;
@@ -207,8 +207,8 @@ void CreditsManager::update( void )
207207
{
208208
TheDisplayStringManager->freeDisplayString(cLine->m_displayString);
209209
TheDisplayStringManager->freeDisplayString(cLine->m_secondDisplayString);
210-
cLine->m_displayString = NULL;
211-
cLine->m_secondDisplayString = NULL;
210+
cLine->m_displayString = nullptr;
211+
cLine->m_secondDisplayString = nullptr;
212212
drawIt = m_displayedCreditLineList.erase(drawIt);
213213
}
214214
else

Generals/Code/GameEngine/Source/GameClient/Display.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,31 +38,31 @@
3838
//#include "GameLogic/GameLogic.h"
3939

4040
/// The Display singleton instance.
41-
Display *TheDisplay = NULL;
41+
Display *TheDisplay = nullptr;
4242

4343

4444
Display::Display()
4545
{
46-
m_viewList = NULL;
46+
m_viewList = nullptr;
4747
m_width = 0;
4848
m_height = 0;
4949
m_bitDepth = 0;
5050
m_windowed = FALSE;
51-
m_videoBuffer = NULL;
52-
m_videoStream = NULL;
53-
m_debugDisplayCallback = NULL;
54-
m_debugDisplayUserData = NULL;
55-
m_debugDisplay = NULL;
51+
m_videoBuffer = nullptr;
52+
m_videoStream = nullptr;
53+
m_debugDisplayCallback = nullptr;
54+
m_debugDisplayUserData = nullptr;
55+
m_debugDisplay = nullptr;
5656
m_letterBoxFadeLevel = 0;
5757
m_letterBoxEnabled = FALSE;
5858
m_cinematicText = AsciiString::TheEmptyString;
59-
m_cinematicFont = NULL;
59+
m_cinematicFont = nullptr;
6060
m_cinematicTextFrames = 0;
6161
m_movieHoldTime = -1;
6262
m_copyrightHoldTime = -1;
6363
m_elapsedMovieTime = 0;
6464
m_elapsedCopywriteTime = 0;
65-
m_copyrightDisplayString = NULL;
65+
m_copyrightDisplayString = nullptr;
6666

6767
m_currentlyPlayingMovie.clear();
6868
m_letterBoxFadeStartTime = 0;
@@ -92,7 +92,7 @@ void Display::deleteViews( void )
9292
next = v->getNextView();
9393
delete v;
9494
}
95-
m_viewList = NULL;
95+
m_viewList = nullptr;
9696
}
9797

9898
/**
@@ -212,7 +212,7 @@ void Display::playLogoMovie( AsciiString movieName, Int minMovieLength, Int minC
212212

213213
m_videoStream = TheVideoPlayer->open( movieName );
214214

215-
if ( m_videoStream == NULL )
215+
if ( m_videoStream == nullptr )
216216
{
217217
return;
218218
}
@@ -223,7 +223,7 @@ void Display::playLogoMovie( AsciiString movieName, Int minMovieLength, Int minC
223223
m_elapsedMovieTime = timeGetTime(); // we're using time get time becuase legal want's actual "Seconds"
224224

225225
m_videoBuffer = createVideoBuffer();
226-
if ( m_videoBuffer == NULL ||
226+
if ( m_videoBuffer == nullptr ||
227227
!m_videoBuffer->allocate( m_videoStream->width(),
228228
m_videoStream->height())
229229
)
@@ -247,15 +247,15 @@ void Display::playMovie( AsciiString movieName)
247247

248248
m_videoStream = TheVideoPlayer->open( movieName );
249249

250-
if ( m_videoStream == NULL )
250+
if ( m_videoStream == nullptr )
251251
{
252252
return;
253253
}
254254

255255
m_currentlyPlayingMovie = movieName;
256256

257257
m_videoBuffer = createVideoBuffer();
258-
if ( m_videoBuffer == NULL ||
258+
if ( m_videoBuffer == nullptr ||
259259
!m_videoBuffer->allocate( m_videoStream->width(),
260260
m_videoStream->height())
261261
)
@@ -273,12 +273,12 @@ void Display::playMovie( AsciiString movieName)
273273
void Display::stopMovie( void )
274274
{
275275
delete m_videoBuffer;
276-
m_videoBuffer = NULL;
276+
m_videoBuffer = nullptr;
277277

278278
if ( m_videoStream )
279279
{
280280
m_videoStream->close();
281-
m_videoStream = NULL;
281+
m_videoStream = nullptr;
282282
}
283283

284284
if (!m_currentlyPlayingMovie.isEmpty()) {
@@ -288,7 +288,7 @@ void Display::stopMovie( void )
288288
if(m_copyrightDisplayString)
289289
{
290290
TheDisplayStringManager->freeDisplayString(m_copyrightDisplayString);
291-
m_copyrightDisplayString = NULL;
291+
m_copyrightDisplayString = nullptr;
292292
}
293293
m_copyrightHoldTime = -1;
294294
m_movieHoldTime = -1;
@@ -366,7 +366,7 @@ void Display::reset()
366366

367367
Bool Display::isMoviePlaying(void)
368368
{
369-
return m_videoStream != NULL && m_videoBuffer != NULL;
369+
return m_videoStream != nullptr && m_videoBuffer != nullptr;
370370
}
371371

372372
//============================================================================

Generals/Code/GameEngine/Source/GameClient/DisplayString.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@
7474
DisplayString::DisplayString( void )
7575
{
7676
// m_textString = ""; // not necessary, done by default
77-
m_font = NULL;
77+
m_font = nullptr;
7878

79-
m_next = NULL;
80-
m_prev = NULL;
79+
m_next = nullptr;
80+
m_prev = nullptr;
8181

8282
}
8383

@@ -117,7 +117,7 @@ void DisplayString::reset( void )
117117
m_textString.clear();
118118

119119
// no font
120-
m_font = NULL;
120+
m_font = nullptr;
121121

122122
}
123123

Generals/Code/GameEngine/Source/GameClient/DisplayStringManager.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#include "GameClient/DisplayStringManager.h"
3333

3434
// PUBLIC DATA ////////////////////////////////////////////////////////////////////////////////////
35-
DisplayStringManager *TheDisplayStringManager = NULL;
35+
DisplayStringManager *TheDisplayStringManager = nullptr;
3636

3737
///////////////////////////////////////////////////////////////////////////////////////////////////
3838
// PUBLIC FUNCTIONS
@@ -43,8 +43,8 @@ DisplayStringManager *TheDisplayStringManager = NULL;
4343
DisplayStringManager::DisplayStringManager( void )
4444
{
4545

46-
m_stringList = NULL;
47-
m_currentCheckpoint = NULL;
46+
m_stringList = nullptr;
47+
m_currentCheckpoint = nullptr;
4848

4949
}
5050

Generals/Code/GameEngine/Source/GameClient/DrawGroupInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,4 @@ DrawGroupInfo::DrawGroupInfo()
5252
m_usingPixelOffsetY = TRUE;
5353
}
5454

55-
DrawGroupInfo *TheDrawGroupInfo = NULL;
55+
DrawGroupInfo *TheDrawGroupInfo = nullptr;

0 commit comments

Comments
 (0)