120 changes: 60 additions & 60 deletions lib/sound/audio.cpp

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions lib/sound/cdaudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ static const size_t bufferSize = 16 * 1024;
static const unsigned int buffer_count = 32;
static bool music_initialized = false;
static bool stopping = true;
static AUDIO_STREAM *cdStream = NULL;
static AUDIO_STREAM *cdStream = nullptr;

bool cdAudio_Open(const char *user_musicdir)
{
PlayList_Init();

if (user_musicdir == NULL
if (user_musicdir == nullptr
|| !PlayList_Read(user_musicdir))
{
return false;
Expand Down Expand Up @@ -84,14 +84,14 @@ static bool cdAudio_OpenTrack(const char *filename)
PHYSFS_file *music_file = PHYSFS_openRead(filename);

debug(LOG_WZ, "Reading...[directory: %s] %s", PHYSFS_getRealDir(filename), filename);
if (music_file == NULL)
if (music_file == nullptr)
{
debug(LOG_ERROR, "Failed opening file [directory: %s] %s, with error %s", PHYSFS_getRealDir(filename), filename, PHYSFS_getLastError());
return false;
}

cdStream = sound_PlayStreamWithBuf(music_file, music_volume, cdAudio_TrackFinished, (char *)filename, bufferSize, buffer_count);
if (cdStream == NULL)
if (cdStream == nullptr)
{
PHYSFS_close(music_file);
debug(LOG_ERROR, "Failed creating audio stream for %s", filename);
Expand All @@ -111,9 +111,9 @@ static void cdAudio_TrackFinished(void *user_data)
const char *filename = PlayList_NextSong();

// This pointer is now officially invalidated; so set it to NULL
cdStream = NULL;
cdStream = nullptr;

if (filename == NULL)
if (filename == nullptr)
{
debug(LOG_ERROR, "Out of playlist?! was playing %s", (char *)user_data);
return;
Expand All @@ -138,7 +138,7 @@ bool cdAudio_PlayTrack(SONG_CONTEXT context)
{
const char *filename = PlayList_CurrentSong();

if (filename == NULL)
if (filename == nullptr)
{
return false;
}
Expand All @@ -160,7 +160,7 @@ void cdAudio_Stop()
if (cdStream)
{
sound_StopStream(cdStream);
cdStream = NULL;
cdStream = nullptr;
sound_Update();
}
}
Expand Down
38 changes: 19 additions & 19 deletions lib/sound/oggvorbis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ static size_t wz_oggVorbis_read(void *ptr, size_t size, size_t nmemb, void *data
{
PHYSFS_file *fileHandle;

ASSERT(datasource != NULL, "NULL decoder passed!");
ASSERT(datasource != nullptr, "NULL decoder passed!");

fileHandle = ((struct OggVorbisDecoderState *)datasource)->fileHandle;
ASSERT(fileHandle != NULL, "Bad PhysicsFS file handle passed in");
ASSERT(fileHandle != nullptr, "Bad PhysicsFS file handle passed in");

return PHYSFS_read(fileHandle, ptr, 1, size * nmemb);
}
Expand All @@ -95,10 +95,10 @@ static int wz_oggVorbis_seek(void *datasource, ogg_int64_t offset, int whence)
bool allowSeeking;
int newPos;

ASSERT(datasource != NULL, "NULL decoder passed!");
ASSERT(datasource != nullptr, "NULL decoder passed!");

fileHandle = ((struct OggVorbisDecoderState *)datasource)->fileHandle;
ASSERT(fileHandle != NULL, "Bad PhysicsFS file handle passed in");
ASSERT(fileHandle != nullptr, "Bad PhysicsFS file handle passed in");

allowSeeking = ((struct OggVorbisDecoderState *)datasource)->allowSeeking;

Expand Down Expand Up @@ -166,10 +166,10 @@ static long wz_oggVorbis_tell(void *datasource)
{
PHYSFS_file *fileHandle;

ASSERT(datasource != NULL, "NULL decoder passed!");
ASSERT(datasource != nullptr, "NULL decoder passed!");

fileHandle = ((struct OggVorbisDecoderState *)datasource)->fileHandle;
ASSERT(fileHandle != NULL, "Bad PhysicsFS file handle passed in");
ASSERT(fileHandle != nullptr, "Bad PhysicsFS file handle passed in");

return PHYSFS_tell(fileHandle);
}
Expand All @@ -187,24 +187,24 @@ struct OggVorbisDecoderState *sound_CreateOggVorbisDecoder(PHYSFS_file *PHYSFS_f
int error;

struct OggVorbisDecoderState *decoder = (struct OggVorbisDecoderState *)malloc(sizeof(struct OggVorbisDecoderState));
if (decoder == NULL)
if (decoder == nullptr)
{
debug(LOG_FATAL, "Out of memory");
abort();
return NULL;
return nullptr;
}

ASSERT(PHYSFS_fileHandle != NULL, "Bad PhysicsFS file handle passed in");
ASSERT(PHYSFS_fileHandle != nullptr, "Bad PhysicsFS file handle passed in");

decoder->fileHandle = PHYSFS_fileHandle;
decoder->allowSeeking = allowSeeking;

error = ov_open_callbacks(decoder, &decoder->oggVorbis_stream, NULL, 0, wz_oggVorbis_callbacks);
error = ov_open_callbacks(decoder, &decoder->oggVorbis_stream, nullptr, 0, wz_oggVorbis_callbacks);
if (error < 0)
{
debug(LOG_ERROR, "ov_open_callbacks failed with errorcode %s", wz_oggVorbis_getErrorStr(error));
free(decoder);
return NULL;
return nullptr;
}

// Aquire some info about the sound data
Expand All @@ -215,7 +215,7 @@ struct OggVorbisDecoderState *sound_CreateOggVorbisDecoder(PHYSFS_file *PHYSFS_f

void sound_DestroyOggVorbisDecoder(struct OggVorbisDecoderState *decoder)
{
ASSERT(decoder != NULL, "NULL decoder passed!");
ASSERT(decoder != nullptr, "NULL decoder passed!");

// Close the OggVorbis decoding stream
ov_clear(&decoder->oggVorbis_stream);
Expand All @@ -227,7 +227,7 @@ static inline unsigned int getSampleCount(struct OggVorbisDecoderState *decoder)
{
int numSamples;

ASSERT(decoder != NULL, "NULL decoder passed!");
ASSERT(decoder != nullptr, "NULL decoder passed!");

numSamples = ov_pcm_total(&decoder->oggVorbis_stream, -1);

Expand All @@ -243,7 +243,7 @@ static inline unsigned int getCurrentSample(struct OggVorbisDecoderState *decode
{
int samplePos;

ASSERT(decoder != NULL, "NULL decoder passed!");
ASSERT(decoder != nullptr, "NULL decoder passed!");

samplePos = ov_pcm_tell(&decoder->oggVorbis_stream);

Expand All @@ -262,7 +262,7 @@ soundDataBuffer *sound_DecodeOggVorbis(struct OggVorbisDecoderState *decoder, si

soundDataBuffer *buffer;

ASSERT(decoder != NULL, "NULL decoder passed!");
ASSERT(decoder != nullptr, "NULL decoder passed!");

if (decoder->allowSeeking)
{
Expand All @@ -280,14 +280,14 @@ soundDataBuffer *sound_DecodeOggVorbis(struct OggVorbisDecoderState *decoder, si
if (bufferSize == 0)
{
debug(LOG_ERROR, "can't find a proper buffer size");
return NULL;
return nullptr;
}

buffer = (soundDataBuffer *)malloc(bufferSize + sizeof(soundDataBuffer));
if (buffer == NULL)
if (buffer == nullptr)
{
debug(LOG_ERROR, "couldn't allocate memory (%lu bytes requested)", (unsigned long) bufferSize + sizeof(soundDataBuffer));
return NULL;
return nullptr;
}

buffer->data = (char *)(buffer + 1);
Expand All @@ -308,7 +308,7 @@ soundDataBuffer *sound_DecodeOggVorbis(struct OggVorbisDecoderState *decoder, si
{
debug(LOG_ERROR, "error decoding from OggVorbis file; errorcode from ov_read: %s", wz_oggVorbis_getErrorStr(result));
free(buffer);
return NULL;
return nullptr;
}
else
{
Expand Down
78 changes: 39 additions & 39 deletions lib/sound/openal_track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ struct SAMPLE_LIST
SAMPLE_LIST *next;
};

static SAMPLE_LIST *active_samples = NULL;
static SAMPLE_LIST *active_samples = nullptr;

static AUDIO_STREAM *active_streams = NULL;
static AUDIO_STREAM *active_streams = nullptr;

static ALfloat sfx_volume = 1.0;
static ALfloat sfx3d_volume = 1.0;

static ALCdevice *device = NULL;
static ALCcontext *context = NULL;
static ALCdevice *device = nullptr;
static ALCcontext *context = nullptr;


/** Removes the given sample from the "active_samples" linked list
Expand All @@ -92,7 +92,7 @@ static ALCcontext *context = NULL;
*/
static void sound_RemoveSample(SAMPLE_LIST *previous, SAMPLE_LIST *to_remove)
{
if (previous != NULL && previous != to_remove)
if (previous != nullptr && previous != to_remove)
{
// Verify that the given two samples actually follow eachother in the list
ASSERT(previous->next == to_remove, "Sound samples don't follow eachother in the list, we're probably removing the wrong item.");
Expand Down Expand Up @@ -149,7 +149,7 @@ bool sound_InitLibrary(void)
#endif
{
// Open default device
device = alcOpenDevice(NULL);
device = alcOpenDevice(nullptr);
}

if (!device)
Expand All @@ -164,7 +164,7 @@ bool sound_InitLibrary(void)
ssprintf(buf, "OpenAL Device Name: %s", deviceName);
addDumpInfo(buf);

context = alcCreateContext(device, NULL); //NULL was contextAttributes
context = alcCreateContext(device, nullptr); //NULL was contextAttributes
if (!context)
{
debug(LOG_ERROR, "Couldn't open audio context.");
Expand Down Expand Up @@ -218,7 +218,7 @@ static void sound_UpdateStreams(void);
void sound_ShutdownLibrary(void)
{
AUDIO_STREAM *stream;
SAMPLE_LIST *aSample = active_samples, * tmpSample = NULL;
SAMPLE_LIST *aSample = active_samples, * tmpSample = nullptr;

if (!openal_initialized)
{
Expand All @@ -227,7 +227,7 @@ void sound_ShutdownLibrary(void)
debug(LOG_SOUND, "starting shutdown");

// Stop all streams, sound_UpdateStreams() will deallocate all stopped streams
for (stream = active_streams; stream != NULL; stream = stream->next)
for (stream = active_streams; stream != nullptr; stream = stream->next)
{
sound_StopStream(stream);
}
Expand All @@ -237,7 +237,7 @@ void sound_ShutdownLibrary(void)

/* On Linux since this caused some versions of OpenAL to hang on exit. - Per */
debug(LOG_SOUND, "make default context NULL");
alcMakeContextCurrent(NULL);
alcMakeContextCurrent(nullptr);
sound_GetContextError(device);

debug(LOG_SOUND, "destroy previous context");
Expand All @@ -256,7 +256,7 @@ void sound_ShutdownLibrary(void)
free(aSample);
aSample = tmpSample;
}
active_samples = NULL;
active_samples = nullptr;
}

/** Deletes the given sample and updates the \c previous and \c current iterators
Expand All @@ -281,7 +281,7 @@ static void sound_DestroyIteratedSample(SAMPLE_LIST **previous, SAMPLE_LIST **sa
free(*sample);

// Get a pointer to the next node, the previous pointer doesn't change
*sample = (*previous != NULL) ? (*previous)->next : active_samples;
*sample = (*previous != nullptr) ? (*previous)->next : active_samples;
}

/** Counts the number of samples in active_samples
Expand All @@ -303,7 +303,7 @@ unsigned int sound_GetActiveSamplesCount()
void sound_Update()
{
SAMPLE_LIST *node = active_samples;
SAMPLE_LIST *previous = NULL;
SAMPLE_LIST *previous = nullptr;
ALCenum err;
ALfloat gain;

Expand All @@ -315,7 +315,7 @@ void sound_Update()
// Update all streaming audio
sound_UpdateStreams();

while (node != NULL)
while (node != nullptr)
{
ALenum state, err;

Expand Down Expand Up @@ -417,10 +417,10 @@ bool sound_QueueSamplePlaying(void)
if (current_queue_sample != (ALuint)AL_INVALID)
{
SAMPLE_LIST *node = active_samples;
SAMPLE_LIST *previous = NULL;
SAMPLE_LIST *previous = nullptr;

// We need to remove it from the queue of actively played samples
while (node != NULL)
while (node != nullptr)
{
if (node->curr->iSample == current_queue_sample)
{
Expand Down Expand Up @@ -454,24 +454,24 @@ static inline TRACK *sound_DecodeOggVorbisTrack(TRACK *psTrack, PHYSFS_file *PHY

if (!openal_initialized)
{
return NULL;
return nullptr;
}

decoder = sound_CreateOggVorbisDecoder(PHYSFS_fileHandle, true);
if (decoder == NULL)
if (decoder == nullptr)
{
debug(LOG_WARNING, "Failed to open audio file for decoding");
free(psTrack);
return NULL;
return nullptr;
}

soundBuffer = sound_DecodeOggVorbis(decoder, 0);
sound_DestroyOggVorbisDecoder(decoder);

if (soundBuffer == NULL)
if (soundBuffer == nullptr)
{
free(psTrack);
return NULL;
return nullptr;
}

if (soundBuffer->size == 0)
Expand Down Expand Up @@ -518,13 +518,13 @@ TRACK *sound_LoadTrackFromFile(const char *fileName)
// Use PhysicsFS to open the file
fileHandle = PHYSFS_openRead(fileName);
debug(LOG_NEVER, "Reading...[directory: %s] %s", PHYSFS_getRealDir(fileName), fileName);
if (fileHandle == NULL)
if (fileHandle == nullptr)
{
debug(LOG_ERROR, "sound_LoadTrackFromFile: PHYSFS_openRead(\"%s\") failed with error: %s\n", fileName, PHYSFS_getLastError());
return NULL;
return nullptr;
}

if (GetLastResourceFilename() == NULL)
if (GetLastResourceFilename() == nullptr)
{
// This is a non fatal error. We just can't find filename for some reason.
debug(LOG_WARNING, "sound_LoadTrackFromFile: missing resource filename?");
Expand All @@ -538,11 +538,11 @@ TRACK *sound_LoadTrackFromFile(const char *fileName)
// allocate track, plus the memory required to contain the filename
// one malloc call ensures only one free call is required
pTrack = (TRACK *)malloc(sizeof(TRACK) + filename_size);
if (pTrack == NULL)
if (pTrack == nullptr)
{
debug(LOG_FATAL, "sound_ConstructTrack: couldn't allocate memory\n");
abort();
return NULL;
return nullptr;
}

// Initialize everyting (except for the filename) to zero
Expand All @@ -551,7 +551,7 @@ TRACK *sound_LoadTrackFromFile(const char *fileName)
// Set filename pointer; if the filename (as returned by
// GetLastResourceFilename()) is a NULL pointer, then this will be a
// NULL pointer as well.
track_name = filename_size ? (char *)(pTrack + 1) : NULL;
track_name = filename_size ? (char *)(pTrack + 1) : nullptr;

// Copy the filename into the struct, if we don't have a NULL pointer
if (filename_size != 0)
Expand Down Expand Up @@ -588,9 +588,9 @@ static void sound_AddActiveSample(AUDIO_SAMPLE *psSample)
void sound_RemoveActiveSample(AUDIO_SAMPLE *psSample)
{
SAMPLE_LIST *node = active_samples;
SAMPLE_LIST *previous = NULL;
SAMPLE_LIST *previous = nullptr;

while (node != NULL)
while (node != nullptr)
{
if (node->curr->psObj == psSample->psObj)
{
Expand Down Expand Up @@ -797,15 +797,15 @@ AUDIO_STREAM *sound_PlayStreamWithBuf(PHYSFS_file *fileHandle, float volume, voi
if (!openal_initialized)
{
debug(LOG_WARNING, "OpenAL isn't initialized, not creating an audio stream");
return NULL;
return nullptr;
}

stream = (AUDIO_STREAM *)malloc(sizeof(AUDIO_STREAM));
if (stream == NULL)
if (stream == nullptr)
{
debug(LOG_FATAL, "sound_PlayStream: Out of memory");
abort();
return NULL;
return nullptr;
}

// Clear error codes
Expand All @@ -820,17 +820,17 @@ AUDIO_STREAM *sound_PlayStreamWithBuf(PHYSFS_file *fileHandle, float volume, voi
// Failed to create OpenAL sound source, so bail out...
debug(LOG_SOUND, "alGenSources failed, most likely out of sound sources");
free(stream);
return NULL;
return nullptr;
}

stream->fileHandle = fileHandle;

stream->decoder = sound_CreateOggVorbisDecoder(stream->fileHandle, false);
if (stream->decoder == NULL)
if (stream->decoder == nullptr)
{
debug(LOG_ERROR, "sound_PlayStream: Failed to open audio file for decoding");
free(stream);
return NULL;
return nullptr;
}

stream->volume = volume;
Expand Down Expand Up @@ -895,7 +895,7 @@ AUDIO_STREAM *sound_PlayStreamWithBuf(PHYSFS_file *fileHandle, float volume, voi
// Free allocated memory
free(stream);

return NULL;
return nullptr;
}

// Attach the OpenAL buffers to our OpenAL source
Expand Down Expand Up @@ -949,7 +949,7 @@ bool sound_isStreamPlaying(AUDIO_STREAM *stream)
*/
void sound_StopStream(AUDIO_STREAM *stream)
{
assert(stream != NULL);
assert(stream != nullptr);

alGetError(); // clear error codes
// Tell OpenAL to stop playing on the given source
Expand Down Expand Up @@ -1162,9 +1162,9 @@ static void sound_DestroyStream(AUDIO_STREAM *stream)
*/
static void sound_UpdateStreams()
{
AUDIO_STREAM *stream = active_streams, *previous = NULL, *next = NULL;
AUDIO_STREAM *stream = active_streams, *previous = nullptr, *next = nullptr;

while (stream != NULL)
while (stream != nullptr)
{
next = stream->next;

Expand Down
16 changes: 8 additions & 8 deletions lib/sound/playlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ struct WZ_TRACK
WZ_TRACK *next;
};

static WZ_TRACK *currentSong = NULL;
static WZ_TRACK *currentSong = nullptr;
static int numSongs = 0;
static WZ_TRACK *songList = NULL;
static WZ_TRACK *songList = nullptr;

void PlayList_Init()
{
songList = NULL;
currentSong = NULL;
songList = nullptr;
currentSong = nullptr;
numSongs = 0;
}

Expand Down Expand Up @@ -71,7 +71,7 @@ bool PlayList_Read(const char *path)
// Attempt to open the playlist file
fileHandle = PHYSFS_openRead(listName);
debug(LOG_WZ, "Reading...[directory: %s] %s", PHYSFS_getRealDir(listName), listName);
if (fileHandle == NULL)
if (fileHandle == nullptr)
{
debug(LOG_INFO, "PHYSFS_openRead(\"%s\") failed with error: %s\n", listName, PHYSFS_getLastError());
return false;
Expand Down Expand Up @@ -105,7 +105,7 @@ bool PlayList_Read(const char *path)
}

song = (WZ_TRACK *)malloc(sizeof(*songList));
if (song == NULL)
if (song == nullptr)
{
debug(LOG_FATAL, "Out of memory!");
PHYSFS_close(fileHandle);
Expand All @@ -116,7 +116,7 @@ bool PlayList_Read(const char *path)
sstrcpy(song->path, path);
sstrcat(song->path, "/");
sstrcat(song->path, filename);
song->next = NULL;
song->next = nullptr;

// Append this song to the list
*last = song;
Expand All @@ -139,7 +139,7 @@ const char *PlayList_CurrentSong()
}
else
{
return NULL;
return nullptr;
}
}

Expand Down
34 changes: 17 additions & 17 deletions lib/sound/track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ static SDWORD g_iCurTracks = 0;

// flag set when system is active (for callbacks etc)
static bool g_bSystemActive = false;
static AUDIO_CALLBACK g_pStopTrackCallback = NULL;
static AUDIO_CALLBACK g_pStopTrackCallback = nullptr;

//*
// =======================================================================================================================
Expand Down Expand Up @@ -96,14 +96,14 @@ unsigned int sound_SetTrackVals(const char *fileName, bool loop, unsigned int vo
unsigned int trackID;
TRACK *psTrack;

if (fileName == NULL || strlen(fileName) == 0) // check for empty filename. This is a non fatal error.
if (fileName == nullptr || strlen(fileName) == 0) // check for empty filename. This is a non fatal error.
{
debug(LOG_WARNING, "fileName is %s", (fileName == NULL) ? "a NULL pointer" : "empty");
debug(LOG_WARNING, "fileName is %s", (fileName == nullptr) ? "a NULL pointer" : "empty");
return 0;
}

psTrack = (TRACK *)resGetData("WAV", fileName);
if (psTrack == NULL)
if (psTrack == nullptr)
{
debug(LOG_WARNING, "track %s resource not found", fileName);
return 0;
Expand All @@ -117,7 +117,7 @@ unsigned int sound_SetTrackVals(const char *fileName, bool loop, unsigned int vo
trackID = sound_GetAvailableID();
}

if (g_apTrack[trackID] != NULL)
if (g_apTrack[trackID] != nullptr)
{
debug(LOG_ERROR, "sound_SetTrackVals: track %i already set (filename: \"%s\"\n", trackID, g_apTrack[trackID]->fileName);
return 0;
Expand Down Expand Up @@ -163,7 +163,7 @@ void sound_ReleaseTrack(TRACK *psTrack)
{
if (*currTrack == psTrack)
{
*currTrack = NULL;
*currTrack = nullptr;
}
}

Expand All @@ -181,7 +181,7 @@ void sound_CheckAllUnloaded(void)

for (currTrack = &g_apTrack[0]; currTrack != &g_apTrack[MAX_TRACKS]; ++currTrack)
{
ASSERT(*currTrack == NULL, "A track is not unloaded yet (%s); check audio.cfg for duplicate IDs", (*currTrack)->fileName);
ASSERT(*currTrack == nullptr, "A track is not unloaded yet (%s); check audio.cfg for duplicate IDs", (*currTrack)->fileName);
}
}

Expand Down Expand Up @@ -217,7 +217,7 @@ bool sound_CheckTrack(SDWORD iTrack)
return false;
}

if (g_apTrack[iTrack] == NULL)
if (g_apTrack[iTrack] == nullptr)
{
debug(LOG_SOUND, "Track %i NULL\n", iTrack);
return false;
Expand Down Expand Up @@ -267,9 +267,9 @@ const char *sound_GetTrackName(SDWORD iTrack)
if (iTrack <= 0
|| iTrack >= MAX_TRACKS
|| iTrack == SAMPLE_NOT_FOUND
|| g_apTrack[iTrack] == NULL)
|| g_apTrack[iTrack] == nullptr)
{
return NULL;
return nullptr;
}

return g_apTrack[iTrack]->fileName;
Expand Down Expand Up @@ -317,12 +317,12 @@ bool sound_Play3DTrack(AUDIO_SAMPLE *psSample)
//
void sound_StopTrack(AUDIO_SAMPLE *psSample)
{
ASSERT_OR_RETURN(, psSample != NULL, "Sample pointer invalid");
ASSERT_OR_RETURN(, psSample != nullptr, "Sample pointer invalid");

sound_StopSample(psSample);

// do stopped callback
if (g_pStopTrackCallback != NULL && psSample->psObj != NULL)
if (g_pStopTrackCallback != nullptr && psSample->psObj != nullptr)
{
g_pStopTrackCallback(psSample->psObj);
}
Expand All @@ -343,15 +343,15 @@ void sound_PauseTrack(AUDIO_SAMPLE *psSample)
//
void sound_FinishedCallback(AUDIO_SAMPLE *psSample)
{
ASSERT(psSample != NULL, "sound_FinishedCallback: sample pointer invalid\n");
ASSERT(psSample != nullptr, "sound_FinishedCallback: sample pointer invalid\n");

if (g_apTrack[psSample->iTrack] != NULL)
if (g_apTrack[psSample->iTrack] != nullptr)
{
g_apTrack[psSample->iTrack]->iTimeLastFinished = sound_GetGameTime();
}

// call user callback if specified
if (psSample->pCallback != NULL)
if (psSample->pCallback != nullptr)
{
psSample->pCallback(psSample->psObj);
// NOTE: we must invalidate the iAudioID (iTrack) so the game knows to add the
Expand All @@ -375,7 +375,7 @@ SDWORD sound_GetTrackID(TRACK *psTrack)
{
unsigned int i;

if (psTrack == NULL)
if (psTrack == nullptr)
{
return SAMPLE_NOT_FOUND;
}
Expand Down Expand Up @@ -409,7 +409,7 @@ SDWORD sound_GetAvailableID()
// Iterate through the list of tracks until we find an unused ID slot
for (i = ID_SOUND_NEXT; i < MAX_TRACKS; ++i)
{
if (g_apTrack[i] == NULL)
if (g_apTrack[i] == nullptr)
{
break;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/widget/bar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ W_BARGRAPH::W_BARGRAPH(W_BARINIT const *init)
void widgSetBarSize(W_SCREEN *psScreen, UDWORD id, UDWORD iValue)
{
W_BARGRAPH *psBGraph = (W_BARGRAPH *)widgGetFromID(psScreen, id);
ASSERT_OR_RETURN(, psBGraph != NULL, "Could not find widget from ID");
ASSERT_OR_RETURN(, psBGraph != nullptr, "Could not find widget from ID");
ASSERT_OR_RETURN(, psBGraph->type == WIDG_BARGRAPH, "Wrong widget type");

psBGraph->iOriginal = iValue;
Expand All @@ -101,7 +101,7 @@ void widgSetBarSize(W_SCREEN *psScreen, UDWORD id, UDWORD iValue)
void widgSetMinorBarSize(W_SCREEN *psScreen, UDWORD id, UDWORD iValue)
{
W_BARGRAPH *psBGraph = (W_BARGRAPH *)widgGetFromID(psScreen, id);
ASSERT_OR_RETURN(, psBGraph != NULL, "Could not find widget from ID");
ASSERT_OR_RETURN(, psBGraph != nullptr, "Could not find widget from ID");
ASSERT_OR_RETURN(, psBGraph->type == WIDG_BARGRAPH, "Wrong widget type");
psBGraph->minorSize = MIN(WBAR_SCALE * iValue / MAX(psBGraph->iRange, 1), WBAR_SCALE);
psBGraph->dirty = true;
Expand Down
2 changes: 1 addition & 1 deletion lib/widget/button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@


W_BUTINIT::W_BUTINIT()
: pText(NULL)
: pText(nullptr)
, FontID(font_regular)
{}

Expand Down
8 changes: 4 additions & 4 deletions lib/widget/editbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@
#define EB_MAX_STRINGSIZE 72

W_EDBINIT::W_EDBINIT()
: pText(NULL)
: pText(nullptr)
, FontID(font_regular)
, pBoxDisplay(NULL)
, pBoxDisplay(nullptr)
{}

W_EDITBOX::W_EDITBOX(W_EDBINIT const *init)
Expand Down Expand Up @@ -585,7 +585,7 @@ void W_EDITBOX::display(int xOffset, int yOffset)
int x1 = x0 + width();
int y1 = y0 + height();

if (pBoxDisplay != NULL)
if (pBoxDisplay != nullptr)
{
pBoxDisplay(this, xOffset, yOffset);
}
Expand Down Expand Up @@ -641,7 +641,7 @@ void W_EDITBOX::display(int xOffset, int yOffset)
iV_Line(cx, cy, cx + WEDB_CURSORSIZE, cy, WZCOL_FORM_CURSOR);
}

if (pBoxDisplay == NULL)
if (pBoxDisplay == nullptr)
{
if ((state & WEDBS_HILITE) != 0)
{
Expand Down
4 changes: 2 additions & 2 deletions lib/widget/form.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void W_CLICKFORM::clicked(W_CONTEXT *psContext, WIDGET_KEY key)
state |= WBUT_DOWN;
dirty = true;

if (AudioCallback != NULL)
if (AudioCallback != nullptr)
{
AudioCallback(ClickedAudioID);
}
Expand Down Expand Up @@ -155,7 +155,7 @@ void W_CLICKFORM::highlight(W_CONTEXT *psContext)
tipStart(this, pTip, screenPointer->TipFontID, x() + psContext->xOffset, y() + psContext->yOffset, width(), height());
}

if (AudioCallback != NULL)
if (AudioCallback != nullptr)
{
AudioCallback(HilightAudioID);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/widget/slider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ UDWORD widgGetSliderPos(W_SCREEN *psScreen, UDWORD id)
WIDGET *psWidget;

psWidget = widgGetFromID(psScreen, id);
ASSERT(psWidget != NULL, "Could not find widget from id %u", id);
ASSERT(psWidget != nullptr, "Could not find widget from id %u", id);
if (psWidget)
{
return ((W_SLIDER *)psWidget)->pos;
Expand All @@ -83,7 +83,7 @@ void widgSetSliderPos(W_SCREEN *psScreen, UDWORD id, UWORD pos)
WIDGET *psWidget;

psWidget = widgGetFromID(psScreen, id);
ASSERT(psWidget != NULL, "Could not find widget from id %u", id);
ASSERT(psWidget != nullptr, "Could not find widget from id %u", id);
if (psWidget && pos != ((W_SLIDER *)psWidget)->pos)
{
psWidget->dirty = true;
Expand Down
4 changes: 2 additions & 2 deletions lib/widget/tip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void widgSetTipColour(PIELIGHT colour)
*/
void tipStart(WIDGET *psSource, QString pNewTip, iV_fonts NewFontID, int x, int y, int width, int height)
{
ASSERT(psSource != NULL, "Invalid widget pointer");
ASSERT(psSource != nullptr, "Invalid widget pointer");

tipState = TIP_WAIT;
startTime = wzGetTicks();
Expand All @@ -107,7 +107,7 @@ void tipStart(WIDGET *psSource, QString pNewTip, iV_fonts NewFontID, int x, int
*/
void tipStop(WIDGET *psSource)
{
ASSERT(psSource != NULL,
ASSERT(psSource != nullptr,
"tipStop: Invalid widget pointer");

if (tipState != TIP_NONE && psSource == psWidget)
Expand Down
58 changes: 29 additions & 29 deletions lib/widget/widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@
static bool bWidgetsActive = true;

/* The widget the mouse is over this update */
static WIDGET *psMouseOverWidget = NULL;
static WIDGET *psMouseOverWidget = nullptr;

static WIDGET_AUDIOCALLBACK AudioCallback = NULL;
static WIDGET_AUDIOCALLBACK AudioCallback = nullptr;
static SWORD HilightAudioID = -1;
static SWORD ClickedAudioID = -1;
static SWORD ErrorAudioID = -1;
Expand Down Expand Up @@ -103,9 +103,9 @@ W_INIT::W_INIT()
, style(0)
, x(0), y(0)
, width(0), height(0)
, pDisplay(NULL)
, pCallback(NULL)
, pUserData(NULL)
, pDisplay(nullptr)
, pCallback(nullptr)
, pUserData(nullptr)
, UserData(0)
{}

Expand All @@ -118,7 +118,7 @@ WIDGET::WIDGET(W_INIT const *init, WIDGET_TYPE type)
, pUserData(init->pUserData)
, UserData(init->UserData)
, screenPointer(nullptr)
, parentWidget(NULL)
, parentWidget(nullptr)
, dim(init->x, init->y, init->width, init->height)
, dirty(true)
{}
Expand All @@ -127,12 +127,12 @@ WIDGET::WIDGET(WIDGET *parent, WIDGET_TYPE type)
: id(0xFFFFEEEEu)
, type(type)
, style(0)
, displayFunction(NULL)
, callback(NULL)
, pUserData(NULL)
, displayFunction(nullptr)
, callback(nullptr)
, pUserData(nullptr)
, UserData(0)
, screenPointer(nullptr)
, parentWidget(NULL)
, parentWidget(nullptr)
, dim(0, 0, 1, 1)
, dirty(true)
{
Expand All @@ -144,13 +144,13 @@ WIDGET::~WIDGET()
setScreenPointer(nullptr); // Clear any pointers to us directly from screenPointer.
tipStop(this); // Stop showing tooltip, if we are.

if (parentWidget != NULL)
if (parentWidget != nullptr)
{
parentWidget->detach(this);
}
for (unsigned n = 0; n < childWidgets.size(); ++n)
{
childWidgets[n]->parentWidget = NULL; // Detach in advance, slightly faster than detach(), and doesn't change our list.
childWidgets[n]->parentWidget = nullptr; // Detach in advance, slightly faster than detach(), and doesn't change our list.
delete childWidgets[n];
}
}
Expand All @@ -173,18 +173,18 @@ void WIDGET::setGeometry(QRect const &r)

void WIDGET::attach(WIDGET *widget)
{
ASSERT_OR_RETURN(, widget != NULL && widget->parentWidget == NULL, "Bad attach.");
ASSERT_OR_RETURN(, widget != nullptr && widget->parentWidget == nullptr, "Bad attach.");
widget->parentWidget = this;
widget->setScreenPointer(screenPointer);
childWidgets.push_back(widget);
}

void WIDGET::detach(WIDGET *widget)
{
ASSERT_OR_RETURN(, widget != NULL && widget->parentWidget != NULL, "Bad detach.");
ASSERT_OR_RETURN(, widget != nullptr && widget->parentWidget != nullptr, "Bad detach.");

widget->parentWidget = NULL;
widget->setScreenPointer(NULL);
widget->parentWidget = nullptr;
widget->setScreenPointer(nullptr);
childWidgets.erase(std::find(childWidgets.begin(), childWidgets.end(), widget));

widgetLost(widget);
Expand Down Expand Up @@ -219,14 +219,14 @@ void WIDGET::setScreenPointer(W_SCREEN *screen)

void WIDGET::widgetLost(WIDGET *widget)
{
if (parentWidget != NULL)
if (parentWidget != nullptr)
{
parentWidget->widgetLost(widget); // We don't care about the lost widget, maybe the parent does. (Special code for W_TABFORM.)
}
}

W_SCREEN::W_SCREEN()
: psFocus(NULL)
: psFocus(nullptr)
, lastHighlight(nullptr)
, TipFontID(font_regular)
{
Expand Down Expand Up @@ -266,8 +266,8 @@ static bool widgCheckIDForm(WIDGET *psForm, UDWORD id)

static bool widgAddWidget(W_SCREEN *psScreen, W_INIT const *psInit, WIDGET *widget)
{
ASSERT_OR_RETURN(false, widget != NULL, "Invalid widget");
ASSERT_OR_RETURN(false, psScreen != NULL, "Invalid screen pointer");
ASSERT_OR_RETURN(false, widget != nullptr, "Invalid widget");
ASSERT_OR_RETURN(false, psScreen != nullptr, "Invalid screen pointer");
ASSERT_OR_RETURN(false, !widgCheckIDForm(psScreen->psForm, psInit->id), "ID number has already been used (%d)", psInit->id);
// Find the form to add the widget to.
W_FORM *psParent;
Expand All @@ -280,7 +280,7 @@ static bool widgAddWidget(W_SCREEN *psScreen, W_INIT const *psInit, WIDGET *widg
{
psParent = (W_FORM *)widgGetFromID(psScreen, psInit->formID);
}
ASSERT_OR_RETURN(false, psParent != NULL && psParent->type == WIDG_FORM, "Could not find parent form from formID");
ASSERT_OR_RETURN(false, psParent != nullptr && psParent->type == WIDG_FORM, "Could not find parent form from formID");

psParent->attach(widget);
return true;
Expand Down Expand Up @@ -354,12 +354,12 @@ static WIDGET *widgFormGetFromID(WIDGET *widget, UDWORD id)
for (WIDGET::Children::const_iterator i = c.begin(); i != c.end(); ++i)
{
WIDGET *w = widgFormGetFromID(*i, id);
if (w != NULL)
if (w != nullptr)
{
return w;
}
}
return NULL;
return nullptr;
}

/* Find a widget in a screen from its ID number */
Expand All @@ -371,15 +371,15 @@ WIDGET *widgGetFromID(W_SCREEN *psScreen, UDWORD id)
void widgHide(W_SCREEN *psScreen, UDWORD id)
{
WIDGET *psWidget = widgGetFromID(psScreen, id);
ASSERT_OR_RETURN(, psWidget != NULL, "Couldn't find widget from id.");
ASSERT_OR_RETURN(, psWidget != nullptr, "Couldn't find widget from id.");

psWidget->hide();
}

void widgReveal(W_SCREEN *psScreen, UDWORD id)
{
WIDGET *psWidget = widgGetFromID(psScreen, id);
ASSERT_OR_RETURN(, psWidget != NULL, "Couldn't find widget from id.");
ASSERT_OR_RETURN(, psWidget != nullptr, "Couldn't find widget from id.");

psWidget->show();
}
Expand All @@ -392,7 +392,7 @@ void widgGetPos(W_SCREEN *psScreen, UDWORD id, SWORD *pX, SWORD *pY)

/* Find the widget */
psWidget = widgGetFromID(psScreen, id);
if (psWidget != NULL)
if (psWidget != nullptr)
{
*pX = psWidget->x();
*pY = psWidget->y();
Expand All @@ -413,7 +413,7 @@ UDWORD widgGetMouseOver(W_SCREEN *psScreen)
the screen structure */
(void)psScreen;

if (psMouseOverWidget == NULL)
if (psMouseOverWidget == nullptr)
{
return 0;
}
Expand All @@ -433,7 +433,7 @@ void *widgGetUserData(W_SCREEN *psScreen, UDWORD id)
return psWidget->pUserData;
}

return NULL;
return nullptr;
}


Expand Down Expand Up @@ -716,7 +716,7 @@ WidgetTriggers const &widgRunScreen(W_SCREEN *psScreen)
W_CONTEXT sContext;
sContext.xOffset = 0;
sContext.yOffset = 0;
psMouseOverWidget = NULL;
psMouseOverWidget = nullptr;

// Note which keys have been pressed
lastReleasedKey_DEPRECATED = WKEY_NONE;
Expand Down
86 changes: 43 additions & 43 deletions src/action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ const char *getDroidActionName(DROID_ACTION action)
"DACTION_CIRCLE" // (41) circling while engaging
};

ASSERT_OR_RETURN(NULL, action < sizeof(name) / sizeof(name[0]), "DROID_ACTION out of range: %u", action);
ASSERT_OR_RETURN(nullptr, action < sizeof(name) / sizeof(name[0]), "DROID_ACTION out of range: %u", action);

return name[action];
}
Expand Down Expand Up @@ -395,7 +395,7 @@ bool actionTargetTurret(BASE_OBJECT *psAttacker, BASE_OBJECT *psTarget, WEAPON *
bool actionVisibleTarget(DROID *psDroid, BASE_OBJECT *psTarget, int weapon_slot)
{
CHECK_DROID(psDroid);
ASSERT_OR_RETURN(false, psTarget != NULL, "Target is NULL");
ASSERT_OR_RETURN(false, psTarget != nullptr, "Target is NULL");
if (!psTarget->visible[psDroid->player])
{
return false;
Expand All @@ -416,11 +416,11 @@ static void actionAddVtolAttackRun(DROID *psDroid)

CHECK_DROID(psDroid);

if (psDroid->psActionTarget[0] != NULL)
if (psDroid->psActionTarget[0] != nullptr)
{
psTarget = psDroid->psActionTarget[0];
}
else if (psDroid->order.psObj != NULL)
else if (psDroid->order.psObj != nullptr)
{
psTarget = psDroid->order.psObj;
}
Expand Down Expand Up @@ -520,7 +520,7 @@ static void actionCalcPullBackPoint(BASE_OBJECT *psObj, BASE_OBJECT *psTarget, S
// check whether a droid is in the neighboring tile to a build position
bool actionReachedBuildPos(DROID const *psDroid, int x, int y, uint16_t dir, BASE_STATS const *psStats)
{
ASSERT_OR_RETURN(false, psStats != NULL && psDroid != NULL, "Bad stat or droid");
ASSERT_OR_RETURN(false, psStats != nullptr && psDroid != nullptr, "Bad stat or droid");
CHECK_DROID(psDroid);

StructureBounds b = getStructureBounds(psStats, Vector2i(x, y), dir);
Expand All @@ -536,7 +536,7 @@ bool actionReachedBuildPos(DROID const *psDroid, int x, int y, uint16_t dir, BAS
// check if a droid is on the foundations of a new building
static bool actionRemoveDroidsFromBuildPos(unsigned player, Vector2i pos, uint16_t dir, BASE_STATS *psStats)
{
ASSERT_OR_RETURN(false, psStats != NULL, "Bad stat");
ASSERT_OR_RETURN(false, psStats != nullptr, "Bad stat");

bool buildPosEmpty = true;

Expand All @@ -550,7 +550,7 @@ static bool actionRemoveDroidsFromBuildPos(unsigned player, Vector2i pos, uint16
for (GridIterator gi = gridList.begin(); gi != gridList.end(); ++gi)
{
DROID *droid = castDroid(*gi);
if (droid == NULL)
if (droid == nullptr)
{
continue; // Only looking for droids.
}
Expand Down Expand Up @@ -608,7 +608,7 @@ void actionSanity(DROID *psDroid)
bDirect = proj_Direct(asWeaponStats + psDroid->asWeaps[i].nStat);
if (psDroid->psActionTarget[i] && (avoidOverkill ? aiObjectIsProbablyDoomed(psDroid->psActionTarget[i], bDirect) : psDroid->psActionTarget[i]->died))
{
setDroidActionTarget(psDroid, NULL, i);
setDroidActionTarget(psDroid, nullptr, i);
if (i == 0)
{
if (psDroid->action != DACTION_MOVEFIRE &&
Expand Down Expand Up @@ -639,7 +639,7 @@ void actionSanity(DROID *psDroid)
void actionUpdateDroid(DROID *psDroid)
{
PROPULSION_STATS *psPropStats;
bool (*actionUpdateFunc)(DROID * psDroid) = NULL;
bool (*actionUpdateFunc)(DROID * psDroid) = nullptr;
//this is a bit field
bool nonNullWeapon[MAX_WEAPONS] = { false };
BASE_OBJECT *psTargets[MAX_WEAPONS];
Expand All @@ -651,7 +651,7 @@ void actionUpdateDroid(DROID *psDroid)
CHECK_DROID(psDroid);

psPropStats = asPropulsionStats + psDroid->asBits[COMP_PROPULSION];
ASSERT_OR_RETURN(, psPropStats != NULL, "Invalid propulsion stats pointer");
ASSERT_OR_RETURN(, psPropStats != nullptr, "Invalid propulsion stats pointer");

actionSanity(psDroid);

Expand Down Expand Up @@ -703,7 +703,7 @@ void actionUpdateDroid(DROID *psDroid)
{
if (nonNullWeapon[i])
{
BASE_OBJECT *psTemp = NULL;
BASE_OBJECT *psTemp = nullptr;

WEAPON_STATS *const psWeapStats = &asWeaponStats[psDroid->asWeaps[i].nStat];
if (psDroid->asWeaps[i].nStat > 0
Expand Down Expand Up @@ -789,7 +789,7 @@ void actionUpdateDroid(DROID *psDroid)
psScrCBOrder = order->type;
psScrCBOrderDroid = psDroid;
eventFireCallbackTrigger((TRIGGER_TYPE)CALL_DROID_REACH_LOCATION);
psScrCBOrderDroid = NULL;
psScrCBOrderDroid = nullptr;
psScrCBOrder = DORDER_NONE;

triggerEventDroidIdle(psDroid);
Expand All @@ -802,7 +802,7 @@ void actionUpdateDroid(DROID *psDroid)
{
if (nonNullWeapon[i])
{
BASE_OBJECT *psTemp = NULL;
BASE_OBJECT *psTemp = nullptr;

//I moved psWeapStats flag update there
WEAPON_STATS *const psWeapStats = &asWeaponStats[psDroid->asWeaps[i].nStat];
Expand Down Expand Up @@ -844,17 +844,17 @@ void actionUpdateDroid(DROID *psDroid)
{
bDirect = proj_Direct(asWeaponStats + psDroid->asWeaps[i].nStat);
// Does this weapon have a target?
if (psDroid->psActionTarget[i] != NULL)
if (psDroid->psActionTarget[i] != nullptr)
{
// Is target worth shooting yet?
if (aiObjectIsProbablyDoomed(psDroid->psActionTarget[i], bDirect))
{
setDroidActionTarget(psDroid, NULL, i);
setDroidActionTarget(psDroid, nullptr, i);
}
// Is target from our team now? (Electronic Warfare)
else if (electronicDroid(psDroid) && psDroid->player == psDroid->psActionTarget[i]->player)
{
setDroidActionTarget(psDroid, NULL, i);
setDroidActionTarget(psDroid, nullptr, i);
}
// I have a target!
else
Expand All @@ -874,7 +874,7 @@ void actionUpdateDroid(DROID *psDroid)
}
}
// If we have a target for the weapon: is it visible?
if (psDroid->psActionTarget[i] != NULL
if (psDroid->psActionTarget[i] != nullptr
&& visibleObject(psDroid, psDroid->psActionTarget[i], false))
{
hasVisibleTarget = true; // droid have a visible target to shoot
Expand All @@ -888,7 +888,7 @@ void actionUpdateDroid(DROID *psDroid)
for (int i = 0; i < psDroid->numWeaps; ++i)
{
// has weapon a target? is target valid?
if (psDroid->psActionTarget[i] != NULL && validTarget(psDroid, psDroid->psActionTarget[i], i))
if (psDroid->psActionTarget[i] != nullptr && validTarget(psDroid, psDroid->psActionTarget[i], i))
{
// is target visible and weapon is not a Nullweapon?
if (targetVisibile[i] && nonNullWeapon[i]) //to fix a AA-weapon attack ground unit exploit
Expand Down Expand Up @@ -924,7 +924,7 @@ void actionUpdateDroid(DROID *psDroid)
break;
case DACTION_ATTACK:
case DACTION_ROTATETOATTACK:
ASSERT_OR_RETURN(, psDroid->psActionTarget[0] != NULL, "target is NULL while attacking");
ASSERT_OR_RETURN(, psDroid->psActionTarget[0] != nullptr, "target is NULL while attacking");

if (psDroid->action == DACTION_ROTATETOATTACK)
{
Expand All @@ -941,7 +941,7 @@ void actionUpdateDroid(DROID *psDroid)
{
for (int i = 0; i < psDroid->numWeaps; i++)
{
setDroidActionTarget(psDroid, NULL, i);
setDroidActionTarget(psDroid, nullptr, i);
}
psDroid->action = DACTION_NONE;
break;
Expand All @@ -965,8 +965,8 @@ void actionUpdateDroid(DROID *psDroid)
// If we still don't have a target, try to find one
else
{
if (psDroid->psActionTarget[i] == NULL &&
aiChooseTarget(psDroid, &psTargets[i], i, false, NULL)) // Can probably just use psTarget instead of psTargets[i], and delete the psTargets variable.
if (psDroid->psActionTarget[i] == nullptr &&
aiChooseTarget(psDroid, &psTargets[i], i, false, nullptr)) // Can probably just use psTarget instead of psTargets[i], and delete the psTargets variable.
{
setDroidActionTarget(psDroid, psTargets[i], i);
}
Expand Down Expand Up @@ -1006,7 +1006,7 @@ void actionUpdateDroid(DROID *psDroid)
if (psDroid->psActionTarget[i] != psDroid->psActionTarget[0])
{
// Nope, can't shoot this, try something else next time
setDroidActionTarget(psDroid, NULL, i);
setDroidActionTarget(psDroid, nullptr, i);
}
}
else if (psDroid->sMove.Status != MOVESHUFFLE)
Expand All @@ -1025,13 +1025,13 @@ void actionUpdateDroid(DROID *psDroid)
else if (i > 0)
{
// Nope, can't shoot this, try something else next time
setDroidActionTarget(psDroid, NULL, i);
setDroidActionTarget(psDroid, nullptr, i);
}
}
else if (i > 0)
{
// Nope, can't shoot this, try something else next time
setDroidActionTarget(psDroid, NULL, i);
setDroidActionTarget(psDroid, nullptr, i);
}
}

Expand Down Expand Up @@ -1059,15 +1059,15 @@ void actionUpdateDroid(DROID *psDroid)

case DACTION_VTOLATTACK:
{
WEAPON_STATS *psWeapStats = NULL;
WEAPON_STATS *psWeapStats = nullptr;

//uses vtResult
if (psDroid->psActionTarget[0] != NULL &&
if (psDroid->psActionTarget[0] != nullptr &&
validTarget(psDroid, psDroid->psActionTarget[0], 0))
{
//check if vtol that its armed
if ((vtolEmpty(psDroid)) ||
(psDroid->psActionTarget[0] == NULL) ||
(psDroid->psActionTarget[0] == nullptr) ||
//check the target hasn't become one the same player ID - Electronic Warfare
(electronicDroid(psDroid) && (psDroid->player == psDroid->psActionTarget[0]->player)) ||
!validTarget(psDroid, psDroid->psActionTarget[0], 0))
Expand Down Expand Up @@ -1155,15 +1155,15 @@ void actionUpdateDroid(DROID *psDroid)
break;
}

ASSERT_OR_RETURN(, psDroid->psActionTarget[0] != NULL, "action update move to attack target is NULL");
ASSERT_OR_RETURN(, psDroid->psActionTarget[0] != nullptr, "action update move to attack target is NULL");

//check the target hasn't become one the same player ID - Electronic Warfare
if ((electronicDroid(psDroid) && (psDroid->player == psDroid->psActionTarget[0]->player)) ||
!validTarget(psDroid, psDroid->psActionTarget[0], 0))
{
for (int i = 0; i < psDroid->numWeaps; i++)
{
setDroidActionTarget(psDroid, NULL, i);
setDroidActionTarget(psDroid, nullptr, i);
}
psDroid->action = DACTION_NONE;
}
Expand Down Expand Up @@ -1308,7 +1308,7 @@ void actionUpdateDroid(DROID *psDroid)
uint16_t dir = order->direction;
moveStopDroid(psDroid);
objTrace(psDroid->id, "Halted in our tracks - at construction site");
if (order->type == DORDER_BUILD && order->psObj == NULL)
if (order->type == DORDER_BUILD && order->psObj == nullptr)
{
// Starting a new structure
const Vector2i pos = psDroid->actionPos;
Expand Down Expand Up @@ -1373,7 +1373,7 @@ void actionUpdateDroid(DROID *psDroid)
// building a wall.
MAPTILE *const psTile = worldTile(psDroid->actionPos);
syncDebug("Reached build target: wall");
if (order->psObj == NULL
if (order->psObj == nullptr
&& (TileHasStructure(psTile)
|| TileHasFeature(psTile)))
{
Expand Down Expand Up @@ -1713,7 +1713,7 @@ void actionUpdateDroid(DROID *psDroid)
{
if (nonNullWeapon[i])
{
BASE_OBJECT *psTemp = NULL;
BASE_OBJECT *psTemp = nullptr;

WEAPON_STATS *const psWeapStats = &asWeaponStats[psDroid->asWeaps[i].nStat];
if (psDroid->asWeaps[i].nStat > 0 && psWeapStats->rotate
Expand Down Expand Up @@ -1773,7 +1773,7 @@ void actionUpdateDroid(DROID *psDroid)
}
case DACTION_WAITFORREARM:
// wait here for the rearm pad to ask the vtol to move
if (psDroid->psActionTarget[0] == NULL)
if (psDroid->psActionTarget[0] == nullptr)
{
// rearm pad destroyed - move to another
moveToRearm(psDroid);
Expand All @@ -1799,7 +1799,7 @@ void actionUpdateDroid(DROID *psDroid)
// this gets cleared by the rearm pad
break;
case DACTION_MOVETOREARM:
if (psDroid->psActionTarget[0] == NULL)
if (psDroid->psActionTarget[0] == nullptr)
{
// base destroyed - find another
moveToRearm(psDroid);
Expand All @@ -1812,7 +1812,7 @@ void actionUpdateDroid(DROID *psDroid)
// got close to the rearm pad - now find a clear one
objTrace(psDroid->id, "Seen rearm pad - searching for available one");

if (psStruct != NULL)
if (psStruct != nullptr)
{
// found a clear landing pad - go for it
objTrace(psDroid->id, "Found clear rearm pad");
Expand Down Expand Up @@ -1908,12 +1908,12 @@ static void actionDroidBase(DROID *psDroid, DROID_ACTION_DATA *psAction)
{
for (i = 0; i < psDroid->numWeaps; i++)
{
setDroidActionTarget(psDroid, NULL, i);
setDroidActionTarget(psDroid, nullptr, i);
}
}
else
{
setDroidActionTarget(psDroid, NULL, 0);
setDroidActionTarget(psDroid, nullptr, 0);
}
break;

Expand Down Expand Up @@ -1959,7 +1959,7 @@ static void actionDroidBase(DROID *psDroid, DROID_ACTION_DATA *psAction)
psDroid->actionPos = psDroid->pos.xy;
setDroidActionTarget(psDroid, psAction->psObj, 0);

if (!isVtolDroid(psDroid) && (orderStateObj(psDroid, DORDER_FIRESUPPORT) != NULL))
if (!isVtolDroid(psDroid) && (orderStateObj(psDroid, DORDER_FIRESUPPORT) != nullptr))
{
psDroid->action = DACTION_ATTACK; // holding, try attack straightaway
}
Expand Down Expand Up @@ -2055,7 +2055,7 @@ static void actionDroidBase(DROID *psDroid, DROID_ACTION_DATA *psAction)
psDroid->action = DACTION_MOVETODEMOLISH;
psDroid->actionPos.x = psAction->x;
psDroid->actionPos.y = psAction->y;
ASSERT_OR_RETURN(, (order->psObj != NULL) && (order->psObj->type == OBJ_STRUCTURE), "invalid target for demolish order");
ASSERT_OR_RETURN(, (order->psObj != nullptr) && (order->psObj->type == OBJ_STRUCTURE), "invalid target for demolish order");
order->psStats = ((STRUCTURE *)order->psObj)->pStructureType;
setDroidActionTarget(psDroid, psAction->psObj, 0);
moveDroidTo(psDroid, psAction->x, psAction->y);
Expand All @@ -2066,7 +2066,7 @@ static void actionDroidBase(DROID *psDroid, DROID_ACTION_DATA *psAction)
psDroid->actionPos.y = psAction->y;
//this needs setting so that automatic repair works
setDroidActionTarget(psDroid, psAction->psObj, 0);
ASSERT_OR_RETURN(, (psDroid->psActionTarget[0] != NULL) && (psDroid->psActionTarget[0]->type == OBJ_STRUCTURE),
ASSERT_OR_RETURN(, (psDroid->psActionTarget[0] != nullptr) && (psDroid->psActionTarget[0]->type == OBJ_STRUCTURE),
"invalid target for repair order");
order->psStats = ((STRUCTURE *)psDroid->psActionTarget[0])->pStructureType;
if (order->type != DORDER_HOLD)
Expand Down Expand Up @@ -2144,7 +2144,7 @@ static void actionDroidBase(DROID *psDroid, DROID_ACTION_DATA *psAction)
psDroid->action = DACTION_MOVETORESTORE;
psDroid->actionPos.x = psAction->x;
psDroid->actionPos.y = psAction->y;
ASSERT_OR_RETURN(, (order->psObj != NULL) && (order->psObj->type == OBJ_STRUCTURE), "invalid target for restore order");
ASSERT_OR_RETURN(, (order->psObj != nullptr) && (order->psObj->type == OBJ_STRUCTURE), "invalid target for restore order");
order->psStats = ((STRUCTURE *)order->psObj)->pStructureType;
setDroidActionTarget(psDroid, psAction->psObj, 0);
moveDroidTo(psDroid, psAction->x, psAction->y);
Expand Down Expand Up @@ -2234,7 +2234,7 @@ void moveToRearm(DROID *psDroid)
if (psStruct)
{
// note a base rearm pad if the vtol doesn't have one
if (psDroid->psBaseStruct == NULL)
if (psDroid->psBaseStruct == nullptr)
{
setDroidBase(psDroid, psStruct);
}
Expand Down
50 changes: 25 additions & 25 deletions src/ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ static BASE_OBJECT *aiSearchSensorTargets(BASE_OBJECT *psObj, int weapon_slot, W
int tarDist = longRange * longRange;
bool foundCB = false;
int minDist = psWStats->upgrade[psObj->player].minRange * psWStats->upgrade[psObj->player].minRange;
BASE_OBJECT *psTarget = NULL;
BASE_OBJECT *psTarget = nullptr;

if (targetOrigin)
{
Expand All @@ -179,7 +179,7 @@ static BASE_OBJECT *aiSearchSensorTargets(BASE_OBJECT *psObj, int weapon_slot, W

for (BASE_OBJECT *psSensor = apsSensorList[0]; psSensor; psSensor = psSensor->psNextFunc)
{
BASE_OBJECT *psTemp = NULL;
BASE_OBJECT *psTemp = nullptr;
bool isCB = false;
bool isRD = false;

Expand All @@ -191,7 +191,7 @@ static BASE_OBJECT *aiSearchSensorTargets(BASE_OBJECT *psObj, int weapon_slot, W
{
DROID *psDroid = (DROID *)psSensor;

ASSERT_OR_RETURN(NULL, psDroid->droidType == DROID_SENSOR, "A non-sensor droid in a sensor list is non-sense");
ASSERT_OR_RETURN(nullptr, psDroid->droidType == DROID_SENSOR, "A non-sensor droid in a sensor list is non-sense");
// Skip non-observing droids.
if (psDroid->action != DACTION_OBSERVE)
{
Expand Down Expand Up @@ -257,13 +257,13 @@ static SDWORD targetAttackWeight(BASE_OBJECT *psTarget, BASE_OBJECT *psAttacker,
{
SDWORD targetTypeBonus = 0, damageRatio = 0, attackWeight = 0, noTarget = -1;
UDWORD weaponSlot;
DROID *targetDroid = NULL, *psAttackerDroid = NULL, *psGroupDroid, *psDroid;
STRUCTURE *targetStructure = NULL;
DROID *targetDroid = nullptr, *psAttackerDroid = nullptr, *psGroupDroid, *psDroid;
STRUCTURE *targetStructure = nullptr;
WEAPON_EFFECT weaponEffect;
WEAPON_STATS *attackerWeapon;
bool bEmpWeap = false, bCmdAttached = false, bTargetingCmd = false, bDirect = false;

if (psTarget == NULL || psAttacker == NULL || psTarget->died)
if (psTarget == nullptr || psAttacker == nullptr || psTarget->died)
{
return noTarget;
}
Expand Down Expand Up @@ -496,7 +496,7 @@ static SDWORD targetAttackWeight(BASE_OBJECT *psTarget, BASE_OBJECT *psAttacker,
/* Commander-related criterias */
if (bCmdAttached) //attached to a commander and don't have a target assigned by some order
{
ASSERT(psAttackerDroid->psGroup->psCommander != NULL, "Commander is NULL");
ASSERT(psAttackerDroid->psGroup->psCommander != nullptr, "Commander is NULL");

//if commander is being targeted by our target, try to defend the commander
if (bTargetingCmd)
Expand Down Expand Up @@ -531,7 +531,7 @@ int aiBestNearestTarget(DROID *psDroid, BASE_OBJECT **ppsObj, int weapon_slot, i
{
int failure = -1;
int bestMod = 0;
BASE_OBJECT *psTarget = NULL, *bestTarget = NULL, *tempTarget;
BASE_OBJECT *psTarget = nullptr, *bestTarget = nullptr, *tempTarget;
bool electronic = false;
STRUCTURE *targetStructure;
WEAPON_EFFECT weaponEffect;
Expand Down Expand Up @@ -569,14 +569,14 @@ int aiBestNearestTarget(DROID *psDroid, BASE_OBJECT **ppsObj, int weapon_slot, i
gridList = gridStartIterate(psDroid->pos.x, psDroid->pos.y, droidRange);
for (GridIterator gi = gridList.begin(); gi != gridList.end(); ++gi)
{
BASE_OBJECT *friendlyObj = NULL;
BASE_OBJECT *friendlyObj = nullptr;
BASE_OBJECT *targetInQuestion = *gi;

/* This is a friendly unit, check if we can reuse its target */
if (aiCheckAlliances(targetInQuestion->player, psDroid->player))
{
friendlyObj = targetInQuestion;
targetInQuestion = NULL;
targetInQuestion = nullptr;

/* Can we see what it is doing? */
if (friendlyObj->visible[psDroid->player] == UBYTE_MAX)
Expand Down Expand Up @@ -611,7 +611,7 @@ int aiBestNearestTarget(DROID *psDroid, BASE_OBJECT **ppsObj, int weapon_slot, i
}
}

if (targetInQuestion != NULL
if (targetInQuestion != nullptr
&& targetInQuestion != psDroid // in case friendly unit had me as target
&& (targetInQuestion->type == OBJ_DROID || targetInQuestion->type == OBJ_STRUCTURE || targetInQuestion->type == OBJ_FEATURE)
&& targetInQuestion->visible[psDroid->player] == UBYTE_MAX
Expand Down Expand Up @@ -672,12 +672,12 @@ int aiBestNearestTarget(DROID *psDroid, BASE_OBJECT **ppsObj, int weapon_slot, i
}

/* Check if our weapon is most effective against this object */
if (psTarget != NULL && psTarget == targetInQuestion) //was assigned?
if (psTarget != nullptr && psTarget == targetInQuestion) //was assigned?
{
int newMod = targetAttackWeight(psTarget, (BASE_OBJECT *)psDroid, weapon_slot);

/* Remember this one if it's our best target so far */
if (newMod >= 0 && (newMod > bestMod || bestTarget == NULL))
if (newMod >= 0 && (newMod > bestMod || bestTarget == nullptr))
{
bestMod = newMod;
tmpOrigin = ORIGIN_ALLY;
Expand Down Expand Up @@ -754,7 +754,7 @@ bool aiObjectIsProbablyDoomed(BASE_OBJECT *psObject, bool isDirect)
// Update the expected damage of the object.
void aiObjectAddExpectedDamage(BASE_OBJECT *psObject, SDWORD damage, bool isDirect)
{
if (psObject == NULL)
if (psObject == nullptr)
{
return; // Hard to destroy the ground.
}
Expand Down Expand Up @@ -803,7 +803,7 @@ static bool aiObjIsWall(BASE_OBJECT *psObj)
/* See if there is a target in range */
bool aiChooseTarget(BASE_OBJECT *psObj, BASE_OBJECT **ppsTarget, int weapon_slot, bool bUpdateTarget, TARGET_ORIGIN *targetOrigin)
{
BASE_OBJECT *psTarget = NULL;
BASE_OBJECT *psTarget = nullptr;
DROID *psCommander;
SDWORD curTargetWeight = -1;
TARGET_ORIGIN tmpOrigin = ORIGIN_UNKNOWN;
Expand Down Expand Up @@ -852,9 +852,9 @@ bool aiChooseTarget(BASE_OBJECT *psObj, BASE_OBJECT **ppsTarget, int weapon_slot
int longRange = proj_GetLongRange(psWStats, psObj->player);

// see if there is a target from the command droids
psTarget = NULL;
psTarget = nullptr;
psCommander = cmdDroidGetDesignator(psObj->player);
if (!proj_Direct(psWStats) && (psCommander != NULL) &&
if (!proj_Direct(psWStats) && (psCommander != nullptr) &&
aiStructHasRange((STRUCTURE *)psObj, (BASE_OBJECT *)psCommander, weapon_slot))
{
// there is a commander that can fire designate for this structure
Expand All @@ -866,7 +866,7 @@ bool aiChooseTarget(BASE_OBJECT *psObj, BASE_OBJECT **ppsTarget, int weapon_slot
debug(LOG_NEVER, "Commander %d is good enough for fire designation", psCommander->id);

if (psCommander->action == DACTION_ATTACK
&& psCommander->psActionTarget[0] != NULL
&& psCommander->psActionTarget[0] != nullptr
&& !psCommander->psActionTarget[0]->died)
{
// the commander has a target to fire on
Expand All @@ -885,12 +885,12 @@ bool aiChooseTarget(BASE_OBJECT *psObj, BASE_OBJECT **ppsTarget, int weapon_slot
}

// indirect fire structures use sensor towers first
if (psTarget == NULL && !bCommanderBlock && !proj_Direct(psWStats))
if (psTarget == nullptr && !bCommanderBlock && !proj_Direct(psWStats))
{
psTarget = aiSearchSensorTargets(psObj, weapon_slot, psWStats, &tmpOrigin);
}

if (psTarget == NULL && !bCommanderBlock)
if (psTarget == nullptr && !bCommanderBlock)
{
int targetValue = -1;
int tarDist = INT32_MAX;
Expand Down Expand Up @@ -962,7 +962,7 @@ bool aiChooseSensorTarget(BASE_OBJECT *psObj, BASE_OBJECT **ppsTarget)
/* See if there is something in range */
if (psObj->type == OBJ_DROID)
{
BASE_OBJECT *psTarget = NULL;
BASE_OBJECT *psTarget = nullptr;

if (aiBestNearestTarget((DROID *)psObj, &psTarget, 0) >= 0)
{
Expand All @@ -983,7 +983,7 @@ bool aiChooseSensorTarget(BASE_OBJECT *psObj, BASE_OBJECT **ppsTarget)
}
else // structure
{
BASE_OBJECT *psTemp = NULL;
BASE_OBJECT *psTemp = nullptr;
int tarDist = SDWORD_MAX;

static GridList gridList; // static to avoid allocations.
Expand Down Expand Up @@ -1024,7 +1024,7 @@ bool aiChooseSensorTarget(BASE_OBJECT *psObj, BASE_OBJECT **ppsTarget)
/* Make droid/structure look for a better target */
static bool updateAttackTarget(BASE_OBJECT *psAttacker, SDWORD weapon_slot)
{
BASE_OBJECT *psBetterTarget = NULL;
BASE_OBJECT *psBetterTarget = nullptr;
TARGET_ORIGIN tmpOrigin = ORIGIN_UNKNOWN;

if (aiChooseTarget(psAttacker, &psBetterTarget, weapon_slot, true, &tmpOrigin)) //update target
Expand Down Expand Up @@ -1064,7 +1064,7 @@ void aiUpdateDroid(DROID *psDroid)
BASE_OBJECT *psTarget;
bool lookForTarget, updateTarget;

ASSERT(psDroid != NULL, "Invalid droid pointer");
ASSERT(psDroid != nullptr, "Invalid droid pointer");
if (!psDroid || isDead((BASE_OBJECT *)psDroid))
{
return;
Expand Down Expand Up @@ -1174,7 +1174,7 @@ void aiUpdateDroid(DROID *psDroid)
}
else
{
if (aiChooseTarget((BASE_OBJECT *)psDroid, &psTarget, 0, true, NULL))
if (aiChooseTarget((BASE_OBJECT *)psDroid, &psTarget, 0, true, nullptr))
{
actionDroid(psDroid, DACTION_ATTACK, psTarget);
}
Expand Down
2 changes: 1 addition & 1 deletion src/astar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ struct PathNonblockingArea
// Data structures used for pathfinding, can contain cached results.
struct PathfindContext
{
PathfindContext() : myGameTime(0), iteration(0), blockingMap(NULL) {}
PathfindContext() : myGameTime(0), iteration(0), blockingMap(nullptr) {}
bool isBlocked(int x, int y) const
{
if (dstIgnore.isNonblocking(x, y))
Expand Down
4 changes: 2 additions & 2 deletions src/atmos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ enum AP_STATUS
APS_ACTIVE
};

static ATPART *asAtmosParts = NULL;
static ATPART *asAtmosParts = nullptr;
static UDWORD freeParticle;
static WT_CLASS weather = WT_NONE;

Expand Down Expand Up @@ -342,7 +342,7 @@ void atmosSetWeatherType(WT_CLASS type)
if (type == WT_NONE && asAtmosParts)
{
free(asAtmosParts);
asAtmosParts = NULL;
asAtmosParts = nullptr;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/aud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
bool audio_ObjectDead(SIMPLE_OBJECT *psSimpleObj)
{
/* check is valid simple object pointer */
if (psSimpleObj == NULL)
if (psSimpleObj == nullptr)
{
debug(LOG_NEVER, "audio_ObjectDead: simple object pointer invalid");
return true;
Expand Down Expand Up @@ -92,7 +92,7 @@ void audio_GetStaticPos(SDWORD iWorldX, SDWORD iWorldY, SDWORD *piX, SDWORD *piY
void audio_GetObjectPos(SIMPLE_OBJECT *psBaseObj, SDWORD *piX, SDWORD *piY, SDWORD *piZ)
{
/* check is valid pointer */
ASSERT_OR_RETURN(, psBaseObj != NULL, "Game object pointer invalid");
ASSERT_OR_RETURN(, psBaseObj != nullptr, "Game object pointer invalid");

*piX = psBaseObj->pos.x;
*piZ = map_TileHeight(map_coord(psBaseObj->pos.x), map_coord(psBaseObj->pos.y));
Expand Down
8 changes: 4 additions & 4 deletions src/basedef.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ struct BASE_OBJECT;

struct NEXTOBJ
{
NEXTOBJ(BASE_OBJECT *ptr_ = NULL) : ptr(ptr_) {}
NEXTOBJ(BASE_OBJECT *ptr_ = nullptr) : ptr(ptr_) {}
NEXTOBJ &operator =(BASE_OBJECT *ptr_)
{
ptr = ptr_;
Expand Down Expand Up @@ -174,17 +174,17 @@ static inline int objPosDiffSq(SIMPLE_OBJECT const *pos1, SIMPLE_OBJECT const *p
// True iff object is a droid, structure or feature (not a projectile). Will incorrectly return true if passed a nonsense object of type OBJ_TARGET or OBJ_NUM_TYPES.
static inline bool isBaseObject(SIMPLE_OBJECT const *psObject)
{
return psObject != NULL && psObject->type != OBJ_PROJECTILE;
return psObject != nullptr && psObject->type != OBJ_PROJECTILE;
}
// Returns BASE_OBJECT * if base_object or NULL if not.
static inline BASE_OBJECT *castBaseObject(SIMPLE_OBJECT *psObject)
{
return isBaseObject(psObject) ? (BASE_OBJECT *)psObject : (BASE_OBJECT *)NULL;
return isBaseObject(psObject) ? (BASE_OBJECT *)psObject : (BASE_OBJECT *)nullptr;
}
// Returns BASE_OBJECT const * if base_object or NULL if not.
static inline BASE_OBJECT const *castBaseObject(SIMPLE_OBJECT const *psObject)
{
return isBaseObject(psObject) ? (BASE_OBJECT const *)psObject : (BASE_OBJECT const *)NULL;
return isBaseObject(psObject) ? (BASE_OBJECT const *)psObject : (BASE_OBJECT const *)nullptr;
}

#endif // __INCLUDED_BASEDEF_H__
10 changes: 5 additions & 5 deletions src/baseobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@ BASE_OBJECT::BASE_OBJECT(OBJECT_TYPE type, uint32_t id, unsigned player)
, periodicalDamage(0)
, flags(0)
, jammedTiles(false)
, watchedTiles(NULL)
, watchedTiles(nullptr)
, timeAnimationStarted(0)
, animationEvent(ANIM_EVENT_NONE)
{
memset(visible, 0, sizeof(visible));
sDisplay.imd = NULL;
sDisplay.imd = nullptr;
sDisplay.frameNumber = 0;
sDisplay.screenX = 0;
sDisplay.screenY = 0;
Expand All @@ -135,7 +135,7 @@ void checkObject(const SIMPLE_OBJECT *psObject, const char *const location_descr
return;
}

ASSERT(psObject != NULL, "NULL pointer");
ASSERT(psObject != nullptr, "NULL pointer");

switch (psObject->type)
{
Expand Down Expand Up @@ -193,11 +193,11 @@ StructureBounds getStructureBounds(BASE_OBJECT const *object)
STRUCTURE const *psStructure = castStructure(object);
FEATURE const *psFeature = castFeature(object);

if (psStructure != NULL)
if (psStructure != nullptr)
{
return getStructureBounds(psStructure);
}
else if (psFeature != NULL)
else if (psFeature != nullptr)
{
return getStructureBounds(psFeature);
}
Expand Down
2 changes: 1 addition & 1 deletion src/bucket3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ static SDWORD bucketCalculateZ(RENDER_TYPE objectType, void *pObject, const glm:
{
//particle use the image radius
pImd = ((EFFECT *)pObject)->imd;
if (pImd != NULL)
if (pImd != nullptr)
{
radius = pImd->radius;
radius *= SCALE_DEPTH;
Expand Down
4 changes: 2 additions & 2 deletions src/challenge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ bool addChallenges()

// add challenges to buttons
files = PHYSFS_enumerateFiles(sSearchPath);
for (i = files; *i != NULL; ++i)
for (i = files; *i != nullptr; ++i)
{
W_BUTTON *button;
QString name, map, difficulty, highscore, description;
Expand Down Expand Up @@ -319,7 +319,7 @@ bool addChallenges()
bool closeChallenges()
{
delete psRequestScreen;
psRequestScreen = NULL;
psRequestScreen = nullptr;
// need to "eat" up the return key so it don't pass back to game.
inputLoseFocus();
challengesUp = false;
Expand Down
102 changes: 51 additions & 51 deletions src/clparse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ static int poptGetNextOpt(poptContext ctx)
char *pparam;
int i;

ctx->bad = NULL;
ctx->parameter = NULL;
ctx->bad = nullptr;
ctx->parameter = nullptr;
parameter[0] = '\0';
match[0] = '\0';

Expand Down Expand Up @@ -211,7 +211,7 @@ static poptContext poptGetContext(WZ_DECL_UNUSED void *unused, int argc, const c
ctx.argv = argv;
ctx.table = table;
ctx.current = 1;
ctx.parameter = NULL;
ctx.parameter = nullptr;

for (ctx.size = 0; table[ctx.size].string; ctx.size++) ; // count table size

Expand Down Expand Up @@ -258,38 +258,38 @@ static const struct poptOption *getOptionsTable(void)
{
static const struct poptOption optionsTable[] =
{
{ "configdir", '\0', POPT_ARG_STRING, NULL, CLI_CONFIGDIR, N_("Set configuration directory"), N_("configuration directory"), false },
{ "datadir", '\0', POPT_ARG_STRING, NULL, CLI_DATADIR, N_("Add data directory"), N_("data directory"), false },
{ "debug", '\0', POPT_ARG_STRING, NULL, CLI_DEBUG, N_("Show debug for given level"), N_("debug level"), false },
{ "debugfile", '\0', POPT_ARG_STRING, NULL, CLI_DEBUGFILE, N_("Log debug output to file"), N_("file"), false },
{ "flush-debug-stderr", '\0', POPT_ARG_NONE, NULL, CLI_FLUSHDEBUGSTDERR, N_("Flush all debug output written to stderr"), NULL, true },
{ "fullscreen", '\0', POPT_ARG_NONE, NULL, CLI_FULLSCREEN, N_("Play in fullscreen mode"), NULL, false },
{ "game", '\0', POPT_ARG_STRING, NULL, CLI_GAME, N_("Load a specific game mode"), N_("level name"), true },
{ "help", 'h', POPT_ARG_NONE, NULL, CLI_HELP, N_("Show options and exit"), NULL, false },
{ "help-all", '\0', POPT_ARG_NONE, NULL, CLI_HELP_ALL, N_("Show all options and exit"), NULL, false },
{ "mod", '\0', POPT_ARG_STRING, NULL, CLI_MOD_GLOB, N_("Enable a global mod"), N_("mod"), false },
{ "mod_ca", '\0', POPT_ARG_STRING, NULL, CLI_MOD_CA, N_("Enable a campaign only mod"), N_("mod"), false },
{ "mod_mp", '\0', POPT_ARG_STRING, NULL, CLI_MOD_MP, N_("Enable a multiplay only mod"), N_("mod"), false },
{ "noassert", '\0', POPT_ARG_NONE, NULL, CLI_NOASSERT, N_("Disable asserts"), NULL, false },
{ "crash", '\0', POPT_ARG_NONE, NULL, CLI_CRASH, N_("Causes a crash to test the crash handler"), NULL, true },
{ "loadskirmish",'\0', POPT_ARG_STRING, NULL, CLI_LOADSKIRMISH, N_("Load a saved skirmish game"), N_("savegame"), true },
{ "loadcampaign",'\0', POPT_ARG_STRING, NULL, CLI_LOADCAMPAIGN, N_("Load a saved campaign game"), N_("savegame"), true },
{ "window", '\0', POPT_ARG_NONE, NULL, CLI_WINDOW, N_("Play in windowed mode"), NULL, false },
{ "version", '\0', POPT_ARG_NONE, NULL, CLI_VERSION, N_("Show version information and exit"), NULL, false },
{ "resolution", '\0', POPT_ARG_STRING, NULL, CLI_RESOLUTION, N_("Set the resolution to use"), N_("WIDTHxHEIGHT"), false },
{ "shadows", '\0', POPT_ARG_NONE, NULL, CLI_SHADOWS, N_("Enable shadows"), NULL, false },
{ "noshadows", '\0', POPT_ARG_NONE, NULL, CLI_NOSHADOWS, N_("Disable shadows"), NULL, false },
{ "sound", '\0', POPT_ARG_NONE, NULL, CLI_SOUND, N_("Enable sound"), NULL, false },
{ "nosound", '\0', POPT_ARG_NONE, NULL, CLI_NOSOUND, N_("Disable sound"), NULL, false },
{ "join", '\0', POPT_ARG_STRING, NULL, CLI_CONNECTTOIP, N_("Connect directly to IP/hostname"), N_("host"), true },
{ "host", '\0', POPT_ARG_NONE, NULL, CLI_HOSTLAUNCH, N_("Go directly to host screen"), NULL, true },
{ "texturecompression", '\0', POPT_ARG_NONE, NULL, CLI_TEXTURECOMPRESSION, N_("Enable texture compression"), NULL, false },
{ "notexturecompression", '\0', POPT_ARG_NONE, NULL, CLI_NOTEXTURECOMPRESSION, N_("Disable texture compression"), NULL, false },
{ "autogame", '\0', POPT_ARG_NONE, NULL, CLI_AUTOGAME, N_("Run games automatically for testing"), NULL, true },
{ "saveandquit", '\0', POPT_ARG_STRING, NULL, CLI_SAVEANDQUIT, N_("Immediately save game and quit"), N_("save name"), true },
{ "skirmish", '\0', POPT_ARG_STRING, NULL, CLI_SKIRMISH, N_("Start skirmish game with given settings file"), N_("test"), true },
{ "configdir", '\0', POPT_ARG_STRING, nullptr, CLI_CONFIGDIR, N_("Set configuration directory"), N_("configuration directory"), false },
{ "datadir", '\0', POPT_ARG_STRING, nullptr, CLI_DATADIR, N_("Add data directory"), N_("data directory"), false },
{ "debug", '\0', POPT_ARG_STRING, nullptr, CLI_DEBUG, N_("Show debug for given level"), N_("debug level"), false },
{ "debugfile", '\0', POPT_ARG_STRING, nullptr, CLI_DEBUGFILE, N_("Log debug output to file"), N_("file"), false },
{ "flush-debug-stderr", '\0', POPT_ARG_NONE, nullptr, CLI_FLUSHDEBUGSTDERR, N_("Flush all debug output written to stderr"), nullptr, true },
{ "fullscreen", '\0', POPT_ARG_NONE, nullptr, CLI_FULLSCREEN, N_("Play in fullscreen mode"), nullptr, false },
{ "game", '\0', POPT_ARG_STRING, nullptr, CLI_GAME, N_("Load a specific game mode"), N_("level name"), true },
{ "help", 'h', POPT_ARG_NONE, nullptr, CLI_HELP, N_("Show options and exit"), nullptr, false },
{ "help-all", '\0', POPT_ARG_NONE, nullptr, CLI_HELP_ALL, N_("Show all options and exit"), nullptr, false },
{ "mod", '\0', POPT_ARG_STRING, nullptr, CLI_MOD_GLOB, N_("Enable a global mod"), N_("mod"), false },
{ "mod_ca", '\0', POPT_ARG_STRING, nullptr, CLI_MOD_CA, N_("Enable a campaign only mod"), N_("mod"), false },
{ "mod_mp", '\0', POPT_ARG_STRING, nullptr, CLI_MOD_MP, N_("Enable a multiplay only mod"), N_("mod"), false },
{ "noassert", '\0', POPT_ARG_NONE, nullptr, CLI_NOASSERT, N_("Disable asserts"), nullptr, false },
{ "crash", '\0', POPT_ARG_NONE, nullptr, CLI_CRASH, N_("Causes a crash to test the crash handler"), nullptr, true },
{ "loadskirmish",'\0', POPT_ARG_STRING, nullptr, CLI_LOADSKIRMISH, N_("Load a saved skirmish game"), N_("savegame"), true },
{ "loadcampaign",'\0', POPT_ARG_STRING, nullptr, CLI_LOADCAMPAIGN, N_("Load a saved campaign game"), N_("savegame"), true },
{ "window", '\0', POPT_ARG_NONE, nullptr, CLI_WINDOW, N_("Play in windowed mode"), nullptr, false },
{ "version", '\0', POPT_ARG_NONE, nullptr, CLI_VERSION, N_("Show version information and exit"), nullptr, false },
{ "resolution", '\0', POPT_ARG_STRING, nullptr, CLI_RESOLUTION, N_("Set the resolution to use"), N_("WIDTHxHEIGHT"), false },
{ "shadows", '\0', POPT_ARG_NONE, nullptr, CLI_SHADOWS, N_("Enable shadows"), nullptr, false },
{ "noshadows", '\0', POPT_ARG_NONE, nullptr, CLI_NOSHADOWS, N_("Disable shadows"), nullptr, false },
{ "sound", '\0', POPT_ARG_NONE, nullptr, CLI_SOUND, N_("Enable sound"), nullptr, false },
{ "nosound", '\0', POPT_ARG_NONE, nullptr, CLI_NOSOUND, N_("Disable sound"), nullptr, false },
{ "join", '\0', POPT_ARG_STRING, nullptr, CLI_CONNECTTOIP, N_("Connect directly to IP/hostname"), N_("host"), true },
{ "host", '\0', POPT_ARG_NONE, nullptr, CLI_HOSTLAUNCH, N_("Go directly to host screen"), nullptr, true },
{ "texturecompression", '\0', POPT_ARG_NONE, nullptr, CLI_TEXTURECOMPRESSION, N_("Enable texture compression"), nullptr, false },
{ "notexturecompression", '\0', POPT_ARG_NONE, nullptr, CLI_NOTEXTURECOMPRESSION, N_("Disable texture compression"), nullptr, false },
{ "autogame", '\0', POPT_ARG_NONE, nullptr, CLI_AUTOGAME, N_("Run games automatically for testing"), nullptr, true },
{ "saveandquit", '\0', POPT_ARG_STRING, nullptr, CLI_SAVEANDQUIT, N_("Immediately save game and quit"), N_("save name"), true },
{ "skirmish", '\0', POPT_ARG_STRING, nullptr, CLI_SKIRMISH, N_("Start skirmish game with given settings file"), N_("test"), true },
// Terminating entry
{ NULL, '\0', 0, NULL, 0, NULL, NULL, true },
{ nullptr, '\0', 0, nullptr, 0, nullptr, nullptr, true },
};

static struct poptOption TranslatedOptionsTable[sizeof(optionsTable) / sizeof(struct poptOption)];
Expand All @@ -305,12 +305,12 @@ static const struct poptOption *getOptionsTable(void)
TranslatedOptionsTable[i] = optionsTable[i];

// If there is a description, make sure to translate it with gettext
if (TranslatedOptionsTable[i].descrip != NULL)
if (TranslatedOptionsTable[i].descrip != nullptr)
{
TranslatedOptionsTable[i].descrip = gettext(TranslatedOptionsTable[i].descrip);
}

if (TranslatedOptionsTable[i].argDescrip != NULL)
if (TranslatedOptionsTable[i].argDescrip != nullptr)
{
TranslatedOptionsTable[i].argDescrip = gettext(TranslatedOptionsTable[i].argDescrip);
}
Expand All @@ -333,7 +333,7 @@ static const struct poptOption *getOptionsTable(void)
* \return Returns true on success, false on error */
bool ParseCommandLineEarly(int argc, const char **argv)
{
poptContext poptCon = poptGetContext(NULL, argc, argv, getOptionsTable(), 0);
poptContext poptCon = poptGetContext(nullptr, argc, argv, getOptionsTable(), 0);
int iOption;

#if defined(WZ_OS_MAC) && defined(DEBUG)
Expand All @@ -356,7 +356,7 @@ bool ParseCommandLineEarly(int argc, const char **argv)
case CLI_DEBUG:
// retrieve the debug section name
token = poptGetOptArg(poptCon);
if (token == NULL)
if (token == nullptr)
{
qFatal("Usage: --debug=<flag>");
}
Expand All @@ -371,7 +371,7 @@ bool ParseCommandLineEarly(int argc, const char **argv)
case CLI_DEBUGFILE:
// find the file name
token = poptGetOptArg(poptCon);
if (token == NULL)
if (token == nullptr)
{
qFatal("Missing debugfile filename?");
}
Expand All @@ -387,7 +387,7 @@ bool ParseCommandLineEarly(int argc, const char **argv)
case CLI_CONFIGDIR:
// retrieve the configuration directory
token = poptGetOptArg(poptCon);
if (token == NULL)
if (token == nullptr)
{
qFatal("Unrecognised configuration directory");
}
Expand Down Expand Up @@ -420,7 +420,7 @@ bool ParseCommandLineEarly(int argc, const char **argv)
* \return Returns true on success, false on error */
bool ParseCommandLine(int argc, const char **argv)
{
poptContext poptCon = poptGetContext(NULL, argc, argv, getOptionsTable(), 0);
poptContext poptCon = poptGetContext(nullptr, argc, argv, getOptionsTable(), 0);
int iOption;

/* loop through command line */
Expand Down Expand Up @@ -456,7 +456,7 @@ bool ParseCommandLine(int argc, const char **argv)
case CLI_DATADIR:
// retrieve the quoted path name
token = poptGetOptArg(poptCon);
if (token == NULL)
if (token == nullptr)
{
qFatal("Unrecognised datadir");
}
Expand All @@ -469,7 +469,7 @@ bool ParseCommandLine(int argc, const char **argv)
case CLI_CONNECTTOIP:
//get the ip we want to connect with, and go directly to join screen.
token = poptGetOptArg(poptCon);
if (token == NULL)
if (token == nullptr)
{
qFatal("No IP/hostname given");
}
Expand All @@ -482,7 +482,7 @@ bool ParseCommandLine(int argc, const char **argv)
case CLI_GAME:
// retrieve the game name
token = poptGetOptArg(poptCon);
if (token == NULL
if (token == nullptr
|| (strcmp(token, "CAM_1A") && strcmp(token, "CAM_2A") && strcmp(token, "CAM_3A")
&& strcmp(token, "TUTORIAL3") && strcmp(token, "FASTPLAY")))
{
Expand Down Expand Up @@ -512,7 +512,7 @@ bool ParseCommandLine(int argc, const char **argv)
{
// retrieve the file name
token = poptGetOptArg(poptCon);
if (token == NULL)
if (token == nullptr)
{
qFatal("Missing mod name?");
}
Expand All @@ -524,7 +524,7 @@ bool ParseCommandLine(int argc, const char **argv)
{
// retrieve the file name
token = poptGetOptArg(poptCon);
if (token == NULL)
if (token == nullptr)
{
qFatal("Missing mod name?");
}
Expand All @@ -536,7 +536,7 @@ bool ParseCommandLine(int argc, const char **argv)
{
// retrieve the file name
token = poptGetOptArg(poptCon);
if (token == NULL)
if (token == nullptr)
{
qFatal("Missing mod name?");
}
Expand Down Expand Up @@ -574,7 +574,7 @@ bool ParseCommandLine(int argc, const char **argv)
case CLI_LOADSKIRMISH:
// retrieve the game name
token = poptGetOptArg(poptCon);
if (token == NULL)
if (token == nullptr)
{
qFatal("Unrecognised skirmish savegame name");
}
Expand All @@ -587,7 +587,7 @@ bool ParseCommandLine(int argc, const char **argv)
case CLI_LOADCAMPAIGN:
// retrieve the game name
token = poptGetOptArg(poptCon);
if (token == NULL)
if (token == nullptr)
{
qFatal("Unrecognised campaign savegame name");
}
Expand Down Expand Up @@ -630,7 +630,7 @@ bool ParseCommandLine(int argc, const char **argv)

case CLI_SAVEANDQUIT:
token = poptGetOptArg(poptCon);
if (token == NULL || !strchr(token, '/'))
if (token == nullptr || !strchr(token, '/'))
{
qFatal("Bad savegame name (needs to be a full path)");
}
Expand All @@ -640,7 +640,7 @@ bool ParseCommandLine(int argc, const char **argv)
case CLI_SKIRMISH:
hostlaunch = 2;
token = poptGetOptArg(poptCon);
if (token == NULL)
if (token == nullptr)
{
qFatal("Bad test key");
}
Expand Down
8 changes: 4 additions & 4 deletions src/cluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,8 +440,8 @@ void clustObjectSeen(BASE_OBJECT *psObj, BASE_OBJECT *psViewer)
break;
}

psScrCBObjSeen = NULL;
psScrCBObjViewer = NULL;
psScrCBObjSeen = nullptr;
psScrCBObjViewer = nullptr;
}
}
}
Expand All @@ -459,12 +459,12 @@ void clustObjectAttacked(BASE_OBJECT *psObj)
case OBJ_DROID:
psLastDroidHit = (DROID *)psObj;
eventFireCallbackTrigger((TRIGGER_TYPE)CALL_DROID_ATTACKED);
psLastDroidHit = NULL;
psLastDroidHit = nullptr;
break;
case OBJ_STRUCTURE:
psLastStructHit = (STRUCTURE *)psObj;
eventFireCallbackTrigger((TRIGGER_TYPE)CALL_STRUCT_ATTACKED);
psLastStructHit = NULL;
psLastStructHit = nullptr;
break;
default:
ASSERT(!"invalid object type", "clustObjectAttacked: invalid object type");
Expand Down
16 changes: 8 additions & 8 deletions src/cmddroid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void cmdDroidUpdate(void)
{
if (apsCmdDesignator[i] && apsCmdDesignator[i]->died)
{
apsCmdDesignator[i] = NULL;
apsCmdDesignator[i] = nullptr;
}
}
}
Expand All @@ -83,7 +83,7 @@ void cmdDroidAddDroid(DROID *psCommander, DROID *psDroid)
{
DROID_GROUP *psGroup;

if (psCommander->psGroup == NULL)
if (psCommander->psGroup == nullptr)
{
psGroup = grpCreate();
psGroup->add(psCommander);
Expand Down Expand Up @@ -115,7 +115,7 @@ DROID *cmdDroidGetDesignator(UDWORD player)

void cmdDroidSetDesignator(DROID *psDroid)
{
ASSERT_OR_RETURN(, psDroid != NULL, "Invalid droid!");
ASSERT_OR_RETURN(, psDroid != nullptr, "Invalid droid!");
if (psDroid->droidType != DROID_COMMAND)
{
return;
Expand All @@ -126,7 +126,7 @@ void cmdDroidSetDesignator(DROID *psDroid)

void cmdDroidClearDesignator(UDWORD player)
{
apsCmdDesignator[player] = NULL;
apsCmdDesignator[player] = nullptr;
}

/** This function returns the index of the command droid.
Expand Down Expand Up @@ -175,7 +175,7 @@ unsigned int cmdDroidMaxGroup(const DROID *psCommander)
/** This function adds experience to the command droid of the psKiller's command group.*/
void cmdDroidUpdateKills(DROID *psKiller, uint32_t experienceInc)
{
ASSERT_OR_RETURN(, psKiller != NULL, "invalid Unit pointer");
ASSERT_OR_RETURN(, psKiller != nullptr, "invalid Unit pointer");

if (hasCommander(psKiller))
{
Expand All @@ -187,10 +187,10 @@ void cmdDroidUpdateKills(DROID *psKiller, uint32_t experienceInc)
/** This function returns true if the droid is assigned to a commander group and it is not the commander.*/
bool hasCommander(const DROID *psDroid)
{
ASSERT_OR_RETURN(false, psDroid != NULL, "invalid droid pointer");
ASSERT_OR_RETURN(false, psDroid != nullptr, "invalid droid pointer");

if (psDroid->droidType != DROID_COMMAND &&
psDroid->psGroup != NULL &&
psDroid->psGroup != nullptr &&
psDroid->psGroup->type == GT_COMMAND)
{
return true;
Expand All @@ -204,7 +204,7 @@ unsigned int cmdGetCommanderLevel(const DROID *psDroid)
{
const DROID *psCommander;

ASSERT(psDroid != NULL, "invalid droid pointer");
ASSERT(psDroid != nullptr, "invalid droid pointer");

// If this droid is not the member of a Commander's group
// Return an experience level of 0
Expand Down
12 changes: 6 additions & 6 deletions src/combat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ bool combFire(WEAPON *psWeap, BASE_OBJECT *psAttacker, BASE_OBJECT *psTarget, in

CHECK_OBJECT(psAttacker);
CHECK_OBJECT(psTarget);
ASSERT(psWeap != NULL, "Invalid weapon pointer");
ASSERT(psWeap != nullptr, "Invalid weapon pointer");

/* Don't shoot if the weapon_slot of a vtol is empty */
if (psAttacker->type == OBJ_DROID && isVtolDroid(((DROID *)psAttacker))
Expand Down Expand Up @@ -280,7 +280,7 @@ bool combFire(WEAPON *psWeap, BASE_OBJECT *psAttacker, BASE_OBJECT *psTarget, in
Vector3i miss = Vector3i(iSinCosR(gameRand(DEG(360)), missDist), 0);
predict += miss;

psTarget = NULL; // Missed the target, so don't expect to hit it.
psTarget = nullptr; // Missed the target, so don't expect to hit it.

objTrace(psAttacker->id, "combFire: Missed shot by (%4d,%4d)", miss.x, miss.y);
syncDebug("miss=(%d,%d,%d)", predict.x, predict.y, predict.z);
Expand All @@ -302,9 +302,9 @@ void counterBatteryFire(BASE_OBJECT *psAttacker, BASE_OBJECT *psTarget)
projectile is sent - we may have to cater for these at some point*/
// also ignore cases where you attack your own player
// Also ignore cases where there are already 1000 missiles heading towards the attacker.
if (psTarget == NULL
|| (psAttacker != NULL && psAttacker->player == psTarget->player)
|| (psAttacker != NULL && aiObjectIsProbablyDoomed(psAttacker, false)))
if (psTarget == nullptr
|| (psAttacker != nullptr && psAttacker->player == psTarget->player)
|| (psAttacker != nullptr && aiObjectIsProbablyDoomed(psAttacker, false)))
{
return;
}
Expand Down Expand Up @@ -471,7 +471,7 @@ unsigned int objGuessFutureDamage(WEAPON_STATS *psStats, unsigned int player, BA
unsigned int damage;
int actualDamage, armour, level = 1;

if (psTarget == NULL)
if (psTarget == nullptr)
{
return 0; // Hard to destroy the ground. The armour on the mud is very strong and blocks all damage.
}
Expand Down
40 changes: 20 additions & 20 deletions src/component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ UDWORD getComponentDroidTemplateRadius(DROID_TEMPLATE *)

UDWORD getComponentRadius(BASE_STATS *psComponent)
{
iIMDShape *ComponentIMD = NULL;
iIMDShape *MountIMD = NULL;
iIMDShape *ComponentIMD = nullptr;
iIMDShape *MountIMD = nullptr;
SDWORD compID;

compID = StatIsComponent(psComponent);
Expand Down Expand Up @@ -177,7 +177,7 @@ static void sharedStructureButton(STRUCTURE_STATS *Stats, iIMDShape *strImd, con
/* Draw the building's base first */
baseImd = Stats->pBaseIMD;

if (baseImd != NULL)
if (baseImd != nullptr)
{
pie_Draw3DShape(baseImd, 0, getPlayerColour(selectedPlayer), WZCOL_WHITE, pie_BUTTON, 0, matrix);
}
Expand All @@ -186,39 +186,39 @@ static void sharedStructureButton(STRUCTURE_STATS *Stats, iIMDShape *strImd, con
//and draw the turret
if (strImd->nconnectors)
{
weaponImd[0] = NULL;
mountImd[0] = NULL;
weaponImd[0] = nullptr;
mountImd[0] = nullptr;
for (int i = 0; i < Stats->numWeaps; i++)
{
weaponImd[i] = NULL;//weapon is gun ecm or sensor
mountImd[i] = NULL;
weaponImd[i] = nullptr;//weapon is gun ecm or sensor
mountImd[i] = nullptr;
}
//get an imd to draw on the connector priority is weapon, ECM, sensor
//check for weapon
//can only have the MAX_WEAPONS
for (int i = 0; i < MAX(1, Stats->numWeaps); i++)
{
//can only have the one
if (Stats->psWeapStat[i] != NULL)
if (Stats->psWeapStat[i] != nullptr)
{
weaponImd[i] = Stats->psWeapStat[i]->pIMD;
mountImd[i] = Stats->psWeapStat[i]->pMountGraphic;
}

if (weaponImd[i] == NULL)
if (weaponImd[i] == nullptr)
{
//check for ECM
if (Stats->pECM != NULL)
if (Stats->pECM != nullptr)
{
weaponImd[i] = Stats->pECM->pIMD;
mountImd[i] = Stats->pECM->pMountGraphic;
}
}

if (weaponImd[i] == NULL)
if (weaponImd[i] == nullptr)
{
//check for sensor
if (Stats->pSensor != NULL)
if (Stats->pSensor != nullptr)
{
weaponImd[i] = Stats->pSensor->pIMD;
mountImd[i] = Stats->pSensor->pMountGraphic;
Expand All @@ -227,12 +227,12 @@ static void sharedStructureButton(STRUCTURE_STATS *Stats, iIMDShape *strImd, con
}

//draw Weapon/ECM/Sensor for structure
if (weaponImd[0] != NULL)
if (weaponImd[0] != nullptr)
{
for (int i = 0; i < MAX(1, Stats->numWeaps); i++)
{
glm::mat4 localMatrix = glm::translate(strImd->connectors[i].xzy);
if (mountImd[i] != NULL)
if (mountImd[i] != nullptr)
{
pie_Draw3DShape(mountImd[i], 0, getPlayerColour(selectedPlayer), WZCOL_WHITE, pie_BUTTON, 0, matrix * localMatrix);
if (mountImd[i]->nconnectors)
Expand Down Expand Up @@ -261,8 +261,8 @@ void displayStructureStatButton(STRUCTURE_STATS *Stats, const Vector3i *rotation
//
void displayComponentButton(BASE_STATS *Stat, const Vector3i *Rotation, const Vector3i *Position, int scale)
{
iIMDShape *ComponentIMD = NULL;
iIMDShape *MountIMD = NULL;
iIMDShape *ComponentIMD = nullptr;
iIMDShape *MountIMD = nullptr;
int compID = StatIsComponent(Stat);

if (compID >= 0)
Expand Down Expand Up @@ -400,7 +400,7 @@ static void displayCompObj(DROID *psDroid, bool bButton, const glm::mat4 &viewMa

/* get propulsion stats */
psPropStats = asPropulsionStats + psDroid->asBits[COMP_PROPULSION];
ASSERT_OR_RETURN(, psPropStats != NULL, "invalid propulsion stats pointer");
ASSERT_OR_RETURN(, psPropStats != nullptr, "invalid propulsion stats pointer");

//set pieflag for button object or ingame object
if (bButton)
Expand Down Expand Up @@ -828,7 +828,7 @@ void displayComponentObject(DROID *psDroid, const glm::mat4 &viewMatrix)
position.y = st.pos.z + rand() % 8;
position.z = st.pos.y + DROID_EMP_SPREAD;
effectGiveAuxVar(90 + rand() % 20);
addEffect(&position, EFFECT_EXPLOSION, EXPLOSION_TYPE_PLASMA, false, NULL, 0);
addEffect(&position, EFFECT_EXPLOSION, EXPLOSION_TYPE_PLASMA, false, nullptr, 0);
}

if (psDroid->visible[selectedPlayer] == UBYTE_MAX)
Expand All @@ -849,7 +849,7 @@ void destroyFXDroid(DROID *psDroid, unsigned impactTime)
{
for (int i = 0; i < 5; ++i)
{
iIMDShape *psImd = NULL;
iIMDShape *psImd = nullptr;

int maxHorizontalScatter = TILE_UNITS / 4;
int heightScatter = TILE_UNITS / 5;
Expand Down Expand Up @@ -901,7 +901,7 @@ void destroyFXDroid(DROID *psDroid, unsigned impactTime)
}
break;
}
if (psImd == NULL)
if (psImd == nullptr)
{
psImd = getRandomDebrisImd();
}
Expand Down
68 changes: 34 additions & 34 deletions src/data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ static bool bufferSWEAPONLoad(const char *fileName, void **ppData)
}

// not interested in this value
*ppData = NULL;
*ppData = nullptr;
return true;
}

Expand All @@ -179,7 +179,7 @@ static bool bufferSCONSTRLoad(const char *fileName, void **ppData)
}

//not interested in this value
*ppData = NULL;
*ppData = nullptr;
return true;
}

Expand All @@ -193,7 +193,7 @@ static bool bufferSECMLoad(const char *fileName, void **ppData)
}

//not interested in this value
*ppData = NULL;
*ppData = nullptr;
return true;
}

Expand All @@ -219,7 +219,7 @@ static bool bufferSSENSORLoad(const char *fileName, void **ppData)
}

//not interested in this value
*ppData = NULL;
*ppData = nullptr;
return true;
}

Expand All @@ -232,7 +232,7 @@ static bool bufferSREPAIRLoad(const char *fileName, void **ppData)
}

//not interested in this value
*ppData = NULL;
*ppData = nullptr;
return true;
}

Expand All @@ -244,7 +244,7 @@ static bool bufferSBRAINLoad(const char *fileName, void **ppData)
return false;
}
//not interested in this value
*ppData = NULL;
*ppData = nullptr;
return true;
}

Expand All @@ -258,7 +258,7 @@ static bool bufferSPROPTYPESLoad(const char *fileName, void **ppData)


//not interested in this value
*ppData = NULL;
*ppData = nullptr;
return true;
}

Expand All @@ -271,7 +271,7 @@ static bool bufferSPROPSNDLoad(const char *fileName, void **ppData)
}

//not interested in this value
*ppData = NULL;
*ppData = nullptr;
return true;
}

Expand All @@ -284,15 +284,15 @@ static bool bufferSTERRTABLELoad(const char *fileName, void **ppData)
}

//not interested in this value
*ppData = NULL;
*ppData = nullptr;
return true;
}

/* Load the body/propulsion IMDs stats -- FIXME, REMOVE IT, NOT USED */
static bool bufferSBPIMDLoad(const char *fileName, void **ppData)
{
//not interested in this value
*ppData = NULL;
*ppData = nullptr;
return true;
}

Expand All @@ -305,7 +305,7 @@ static bool bufferSWEAPMODLoad(const char *fileName, void **ppData)
}

//not interested in this value
*ppData = NULL;
*ppData = nullptr;
return true;
}

Expand Down Expand Up @@ -364,7 +364,7 @@ static bool bufferSSTRMODLoad(const char *fileName, void **ppData)
}

//not interested in this value
*ppData = NULL;
*ppData = nullptr;
return true;
}

Expand Down Expand Up @@ -402,7 +402,7 @@ static bool bufferRESCHLoad(const char *fileName, void **ppData)
if (!asResearch.empty())
{
//release previous data before loading in the new
dataRESCHRelease(NULL);
dataRESCHRelease(nullptr);
}

if (!loadResearch(QString(fileName)))
Expand Down Expand Up @@ -482,15 +482,15 @@ static bool dataTERTILESLoad(const char *fileName, void **ppData)
ASSERT_OR_RETURN(false, status, "Error loading tertiles!");
debug(LOG_TEXTURE, "HW Tiles loaded");

*ppData = NULL; // don't bother calling cleanup
*ppData = nullptr; // don't bother calling cleanup

return true;
}

static bool dataIMGLoad(const char *fileName, void **ppData)
{
*ppData = iV_LoadImageFile(fileName);
if (*ppData == NULL)
if (*ppData == nullptr)
{
return false;
}
Expand Down Expand Up @@ -523,15 +523,15 @@ static bool dataAudioLoad(const char *fileName, void **ppData)
{
if (audio_Disabled() == true)
{
*ppData = NULL;
*ppData = nullptr;
// No error occurred (sound is just disabled), so we return true
return true;
}

// Load the track from a file
*ppData = sound_LoadTrackFromFile(fileName);

return *ppData != NULL;
return *ppData != nullptr;
}

/* Load an audio file */
Expand All @@ -540,7 +540,7 @@ static bool dataAudioCfgLoad(const char *fileName, void **ppData)
bool success;
PHYSFS_file *fileHandle;

*ppData = NULL;
*ppData = nullptr;

if (audio_Disabled())
{
Expand All @@ -549,7 +549,7 @@ static bool dataAudioCfgLoad(const char *fileName, void **ppData)
debug(LOG_WZ, "Reading...[directory: %s] %s", PHYSFS_getRealDir(fileName), fileName);
fileHandle = PHYSFS_openRead(fileName);

if (fileHandle == NULL)
if (fileHandle == nullptr)
{
return false;
}
Expand All @@ -565,7 +565,7 @@ static bool dataAudioCfgLoad(const char *fileName, void **ppData)
static bool dataStrResLoad(const char *fileName, void **ppData)
{
// recreate the string resource if it was freed by a WRF release
if (psStringRes == NULL)
if (psStringRes == nullptr)
{
if (!stringsInitialise())
{
Expand All @@ -584,10 +584,10 @@ static bool dataStrResLoad(const char *fileName, void **ppData)

static void dataStrResRelease(WZ_DECL_UNUSED void *pData)
{
if (psStringRes != NULL)
if (psStringRes != nullptr)
{
strresDestroy(psStringRes);
psStringRes = NULL;
psStringRes = nullptr;
}
}

Expand All @@ -606,7 +606,7 @@ static bool dataScriptLoad(const char *fileName, void **ppData)

fileHandle = PHYSFS_openRead(fileName);
debug(LOG_WZ, "Reading...[directory: %s] %s", PHYSFS_getRealDir(fileName), fileName);
if (fileHandle == NULL)
if (fileHandle == nullptr)
{
return false;
}
Expand Down Expand Up @@ -653,7 +653,7 @@ static void dataScriptRelease(void *pData)
static bool jsLoad(const char *fileName, void **ppData)
{
debug(LOG_WZ, "jsload: %s", fileName);
*ppData = NULL;
*ppData = nullptr;
return loadGlobalScript(fileName);
}

Expand All @@ -665,7 +665,7 @@ static bool dataScriptLoadVals(const char *fileName, void **ppData)
uint8_t *pBuffer;
PHYSFS_sint64 fileSize = 0;

*ppData = NULL;
*ppData = nullptr;

// don't load anything if a saved game is being loaded
if (saveFlag)
Expand All @@ -677,7 +677,7 @@ static bool dataScriptLoadVals(const char *fileName, void **ppData)

fileHandle = PHYSFS_openRead(fileName);
debug(LOG_WZ, "Reading...[directory: %s] %s", PHYSFS_getRealDir(fileName), fileName);
if (fileHandle == NULL)
if (fileHandle == nullptr)
{
return false;
}
Expand Down Expand Up @@ -721,7 +721,7 @@ struct RES_TYPE_MIN_BUF
static const RES_TYPE_MIN_BUF BufferResourceTypes[] =
{
{"SMSG", bufferSMSGLoad, dataSMSGRelease},
{"IMD", NULL, NULL}, // ignored
{"IMD", nullptr, nullptr}, // ignored
};

struct RES_TYPE_MIN_FILE
Expand Down Expand Up @@ -749,18 +749,18 @@ static const RES_TYPE_MIN_FILE FileResourceTypes[] =
{"SBODY", bufferSBODYLoad, dataReleaseStats},
{"SWEAPMOD", bufferSWEAPMODLoad, dataReleaseStats},
{"SPROPSND", bufferSPROPSNDLoad, dataReleaseStats},
{"AUDIOCFG", dataAudioCfgLoad, NULL},
{"AUDIOCFG", dataAudioCfgLoad, nullptr},
{"IMGPAGE", dataImageLoad, dataImageRelease},
{"TERTILES", dataTERTILESLoad, NULL},
{"TERTILES", dataTERTILESLoad, nullptr},
{"IMG", dataIMGLoad, dataIMGRelease},
{"TEXPAGE", NULL, NULL}, // ignored
{"TCMASK", NULL, NULL}, // ignored
{"TEXPAGE", nullptr, nullptr}, // ignored
{"TCMASK", nullptr, nullptr}, // ignored
{"SCRIPT", dataScriptLoad, dataScriptRelease},
{"SCRIPTVAL", dataScriptLoadVals, NULL},
{"SCRIPTVAL", dataScriptLoadVals, nullptr},
{"STR_RES", dataStrResLoad, dataStrResRelease},
{"RESEARCHMSG", dataResearchMsgLoad, dataSMSGRelease },
{"SSTRMOD", bufferSSTRMODLoad, NULL},
{"JAVASCRIPT", jsLoad, NULL},
{"SSTRMOD", bufferSSTRMODLoad, nullptr},
{"JAVASCRIPT", jsLoad, nullptr},
{"SSTRUCT", bufferSSTRUCTLoad, dataSSTRUCTRelease}, //structure stats and associated files
{"RESCH", bufferRESCHLoad, dataRESCHRelease}, //research stats files
};
Expand Down
Loading