NANCY: Silence warnings

Fixed several small issues that caused compiler and/or
Coverity warnings.
This commit is contained in:
Kaloyan Chehlarski 2023-08-23 16:05:50 +03:00
parent 21e2ca475a
commit 4c5d0d2299
11 changed files with 28 additions and 23 deletions

View File

@ -54,7 +54,7 @@ protected:
Common::Array<byte> _solveOrder;
SoundDescription _snipSound;
SoundDescription _noToolSound;
uint16 _toolID;
uint16 _toolID = 0;
SceneChangeWithFlag _solveSceneChange;
SoundDescription _solveSound;
SceneChangeWithFlag _failSceneChange;

View File

@ -45,7 +45,7 @@ void Overlay::readData(Common::SeekableReadStream &stream) {
Common::Serializer ser(&stream, nullptr);
ser.setVersion(g_nancy->getGameType());
uint16 numSrcRects;
uint16 numSrcRects = 0;
readFilename(ser, _imageName);
ser.skip(2, kGameTypeVampire, kGameTypeNancy2);

View File

@ -103,13 +103,13 @@ protected:
int32 _playerX = -1; // Player position with precision 1/128th of cell width/height
int32 _playerY = -1;
int32 _playerRotation; // Rotation of player (0 - 4096)
int32 _playerRotation = 0; // Rotation of player (0 - 4096)
uint32 _playerAltitude = 88; // Z position of "camera"; only modified in god mode
float _rotationSingleStep = 4096.0 / (_pi * 2);
float _maxWorldDistance;
float _maxWorldDistance = 0.0;
uint32 _lastMovementTime;
uint32 _lastMovementTime = 0;
int _lastMouseX = -1;
uint32 _nextSlowdownMovementTime = 0;

View File

@ -58,8 +58,8 @@ protected:
void drawText();
uint16 _viewportTextFontID;
uint16 _textboxTextFontID;
uint16 _viewportTextFontID = 0;
uint16 _textboxTextFontID = 0;
Time _cursorBlinkTime;
SoundDescription _typeSound;
SoundDescription _eraseSound;

View File

@ -77,7 +77,7 @@ void PlaySecondaryMovie::readData(Common::SeekableReadStream &stream) {
_sound.readNormal(stream);
_sceneChange.readData(stream, ser.getVersion() == kGameTypeVampire);
uint16 numVideoDescs;
uint16 numVideoDescs = 0;
ser.syncAsUint16LE(numVideoDescs);
_videoDescs.resize(numVideoDescs);
for (uint i = 0; i < numVideoDescs; ++i) {

View File

@ -178,7 +178,7 @@ void PlaySecondaryVideo::readData(Common::SeekableReadStream &stream) {
_sceneChange.readData(stream, ser.getVersion() == kGameTypeVampire);
ser.skip(1, kGameTypeNancy1);
uint16 numVideoDescs;
uint16 numVideoDescs = 0;
ser.syncAsUint16LE(numVideoDescs);
_videoDescs.resize(numVideoDescs);
for (uint i = 0; i < numVideoDescs; ++i) {

View File

@ -74,7 +74,7 @@ protected:
SoundDescription _buttonSound;
SceneChangeWithFlag _alarmSetScene;
uint16 _alarmSoundDelay;
uint16 _alarmSoundDelay = 0;
SoundDescription _alarmRingSound; // NO SOUND in MHM
SceneChangeWithFlag _exitScene;

View File

@ -70,11 +70,11 @@ public:
Common::Array<uint16> _minRate;
Common::Array<uint16> _maxRate;
uint16 _solveChannelID;
uint16 _solveMinVolume;
uint16 _solveMaxVolume;
uint16 _solveMinRate;
uint16 _solveMaxRate;
uint16 _solveChannelID = 0;
uint16 _solveMinVolume = 0;
uint16 _solveMaxVolume = 0;
uint16 _solveMinRate = 0;
uint16 _solveMaxRate = 0;
SceneChangeDescription _exitScene;
SoundDescription _exitSound;

View File

@ -358,8 +358,9 @@ HINT::HINT(Common::SeekableReadStream *chunkStream) {
assert(chunkStream);
chunkStream->seek(0);
numHints.resize(chunkStream->size());
for (uint i = 0; i < numHints.size(); ++i) {
uint size = chunkStream->size();
numHints.resize(size);
for (uint i = 0; i < size; ++i) {
numHints[i] = chunkStream->readByte();
}

View File

@ -271,7 +271,7 @@ void GraphicsManager::copyToManaged(void *src, Graphics::ManagedSurface &dst, ui
void GraphicsManager::rotateBlit(const Graphics::ManagedSurface &src, Graphics::ManagedSurface &dest, byte rotation) {
assert(!src.empty() && !dest.empty());
assert(src.w == src.h && src.h == dest.w && dest.w == dest.h);
assert(rotation >= 0 && rotation <= 3);
assert(rotation <= 3);
assert(src.format.bytesPerPixel == 2 && dest.format.bytesPerPixel == 2);
uint size = src.w;

View File

@ -343,8 +343,11 @@ void Scene::setLogicCondition(int16 label, byte flag) {
// In nancy3 and onwards logic conditions begin from 2000
label -= 2000;
}
_flags.logicConditions[label].flag = flag;
_flags.logicConditions[label].timestamp = g_nancy->getTotalPlayTime();
if (label > kEvNoEvent && (uint)label < 30) {
_flags.logicConditions[label].flag = flag;
_flags.logicConditions[label].timestamp = g_nancy->getTotalPlayTime();
}
}
}
@ -496,7 +499,8 @@ void Scene::synchronize(Common::Serializer &ser) {
ser.syncAsUint16LE(entry._value);
}
} else {
uint16 key, val;
uint16 key = 0;
uint16 val = 0;
for (uint i = 0; i < numSceneCounts; ++i) {
ser.syncAsUint16LE(key);
ser.syncAsUint16LE(val);
@ -526,7 +530,7 @@ void Scene::synchronize(Common::Serializer &ser) {
ser.syncAsByte(numPuzzleData);
if (ser.isSaving()) {
for (auto pd : _puzzleData) {
for (auto &pd : _puzzleData) {
uint32 tag = pd._key;
ser.syncAsUint32LE(tag);
pd._value->synchronize(ser);
@ -534,7 +538,7 @@ void Scene::synchronize(Common::Serializer &ser) {
} else {
clearPuzzleData();
uint32 tag;
uint32 tag = 0;
for (uint i = 0; i < numPuzzleData; ++i) {
ser.syncAsUint32LE(tag);
PuzzleData *pd = getPuzzleData(tag);