[Scummvm-git-logs] scummvm master -> e4b4b67bc6b25099f883275c13f9105744dc5b43
mduggan
noreply at scummvm.org
Tue Oct 29 09:02:30 UTC 2024
This automated email contains information about 9 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
01a38de001 DGDS: Fix pointer validation and unused param PVS-Studio V595, V763.
fbfee0d0cc DGDS: Fix duplicate case statements. PVS-Studio V1037
bccc509bcb DGDS: Fix some undefined behavior, PVS-Studio V1053, V1077
6c85f2e091 DGDS: Check malloc return val. PVS-Studio V575
f38e78a393 DGDS: Be more sure about not using null ptr. PVS-Studio V522
f55d37d353 DGDS: Initialize all members of object. PVS-Studio V730
2495c1bcbc DGDS: Avoid unsigned/signed comparison. PVS-Studio V1112.
9d7266c280 DGDS: Remove redundant null checks. PVS-Studio V560
e4b4b67bc6 DGDS: Initialize _channels and assume new will succeed or throw. PVS-Studio V730, V668
Commit: 01a38de0018e2ee6203aee613a061774e3f5bfd4
https://github.com/scummvm/scummvm/commit/01a38de0018e2ee6203aee613a061774e3f5bfd4
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2024-10-29T17:51:58+11:00
Commit Message:
DGDS: Fix pointer validation and unused param PVS-Studio V595, V763.
Changed paths:
engines/dgds/ads.cpp
engines/dgds/ads.h
diff --git a/engines/dgds/ads.cpp b/engines/dgds/ads.cpp
index 359ac810044..01983d1473e 100644
--- a/engines/dgds/ads.cpp
+++ b/engines/dgds/ads.cpp
@@ -334,7 +334,7 @@ void ADSInterpreter::findEndOrInitOp() {
}
bool ADSInterpreter::logicOpResult(uint16 code, const TTMEnviro *env, const TTMSeq *seq, uint16 arg) {
- const char *tag = seq ? env->_tags.getValOrDefault(seq->_seqNum).c_str() : "";
+ const char *tag = (seq && env) ? env->_tags.getValOrDefault(seq->_seqNum).c_str() : "";
int16 envNum = env ? env->_enviro : 0;
int16 seqNum = seq ? seq->_seqNum : 0;
const char *optype = (code < 0x1300 ? "while" : "if");
@@ -468,13 +468,13 @@ int16 ADSInterpreter::randomOpGetProportion(uint16 code, Common::SeekableReadStr
return result;
}
-void ADSInterpreter::handleRandomOp(uint16 code, Common::SeekableReadStream *scr) {
+void ADSInterpreter::handleRandomOp(Common::SeekableReadStream *scr) {
int16 max = 0;
int64 startpos = scr->pos();
// Collect the random proportions
- code = scr->readUint16LE();
- while (code != 0 && code != 0x30ff && scr->pos() < scr->size()) {
+ uint16 code = scr->readUint16LE();
+ while (code != 0 && code != 0x30FF && scr->pos() < scr->size()) {
int16 val = randomOpGetProportion(code, scr);
// leaves pointer at beginning of next op
max += val;
@@ -628,11 +628,13 @@ bool ADSInterpreter::handleOperation(uint16 code, Common::SeekableReadStream *sc
return true;
}
case 0x3010: // RANDOM_START, 0 params
- case 0x30FF: // RANDOM_END, 0 params
debug(10, "ADS 0x%04x: random %s", code, code == 0x3010 ? "start" : "end");
- handleRandomOp(code, scr);
+ handleRandomOp(scr);
break;
+ case 0x30FF: // RANDOM_END, 0 params
+ error("Unexpected RANDOM END mid-stream (no RANDOM START?).");
+
case 0x4000: { // MOVE SEQ TO FRONT
enviro = scr->readUint16LE();
seqnum = scr->readUint16LE();
@@ -776,6 +778,7 @@ bool ADSInterpreter::run() {
}
}
+ assert(_adsData->scr || !_adsData->_maxSegments);
for (int i = 0; i < _adsData->_maxSegments; i++) {
int16 state = _adsData->_state[i];
int32 offset = _adsData->_segments[i];
@@ -800,7 +803,7 @@ bool ADSInterpreter::run() {
}
_adsData->_runningSegmentIdx = i;
- if (_adsData->scr && state == 1) {
+ if (state == 1) {
_adsData->scr->seek(offset);
//debug("ADS: Run segment %d idx %d/%d", segnum, i, _adsData->_maxSegments);
runUntilBranchOpOrEnd();
diff --git a/engines/dgds/ads.h b/engines/dgds/ads.h
index 00d5f46685d..b39ada32290 100644
--- a/engines/dgds/ads.h
+++ b/engines/dgds/ads.h
@@ -82,7 +82,7 @@ public:
protected:
bool handleOperation(uint16 code, Common::SeekableReadStream *scr);
- void handleRandomOp(uint16 code, Common::SeekableReadStream *scr);
+ void handleRandomOp(Common::SeekableReadStream *scr);
bool handleLogicOp(uint16 code, Common::SeekableReadStream *scr);
bool logicOpResult(uint16 code, const TTMEnviro *env, const TTMSeq *seq, uint16 arg);
int16 randomOpGetProportion(uint16 code, Common::SeekableReadStream *scr);
Commit: fbfee0d0cc9c08a85498196cbd8c1f2714f4067e
https://github.com/scummvm/scummvm/commit/fbfee0d0cc9c08a85498196cbd8c1f2714f4067e
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2024-10-29T17:51:58+11:00
Commit Message:
DGDS: Fix duplicate case statements. PVS-Studio V1037
Changed paths:
engines/dgds/console.cpp
diff --git a/engines/dgds/console.cpp b/engines/dgds/console.cpp
index 007a707d0bc..8930505104b 100644
--- a/engines/dgds/console.cpp
+++ b/engines/dgds/console.cpp
@@ -428,10 +428,10 @@ bool Console::cmdScriptDump(int argc, const char **argv) {
printOp(--indent, "END WHILE");
break;
case 0x2000:
- printOp(indent, "ADD sequence");
+ printOp(indent, "ADD sequence (restart)");
break;
case 0x2005:
- printOp(indent, "ADD sequence");
+ printOp(indent, "ADD sequence (continue)");
break;
case 0x2010:
printOp(indent, "STOP SCENE");
@@ -467,7 +467,7 @@ bool Console::cmdScriptDump(int argc, const char **argv) {
printOp(indent, "RUN_SCRIPT");
break;
case 0xF210:
- printOp(indent, "RUN_SCRIPT");
+ printOp(indent, "RESTART_SCRIPT");
break;
case 0x1420:
printOp(--indent, "AND");
Commit: bccc509bcb0700744d4897691d38bd6460d7948d
https://github.com/scummvm/scummvm/commit/bccc509bcb0700744d4897691d38bd6460d7948d
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2024-10-29T17:51:58+11:00
Commit Message:
DGDS: Fix some undefined behavior, PVS-Studio V1053, V1077
Changed paths:
engines/dgds/dgds.cpp
engines/dgds/dgds.h
diff --git a/engines/dgds/dgds.cpp b/engines/dgds/dgds.cpp
index 7e41e539f41..c137063a012 100644
--- a/engines/dgds/dgds.cpp
+++ b/engines/dgds/dgds.cpp
@@ -86,8 +86,7 @@ DgdsEngine::DgdsEngine(OSystem *syst, const ADGameDescription *gameDesc)
_detailLevel(kDgdsDetailHigh), _textSpeed(1), _justChangedScene1(false), _justChangedScene2(false),
_random("dgds"), _currentCursor(-1), _menuToTrigger(kMenuNone), _isLoading(true), _flipMode(false),
_rstFileName(nullptr), _difficulty(1), _menu(nullptr), _adsInterp(nullptr), _isDemo(false),
- _dragonArcade(nullptr), _skipNextFrame(false) {
- syncSoundSettings();
+ _dragonArcade(nullptr), _skipNextFrame(false), _gameId(GID_INVALID) {
_platform = gameDesc->platform;
@@ -476,6 +475,7 @@ static void _dumpFrame(const Graphics::ManagedSurface &surf, const char *name) {
Common::Error DgdsEngine::run() {
+ syncSoundSettings();
_isLoading = true;
init(false);
loadGameFiles();
diff --git a/engines/dgds/dgds.h b/engines/dgds/dgds.h
index 72fc40b2544..aec3b6e23b7 100644
--- a/engines/dgds/dgds.h
+++ b/engines/dgds/dgds.h
@@ -71,7 +71,8 @@ enum DgdsGameId {
GID_SQ5DEMO,
GID_COMINGATTRACTIONS,
GID_QUARKY,
- GID_CASTAWAY
+ GID_CASTAWAY,
+ GID_INVALID,
};
enum DgdsDetailLevel {
Commit: 6c85f2e091ff0d7e2557e6d75b7ba533e08ec13c
https://github.com/scummvm/scummvm/commit/6c85f2e091ff0d7e2557e6d75b7ba533e08ec13c
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2024-10-29T17:51:58+11:00
Commit Message:
DGDS: Check malloc return val. PVS-Studio V575
Changed paths:
engines/dgds/image.cpp
diff --git a/engines/dgds/image.cpp b/engines/dgds/image.cpp
index 160d196d5aa..bf5da4e75c0 100644
--- a/engines/dgds/image.cpp
+++ b/engines/dgds/image.cpp
@@ -482,6 +482,8 @@ uint32 Image::loadVQT(Graphics::ManagedSurface *surf, uint32 toffset, Common::Se
// FIXME: This sometimes reads more than it needs to..
uint64 nbytes = stream->size() - stream->pos();
byte *buf = (byte *)malloc(nbytes + 8);
+ if (!buf)
+ error("Image::loadVQT: Alloc failed");
memset(buf, 0, nbytes + 8);
stream->read(buf, nbytes);
state.srcPtr = buf;
Commit: f38e78a3933c8746929fb6104dab8cc2e54ae565
https://github.com/scummvm/scummvm/commit/f38e78a3933c8746929fb6104dab8cc2e54ae565
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2024-10-29T17:51:58+11:00
Commit Message:
DGDS: Be more sure about not using null ptr. PVS-Studio V522
Changed paths:
engines/dgds/menu.cpp
diff --git a/engines/dgds/menu.cpp b/engines/dgds/menu.cpp
index ba75de61e20..98f42b7cc82 100644
--- a/engines/dgds/menu.cpp
+++ b/engines/dgds/menu.cpp
@@ -178,19 +178,18 @@ void Menu::configureGadget(MenuId menu, Gadget *gadget) {
// a bit of a hack - set up the gadget with the correct value before we draw it.
if (menu == kMenuControls) {
SliderGadget *slider = dynamic_cast<SliderGadget *>(gadget);
+ if (!slider)
+ return;
switch (gadget->_gadgetNo) {
case kMenuSliderControlsDifficulty:
- assert(slider);
slider->setSteps(3, false);
slider->setValue(engine->getDifficulty()); // TODO: set a difficulty value
break;
case kMenuSliderControlsTextSpeed:
- assert(slider);
slider->setSteps(10, false);
slider->setValue(9 - engine->getTextSpeed());
break;
case kMenuSliderControlsDetailLevel:
- assert(slider);
slider->setSteps(2, true);
slider->setValue(engine->getDetailLevel());
break;
@@ -484,20 +483,29 @@ void Menu::handleClick(const Common::Point &mouse) {
drawMenu(kMenuRestart);
break;
case kMenuSliderControlsDifficulty: {
- int16 setting = dynamic_cast<SliderGadget *>(gadget)->onClick(mouse);
+ SliderGadget *slider = dynamic_cast<SliderGadget *>(gadget);
+ if (!slider)
+ break;
+ int16 setting = slider->onClick(mouse);
engine->setDifficulty(setting);
// redraw for update.
drawMenu(_curMenu);
break;
}
case kMenuSliderControlsTextSpeed: {
- int16 setting = dynamic_cast<SliderGadget *>(gadget)->onClick(mouse);
+ SliderGadget *slider = dynamic_cast<SliderGadget *>(gadget);
+ if (!slider)
+ break;
+ int16 setting = slider->onClick(mouse);
engine->setTextSpeed(9 - setting);
drawMenu(_curMenu);
break;
}
case kMenuSliderControlsDetailLevel: {
- int16 setting = dynamic_cast<SliderGadget *>(gadget)->onClick(mouse);
+ SliderGadget *slider = dynamic_cast<SliderGadget *>(gadget);
+ if (!slider)
+ break;
+ int16 setting = slider->onClick(mouse);
engine->setDetailLevel(static_cast<DgdsDetailLevel>(setting));
drawMenu(_curMenu);
break;
Commit: f55d37d3531474162387bec251a874c553f8f47c
https://github.com/scummvm/scummvm/commit/f55d37d3531474162387bec251a874c553f8f47c
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2024-10-29T17:51:58+11:00
Commit Message:
DGDS: Initialize all members of object. PVS-Studio V730
Changed paths:
engines/dgds/resource.cpp
engines/dgds/resource.h
diff --git a/engines/dgds/resource.cpp b/engines/dgds/resource.cpp
index e3cf35fbf50..7ab89784423 100644
--- a/engines/dgds/resource.cpp
+++ b/engines/dgds/resource.cpp
@@ -144,6 +144,12 @@ bool ResourceManager::hasResource(Common::String name) const {
return _resources.contains(name);
}
+DgdsChunkReader::DgdsChunkReader(Common::SeekableReadStream *stream)
+: _sourceStream(stream), _contentStream(nullptr), _size(0), _container(false),
+ _startPos(0), _id(0), _ex(0) {
+ ARRAYCLEAR(_idStr);
+}
+
DgdsChunkReader::~DgdsChunkReader() {
if (_contentStream)
delete _contentStream;
diff --git a/engines/dgds/resource.h b/engines/dgds/resource.h
index c8e55a60641..fbf197486d5 100644
--- a/engines/dgds/resource.h
+++ b/engines/dgds/resource.h
@@ -64,7 +64,7 @@ private:
class DgdsChunkReader {
public:
- DgdsChunkReader(Common::SeekableReadStream *stream) : _sourceStream(stream), _contentStream(nullptr), _size(0), _container(false), _startPos(0), _id(0), _ex(0) {}
+ DgdsChunkReader(Common::SeekableReadStream *stream);
~DgdsChunkReader();
bool isSection(const Common::String §ion) const;
Commit: 2495c1bcbc94d23210662616d38181c604285135
https://github.com/scummvm/scummvm/commit/2495c1bcbc94d23210662616d38181c604285135
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2024-10-29T17:51:58+11:00
Commit Message:
DGDS: Avoid unsigned/signed comparison. PVS-Studio V1112.
Object numbers should never be negative, but globals technically can be.
Changed paths:
engines/dgds/scene.cpp
diff --git a/engines/dgds/scene.cpp b/engines/dgds/scene.cpp
index ba1b52aff8e..4b790fa1d57 100644
--- a/engines/dgds/scene.cpp
+++ b/engines/dgds/scene.cpp
@@ -2324,10 +2324,10 @@ int GDSScene::countItemsInScene2() const {
GameItem *GDSScene::getActiveItem() {
int16 itemNum = getGlobal(0x60);
- if (!itemNum)
+ if (itemNum <= 0)
return nullptr;
for (auto &item : _gameItems) {
- if (item._num == itemNum)
+ if (item._num == (uint16)itemNum)
return &item;
}
return nullptr;
Commit: 9d7266c2809b2296f249120c99a86671b6ae24af
https://github.com/scummvm/scummvm/commit/9d7266c2809b2296f249120c99a86671b6ae24af
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2024-10-29T17:51:58+11:00
Commit Message:
DGDS: Remove redundant null checks. PVS-Studio V560
Changed paths:
engines/dgds/scene.cpp
diff --git a/engines/dgds/scene.cpp b/engines/dgds/scene.cpp
index 4b790fa1d57..dcd3229da82 100644
--- a/engines/dgds/scene.cpp
+++ b/engines/dgds/scene.cpp
@@ -1686,10 +1686,10 @@ void SDSScene::mouseLUp(const Common::Point &pt) {
GDSScene *gds = engine->getGDSScene();
- if (area && area->_num == 0) {
+ if (area->_num == 0) {
debug("Mouseup on inventory.");
engine->getInventory()->open();
- } else if (area && area->_num == 0xffff) {
+ } else if (area->_num == 0xffff) {
debug("Mouseup on swap characters.");
bool haveInvBtn = _hotAreaList.size() && _hotAreaList.front()._num == 0;
if (haveInvBtn)
@@ -1707,19 +1707,18 @@ void SDSScene::mouseLUp(const Common::Point &pt) {
if (activeItem) {
if (!runOps(activeItem->onBothButtonsOps))
return;
- if (area) {
- const GameItem *destItem = dynamic_cast<const GameItem *>(area);
- const ObjectInteraction *i;
- if (destItem) {
- i =_findInteraction(gds->getObjInteractions2(), activeItem->_num, area->_num);
- } else {
- i = _findInteraction(_objInteractions2, activeItem->_num, area->_num);
- }
- if (i) {
- debug(" --> exec %d both-click ops for item combo %d", i->opList.size(), activeItem->_num);
- if (!runOps(i->opList, engine->getGameGlobals()->getGameMinsToAddOnObjInteraction()))
- return;
- }
+
+ const GameItem *destItem = dynamic_cast<const GameItem *>(area);
+ const ObjectInteraction *i;
+ if (destItem) {
+ i =_findInteraction(gds->getObjInteractions2(), activeItem->_num, area->_num);
+ } else {
+ i = _findInteraction(_objInteractions2, activeItem->_num, area->_num);
+ }
+ if (i) {
+ debug(" --> exec %d both-click ops for item combo %d", i->opList.size(), activeItem->_num);
+ if (!runOps(i->opList, engine->getGameGlobals()->getGameMinsToAddOnObjInteraction()))
+ return;
}
}
} else {
Commit: e4b4b67bc6b25099f883275c13f9105744dc5b43
https://github.com/scummvm/scummvm/commit/e4b4b67bc6b25099f883275c13f9105744dc5b43
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2024-10-29T17:51:59+11:00
Commit Message:
DGDS: Initialize _channels and assume new will succeed or throw. PVS-Studio V730, V668
Changed paths:
engines/dgds/sound.cpp
diff --git a/engines/dgds/sound.cpp b/engines/dgds/sound.cpp
index eebbb4b5057..2db463f373d 100644
--- a/engines/dgds/sound.cpp
+++ b/engines/dgds/sound.cpp
@@ -195,6 +195,7 @@ static byte _loadSndTrack(uint32 track, const byte** trackPtr, uint16* trackSiz,
Sound::Sound(Audio::Mixer *mixer, ResourceManager *resource, Decompressor *decompressor) :
_mixer(mixer), _resource(resource), _decompressor(decompressor), _music(nullptr) {
+ ARRAYCLEAR(_channels);
_music = new SciMusic(true);
_music->init();
}
@@ -223,11 +224,9 @@ void Sound::playAmigaSfx(const Common::String &filename, byte channel, byte volu
stopSfxForChannel(channel);
- if (soundData) {
- Channel *ch = &_channels[channel];
- Audio::AudioStream *input = Audio::makeAIFFStream(soundData, DisposeAfterUse::YES);
- _mixer->playStream(Audio::Mixer::kSFXSoundType, &ch->handle, input, -1, volume);
- }
+ Channel *ch = &_channels[channel];
+ Audio::AudioStream *input = Audio::makeAIFFStream(soundData, DisposeAfterUse::YES);
+ _mixer->playStream(Audio::Mixer::kSFXSoundType, &ch->handle, input, -1, volume);
}
void Sound::stopAllSfx() {
More information about the Scummvm-git-logs
mailing list