[Scummvm-git-logs] scummvm master -> b6da843f16e227907930732ba2bcc60d2741e3f0
bluegr
noreply at scummvm.org
Wed Apr 16 06:40:47 UTC 2025
This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
1bc14ddcfe ALG: Remove superfluous namespace prefix
a56a80b18e ALG: Remove superfluous null pointer reference checks
c26b7acf33 ALG: Const correctness
b6da843f16 ALG: Cleanup
Commit: 1bc14ddcfe08ce7a3cb2d74d77defa9785088a33
https://github.com/scummvm/scummvm/commit/1bc14ddcfe08ce7a3cb2d74d77defa9785088a33
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-04-16T09:40:15+03:00
Commit Message:
ALG: Remove superfluous namespace prefix
Changed paths:
engines/alg/alg.cpp
diff --git a/engines/alg/alg.cpp b/engines/alg/alg.cpp
index 8f62e207394..d1dc7ec046c 100644
--- a/engines/alg/alg.cpp
+++ b/engines/alg/alg.cpp
@@ -38,43 +38,43 @@ namespace Alg {
AlgEngine::AlgEngine(OSystem *syst, const AlgGameDescription *gd)
: Engine(syst), _gameDescription(gd) {
switch (gd->gameType) {
- case Alg::GType_CRIME_PATROL: {
+ case GType_CRIME_PATROL: {
GameCrimePatrol *game = new GameCrimePatrol(this, gd);
_debugger = new DebuggerCrimePatrol(game);
_game = game;
break;
}
- case Alg::GType_DRUG_WARS: {
+ case GType_DRUG_WARS: {
GameDrugWars *game = new GameDrugWars(this, gd);
_debugger = new DebuggerDrugWars(game);
_game = game;
break;
}
- case Alg::GType_WSJR: {
+ case GType_WSJR: {
GameJohnnyRock *game = new GameJohnnyRock(this, gd);
_debugger = new DebuggerJohnnyRock(game);
_game = game;
break;
}
- case Alg::GType_LAST_BOUNTY_HUNTER: {
+ case GType_LAST_BOUNTY_HUNTER: {
GameBountyHunter *game = new GameBountyHunter(this, gd);
_debugger = new DebuggerBountyHunter(game);
_game = game;
break;
}
- case Alg::GType_MADDOG: {
+ case GType_MADDOG: {
GameMaddog *game = new GameMaddog(this, gd);
_debugger = new DebuggerMaddog(game);
_game = game;
break;
}
- case Alg::GType_MADDOG2: {
+ case GType_MADDOG2: {
GameMaddog2 *game = new GameMaddog2(this, gd);
_debugger = new DebuggerMaddog2(game);
_game = game;
break;
}
- case Alg::GType_SPACE_PIRATES: {
+ case GType_SPACE_PIRATES: {
GameSpacePirates *game = new GameSpacePirates(this, gd);
_debugger = new DebuggerSpacePirates(game);
_game = game;
Commit: a56a80b18ed94177bc4442375cefd2674154226b
https://github.com/scummvm/scummvm/commit/a56a80b18ed94177bc4442375cefd2674154226b
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-04-16T09:40:16+03:00
Commit Message:
ALG: Remove superfluous null pointer reference checks
Changed paths:
engines/alg/video.cpp
diff --git a/engines/alg/video.cpp b/engines/alg/video.cpp
index 7322054dec6..d1a2b8cbd16 100644
--- a/engines/alg/video.cpp
+++ b/engines/alg/video.cpp
@@ -20,10 +20,9 @@
*/
#include "common/textconsole.h"
-
-#include "alg/video.h"
-
+#include "graphics/surface.h"
#include "audio/decoders/raw.h"
+#include "alg/video.h"
namespace Alg {
@@ -37,9 +36,8 @@ AlgVideoDecoder::~AlgVideoDecoder() {
_frame->free();
delete _frame;
}
- if (_audioStream) {
- delete _audioStream;
- }
+
+ delete _audioStream;
}
void AlgVideoDecoder::loadVideoFromStream(uint32 offset) {
@@ -78,9 +76,7 @@ void AlgVideoDecoder::loadVideoFromStream(uint32 offset) {
_frame->free();
delete _frame;
}
- if (_audioStream) {
- delete _audioStream;
- }
+ delete _audioStream;
_frame = new Graphics::Surface();
_frame->create(_width, _height, Graphics::PixelFormat::createFormatCLUT8());
_audioStream = makePacketizedRawStream(8000, Audio::FLAG_UNSIGNED);
Commit: c26b7acf3349015561f5e49fd55795922ed22e52
https://github.com/scummvm/scummvm/commit/c26b7acf3349015561f5e49fd55795922ed22e52
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-04-16T09:40:17+03:00
Commit Message:
ALG: Const correctness
Changed paths:
engines/alg/video.h
diff --git a/engines/alg/video.h b/engines/alg/video.h
index 5682c66b2bd..67b5b9696d7 100644
--- a/engines/alg/video.h
+++ b/engines/alg/video.h
@@ -26,9 +26,6 @@
#include "audio/mixer.h"
#include "common/file.h"
-#include "common/stream.h"
-
-#include "graphics/surface.h"
namespace Alg {
@@ -40,14 +37,14 @@ public:
void loadVideoFromStream(uint32 offset);
void skipNumberOfFrames(uint32 num);
void setInputFile(Common::File *input) { _input = input; }
- bool isFinished() { return _bytesLeft == 0; }
- Graphics::Surface *getVideoFrame() { return _frame; }
+ bool isFinished() const { return _bytesLeft == 0; }
+ Graphics::Surface *getVideoFrame() const { return _frame; }
void setPalette(uint8 *palette) { _palette = palette; }
- bool isPaletteDirty() { return _paletteDirty; }
- void pauseAudio(bool pause) { g_system->getMixer()->pauseHandle(_audioHandle, pause); }
- uint16 getWidth() { return _width; }
- uint16 getHeight() { return _height; }
- uint32 getCurrentFrame() { return _currentFrame; }
+ bool isPaletteDirty() const { return _paletteDirty; }
+ void pauseAudio(bool pause) const { g_system->getMixer()->pauseHandle(_audioHandle, pause); }
+ uint16 getWidth() const { return _width; }
+ uint16 getHeight() const { return _height; }
+ uint32 getCurrentFrame() const { return _currentFrame; }
private:
Common::File *_input;
Commit: b6da843f16e227907930732ba2bcc60d2741e3f0
https://github.com/scummvm/scummvm/commit/b6da843f16e227907930732ba2bcc60d2741e3f0
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-04-16T09:40:18+03:00
Commit Message:
ALG: Cleanup
- Use C++11 style for loops
- Use const references for Common::String parameters
- Add missing initializers
- Use boolean keywords for boolean parameters
- Remove superfluous initializers to base classes
Changed paths:
engines/alg/game.cpp
engines/alg/game.h
engines/alg/graphics.cpp
engines/alg/logic/game_bountyhunter.cpp
engines/alg/logic/game_crimepatrol.cpp
engines/alg/logic/game_drugwars.cpp
engines/alg/logic/game_drugwars.h
engines/alg/logic/game_johnnyrock.cpp
engines/alg/logic/game_maddog.cpp
engines/alg/logic/game_maddog.h
engines/alg/logic/game_maddog2.cpp
engines/alg/logic/game_spacepirates.cpp
engines/alg/scene.cpp
engines/alg/scene.h
diff --git a/engines/alg/game.cpp b/engines/alg/game.cpp
index 1b567b9b8fd..739ff76c8b9 100644
--- a/engines/alg/game.cpp
+++ b/engines/alg/game.cpp
@@ -239,17 +239,14 @@ Zone *Game::checkZonesV2(Scene *scene, Rect *&hitRect, Common::Point *point) {
// only used by earlier games
void Game::adjustDifficulty(uint8 newDifficulty, uint8 oldDifficulty) {
Common::Array<Scene *> *scenes = _sceneInfo->getScenes();
- for (size_t i = 0; i < scenes->size(); i++) {
- Scene *scene = (*scenes)[i];
+ for (const auto &scene : *scenes) {
if (!(scene->_diff & 0x01)) {
if (scene->_preop == "PAUSE" || scene->_preop == "PAUSFI" || scene->_preop == "PAUSPR") {
scene->_dataParam1 = (scene->_dataParam1 * _pauseDiffScale[newDifficulty - 1]) / _pauseDiffScale[oldDifficulty - 1];
}
}
- for (size_t j = 0; j < scene->_zones.size(); j++) {
- Zone *zone = scene->_zones[j];
- for (size_t k = 0; k < zone->_rects.size(); k++) {
- Rect *rect = zone->_rects[k];
+ for (const auto &zone : scene->_zones) {
+ for (const auto &rect : zone->_rects) {
if (!(scene->_diff & 0x02)) {
int16 cx = (rect->left + rect->right) / 2;
int16 cy = (rect->top + rect->bottom) / 2;
@@ -301,7 +298,7 @@ uint16 Game::randomUnusedInt(uint8 max, uint16 *mask, uint16 exclude) {
}
uint16 randomNum = 0;
// find an unused random number
- while (1) {
+ while (true) {
randomNum = _rnd->getRandomNumber(max - 1);
// check if bit is already used
uint16 bit = 1 << randomNum;
diff --git a/engines/alg/game.h b/engines/alg/game.h
index a2de5ee2530..783c770e111 100644
--- a/engines/alg/game.h
+++ b/engines/alg/game.h
@@ -77,8 +77,8 @@ protected:
Zone *_menuzone;
Zone *_submenzone;
- bool _leftDown = 0;
- bool _rightDown = 0;
+ bool _leftDown = false;
+ bool _rightDown = false;
Common::Point _mousePos;
const uint32 _pauseDiffScale[3] = {0x10000, 0x8000, 0x4000};
@@ -147,7 +147,7 @@ protected:
bool _buttonDown = false;
uint8 _difficulty = 1;
uint8 _emptyCount = 0;
- bool _fired = 0;
+ bool _fired = false;
uint32 _currentFrame;
bool _gameInProgress = false;
uint32 _thisGameTimer = 0;
diff --git a/engines/alg/graphics.cpp b/engines/alg/graphics.cpp
index 386ae9436a8..5f4f8ca6f7f 100644
--- a/engines/alg/graphics.cpp
+++ b/engines/alg/graphics.cpp
@@ -122,7 +122,7 @@ Common::Array<Graphics::Surface *> *AlgGraphics::loadScreenCoordAniImage(const C
Graphics::Surface *renderTarget = new Graphics::Surface();
renderTarget->create(320, 200, Graphics::PixelFormat::createFormatCLUT8());
uint32 centerOffset = (renderTarget->w * renderTarget->h / 2) + (renderTarget->w / 2);
- while (1) {
+ while (true) {
length = aniFile.readUint16LE();
if (length == 0) {
break;
diff --git a/engines/alg/logic/game_bountyhunter.cpp b/engines/alg/logic/game_bountyhunter.cpp
index b10a3fbc5a3..cac1abcb221 100644
--- a/engines/alg/logic/game_bountyhunter.cpp
+++ b/engines/alg/logic/game_bountyhunter.cpp
@@ -1008,10 +1008,10 @@ void GameBountyHunter::sceneIsoGivemoney(Scene *scene) {
int bonus = (2 ^ _numLevelsDone) * 100;
_playerScore[i] += bonus;
}
- _wounded = 0;
- _given = 1;
+ _wounded = false;
+ _given = true;
} else if (moneyFrame != _currentFrame) {
- _given = 0;
+ _given = false;
}
}
displayScores(i);
@@ -1315,7 +1315,7 @@ void GameBountyHunter::debugWarpTo(int val) {
}
// Debugger methods
-DebuggerBountyHunter::DebuggerBountyHunter(GameBountyHunter *game) : GUI::Debugger() {
+DebuggerBountyHunter::DebuggerBountyHunter(GameBountyHunter *game) {
_game = game;
registerVar("drawRects", &game->_debug_drawRects);
registerVar("godMode", &game->_debug_godMode);
diff --git a/engines/alg/logic/game_crimepatrol.cpp b/engines/alg/logic/game_crimepatrol.cpp
index 5c6a177f960..d77abace7e8 100644
--- a/engines/alg/logic/game_crimepatrol.cpp
+++ b/engines/alg/logic/game_crimepatrol.cpp
@@ -1307,7 +1307,7 @@ void GameCrimePatrol::debugDrawPracticeRects() {
}
// Debugger methods
-DebuggerCrimePatrol::DebuggerCrimePatrol(GameCrimePatrol *game) : GUI::Debugger() {
+DebuggerCrimePatrol::DebuggerCrimePatrol(GameCrimePatrol *game) {
_game = game;
registerVar("drawRects", &game->_debug_drawRects);
registerVar("godMode", &game->_debug_godMode);
diff --git a/engines/alg/logic/game_drugwars.cpp b/engines/alg/logic/game_drugwars.cpp
index 7cf4e4a854a..15b45ef7bfa 100644
--- a/engines/alg/logic/game_drugwars.cpp
+++ b/engines/alg/logic/game_drugwars.cpp
@@ -199,7 +199,7 @@ void GameDrugWars::verifyScriptFunctions() {
}
}
-DWScriptFunctionRect GameDrugWars::getScriptFunctionRectHit(Common::String name) {
+DWScriptFunctionRect GameDrugWars::getScriptFunctionRectHit(const Common::String &name) {
auto it = _rectHitFuncs.find(name);
if (it != _rectHitFuncs.end()) {
return *it->_value;
@@ -208,7 +208,7 @@ DWScriptFunctionRect GameDrugWars::getScriptFunctionRectHit(Common::String name)
}
}
-DWScriptFunctionScene GameDrugWars::getScriptFunctionScene(SceneFuncType type, Common::String name) {
+DWScriptFunctionScene GameDrugWars::getScriptFunctionScene(SceneFuncType type, const Common::String &name) {
DWScriptFunctionSceneMap *functionMap;
switch (type) {
case PREOP:
@@ -245,12 +245,12 @@ DWScriptFunctionScene GameDrugWars::getScriptFunctionScene(SceneFuncType type, C
}
}
-void GameDrugWars::callScriptFunctionRectHit(Common::String name, Rect *rect) {
+void GameDrugWars::callScriptFunctionRectHit(const Common::String &name, Rect *rect) {
DWScriptFunctionRect function = getScriptFunctionRectHit(name);
function(rect);
}
-void GameDrugWars::callScriptFunctionScene(SceneFuncType type, Common::String name, Scene *scene) {
+void GameDrugWars::callScriptFunctionScene(SceneFuncType type, const Common::String &name, Scene *scene) {
DWScriptFunctionScene function = getScriptFunctionScene(type, name);
function(scene);
}
diff --git a/engines/alg/logic/game_drugwars.h b/engines/alg/logic/game_drugwars.h
index 9e3776d4ddb..32abe178780 100644
--- a/engines/alg/logic/game_drugwars.h
+++ b/engines/alg/logic/game_drugwars.h
@@ -59,10 +59,10 @@ private:
void init() override;
void registerScriptFunctions();
void verifyScriptFunctions();
- DWScriptFunctionRect getScriptFunctionRectHit(Common::String name);
- DWScriptFunctionScene getScriptFunctionScene(SceneFuncType type, Common::String name);
- void callScriptFunctionRectHit(Common::String name, Rect *rect);
- void callScriptFunctionScene(SceneFuncType type, Common::String name, Scene *scene);
+ DWScriptFunctionRect getScriptFunctionRectHit(const Common::String &name);
+ DWScriptFunctionScene getScriptFunctionScene(SceneFuncType type, const Common::String &name);
+ void callScriptFunctionRectHit(const Common::String &name, Rect *rect);
+ void callScriptFunctionScene(SceneFuncType type, const Common::String &name, Scene *scene);
DWScriptFunctionRectMap _rectHitFuncs;
DWScriptFunctionSceneMap _scenePreOps;
diff --git a/engines/alg/logic/game_johnnyrock.cpp b/engines/alg/logic/game_johnnyrock.cpp
index d5dcc6b31bc..6788dac1caf 100644
--- a/engines/alg/logic/game_johnnyrock.cpp
+++ b/engines/alg/logic/game_johnnyrock.cpp
@@ -917,8 +917,8 @@ void GameJohnnyRock::rectLoad(Rect *rect) {
}
void GameJohnnyRock::rectContinue(Rect *rect) {
- _inMenu = 0;
- _fired = 0;
+ _inMenu = false;
+ _fired = false;
if (_gameMoney < 0) {
newGame();
_retScene = "";
@@ -937,8 +937,8 @@ void GameJohnnyRock::rectContinue(Rect *rect) {
}
void GameJohnnyRock::rectStart(Rect *rect) {
- _inMenu = 0;
- _fired = 0;
+ _inMenu = false;
+ _fired = false;
_thisDifficulty = 0;
Scene *scene = _sceneInfo->findScene(_startScene);
if (scene->_nxtscn == "DRAWGUN") {
@@ -1528,7 +1528,7 @@ void GameJohnnyRock::sceneNxtscnPickMap(Scene *scene) {
_hadGoToMansion = 3;
nextScene = "scene166";
}
- if (nextScene.size() > 0) {
+ if (!nextScene.empty()) {
_curScene = nextScene;
} else {
_curScene = numToScene(_thisMap + 174);
@@ -1730,7 +1730,7 @@ void GameJohnnyRock::debugWarpTo(int val) {
}
// Debugger methods
-DebuggerJohnnyRock::DebuggerJohnnyRock(GameJohnnyRock *game) : GUI::Debugger() {
+DebuggerJohnnyRock::DebuggerJohnnyRock(GameJohnnyRock *game) {
_game = game;
registerVar("drawRects", &game->_debug_drawRects);
registerVar("godMode", &game->_debug_godMode);
diff --git a/engines/alg/logic/game_maddog.cpp b/engines/alg/logic/game_maddog.cpp
index 9f1570e516e..8f1f7be009d 100644
--- a/engines/alg/logic/game_maddog.cpp
+++ b/engines/alg/logic/game_maddog.cpp
@@ -1524,7 +1524,7 @@ void GameMaddog::debugWarpTo(int val) {
}
// Debugger methods
-DebuggerMaddog::DebuggerMaddog(GameMaddog *game) : GUI::Debugger() {
+DebuggerMaddog::DebuggerMaddog(GameMaddog *game) {
_game = game;
registerVar("drawRects", &game->_debug_drawRects);
registerVar("godMode", &game->_debug_godMode);
diff --git a/engines/alg/logic/game_maddog.h b/engines/alg/logic/game_maddog.h
index 4309d78045c..f6290becef8 100644
--- a/engines/alg/logic/game_maddog.h
+++ b/engines/alg/logic/game_maddog.h
@@ -101,17 +101,17 @@ private:
// gamestate
uint8 _badMen = 0;
uint8 _badMenBits = 0;
- bool _bartenderAlive = 0;
+ bool _bartenderAlive = false;
uint16 _beenTo = 0;
uint8 _bottles = 0;
uint8 _bottlesMask = 0;
bool _gotClue = false;
uint16 _gotInto = 0;
uint8 _gunTime = 0;
- bool _hadSkull = 0;
- bool _hadLantern = 0;
- bool _hideOutFront = 0;
- bool _inShootout = 0;
+ bool _hadSkull = false;
+ bool _hadLantern = false;
+ bool _hideOutFront = false;
+ bool _inShootout = false;
int8 _map0 = 0;
int8 _map1 = 0;
int8 _map2 = 0;
diff --git a/engines/alg/logic/game_maddog2.cpp b/engines/alg/logic/game_maddog2.cpp
index d24792e4b0a..cd0ad42fc76 100644
--- a/engines/alg/logic/game_maddog2.cpp
+++ b/engines/alg/logic/game_maddog2.cpp
@@ -467,8 +467,8 @@ void GameMaddog2::resetParams() {
_thisGuide = -1;
_doneGuide = 0;
_totalDies = 0;
- _hadSkull = 0;
- _inShootout = 0;
+ _hadSkull = false;
+ _inShootout = false;
updateStat();
}
@@ -790,7 +790,7 @@ uint16 GameMaddog2::pickBits(uint16 *bits, uint8 max) {
}
uint16 randomNum = _rnd->getRandomNumber(max - 1);
// find an unused bit
- while (1) {
+ while (true) {
uint16 bitMask = 1 << randomNum;
// if bit is already used or matches _lastPick, try next position
if ((*bits & bitMask) || randomNum == _lastPick) {
@@ -1377,7 +1377,7 @@ void GameMaddog2::sceneNxtscnShootSkull(Scene *scene) {
if (_hadSkull) {
return;
}
- _hadSkull = 1;
+ _hadSkull = true;
doSkullSound();
_shots = 12;
_score += 1000;
@@ -1684,7 +1684,7 @@ void GameMaddog2::debugWarpTo(int val) {
}
// Debugger methods
-DebuggerMaddog2::DebuggerMaddog2(GameMaddog2 *game) : GUI::Debugger() {
+DebuggerMaddog2::DebuggerMaddog2(GameMaddog2 *game) {
_game = game;
registerVar("drawRects", &game->_debug_drawRects);
registerVar("godMode", &game->_debug_godMode);
diff --git a/engines/alg/logic/game_spacepirates.cpp b/engines/alg/logic/game_spacepirates.cpp
index c8606f788ea..7cc8e4b71e3 100644
--- a/engines/alg/logic/game_spacepirates.cpp
+++ b/engines/alg/logic/game_spacepirates.cpp
@@ -443,9 +443,9 @@ void GameSpacePirates::resetParams() {
_randomCountAsteroids = 0;
_sceneBeforeFlyingSkulls = 0;
_miscRoomsCount = 0;
- _playerDied = 0;
+ _playerDied = false;
_gotTo = 0;
- _selectedAWorld = 0;
+ _selectedAWorld = false;
_selectedWorldStart = 0;
_currentWorld = -1;
_worldGotTo[0] = 0x91;
@@ -818,7 +818,7 @@ uint16 GameSpacePirates::sceneToNumber(Scene *scene) {
}
uint16 GameSpacePirates::randomUnusedScene(uint8 max) {
- bool found = 0;
+ bool found = false;
uint8 randomNum = 0;
for (int i = 0; i < max && !found; i++) {
randomNum = _rnd->getRandomNumber(max - 1);
@@ -1322,10 +1322,10 @@ void GameSpacePirates::scenePsoSetWorldGotTo(Scene *scene) {
void GameSpacePirates::sceneIsoPickAWorld(Scene *scene) {
Zone *zone = scene->_zones[0];
uint8 world = 3;
- for (size_t i = 0; i < zone->_rects.size(); i++) {
+ for (auto &rect : zone->_rects) {
if (_worldDone[world]) {
- uint16 centerX = zone->_rects[i]->left + (zone->_rects[i]->width() / 2);
- uint16 centerY = zone->_rects[i]->top + (zone->_rects[i]->height() / 2);
+ uint16 centerX = rect->left + (rect->width() / 2);
+ uint16 centerY = rect->top + (rect->height() / 2);
AlgGraphics::drawImageCentered(_videoDecoder->getVideoFrame(), (*_gun)[2], centerX - 16, centerY - 24);
}
world--;
@@ -1402,7 +1402,7 @@ void GameSpacePirates::sceneNxtscnMiscRooms1(Scene *scene) {
uint16 picked = 0;
if (_miscRoomsCount == 0) {
_pickedMiscRooms = 0;
- while (1) {
+ while (true) {
uint8 randomNum = _rnd->getRandomNumber(9);
if (randomNum <= 5) {
picked = 0x1F;
@@ -1937,7 +1937,7 @@ void GameSpacePirates::debugWarpTo(int val) {
}
// Debugger methods
-DebuggerSpacePirates::DebuggerSpacePirates(GameSpacePirates *game) : GUI::Debugger() {
+DebuggerSpacePirates::DebuggerSpacePirates(GameSpacePirates *game) {
_game = game;
registerVar("drawRects", &game->_debug_drawRects);
registerVar("godMode", &game->_debug_godMode);
diff --git a/engines/alg/scene.cpp b/engines/alg/scene.cpp
index 4bd10bca319..f6e20038a35 100644
--- a/engines/alg/scene.cpp
+++ b/engines/alg/scene.cpp
@@ -94,7 +94,7 @@ void SceneInfo::loadScnFile(const Common::Path &path) {
addZonesToScenes();
}
-void SceneInfo::parseScene(Common::String sceneName, uint32 startFrame, uint32 endFrame) {
+void SceneInfo::parseScene(const Common::String &sceneName, uint32 startFrame, uint32 endFrame) {
Scene *scene = new Scene(sceneName, startFrame, endFrame);
bool done = false;
while (_scnFile.pos() < _scnFile.size() && !done) {
@@ -176,7 +176,7 @@ void SceneInfo::parseScene(Common::String sceneName, uint32 startFrame, uint32 e
_scenes.push_back(scene);
}
-void SceneInfo::parseZone(Common::String zoneName, uint32 startFrame, uint32 endFrame) {
+void SceneInfo::parseZone(const Common::String &zoneName, uint32 startFrame, uint32 endFrame) {
Zone *zone = new Zone(zoneName, startFrame, endFrame);
bool done = false;
while (_scnFile.pos() < _scnFile.size() && !done) {
@@ -246,8 +246,7 @@ void SceneInfo::parseZone(Common::String zoneName, uint32 startFrame, uint32 end
}
void SceneInfo::addZonesToScenes() {
- for (uint32 i = 0; i < _scenes.size(); i++) {
- Scene *scene = _scenes[i];
+ for (auto &scene : _scenes) {
if (!scene->_zonesStart.empty()) {
Zone *zone = findZone(scene->_zonesStart);
scene->_zones.push_back(zone);
@@ -288,26 +287,26 @@ void SceneInfo::addScene(Scene *scene) {
_scenes.push_back(scene);
}
-Zone *SceneInfo::findZone(Common::String zoneName) {
- for (uint32 i = 0; i < _zones.size(); i++) {
- if (_zones[i]->_name.equalsIgnoreCase(zoneName)) {
- return _zones[i];
+Zone *SceneInfo::findZone(const Common::String &zoneName) {
+ for (auto &zone : _zones) {
+ if (zone->_name.equalsIgnoreCase(zoneName)) {
+ return zone;
}
}
warning("SceneInfo::findZone(): Cannot find zone %s", zoneName.c_str());
return nullptr;
}
-Scene *SceneInfo::findScene(Common::String sceneName) {
- for (uint32 i = 0; i < _scenes.size(); i++) {
- if (_scenes[i]->_name.equalsIgnoreCase(sceneName)) {
- return _scenes[i];
+Scene *SceneInfo::findScene(const Common::String &sceneName) {
+ for (auto &scene : _scenes) {
+ if (scene->_name.equalsIgnoreCase(sceneName)) {
+ return scene;
}
}
error("SceneInfo::findScene(): Cannot find scene %s", sceneName.c_str());
}
-int8 SceneInfo::getToken(const struct TokenEntry *tokenList, Common::String token) {
+int8 SceneInfo::getToken(const TokenEntry *tokenList, const Common::String &token) {
for (int i = 0; tokenList[i].name != nullptr; i++) {
if (token == tokenList[i].name) {
return tokenList[i].value;
@@ -316,8 +315,8 @@ int8 SceneInfo::getToken(const struct TokenEntry *tokenList, Common::String toke
return -1;
}
-bool SceneInfo::ignoreScriptLine(Common::String line) {
- if (line.size() == 0) {
+bool SceneInfo::ignoreScriptLine(const Common::String &line) {
+ if (line.empty()) {
return true; // empty line
} else if (line.hasPrefix("//")) {
return true; // comment
@@ -333,7 +332,7 @@ bool SceneInfo::ignoreScriptLine(Common::String line) {
return false;
}
-Scene::Scene(Common::String name, uint32 startFrame, uint32 endFrame) {
+Scene::Scene(const Common::String &name, uint32 startFrame, uint32 endFrame) {
_preop = "DEFAULT";
_insop = "DEFAULT";
_scnmsg = "DEFAULT";
@@ -355,15 +354,12 @@ Scene::Scene(Common::String name, uint32 startFrame, uint32 endFrame) {
_difficultyMod = 0;
}
-Scene::~Scene() {
-}
-
-Zone::Zone(Common::String name, Common::String ptrfb) {
+Zone::Zone(const Common::String &name, const Common::String &ptrfb) {
_name = name;
_ptrfb = ptrfb;
}
-Zone::Zone(Common::String name, uint32 startFrame, uint32 endFrame) {
+Zone::Zone(const Common::String &name, uint32 startFrame, uint32 endFrame) {
_name = name;
_startFrame = startFrame;
_endFrame = endFrame;
@@ -375,7 +371,7 @@ Zone::~Zone() {
}
}
-void Zone::addRect(int16 left, int16 top, int16 right, int16 bottom, Common::String scene, uint32 score, Common::String rectHit, Common::String unknown) {
+void Zone::addRect(int16 left, int16 top, int16 right, int16 bottom, const Common::String &scene, uint32 score, const Common::String &rectHit, const Common::String &unknown) {
Rect *rect = new Rect();
rect->left = left;
rect->top = top;
diff --git a/engines/alg/scene.h b/engines/alg/scene.h
index 07e994296d4..270a1ed0b66 100644
--- a/engines/alg/scene.h
+++ b/engines/alg/scene.h
@@ -87,22 +87,22 @@ public:
class Zone {
public:
- Zone(Common::String name, uint32 startFrame, uint32 endFrame);
- Zone(Common::String name, Common::String ptrfb);
+ Zone(const Common::String &name, uint32 startFrame, uint32 endFrame);
+ Zone(const Common::String &name, const Common::String &ptrfb);
~Zone();
Common::String _name;
- uint32 _startFrame;
- uint32 _endFrame;
+ uint32 _startFrame = 0;
+ uint32 _endFrame = 0;
Common::String _ptrfb;
Common::Array<Rect *> _rects;
Common::String _next;
- void addRect(int16 left, int16 top, int16 right, int16 bottom, Common::String scene, uint32 score, Common::String rectHit, Common::String unknown);
+ void addRect(int16 left, int16 top, int16 right, int16 bottom, const Common::String &scene, uint32 score, const Common::String &rectHit, const Common::String &unknown);
};
class Scene {
public:
- Scene(Common::String name, uint32 startFrame, uint32 endFrame);
- ~Scene();
+ Scene(const Common::String &name, uint32 startFrame, uint32 endFrame);
+ ~Scene() = default;
Common::String _name;
uint32 _startFrame;
uint32 _endFrame;
@@ -141,7 +141,7 @@ public:
void loadScnFile(const Common::Path &path);
Common::String getStartScene() { return _startScene; }
Common::Array<Scene *> *getScenes() { return &_scenes; }
- Scene *findScene(Common::String sceneName);
+ Scene *findScene(const Common::String &sceneName);
void addScene(Scene *scene);
private:
@@ -150,12 +150,12 @@ private:
Common::Array<Scene *> _scenes;
Common::Array<Zone *> _zones;
- void parseScene(Common::String sceneName, uint32 startFrame, uint32 endFrame);
- void parseZone(Common::String zoneName, uint32 startFrame, uint32 endFrame);
+ void parseScene(const Common::String &sceneName, uint32 startFrame, uint32 endFrame);
+ void parseZone(const Common::String &zoneName, uint32 startFrame, uint32 endFrame);
void addZonesToScenes();
- Zone *findZone(Common::String zoneName);
- int8 getToken(const struct TokenEntry *tokenList, Common::String token);
- bool ignoreScriptLine(Common::String line);
+ Zone *findZone(const Common::String &zoneName);
+ int8 getToken(const TokenEntry *tokenList, const Common::String &token);
+ bool ignoreScriptLine(const Common::String &line);
};
} // End of namespace Alg
More information about the Scummvm-git-logs
mailing list