[Scummvm-git-logs] scummvm master -> bd09713d422e450b088f47c364c09e3a1607f3e6
AndywinXp
noreply at scummvm.org
Sat Dec 9 08:35:26 UTC 2023
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
bd09713d42 JANITORIAL: SWORD2: Replace NULL with nullptr and remove whitespaces
Commit: bd09713d422e450b088f47c364c09e3a1607f3e6
https://github.com/scummvm/scummvm/commit/bd09713d422e450b088f47c364c09e3a1607f3e6
Author: AndywinXp (andywinxp at gmail.com)
Date: 2023-12-09T09:35:20+01:00
Commit Message:
JANITORIAL: SWORD2: Replace NULL with nullptr and remove whitespaces
This engine somehow survived the NULL purge :D
Changed paths:
engines/sword2/animation.cpp
engines/sword2/animation.h
engines/sword2/controls.cpp
engines/sword2/detection_tables.h
engines/sword2/function.cpp
engines/sword2/header.h
engines/sword2/icons.cpp
engines/sword2/interpreter.cpp
engines/sword2/layers.cpp
engines/sword2/logic.cpp
engines/sword2/maketext.cpp
engines/sword2/maketext.h
engines/sword2/memory.cpp
engines/sword2/menu.cpp
engines/sword2/mouse.cpp
engines/sword2/music.cpp
engines/sword2/protocol.cpp
engines/sword2/render.cpp
engines/sword2/resman.cpp
engines/sword2/resman.h
engines/sword2/router.cpp
engines/sword2/saveload.cpp
engines/sword2/screen.cpp
engines/sword2/screen.h
engines/sword2/sound.h
engines/sword2/sprite.cpp
engines/sword2/startup.cpp
engines/sword2/sword2.cpp
diff --git a/engines/sword2/animation.cpp b/engines/sword2/animation.cpp
index 90c21964e4c..b6661325896 100644
--- a/engines/sword2/animation.cpp
+++ b/engines/sword2/animation.cpp
@@ -80,7 +80,7 @@ bool MoviePlayer::load(const char *name) {
if (_vm->shouldQuit())
return false;
- _textSurface = NULL;
+ _textSurface = nullptr;
Common::String filename;
switch (_decoderType) {
@@ -135,7 +135,7 @@ void MoviePlayer::play(MovieText *movieTexts, uint32 numMovieTexts, uint32 leadI
bool terminated = !playVideo();
- closeTextObject(_currentMovieText, NULL, 0);
+ closeTextObject(_currentMovieText, nullptr, 0);
if (terminated) {
_vm->_sound->stopMovieSounds();
@@ -195,7 +195,7 @@ void MoviePlayer::closeTextObject(uint32 index, Graphics::Surface *screen, uint1
MovieText *text = &_movieTexts[index];
free(text->_textMem);
- text->_textMem = NULL;
+ text->_textMem = nullptr;
if (_textSurface) {
if (screen) {
@@ -226,7 +226,7 @@ void MoviePlayer::closeTextObject(uint32 index, Graphics::Surface *screen, uint1
}
_vm->_screen->deleteSurface(_textSurface);
- _textSurface = NULL;
+ _textSurface = nullptr;
}
}
}
@@ -297,7 +297,7 @@ void MoviePlayer::performPostProcessing(Graphics::Surface *screen, uint16 pitch)
if (_currentMovieText < _numMovieTexts) {
text = &_movieTexts[_currentMovieText];
} else {
- text = NULL;
+ text = nullptr;
}
if (text && frame == text->_startFrame) {
@@ -425,7 +425,7 @@ MoviePlayer *makeMoviePlayer(const char *name, Sword2Engine *vm, OSystem *system
#else
GUI::MessageDialog dialog(_("PSX cutscenes found but ScummVM has been built without RGB color support"), _("OK"));
dialog.runModal();
- return NULL;
+ return nullptr;
#endif
}
@@ -455,7 +455,7 @@ MoviePlayer *makeMoviePlayer(const char *name, Sword2Engine *vm, OSystem *system
#else
GUI::MessageDialog dialog(_("MPEG-2 cutscenes found but ScummVM has been built without MPEG-2 support"), _("OK"));
dialog.runModal();
- return NULL;
+ return nullptr;
#endif
}
@@ -468,7 +468,7 @@ MoviePlayer *makeMoviePlayer(const char *name, Sword2Engine *vm, OSystem *system
} else
warning("Cutscene '%s' not found", name);
- return NULL;
+ return nullptr;
}
} // End of namespace Sword2
diff --git a/engines/sword2/animation.h b/engines/sword2/animation.h
index af0f096facd..18ff9f52e98 100644
--- a/engines/sword2/animation.h
+++ b/engines/sword2/animation.h
@@ -53,7 +53,7 @@ struct MovieText {
bool _played;
void reset() {
- _textMem = NULL;
+ _textMem = nullptr;
_speechId = 0;
_played = false;
}
diff --git a/engines/sword2/controls.cpp b/engines/sword2/controls.cpp
index 178718082c0..36085deea87 100644
--- a/engines/sword2/controls.cpp
+++ b/engines/sword2/controls.cpp
@@ -85,7 +85,7 @@ public:
void setState(int state);
int getState();
- virtual void paint(Common::Rect *clipRect = NULL);
+ virtual void paint(Common::Rect *clipRect = nullptr);
virtual void onMouseEnter() {}
virtual void onMouseExit() {}
@@ -429,7 +429,7 @@ Widget::~Widget() {
}
void Widget::createSurfaceImage(int state, uint32 res, int x, int y, uint32 pc) {
- byte *file, *colTablePtr = NULL;
+ byte *file, *colTablePtr = nullptr;
AnimHeader anim_head;
FrameHeader frame_head;
CdtEntry cdt_entry;
@@ -689,7 +689,7 @@ private:
public:
Slider(Dialog *parent, Widget *background, int max,
- int x, int y, int w, int h, int step, Widget *base = NULL)
+ int x, int y, int w, int h, int step, Widget *base = nullptr)
: Widget(parent, 1), _background(background),
_dragging(false), _value(0), _targetValue(0),
_maxValue(max), _valueStep(step) {
@@ -704,7 +704,7 @@ public:
createSurfaceImages(3406, x, y);
}
- void paint(Common::Rect *clipRect = NULL) override {
+ void paint(Common::Rect *clipRect = nullptr) override {
// This will redraw a bit more than is strictly necessary,
// but I doubt that will make any noticeable difference.
@@ -1104,7 +1104,7 @@ public:
return &_text[0];
}
- void paint(Common::Rect *clipRect = NULL) override {
+ void paint(Common::Rect *clipRect = nullptr) override {
Widget::paint();
// HACK: The main dialog is responsible for drawing the text
@@ -1252,7 +1252,7 @@ void SaveRestoreDialog::updateSlots() {
slot->setText(fr, baseSlot + i, description);
slot->setClickable(true);
} else {
- slot->setText(fr, baseSlot + i, NULL);
+ slot->setText(fr, baseSlot + i, nullptr);
slot->setClickable(_mode == kSaveDialog);
}
diff --git a/engines/sword2/detection_tables.h b/engines/sword2/detection_tables.h
index 6370e536b8f..0da3c0f362f 100644
--- a/engines/sword2/detection_tables.h
+++ b/engines/sword2/detection_tables.h
@@ -88,8 +88,8 @@ static const ADGameDescription gameDescriptions[] = {
"text.clu", "9b344d976ca8d19a1cf5aa4413397f6b", 304968,
"speech1.clu", "a403904a0e825356107d228f8f74092e", 176260048,
"docks.clu", "b39246fbb5b955a29f9a207c69bfc318", 20262263,
- "bs2k.fnt", NULL, 1222000,
- "korean.clu", NULL, -1),
+ "bs2k.fnt", nullptr, 1222000,
+ "korean.clu", nullptr, -1),
Common::KO_KOR,
Common::kPlatformWindows,
ADGF_NO_FLAGS,
diff --git a/engines/sword2/function.cpp b/engines/sword2/function.cpp
index d324a34d19d..4699c31aae4 100644
--- a/engines/sword2/function.cpp
+++ b/engines/sword2/function.cpp
@@ -114,7 +114,7 @@ int32 Logic::fnRegisterMouse(int32 *params) {
// params: 0 pointer to ObjectMouse or 0 for no write to mouse
// list
- _vm->_mouse->registerMouse(decodePtr(params[0]), NULL);
+ _vm->_mouse->registerMouse(decodePtr(params[0]), nullptr);
return IR_CONT;
}
@@ -2035,7 +2035,7 @@ int32 Logic::fnAddWalkGrid(int32 *params) {
// DON'T EVER KILL GEORGE!
if (readVar(ID) != CUR_PLAYER_ID) {
// Need to call this in case it wasn't called in script!
- fnAddToKillList(NULL);
+ fnAddToKillList(nullptr);
}
_router->addWalkGrid(params[0]);
@@ -2134,7 +2134,7 @@ int32 Logic::fnPlaySequence(int32 *params) {
debug(5, "PLAYING SEQUENCE \"%s\"", filename);
// don't want to carry on streaming game music when cutscene starts!
- fnStopMusic(NULL);
+ fnStopMusic(nullptr);
// pause sfx during sequence
_vm->_sound->pauseFx();
@@ -2150,7 +2150,7 @@ int32 Logic::fnPlaySequence(int32 *params) {
_sequenceTextLines = 0;
delete _moviePlayer;
- _moviePlayer = NULL;
+ _moviePlayer = nullptr;
// unpause sound fx again, in case we're staying in same location
_vm->_sound->unpauseFx();
diff --git a/engines/sword2/header.h b/engines/sword2/header.h
index 3914f30aaf4..3534558aff8 100644
--- a/engines/sword2/header.h
+++ b/engines/sword2/header.h
@@ -299,7 +299,7 @@ private:
public:
ObjectHub() {
- _addr = NULL;
+ _addr = nullptr;
}
static int size() {
diff --git a/engines/sword2/icons.cpp b/engines/sword2/icons.cpp
index bb2c5b0322c..2eb8fa921c1 100644
--- a/engines/sword2/icons.cpp
+++ b/engines/sword2/icons.cpp
@@ -150,7 +150,7 @@ void Mouse::buildMenu() {
for (i = 0; i < 15; i++) {
uint32 res = _masterMenuList[i].icon_resource;
- byte *icon = NULL;
+ byte *icon = nullptr;
if (res) {
bool icon_colored;
diff --git a/engines/sword2/interpreter.cpp b/engines/sword2/interpreter.cpp
index 6cd71bac87b..f5e9a9d2e8e 100644
--- a/engines/sword2/interpreter.cpp
+++ b/engines/sword2/interpreter.cpp
@@ -395,7 +395,7 @@ int Logic::runScript2(byte *scriptData, byte *objectData, byte *offsetPtr) {
if (checkElevatorBug && readVar(RIGHT_BUTTON)) {
warning("Working around elevator bug: Restoring mouse pointer");
- fnAddHuman(NULL);
+ fnAddHuman(nullptr);
}
debug(9, "CP_END_SCRIPT");
diff --git a/engines/sword2/layers.cpp b/engines/sword2/layers.cpp
index d751eaa7c13..a00bb4f1d16 100644
--- a/engines/sword2/layers.cpp
+++ b/engines/sword2/layers.cpp
@@ -181,7 +181,7 @@ void Screen::initBackground(int32 res, int32 new_palette) {
if (screenLayerTable.bg_parallax[i])
initializeBackgroundLayer(_vm->fetchBackgroundParallaxLayer(file, i));
else
- initializeBackgroundLayer(NULL);
+ initializeBackgroundLayer(nullptr);
}
// Normal backround layer
@@ -194,7 +194,7 @@ void Screen::initBackground(int32 res, int32 new_palette) {
if (screenLayerTable.fg_parallax[i])
initializeBackgroundLayer(_vm->fetchForegroundParallaxLayer(file, i));
else
- initializeBackgroundLayer(NULL);
+ initializeBackgroundLayer(nullptr);
}
_vm->_resman->closeResource(_thisScreen.background_layer_id);
@@ -279,14 +279,14 @@ void Screen::initPsxBackground(int32 res, int32 new_palette) {
// Background parallax layers
initializePsxParallaxLayer(_vm->fetchBackgroundParallaxLayer(file, 0));
- initializePsxParallaxLayer(NULL);
+ initializePsxParallaxLayer(nullptr);
// Normal backround layer
initializePsxBackgroundLayer(_vm->fetchBackgroundLayer(file));
// Foreground parallax layers
initializePsxParallaxLayer(_vm->fetchForegroundParallaxLayer(file, 1));
- initializePsxParallaxLayer(NULL);
+ initializePsxParallaxLayer(nullptr);
_vm->_resman->closeResource(_thisScreen.background_layer_id);
diff --git a/engines/sword2/logic.cpp b/engines/sword2/logic.cpp
index 10d5772b60a..530195aab14 100644
--- a/engines/sword2/logic.cpp
+++ b/engines/sword2/logic.cpp
@@ -40,7 +40,7 @@ Logic::Logic(Sword2Engine *vm) :
_speechTime(0), _animId(0), _speechAnimType(0), _leftClickDelay(0),
_rightClickDelay(0), _officialTextNumber(0), _speechTextBlocNo(0) {
- _scriptVars = NULL;
+ _scriptVars = nullptr;
memset(_eventList, 0, sizeof(_eventList));
memset(_syncList, 0, sizeof(_syncList));
_router = new Router(_vm);
diff --git a/engines/sword2/maketext.cpp b/engines/sword2/maketext.cpp
index 44ca3e0c5c3..12a9e15dc66 100644
--- a/engines/sword2/maketext.cpp
+++ b/engines/sword2/maketext.cpp
@@ -214,7 +214,7 @@ uint16 FontRenderer::analyzeSentence(const byte *sentence, uint16 maxWidth, uint
w = charWidth(ch, fontRes) + _charSpacing;
l = 1;
}
-
+
wordWidth += w;
wordLength += l;
pos += l;
@@ -248,7 +248,7 @@ uint16 FontRenderer::analyzeSentence(const byte *sentence, uint16 maxWidth, uint
// The word spills over to the next line, i.e.
// no separating space.
line[lineNo].skipSpace = true;
-
+
lineNo++;
assert(lineNo < MAX_LINES);
@@ -440,7 +440,7 @@ byte *FontRenderer::buildTextSprite(const byte *sentence, uint32 fontRes, uint8
continue;
}
- byte *charPtr = NULL;
+ byte *charPtr = nullptr;
if (isKoreanChar(ch, *currTxtLine, fontRes)) {
charPtr = findWChar(ch, *currTxtLine++, charSet);
j++;
@@ -845,7 +845,7 @@ void FontRenderer::printTextBlocs() {
void FontRenderer::killTextBloc(uint32 bloc_number) {
bloc_number--;
free(_blocList[bloc_number].text_mem);
- _blocList[bloc_number].text_mem = NULL;
+ _blocList[bloc_number].text_mem = nullptr;
}
// Resource 3258 contains text from location script for 152 (install, save &
diff --git a/engines/sword2/maketext.h b/engines/sword2/maketext.h
index c2269c9ea93..f646fc49509 100644
--- a/engines/sword2/maketext.h
+++ b/engines/sword2/maketext.h
@@ -115,7 +115,7 @@ private:
public:
FontRenderer(Sword2Engine *vm) : _vm(vm) {
for (int i = 0; i < MAX_text_blocs; i++)
- _blocList[i].text_mem = NULL;
+ _blocList[i].text_mem = nullptr;
}
~FontRenderer() {
diff --git a/engines/sword2/memory.cpp b/engines/sword2/memory.cpp
index 5026d4cfa06..e0c1cf00332 100644
--- a/engines/sword2/memory.cpp
+++ b/engines/sword2/memory.cpp
@@ -79,8 +79,8 @@ MemoryManager::MemoryManager() {
for (int i = 0; i < MAX_MEMORY_BLOCKS; i++) {
_idStack[i] = MAX_MEMORY_BLOCKS - i - 1;
- _memBlocks[i].ptr = NULL;
- _memBlockIndex[i] = NULL;
+ _memBlocks[i].ptr = nullptr;
+ _memBlockIndex[i] = nullptr;
}
_idStackPtr = MAX_MEMORY_BLOCKS;
@@ -95,7 +95,7 @@ MemoryManager::~MemoryManager() {
}
int32 MemoryManager::encodePtr(byte *ptr) {
- if (ptr == NULL)
+ if (ptr == nullptr)
return 0;
int idx = findPointerInIndex(ptr);
@@ -114,7 +114,7 @@ int32 MemoryManager::encodePtr(byte *ptr) {
byte *MemoryManager::decodePtr(int32 n) {
if (n == 0)
- return NULL;
+ return nullptr;
uint32 id = ((n & 0xffc00000) >> 22) - 1;
uint32 offset = n & 0x003fffff;
@@ -233,7 +233,7 @@ void MemoryManager::memFree(byte *ptr) {
// Release the memory block
free(_memBlockIndex[idx]->ptr);
- _memBlockIndex[idx]->ptr = NULL;
+ _memBlockIndex[idx]->ptr = nullptr;
_totAlloc -= _memBlockIndex[idx]->size;
diff --git a/engines/sword2/menu.cpp b/engines/sword2/menu.cpp
index db515686276..399898c153b 100644
--- a/engines/sword2/menu.cpp
+++ b/engines/sword2/menu.cpp
@@ -310,16 +310,16 @@ int32 Mouse::setMenuIcon(uint8 menu, uint8 pocket, byte *icon) {
if (_icons[menu][pocket]) {
_iconCount--;
free(_icons[menu][pocket]);
- _icons[menu][pocket] = NULL;
+ _icons[menu][pocket] = nullptr;
clearIconArea(menu, pocket, &r);
_vm->_screen->updateRect(&r);
}
// Only put the icon in the pocket if it is not NULL
- if (icon != NULL) {
+ if (icon != nullptr) {
_iconCount++;
_icons[menu][pocket] = (byte *)malloc(menuIconWidth * RDMENU_ICONDEEP);
- if (_icons[menu][pocket] == NULL)
+ if (_icons[menu][pocket] == nullptr)
return RDERR_OUTOFMEMORY;
memcpy(_icons[menu][pocket], icon, menuIconWidth * RDMENU_ICONDEEP);
}
diff --git a/engines/sword2/mouse.cpp b/engines/sword2/mouse.cpp
index 0f17f8098be..3bf61ef1db9 100644
--- a/engines/sword2/mouse.cpp
+++ b/engines/sword2/mouse.cpp
@@ -86,8 +86,8 @@ Mouse::Mouse(Sword2Engine *vm) {
_playerActivityDelay = 0;
_realLuggageItem = 0;
- _mouseAnim.data = NULL;
- _luggageAnim.data = NULL;
+ _mouseAnim.data = nullptr;
+ _luggageAnim.data = nullptr;
// For the menus
_totalTemp = 0;
@@ -107,7 +107,7 @@ Mouse::Mouse(Sword2Engine *vm) {
for (int i = 0; i < 2; i++) {
for (int j = 0; j < RDMENU_MAXPOCKETS; j++) {
- _icons[i][j] = NULL;
+ _icons[i][j] = nullptr;
_pocketStatus[i][j] = 0;
}
@@ -452,7 +452,7 @@ void Mouse::systemMenuMouse() {
pars[1] = FX_LOOP;
_vm->_logic->fnPlayMusic(pars);
} else
- _vm->_logic->fnStopMusic(NULL);
+ _vm->_logic->fnStopMusic(nullptr);
}
void Mouse::dragMouse() {
@@ -829,7 +829,7 @@ void Mouse::normalMouse() {
// off too
noHuman();
- _vm->_logic->fnFadeDown(NULL);
+ _vm->_logic->fnFadeDown(nullptr);
// Tell the walker
@@ -942,7 +942,7 @@ uint32 Mouse::chooseMouse() {
}
for (; i < 15; i++)
- setMenuIcon(RDMENU_BOTTOM, (uint8) i, NULL);
+ setMenuIcon(RDMENU_BOTTOM, (uint8) i, nullptr);
showMenu(RDMENU_BOTTOM);
setMouse(NORMAL_MOUSE_ID);
@@ -1107,7 +1107,7 @@ void Mouse::setMouse(uint32 res) {
_vm->_resman->closeResource(res);
} else {
// blank cursor
- setMouseAnim(NULL, 0, 0);
+ setMouseAnim(nullptr, 0, 0);
}
}
@@ -1121,7 +1121,7 @@ void Mouse::setLuggage(uint32 res) {
setLuggageAnim(icon, len);
_vm->_resman->closeResource(res);
} else
- setLuggageAnim(NULL, 0);
+ setLuggageAnim(nullptr, 0);
}
void Mouse::setObjectHeld(uint32 res) {
@@ -1492,7 +1492,7 @@ void Mouse::pauseEngine(bool pause) {
// we are allowed to clear the luggage this way.
clearPointerText();
- setLuggageAnim(NULL, 0);
+ setLuggageAnim(nullptr, 0);
setMouse(0);
setMouseTouching(1);
} else {
@@ -1650,7 +1650,7 @@ int32 Mouse::animateMouse() {
int32 Mouse::setMouseAnim(byte *ma, int32 size, int32 mouseFlash) {
free(_mouseAnim.data);
- _mouseAnim.data = NULL;
+ _mouseAnim.data = nullptr;
if (ma) {
if (mouseFlash == RDMOUSE_FLASH)
@@ -1696,7 +1696,7 @@ int32 Mouse::setMouseAnim(byte *ma, int32 size, int32 mouseFlash) {
int32 Mouse::setLuggageAnim(byte *ma, int32 size) {
free(_luggageAnim.data);
- _luggageAnim.data = NULL;
+ _luggageAnim.data = nullptr;
if (ma) {
Common::MemoryReadStream readS(ma, size);
diff --git a/engines/sword2/music.cpp b/engines/sword2/music.cpp
index e9897b06741..ce0ca41067c 100644
--- a/engines/sword2/music.cpp
+++ b/engines/sword2/music.cpp
@@ -93,17 +93,17 @@ static Audio::AudioStream *getAudioStream(SoundFileHandle *fh, const char *base,
}
if (soundMode == 0)
- return NULL;
+ return nullptr;
fh->file.open(filename);
fh->fileType = soundMode;
if (!fh->file.isOpen()) {
warning("BS2 getAudioStream: Failed opening file '%s'", filename);
- return NULL;
+ return nullptr;
}
if (fh->fileSize != fh->file.size()) {
free(fh->idxTab);
- fh->idxTab = NULL;
+ fh->idxTab = nullptr;
}
} else
alreadyOpen = true;
@@ -147,7 +147,7 @@ static Audio::AudioStream *getAudioStream(SoundFileHandle *fh, const char *base,
warning("getAudioStream: Could not find %s ID %d! Possibly the wrong file", base, id);
if (!alreadyOpen)
fh->file.close();
- return NULL;
+ return nullptr;
}
fh->file.seek(pos, SEEK_SET);
@@ -177,7 +177,7 @@ static Audio::AudioStream *getAudioStream(SoundFileHandle *fh, const char *base,
}
#endif
default:
- return NULL;
+ return nullptr;
}
}
@@ -301,7 +301,7 @@ MusicInputStream::MusicInputStream(int cd, SoundFileHandle *fh, uint32 musicId,
MusicInputStream::~MusicInputStream() {
delete _decoder;
- _decoder = NULL;
+ _decoder = nullptr;
}
int MusicInputStream::readBuffer(int16 *buffer, const int numSamples) {
@@ -455,7 +455,7 @@ int Sound::readBuffer(int16 *buffer, const int numSamples) {
for (i = 0; i < MAXMUS; i++) {
if (_music[i] && _music[i]->readyToRemove()) {
delete _music[i];
- _music[i] = NULL;
+ _music[i] = nullptr;
}
}
@@ -558,7 +558,7 @@ void Sound::stopMusic(bool immediately) {
if (_music[i]) {
if (immediately) {
delete _music[i];
- _music[i] = NULL;
+ _music[i] = nullptr;
} else
_music[i]->fadeDown();
}
@@ -610,7 +610,7 @@ int32 Sound::streamCompMusic(uint32 musicId, bool loop) {
}
delete _music[primary];
- _music[primary] = NULL;
+ _music[primary] = nullptr;
}
// Pick the available music stream. If no music is playing it doesn't
@@ -757,7 +757,7 @@ int32 Sound::playCompSpeech(uint32 speechId, uint8 vol, int8 pan) {
int cd = _vm->_resman->getCD();
SoundFileHandle *fh = (cd == 1) ? &_speechFile[0] : &_speechFile[1];
- Audio::AudioStream *input = getAudioStream(fh, "speech", cd, speechId, NULL);
+ Audio::AudioStream *input = getAudioStream(fh, "speech", cd, speechId, nullptr);
if (!input)
return RDERR_INVALIDID;
diff --git a/engines/sword2/protocol.cpp b/engines/sword2/protocol.cpp
index 8af22401563..02c3cd43741 100644
--- a/engines/sword2/protocol.cpp
+++ b/engines/sword2/protocol.cpp
@@ -72,7 +72,7 @@ void Sword2Engine::fetchPalette(byte *screenFile, byte *palBuffer) {
byte *Sword2Engine::fetchPaletteMatchTable(byte *screenFile) {
- if (isPsx()) return NULL;
+ if (isPsx()) return nullptr;
MultiScreenHeader mscreenHeader;
@@ -128,7 +128,7 @@ byte *Sword2Engine::fetchLayerHeader(byte *screenFile, uint16 layerNo) {
*/
byte *Sword2Engine::fetchShadingMask(byte *screenFile) {
- if (isPsx()) return NULL;
+ if (isPsx()) return nullptr;
MultiScreenHeader mscreenHeader;
@@ -191,8 +191,8 @@ byte *Sword2Engine::fetchBackgroundParallaxLayer(byte *screenFile, int layer) {
// Manage cache for background psx parallaxes
if (!_screen->getPsxScrCacheStatus(0)) { // This parallax layer is not present
- return NULL;
- } else if (psxParallax != NULL) { // Parallax layer present, and already in cache
+ return nullptr;
+ } else if (psxParallax != nullptr) { // Parallax layer present, and already in cache
return psxParallax;
} else { // Present, but not cached
uint32 locNo = _logic->getLocationNum();
@@ -246,7 +246,7 @@ byte *Sword2Engine::fetchForegroundParallaxLayer(byte *screenFile, int layer) {
// Manage cache for psx parallaxes
if (!_screen->getPsxScrCacheStatus(2)) { // This parallax layer is not present
- return NULL;
+ return nullptr;
} else if (psxParallax) { // Parallax layer present and cached
return psxParallax;
} else { // Present, but still not cached
@@ -305,7 +305,7 @@ byte *Sword2Engine::fetchPsxBackground(uint32 location) {
if (!file.open("screens.clu")) {
GUIErrorMessage("Broken Sword II: Cannot open screens.clu");
- return NULL;
+ return nullptr;
}
file.seek(location * 4, SEEK_SET);
@@ -313,7 +313,7 @@ byte *Sword2Engine::fetchPsxBackground(uint32 location) {
if (screenOffset == 0) { // We don't have screen data for this location number.
file.close();
- return NULL;
+ return nullptr;
}
// Get to the beginning of PSXScreensEntry
@@ -369,18 +369,18 @@ byte *Sword2Engine::fetchPsxParallax(uint32 location, uint8 level) {
uint32 plxSize;
if (level > 1)
- return NULL;
+ return nullptr;
if (!file.open("screens.clu")) {
GUIErrorMessage("Broken Sword II: Cannot open screens.clu");
- return NULL;
+ return nullptr;
}
file.seek(location * 4, SEEK_SET);
screenOffset = file.readUint32LE();
if (screenOffset == 0) // There is no screen here
- return NULL;
+ return nullptr;
// Get to the beginning of PSXScreensEntry
file.seek(screenOffset + ResHeader::size(), SEEK_SET);
@@ -406,7 +406,7 @@ byte *Sword2Engine::fetchPsxParallax(uint32 location, uint8 level) {
}
if (plxXres == 0 || plxYres == 0 || plxSize == 0) // This screen has no parallax data.
- return NULL;
+ return nullptr;
debug(2, "fetchPsxParallax() -> %s parallax, xRes: %u, yRes: %u", (level == 0) ? "Background" : "Foreground", plxXres, plxYres);
diff --git a/engines/sword2/render.cpp b/engines/sword2/render.cpp
index 1c1973d74b0..d999023bf25 100644
--- a/engines/sword2/render.cpp
+++ b/engines/sword2/render.cpp
@@ -571,7 +571,7 @@ int32 Screen::initializeBackgroundLayer(byte *parallax) {
_blockSurfaces[_layer][i]->transparent = block_is_transparent;
} else
- _blockSurfaces[_layer][i] = NULL;
+ _blockSurfaces[_layer][i] = nullptr;
}
free(memchunk);
@@ -676,7 +676,7 @@ int32 Screen::initializePsxBackgroundLayer(byte *parallax) {
_blockSurfaces[_layer][tileIndex]->transparent = block_is_transparent;
} else
- _blockSurfaces[_layer][tileIndex] = NULL;
+ _blockSurfaces[_layer][tileIndex] = nullptr;
if (posY == _yBlocks[_layer] - 1) {
stripeNumber++;
@@ -822,7 +822,7 @@ int32 Screen::initializePsxParallaxLayer(byte *parallax) {
_blockSurfaces[_layer][tileIndex]->transparent = block_is_transparent;
} else
- _blockSurfaces[_layer][tileIndex] = NULL;
+ _blockSurfaces[_layer][tileIndex] = nullptr;
}
_layer++;
@@ -846,7 +846,7 @@ void Screen::closeBackgroundLayer() {
if (_blockSurfaces[i][j])
free(_blockSurfaces[i][j]);
free(_blockSurfaces[i]);
- _blockSurfaces[i] = NULL;
+ _blockSurfaces[i] = nullptr;
}
}
diff --git a/engines/sword2/resman.cpp b/engines/sword2/resman.cpp
index 5caaeac1389..cc803640aad 100644
--- a/engines/sword2/resman.cpp
+++ b/engines/sword2/resman.cpp
@@ -67,10 +67,10 @@ ResourceManager::ResourceManager(Sword2Engine *vm) {
_vm = vm;
_totalClusters = 0;
- _resList = NULL;
- _resConvTable = NULL;
- _cacheStart = NULL;
- _cacheEnd = NULL;
+ _resList = nullptr;
+ _resConvTable = nullptr;
+ _cacheStart = nullptr;
+ _cacheEnd = nullptr;
_usedMem = 0;
}
@@ -122,7 +122,7 @@ bool ResourceManager::init() {
buf[pos - 1] = 0;
_resFiles[_totalClusters].numEntries = -1;
- _resFiles[_totalClusters].entryTab = NULL;
+ _resFiles[_totalClusters].entryTab = nullptr;
if (++_totalClusters >= MAX_res_files) {
GUIErrorMessage("Broken Sword II: Too many entries in resource.inf");
return false;
@@ -246,10 +246,10 @@ bool ResourceManager::init() {
_resList = (Resource *)malloc(_totalResFiles * sizeof(Resource));
for (i = 0; i < _totalResFiles; i++) {
- _resList[i].ptr = NULL;
+ _resList[i].ptr = nullptr;
_resList[i].size = 0;
_resList[i].refCount = 0;
- _resList[i].prev = _resList[i].next = NULL;
+ _resList[i].prev = _resList[i].next = nullptr;
}
return true;
@@ -297,7 +297,7 @@ byte *ResourceManager::openResource(uint32 res, bool dump) {
Common::File *file = openCluFile(cluFileNum);
- if (_resFiles[cluFileNum].entryTab == NULL) {
+ if (_resFiles[cluFileNum].entryTab == nullptr) {
// we didn't read from this file before, get its index table
readCluIndex(cluFileNum, file);
}
@@ -314,7 +314,7 @@ byte *ResourceManager::openResource(uint32 res, bool dump) {
if (res == ENGLISH_SPEECH_FONT_ID && _vm->_isKorTrs) {
// Load Korean Font
uint32 korFontSize = 0;
- Common::File *korFontFile = NULL;
+ Common::File *korFontFile = nullptr;
korFontFile = new Common::File();
korFontFile->open("bs2k.fnt");
@@ -424,7 +424,7 @@ void ResourceManager::closeResource(uint32 res) {
// Don't try to close the resource if it has already been forcibly
// closed, e.g. by fnResetGlobals().
- if (_resList[res].ptr == NULL)
+ if (_resList[res].ptr == nullptr)
return;
assert(_resList[res].refCount > 0);
@@ -455,11 +455,11 @@ void ResourceManager::removeFromCacheList(Resource *res) {
res->prev->next = res->next;
if (res->next)
res->next->prev = res->prev;
- res->prev = res->next = NULL;
+ res->prev = res->next = nullptr;
}
void ResourceManager::addToCacheList(Resource *res) {
- res->prev = NULL;
+ res->prev = nullptr;
res->next = _cacheStart;
if (_cacheStart)
_cacheStart->prev = res;
@@ -492,7 +492,7 @@ Common::File *ResourceManager::openCluFile(uint16 fileNum) {
void ResourceManager::readCluIndex(uint16 fileNum, Common::File *file) {
// we didn't read from this file before, get its index table
- assert(_resFiles[fileNum].entryTab == NULL);
+ assert(_resFiles[fileNum].entryTab == nullptr);
assert(file);
// 1st DWORD of a cluster is an offset to the look-up table
@@ -577,7 +577,7 @@ uint32 ResourceManager::fetchLen(uint32 res) {
// first we have to find the file via the _resConvTable
// open the cluster file
- if (_resFiles[parent_res_file].entryTab == NULL) {
+ if (_resFiles[parent_res_file].entryTab == nullptr) {
Common::File *file = openCluFile(parent_res_file);
readCluIndex(parent_res_file, file);
delete file;
@@ -592,11 +592,11 @@ void ResourceManager::checkMemUsage() {
// we start freeing from the end, to free the oldest items first
if (_cacheEnd) {
Resource *tmp = _cacheEnd;
- assert((tmp->refCount == 0) && (tmp->ptr) && (tmp->next == NULL));
+ assert((tmp->refCount == 0) && (tmp->ptr) && (tmp->next == nullptr));
removeFromCacheList(tmp);
_vm->_memory->memFree(tmp->ptr);
- tmp->ptr = NULL;
+ tmp->ptr = nullptr;
_usedMem -= tmp->size;
} else {
warning("%d bytes of memory used, but cache list is empty", _usedMem);
@@ -610,7 +610,7 @@ void ResourceManager::remove(int res) {
removeFromCacheList(_resList + res);
_vm->_memory->memFree(_resList[res].ptr);
- _resList[res].ptr = NULL;
+ _resList[res].ptr = nullptr;
_resList[res].refCount = 0;
_usedMem -= _resList[res].size;
}
diff --git a/engines/sword2/resman.h b/engines/sword2/resman.h
index 18e73ae9bfc..b12fb2b74fa 100644
--- a/engines/sword2/resman.h
+++ b/engines/sword2/resman.h
@@ -97,7 +97,7 @@ public:
return type;
}
- byte *fetchName(uint32 res, byte *buf = NULL) {
+ byte *fetchName(uint32 res, byte *buf = nullptr) {
static byte tempbuf[NAME_LEN];
if (!buf)
diff --git a/engines/sword2/router.cpp b/engines/sword2/router.cpp
index b16a98e77b5..c58d5bb748f 100644
--- a/engines/sword2/router.cpp
+++ b/engines/sword2/router.cpp
@@ -159,13 +159,13 @@ void Router::freeRouteMem() {
uint8 slotNo = returnSlotNo(_vm->_logic->readVar(ID));
free(_routeSlots[slotNo]);
- _routeSlots[slotNo] = NULL;
+ _routeSlots[slotNo] = nullptr;
}
void Router::freeAllRouteMem() {
for (int i = 0; i < TOTAL_ROUTE_SLOTS; i++) {
free(_routeSlots[i]);
- _routeSlots[i] = NULL;
+ _routeSlots[i] = nullptr;
}
}
diff --git a/engines/sword2/saveload.cpp b/engines/sword2/saveload.cpp
index 1f2839b0466..c56a69415a3 100644
--- a/engines/sword2/saveload.cpp
+++ b/engines/sword2/saveload.cpp
@@ -359,7 +359,7 @@ uint32 Sword2Engine::restoreFromBuffer(byte *buffer, uint32 size) {
pars[1] = FX_LOOP;
_logic->fnPlayMusic(pars);
} else
- _logic->fnStopMusic(NULL);
+ _logic->fnStopMusic(nullptr);
return SR_OK;
}
diff --git a/engines/sword2/screen.cpp b/engines/sword2/screen.cpp
index 2ac4cfa6f60..22d36f1675f 100644
--- a/engines/sword2/screen.cpp
+++ b/engines/sword2/screen.cpp
@@ -47,7 +47,7 @@ namespace Sword2 {
Screen::Screen(Sword2Engine *vm, int16 width, int16 height) {
_vm = vm;
- _dirtyGrid = _buffer = NULL;
+ _dirtyGrid = _buffer = nullptr;
_screenWide = width;
_screenDeep = height;
@@ -67,9 +67,9 @@ Screen::Screen(Sword2Engine *vm, int16 width, int16 height) {
error("Could not initialize display");
for (int i = 0; i < ARRAYSIZE(_blockSurfaces); i++)
- _blockSurfaces[i] = NULL;
+ _blockSurfaces[i] = nullptr;
- _lightMask = NULL;
+ _lightMask = nullptr;
_needFullRedraw = false;
memset(&_thisScreen, 0, sizeof(_thisScreen));
@@ -99,9 +99,9 @@ Screen::Screen(Sword2Engine *vm, int16 width, int16 height) {
_pauseStartTick = 0;
// Clean the cache for PSX version SCREENS.CLU
- _psxScrCache[0] = NULL;
- _psxScrCache[1] = NULL;
- _psxScrCache[2] = NULL;
+ _psxScrCache[0] = nullptr;
+ _psxScrCache[1] = nullptr;
+ _psxScrCache[2] = nullptr;
_psxCacheEnabled[0] = true;
_psxCacheEnabled[1] = true;
_psxCacheEnabled[2] = true;
@@ -560,7 +560,7 @@ void Screen::processImage(BuildUnit *build_unit) {
return;
byte *file = _vm->_resman->openResource(build_unit->anim_resource);
- byte *colTablePtr = NULL;
+ byte *colTablePtr = nullptr;
byte *frame = _vm->fetchFrameHeader(file, build_unit->anim_pc);
@@ -856,7 +856,7 @@ struct CreditsLine {
byte *sprite;
CreditsLine() {
- sprite = NULL;
+ sprite = nullptr;
}
~CreditsLine() {
@@ -923,7 +923,7 @@ void Screen::rollCredits() {
uint16 logoWidth = 0;
uint16 logoHeight = 0;
- byte *logoData = NULL;
+ byte *logoData = nullptr;
byte palette[256 * 3];
if (f.open("credits.bmp")) {
@@ -1116,7 +1116,7 @@ void Screen::rollCredits() {
debug(2, "Freeing line %d: '%s'", i, creditsLines[i]->str.c_str());
delete creditsLines[i];
- creditsLines[i] = NULL;
+ creditsLines[i] = nullptr;
startLine = i + 1;
} else if (creditsLines[i]->top < scrollPos + 400) {
@@ -1228,11 +1228,11 @@ void Screen::rollCredits() {
void Screen::splashScreen() {
byte *bgfile = _vm->_resman->openResource(2950);
- initializeBackgroundLayer(NULL);
- initializeBackgroundLayer(NULL);
+ initializeBackgroundLayer(nullptr);
+ initializeBackgroundLayer(nullptr);
initializeBackgroundLayer(_vm->fetchBackgroundLayer(bgfile));
- initializeBackgroundLayer(NULL);
- initializeBackgroundLayer(NULL);
+ initializeBackgroundLayer(nullptr);
+ initializeBackgroundLayer(nullptr);
_vm->fetchPalette(bgfile, _palette);
setPalette(0, 256, _palette, RDPAL_FADE);
@@ -1306,7 +1306,7 @@ byte *Screen::getPsxScrCache(uint8 level) {
if (_psxCacheEnabled[level])
return _psxScrCache[level];
else
- return NULL;
+ return nullptr;
}
bool Screen::getPsxScrCacheStatus(uint8 level) {
@@ -1320,7 +1320,7 @@ bool Screen::getPsxScrCacheStatus(uint8 level) {
void Screen::flushPsxScrCache() {
for (uint8 i = 0; i < 3; i++) {
free(_psxScrCache[i]);
- _psxScrCache[i] = NULL;
+ _psxScrCache[i] = nullptr;
_psxCacheEnabled[i] = true;
}
}
diff --git a/engines/sword2/screen.h b/engines/sword2/screen.h
index e3c8923a576..089d8997a2f 100644
--- a/engines/sword2/screen.h
+++ b/engines/sword2/screen.h
@@ -420,7 +420,7 @@ public:
void displayMsg(byte *text, int time);
int32 createSurface(SpriteInfo *s, byte **surface);
- void drawSurface(SpriteInfo *s, byte *surface, Common::Rect *clipRect = NULL);
+ void drawSurface(SpriteInfo *s, byte *surface, Common::Rect *clipRect = nullptr);
void deleteSurface(byte *surface);
int32 drawSprite(SpriteInfo *s);
@@ -445,7 +445,7 @@ public:
void splashScreen();
// Some sprites are compressed in HIF format
- static uint32 decompressHIF(byte *src, byte *dst, uint32 *skipData = NULL);
+ static uint32 decompressHIF(byte *src, byte *dst, uint32 *skipData = nullptr);
// This is used to resize psx sprites back to original resolution
static void resizePsxSprite(byte *dst, byte *src, uint16 destW, uint16 destH);
// Some sprites are divided into 254 pixel wide stripes, this recomposes them
diff --git a/engines/sword2/sound.h b/engines/sword2/sound.h
index 003cfba2cbe..0b35dc227ad 100644
--- a/engines/sword2/sound.h
+++ b/engines/sword2/sound.h
@@ -165,7 +165,7 @@ public:
void fadeUp();
void fadeDown();
- bool isReady() { return _decoder != NULL; }
+ bool isReady() { return _decoder != nullptr; }
int32 isFading() { return _fading; }
bool readyToRemove();
diff --git a/engines/sword2/sprite.cpp b/engines/sword2/sprite.cpp
index d5cdb322659..d830e5f9a86 100644
--- a/engines/sword2/sprite.cpp
+++ b/engines/sword2/sprite.cpp
@@ -270,7 +270,7 @@ uint32 Screen::decompressHIF(byte *src, byte *dst, uint32 *skipData) {
src += 2;
readByte += 2;
if (info_word == 0xFFFF) { // Got 0xFFFF code, finished.
- if (skipData != NULL) *(skipData) = readByte;
+ if (skipData != nullptr) *(skipData) = readByte;
return decompSize;
}
@@ -614,7 +614,7 @@ int32 Screen::drawSprite(SpriteInfo *s) {
if (s->type & RDSPR_FLIP) {
newSprite = (byte *)malloc(s->w * s->h);
- if (newSprite == NULL) {
+ if (newSprite == nullptr) {
if (freeSprite)
free(sprite);
return RDERR_OUTOFMEMORY;
@@ -707,7 +707,7 @@ int32 Screen::drawSprite(SpriteInfo *s) {
}
newSprite = (byte *)malloc(s->scaledWidth * s->scaledHeight);
- if (newSprite == NULL) {
+ if (newSprite == nullptr) {
if (freeSprite)
free(sprite);
return RDERR_OUTOFMEMORY;
@@ -860,7 +860,7 @@ int32 Screen::openLightMask(SpriteInfo *s) {
if (!_lightMask)
return RDERR_OUTOFMEMORY;
- if (s->data == NULL) // Check, as there's no mask in psx version
+ if (s->data == nullptr) // Check, as there's no mask in psx version
return RDERR_NOTOPEN;
if (decompressRLE256(_lightMask, s->data, s->w * s->h))
@@ -878,7 +878,7 @@ int32 Screen::closeLightMask() {
return RDERR_NOTOPEN;
free(_lightMask);
- _lightMask = NULL;
+ _lightMask = nullptr;
return RD_OK;
}
diff --git a/engines/sword2/startup.cpp b/engines/sword2/startup.cpp
index a6b6e84a478..0f0b27f2521 100644
--- a/engines/sword2/startup.cpp
+++ b/engines/sword2/startup.cpp
@@ -146,7 +146,7 @@ void Sword2Engine::runStart(int start) {
// Restarting - stop sfx, music & speech!
_sound->clearFxQueue(true);
- _logic->fnStopMusic(NULL);
+ _logic->fnStopMusic(nullptr);
_sound->unpauseSpeech();
_sound->stopSpeech();
@@ -171,7 +171,7 @@ void Sword2Engine::runStart(int start) {
// Make sure there's a mouse, in case restarting while mouse not
// available
- _logic->fnAddHuman(NULL);
+ _logic->fnAddHuman(nullptr);
}
} // End of namespace Sword2
diff --git a/engines/sword2/sword2.cpp b/engines/sword2/sword2.cpp
index a020723a795..e36736bd610 100644
--- a/engines/sword2/sword2.cpp
+++ b/engines/sword2/sword2.cpp
@@ -65,15 +65,15 @@ Sword2Engine::Sword2Engine(OSystem *syst, const ADGameDescription *gameDesc) : E
_bootParam = ConfMan.getInt("boot_param");
_saveSlot = ConfMan.getInt("save_slot");
- _memory = NULL;
- _resman = NULL;
- _sound = NULL;
- _screen = NULL;
- _mouse = NULL;
- _logic = NULL;
- _fontRenderer = NULL;
+ _memory = nullptr;
+ _resman = nullptr;
+ _sound = nullptr;
+ _screen = nullptr;
+ _mouse = nullptr;
+ _logic = nullptr;
+ _fontRenderer = nullptr;
_isRTL = Common::parseLanguage(ConfMan.get("language")) == Common::HE_ISR;
- _debugger = NULL;
+ _debugger = nullptr;
_keyboardEvent.pending = false;
_mouseEvent.pending = false;
@@ -176,14 +176,14 @@ Common::Error Sword2Engine::run() {
// Get some falling RAM and put it in your pocket, never let it slip
// away
- _debugger = NULL;
- _sound = NULL;
- _fontRenderer = NULL;
- _screen = NULL;
- _mouse = NULL;
- _logic = NULL;
- _resman = NULL;
- _memory = NULL;
+ _debugger = nullptr;
+ _sound = nullptr;
+ _fontRenderer = nullptr;
+ _screen = nullptr;
+ _mouse = nullptr;
+ _logic = nullptr;
+ _resman = nullptr;
+ _memory = nullptr;
initGraphics(640, 480);
_screen = new Screen(this, 640, 480);
@@ -301,7 +301,7 @@ Common::Error Sword2Engine::run() {
case Common::KEYCODE_c:
if (!_logic->readVar(DEMO) && !_mouse->isChoosing()) {
ScreenInfo *screenInfo = _screen->getScreenInfo();
- _logic->fnPlayCredits(NULL);
+ _logic->fnPlayCredits(nullptr);
screenInfo->new_palette = 99;
}
break;
@@ -397,7 +397,7 @@ bool Sword2Engine::checkForMouseEvents() {
MouseEvent *Sword2Engine::mouseEvent() {
if (!_mouseEvent.pending)
- return NULL;
+ return nullptr;
_mouseEvent.pending = false;
return &_mouseEvent;
@@ -405,7 +405,7 @@ MouseEvent *Sword2Engine::mouseEvent() {
KeyboardEvent *Sword2Engine::keyboardEvent() {
if (!_keyboardEvent.pending)
- return NULL;
+ return nullptr;
_keyboardEvent.pending = false;
return &_keyboardEvent;
More information about the Scummvm-git-logs
mailing list