Skip to content

Commit

Permalink
SCUMM: Initialize data to avoid Valgrind warnings on saving
Browse files Browse the repository at this point in the history
This is enough to silence all the Valgrind warnings I got when saving in
The Dig.
  • Loading branch information
Torbjörn Andersson committed Nov 11, 2024
1 parent cc0e753 commit 5f375e4
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 5 deletions.
6 changes: 3 additions & 3 deletions engines/scumm/actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ struct CostumeData {
uint16 frame[16];

/* HE specific */
uint16 heJumpOffsetTable[16];
uint16 heJumpCountTable[16];
uint32 heCondMaskTable[16];
uint16 heJumpOffsetTable[16] = {};
uint16 heJumpCountTable[16] = {};
uint32 heCondMaskTable[16] = {};

void reset() {
animCounter = 0;
Expand Down
8 changes: 8 additions & 0 deletions engines/scumm/imuse_digi/dimuse_fades.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,14 @@ void IMuseDigiFadesHandler::clearAllFades() {
for (int l = 0; l < DIMUSE_MAX_FADES; l++) {
_fades[l].status = 0;
_fades[l].sound = 0;
_fades[l].param = 0;
_fades[l].currentVal = 0;
_fades[l].counter = 0;
_fades[l].length = 0;
_fades[l].slope = 0;
_fades[l].slopeMod = 0;
_fades[l].modOvfloCounter = 0;
_fades[l].nudge = 0;
}
_fadesOn = 0;
}
Expand Down
2 changes: 1 addition & 1 deletion engines/scumm/imuse_digi/dimuse_files.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class IMuseDigiFilesHandler {
ScummEngine_v7 *_vm;
Common::Mutex _mutex;
IMuseDigiSndBuffer _soundBuffers[4];
char _currentSpeechFilename[60];
char _currentSpeechFilename[60] = {};
ScummFile *_ftSpeechFile;
char _ftSpeechFilename[160];
int _ftSpeechSubFileOffset;
Expand Down
11 changes: 11 additions & 0 deletions engines/scumm/imuse_digi/dimuse_tracks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ int IMuseDigital::tracksInit() {
_tracks[l].dispatchPtr = dispatchGetDispatchByTrackId(l);
_tracks[l].dispatchPtr->trackPtr = &_tracks[l];
_tracks[l].soundId = 0;
_tracks[l].group = 0;
_tracks[l].marker = 0;
_tracks[l].priority = 0;
_tracks[l].vol = 0;
_tracks[l].effVol = 0;
_tracks[l].pan = 0;
_tracks[l].detune = 0;
_tracks[l].transpose = 0;
_tracks[l].pitchShift = 0;
_tracks[l].mailbox = 0;
_tracks[l].jumpHook = 0;
_tracks[l].syncSize_0 = 0;
_tracks[l].syncSize_1 = 0;
_tracks[l].syncSize_2 = 0;
Expand Down
26 changes: 26 additions & 0 deletions engines/scumm/imuse_digi/dimuse_triggers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,34 @@ int IMuseDigiTriggersHandler::deinit() {
int IMuseDigiTriggersHandler::clearAllTriggers() {
for (int l = 0; l < DIMUSE_MAX_TRIGGERS; l++) {
_trigs[l].sound = 0;
memset(_trigs[l].text, 0, sizeof(_trigs[l].text));
_trigs[l].opcode = 0;
_trigs[l].a = 0;
_trigs[l].b = 0;
_trigs[l].c = 0;
_trigs[l].d = 0;
_trigs[l].e = 0;
_trigs[l].f = 0;
_trigs[l].g = 0;
_trigs[l].h = 0;
_trigs[l].i = 0;
_trigs[l].j = 0;
_trigs[l].clearLater = 0;
}

for (int l = 0; l < DIMUSE_MAX_DEFERS; l++) {
_defers[l].counter = 0;
_defers[l].opcode = 0;
_defers[l].a = 0;
_defers[l].b = 0;
_defers[l].c = 0;
_defers[l].d = 0;
_defers[l].e = 0;
_defers[l].f = 0;
_defers[l].g = 0;
_defers[l].h = 0;
_defers[l].i = 0;
_defers[l].j = 0;
}
_defersOn = 0;
_midProcessing = 0;
Expand Down
2 changes: 1 addition & 1 deletion engines/scumm/saveload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ struct SaveGameHeader {
uint32 type;
uint32 size;
uint32 ver;
char name[32];
char name[32] = {};
};

struct SaveInfoSection {
Expand Down

0 comments on commit 5f375e4

Please sign in to comment.