MADE: Use nullptr

Using clang-tidy modernize-use-nullptr
This commit is contained in:
Orgad Shaneh 2021-11-13 23:40:32 +02:00 committed by Filippos Karapetis
parent 619a6bafe3
commit 6333092801
8 changed files with 32 additions and 32 deletions

View File

@ -39,7 +39,7 @@ namespace Made {
< 0x7FFE object
*/
Object::Object() : _objData(NULL), _freeData(false) {
Object::Object() : _objData(nullptr), _freeData(false) {
_objSize = 0;
}
@ -52,7 +52,7 @@ const char *Object::getString() {
if (getClass() == 0x7FFF)
return (const char*)getData();
else
return NULL;
return nullptr;
}
void Object::setString(const char *str) {
@ -327,7 +327,7 @@ void GameDatabase::setObjectString(int16 index, const char *str) {
int16 *GameDatabase::findObjectPropertyCached(int16 objectIndex, int16 propertyId, int16 &propertyFlag) {
uint32 id = (objectIndex << 16) | propertyId;
ObjectPropertyCacheMap::iterator iter = _objectPropertyCache.find(id);
int16 *propertyPtr = NULL;
int16 *propertyPtr = nullptr;
if (iter != _objectPropertyCache.end()) {
propertyPtr = (*iter)._value;
} else {
@ -386,7 +386,7 @@ void GameDatabase::dumpObject(int16 index) {
/* GameDatabaseV2 */
GameDatabaseV2::GameDatabaseV2(MadeEngine *vm) : GameDatabase(vm), _gameText(NULL) {
GameDatabaseV2::GameDatabaseV2(MadeEngine *vm) : GameDatabase(vm), _gameText(nullptr) {
}
GameDatabaseV2::~GameDatabaseV2() {
@ -550,7 +550,7 @@ int16 *GameDatabaseV2::findObjectProperty(int16 objectIndex, int16 propertyId, i
// Now check in the object hierarchy of the given object
int16 parentObjectIndex = obj->getClass();
if (parentObjectIndex == 0) {
return NULL;
return nullptr;
}
while (parentObjectIndex != 0) {
@ -587,7 +587,7 @@ int16 *GameDatabaseV2::findObjectProperty(int16 objectIndex, int16 propertyId, i
}
debug(1, "findObjectProperty(%04X, %04X) Property not found", objectIndex, propertyId);
return NULL;
return nullptr;
}
@ -783,7 +783,7 @@ int16 *GameDatabaseV3::findObjectProperty(int16 objectIndex, int16 propertyId, i
// Now check in the object hierarchy of the given object
int16 parentObjectIndex = obj->getClass();
if (parentObjectIndex == 0) {
return NULL;
return nullptr;
}
while (parentObjectIndex != 0) {
@ -829,13 +829,13 @@ int16 *GameDatabaseV3::findObjectProperty(int16 objectIndex, int16 propertyId, i
}
return NULL;
return nullptr;
}
const char *GameDatabaseV3::getString(uint16 offset) {
// Not used in version 3 games
return NULL;
return nullptr;
}
} // End of namespace Made

View File

@ -32,7 +32,7 @@ static const PlainGameDescriptor madeGames[] = {
{"rtz", "Return to Zork"},
{"lgop2", "Leather Goddesses of Phobos 2"},
{"rodney", "Rodney's Funscreen"},
{0, 0}
{nullptr, nullptr}
};
#include "made/detection_tables.h"

View File

@ -47,7 +47,7 @@ MadeEngine::MadeEngine(OSystem *syst, const MadeGameDescription *gameDesc) : Eng
_eventKey = 0;
_autoStopSound = false;
_soundEnergyIndex = 0;
_soundEnergyArray = 0;
_soundEnergyArray = nullptr;
_musicBeatStart = 0;
_cdTimeStart = 0;
_introMusicDigital = true;

View File

@ -38,7 +38,7 @@ namespace Made {
const uint8 MusicPlayer::MT32_GOODBYE_MSG[] = { 0x52, 0x65, 0x74, 0x75, 0x72, 0x6E, 0x20, 0x54, 0x6F, 0x20, 0x5A, 0x6F, 0x72, 0x6B, 0x20, 0x53, 0x6F, 0x6F, 0x6E, 0x21 };
MusicPlayer::MusicPlayer(MadeEngine *vm, bool milesAudio) : _vm(vm), _parser(0) {
MusicPlayer::MusicPlayer(MadeEngine *vm, bool milesAudio) : _vm(vm), _parser(nullptr) {
MidiDriver::DeviceHandle dev = MidiDriver::detectDevice(MDT_MIDI | MDT_ADLIB | MDT_PREFER_MT32);
_driverType = MidiDriver::getMusicType(dev);
if (_driverType == MT_GM && ConfMan.getBool("native_mt32"))
@ -90,7 +90,7 @@ MusicPlayer::~MusicPlayer() {
delete _parser;
}
if (_driver) {
_driver->setTimerCallback(0, 0);
_driver->setTimerCallback(nullptr, nullptr);
_driver->close();
delete _driver;
}
@ -112,7 +112,7 @@ void MusicPlayer::playXMIDI(GenericResource *midiResource) {
if (_parser) {
_parser->unloadMusic();
} else {
_parser = MidiParser::createParser_XMIDI(0, 0, 0);
_parser = MidiParser::createParser_XMIDI(nullptr, nullptr, 0);
_parser->setMidiDriver(_driver);
_parser->setTimerRate(_driver->getBaseTempo());

View File

@ -105,7 +105,7 @@ bool PmvPlayer::play(const char *filename) {
uint32 soundSize = 0;
uint32 soundChunkOfs = 0, palChunkOfs = 0;
uint32 palSize = 0;
byte *frameData = 0, *audioData, *soundData, *palData, *imageData;
byte *frameData = nullptr, *audioData, *soundData, *palData, *imageData;
bool firstTime = true;
uint32 skipFrames = 0;
@ -155,7 +155,7 @@ bool PmvPlayer::play(const char *filename) {
soundSize = chunkCount * chunkSize;
soundData = (byte *)malloc(soundSize);
decompressSound(audioData + 8, soundData, chunkSize, chunkCount, NULL, soundDecoderData);
decompressSound(audioData + 8, soundData, chunkSize, chunkCount, nullptr, soundDecoderData);
_audioStream->queueBuffer(soundData, soundSize, DisposeAfterUse::YES, Audio::FLAG_UNSIGNED);
}

View File

@ -41,7 +41,7 @@ Resource::~Resource() {
/* PictureResource */
PictureResource::PictureResource() : _picture(NULL), _picturePalette(NULL) {
PictureResource::PictureResource() : _picture(nullptr), _picturePalette(nullptr) {
_hasPalette = false;
_paletteColorCount = 0;
}
@ -50,11 +50,11 @@ PictureResource::~PictureResource() {
if (_picture) {
_picture->free();
delete _picture;
_picture = 0;
_picture = nullptr;
}
delete[] _picturePalette;
_picturePalette = 0;
_picturePalette = nullptr;
}
void PictureResource::load(byte *source, int size) {
@ -244,7 +244,7 @@ void AnimationResource::load(byte *source, int size) {
/* SoundResource */
SoundResource::SoundResource() : _soundSize(0), _soundData(NULL) {
SoundResource::SoundResource() : _soundSize(0), _soundData(nullptr) {
_soundEnergyArray = nullptr;
}
@ -308,12 +308,12 @@ const char *MenuResource::getString(uint index) const {
if (index < _strings.size())
return _strings[index].c_str();
else
return NULL;
return nullptr;
}
/* FontResource */
FontResource::FontResource() : _data(NULL), _size(0) {
FontResource::FontResource() : _data(nullptr), _size(0) {
}
FontResource::~FontResource() {
@ -343,7 +343,7 @@ byte *FontResource::getChar(uint c) const {
if (charData)
return charData + 1;
else
return NULL;
return nullptr;
}
int FontResource::getTextWidth(const char *text) {
@ -358,13 +358,13 @@ int FontResource::getTextWidth(const char *text) {
byte *FontResource::getCharData(uint c) const {
if (c < 28 || c > 255)
return NULL;
return nullptr;
return _data + 1 + (c - 28) * (getHeight() + 1);
}
/* GenericResource */
GenericResource::GenericResource() : _data(NULL), _size(0) {
GenericResource::GenericResource() : _data(nullptr), _size(0) {
}
GenericResource::~GenericResource() {
@ -542,12 +542,12 @@ ResourceSlot *ResourceReader::getResourceSlot(uint32 resType, uint index) {
ResourceSlots *slots = _resSlots[resType];
if (!slots)
return NULL;
return nullptr;
if (index >= 1 && index < slots->size()) {
return &(*slots)[index];
} else {
return NULL;
return nullptr;
}
}
@ -583,7 +583,7 @@ void ResourceReader::purgeCache() {
if (slot->refCount <= 0 && slot->res) {
_cacheDataSize -= slot->size;
delete slot->res;
slot->res = NULL;
slot->res = nullptr;
slot->refCount = 0;
_cacheCount--;
}

View File

@ -87,7 +87,7 @@ Screen::Screen(MadeEngine *vm) : _vm(vm) {
_textRect.top = 0;
_textRect.right = 320;
_textRect.bottom = 200;
_font = NULL;
_font = nullptr;
_currentFontNum = 0;
_fontDrawCtx.clipRect = Common::Rect(320, 200);
_fontDrawCtx.destSurface = _backgroundScreen;
@ -155,7 +155,7 @@ void Screen::setExcludeArea(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
void Screen::drawSurface(Graphics::Surface *sourceSurface, int x, int y, int16 flipX, int16 flipY, int16 mask, const ClipInfo &clipInfo) {
byte *source, *dest, *maskp = 0;
byte *source, *dest, *maskp = nullptr;
int startX = 0;
int startY = 0;
int clipWidth = sourceSurface->w;

View File

@ -300,7 +300,7 @@ int16 ScriptFunctions::sfStopMusic(int16 argc, int16 *argv) {
if (_vm->_music->isPlaying() && _musicRes) {
_vm->_music->stop();
_vm->_res->freeResource(_musicRes);
_musicRes = NULL;
_musicRes = nullptr;
}
return 0;
}
@ -498,7 +498,7 @@ int16 ScriptFunctions::sfSetFont(int16 argc, int16 *argv) {
int16 ScriptFunctions::sfDrawText(int16 argc, int16 *argv) {
const char *text = NULL;
const char *text = nullptr;
if (_vm->getGameID() == GID_RTZ) {
text = _vm->_dat->getObjectString(argv[argc - 1]);