aboutsummaryrefslogtreecommitdiff
path: root/engines/scumm
diff options
context:
space:
mode:
authorTorbjörn Andersson2019-01-05 20:09:23 +0100
committerFilippos Karapetis2019-07-14 14:58:19 +0300
commit1e23d43006705a1d25e04d9cc90674044789cb92 (patch)
tree74982033219756724bc69b27cfc962531682b502 /engines/scumm
parent4eef7a42e3f45a18a57674898f5fb5409f6daf5d (diff)
downloadscummvm-rg350-1e23d43006705a1d25e04d9cc90674044789cb92.tar.gz
scummvm-rg350-1e23d43006705a1d25e04d9cc90674044789cb92.tar.bz2
scummvm-rg350-1e23d43006705a1d25e04d9cc90674044789cb92.zip
SCUMM: Silence GCC memset() warnings
Recent GCC versions complain if you memset() a class or struct that contain non-POD data types. Get around that by either initializing the object when created, or by adding a reset() method.
Diffstat (limited to 'engines/scumm')
-rw-r--r--engines/scumm/actor.cpp2
-rw-r--r--engines/scumm/actor.h14
-rw-r--r--engines/scumm/gfx.h12
-rw-r--r--engines/scumm/he/floodfill_he.h7
-rw-r--r--engines/scumm/he/script_v100he.cpp2
-rw-r--r--engines/scumm/he/script_v90he.cpp4
-rw-r--r--engines/scumm/he/sprite_he.cpp9
-rw-r--r--engines/scumm/he/sprite_he.h51
-rw-r--r--engines/scumm/he/wiz_he.cpp4
-rw-r--r--engines/scumm/he/wiz_he.h50
-rw-r--r--engines/scumm/imuse/imuse_internal.h10
-rw-r--r--engines/scumm/imuse/imuse_player.cpp2
-rw-r--r--engines/scumm/imuse_digi/dimuse.cpp6
-rw-r--r--engines/scumm/imuse_digi/dimuse_script.cpp6
-rw-r--r--engines/scumm/imuse_digi/dimuse_track.cpp4
-rw-r--r--engines/scumm/imuse_digi/dimuse_track.h29
-rw-r--r--engines/scumm/scumm.cpp18
17 files changed, 207 insertions, 23 deletions
diff --git a/engines/scumm/actor.cpp b/engines/scumm/actor.cpp
index fdc71602af..48035b5e89 100644
--- a/engines/scumm/actor.cpp
+++ b/engines/scumm/actor.cpp
@@ -159,7 +159,7 @@ void Actor::initActor(int mode) {
memset(_palette, 0, sizeof(_palette));
memset(_sound, 0, sizeof(_sound));
memset(&_cost, 0, sizeof(CostumeData));
- memset(&_walkdata, 0, sizeof(ActorWalkData));
+ _walkdata.reset();
_walkdata.point3.x = 32000;
_walkScript = 0;
}
diff --git a/engines/scumm/actor.h b/engines/scumm/actor.h
index 3556d5b212..02929e3873 100644
--- a/engines/scumm/actor.h
+++ b/engines/scumm/actor.h
@@ -151,6 +151,20 @@ protected:
Common::Point point3;
int32 deltaXFactor, deltaYFactor;
uint16 xfrac, yfrac;
+
+ void reset() {
+ dest.x = dest.y = 0;
+ destbox = 0;
+ destdir = 0;
+ cur.x = cur.y = 0;
+ curbox = 0;
+ next.x = next.y = 0;
+ point3.x = point3.y = 0;
+ deltaXFactor = 0;
+ deltaYFactor = 0;
+ xfrac = 0;
+ yfrac = 0;
+ }
};
diff --git a/engines/scumm/gfx.h b/engines/scumm/gfx.h
index 86913f9e2e..35be19295e 100644
--- a/engines/scumm/gfx.h
+++ b/engines/scumm/gfx.h
@@ -53,6 +53,18 @@ struct CameraData {
int _leftTrigger, _rightTrigger;
byte _follows, _mode;
bool _movingToActor;
+
+ void reset() {
+ _cur.x = _cur.y = 0;
+ _dest.x = _dest.y = 0;
+ _accel.x = _accel.y = 0;
+ _last.x = _last.y = 0;
+ _leftTrigger = 0;
+ _rightTrigger = 0;
+ _follows = 0;
+ _mode = 0;
+ _movingToActor = 0;
+ }
};
/** Virtual screen identifiers */
diff --git a/engines/scumm/he/floodfill_he.h b/engines/scumm/he/floodfill_he.h
index 286bcce4f5..a7f327d452 100644
--- a/engines/scumm/he/floodfill_he.h
+++ b/engines/scumm/he/floodfill_he.h
@@ -32,6 +32,13 @@ struct FloodFillParameters {
int32 x;
int32 y;
int32 flags;
+
+ void reset() {
+ box.top = box.left = box.bottom = box.right = 0;
+ x = 0;
+ y = 0;
+ flags = 0;
+ }
};
struct FloodFillLine {
diff --git a/engines/scumm/he/script_v100he.cpp b/engines/scumm/he/script_v100he.cpp
index 714f431188..53ad81aedb 100644
--- a/engines/scumm/he/script_v100he.cpp
+++ b/engines/scumm/he/script_v100he.cpp
@@ -906,7 +906,7 @@ void ScummEngine_v100he::o100_floodFill() {
switch (subOp) {
case 0:
- memset(&_floodFillParams, 0, sizeof(_floodFillParams));
+ _floodFillParams.reset();
_floodFillParams.box.left = 0;
_floodFillParams.box.top = 0;
_floodFillParams.box.right = 639;
diff --git a/engines/scumm/he/script_v90he.cpp b/engines/scumm/he/script_v90he.cpp
index f63973e3f1..3c2becec45 100644
--- a/engines/scumm/he/script_v90he.cpp
+++ b/engines/scumm/he/script_v90he.cpp
@@ -1486,7 +1486,7 @@ void ScummEngine_v90he::o90_floodFill() {
pop();
break;
case 57:
- memset(&_floodFillParams, 0, sizeof(_floodFillParams));
+ _floodFillParams.reset();
_floodFillParams.box.left = 0;
_floodFillParams.box.top = 0;
_floodFillParams.box.right = 639;
@@ -1630,7 +1630,7 @@ void ScummEngine_v90he::o90_getPolygonOverlap() {
push(0);
} else {
WizPolygon wp;
- memset(&wp, 0, sizeof(wp));
+ wp.reset();
wp.numVerts = n1;
assert(n1 < ARRAYSIZE(wp.vert));
for (int i = 0; i < n1; ++i) {
diff --git a/engines/scumm/he/sprite_he.cpp b/engines/scumm/he/sprite_he.cpp
index e210e0b6b2..9e20ab6c84 100644
--- a/engines/scumm/he/sprite_he.cpp
+++ b/engines/scumm/he/sprite_he.cpp
@@ -1086,8 +1086,13 @@ void Sprite::resetGroup(int spriteGroupId) {
}
void Sprite::resetTables(bool refreshScreen) {
- memset(_spriteTable, 0, (_varNumSprites + 1) * sizeof(SpriteInfo));
- memset(_spriteGroups, 0, (_varNumSpriteGroups + 1) * sizeof(SpriteGroup));
+ for (int i = 0; i < _varNumSprites; i++) {
+ _spriteTable[i].reset();
+ }
+ for (int i = 0; i < _varNumSpriteGroups; i++) {
+ _spriteGroups[i].reset();
+ }
+
for (int curGrp = 1; curGrp < _varNumSpriteGroups; ++curGrp)
resetGroup(curGrp);
diff --git a/engines/scumm/he/sprite_he.h b/engines/scumm/he/sprite_he.h
index 77e527b3ce..bb7f9574c8 100644
--- a/engines/scumm/he/sprite_he.h
+++ b/engines/scumm/he/sprite_he.h
@@ -82,6 +82,43 @@ struct SpriteInfo {
int32 classFlags;
int32 imgFlags;
int32 conditionBits;
+
+ void reset() {
+ id = 0;
+ zorder = 0;
+ flags = 0;
+ image = 0;
+ imageState = 0;
+ group = 0;
+ palette = 0;
+ priority = 0;
+ bbox.top = bbox.left = bbox.bottom = bbox.right = 0;
+ dx = 0;
+ dy = 0;
+ pos.x = pos.y = 0;
+ tx = 0;
+ ty = 0;
+ userValue = 0;
+ curImageState = 0;
+ curImage = 0;
+ imglistNum = 0;
+ shadow = 0;
+ imageStateCount = 0;
+ angle = 0;
+ scale = 0;
+ animProgress = 0;
+ curAngle = 0;
+ curScale = 0;
+ curImgFlags = 0;
+ animIndex = 0;
+ animSpeed = 0;
+ sourceImage = 0;
+ maskImage = 0;
+ zbufferImage = 0;
+ classFlags = 0;
+ imgFlags = 0;
+ conditionBits = 0;
+ }
};
struct SpriteGroup {
@@ -96,6 +133,20 @@ struct SpriteGroup {
int32 scale_x_ratio_div;
int32 scale_y_ratio_mul;
int32 scale_y_ratio_div;
+
+ void reset() {
+ bbox.top = bbox.left = bbox.bottom = bbox.right = 0;
+ priority = 0;
+ flags = 0;
+ tx = 0;
+ ty = 0;
+ image = 0;
+ scaling = 0;
+ scale_x_ratio_mul = 0;
+ scale_x_ratio_div = 0;
+ scale_y_ratio_mul = 0;
+ scale_y_ratio_div = 0;
+ }
};
class ScummEngine_v90he;
diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp
index 2db57022fd..c2cefeaa3b 100644
--- a/engines/scumm/he/wiz_he.cpp
+++ b/engines/scumm/he/wiz_he.cpp
@@ -50,7 +50,7 @@ void Wiz::clearWizBuffer() {
void Wiz::polygonClear() {
for (int i = 0; i < ARRAYSIZE(_polygons); i++) {
if (_polygons[i].flag == 1)
- memset(&_polygons[i], 0, sizeof(WizPolygon));
+ _polygons[i].reset();
}
}
@@ -173,7 +173,7 @@ void Wiz::polygonCalcBoundBox(Common::Point *vert, int numVerts, Common::Rect &b
void Wiz::polygonErase(int fromId, int toId) {
for (int i = 0; i < ARRAYSIZE(_polygons); i++) {
if (_polygons[i].id >= fromId && _polygons[i].id <= toId)
- memset(&_polygons[i], 0, sizeof(WizPolygon));
+ _polygons[i].reset();
}
}
diff --git a/engines/scumm/he/wiz_he.h b/engines/scumm/he/wiz_he.h
index 692ad76db5..a6d99c7df6 100644
--- a/engines/scumm/he/wiz_he.h
+++ b/engines/scumm/he/wiz_he.h
@@ -33,6 +33,16 @@ struct WizPolygon {
int id;
int numVerts;
bool flag;
+
+ void reset() {
+ for (int i = 0; i < ARRAYSIZE(vert); i++) {
+ vert[i].x = vert[i].y = 0;
+ }
+ bound.top = bound.left = bound.bottom = bound.right = 0;
+ id = 0;
+ numVerts = 0;
+ flag = 0;
+ }
};
struct WizImage {
@@ -107,6 +117,46 @@ struct WizParameters {
int spriteGroup;
int conditionBits;
WizImage img;
+
+ void reset() {
+ field_0 = 0;
+ memset(filename, 0, sizeof(filename));
+ box.top = box.left = box.bottom = box.right = 0;
+ processFlags = 0;
+ processMode = 0;
+ field_11C = 0;
+ field_120 = 0;
+ field_124 = 0;
+ field_128 = 0;
+ field_12C = 0;
+ field_130 = 0;
+ field_134 = 0;
+ field_138 = 0;
+ compType = 0;
+ fileWriteMode = 0;
+ angle = 0;
+ scale = 0;
+ polygonId1 = 0;
+ polygonId2 = 0;
+ resDefImgW = 0;
+ resDefImgH = 0;
+ sourceImage = 0;
+ params1 = 0;
+ params2 = 0;
+ memset(remapColor, 0, sizeof(remapColor));
+ memset(remapIndex, 0, sizeof(remapIndex));
+ remapNum = 0;
+ dstResNum = 0;
+ fillColor = 0;
+ memset(&fontProperties, 0, sizeof(FontProperties));
+ memset(&ellipseProperties, 0, sizeof(EllipseProperties));
+ box2.left = box2.top = box2.bottom = box2.right = 0;
+ blendFlags = 0;
+ spriteId = 0;
+ spriteGroup = 0;
+ conditionBits = 0;
+ memset(&img, 0, sizeof(WizImage));
+ }
};
enum WizImageFlags {
diff --git a/engines/scumm/imuse/imuse_internal.h b/engines/scumm/imuse/imuse_internal.h
index 36793b85cc..7aff68ae76 100644
--- a/engines/scumm/imuse/imuse_internal.h
+++ b/engines/scumm/imuse/imuse_internal.h
@@ -106,7 +106,15 @@ struct HookDatas {
int query_param(int param, byte chan);
int set(byte cls, byte value, byte chan);
- HookDatas() { memset(this, 0, sizeof(HookDatas)); }
+ HookDatas() { reset(); }
+ void reset() {
+ _transpose = 0;
+ memset(_jump, 0, sizeof(_jump));
+ memset(_part_onoff, 0, sizeof(_part_onoff));
+ memset(_part_volume, 0, sizeof(_part_volume));
+ memset(_part_program, 0, sizeof(_part_program));
+ memset(_part_transpose, 0, sizeof(_part_transpose));
+ }
};
struct ParameterFader {
diff --git a/engines/scumm/imuse/imuse_player.cpp b/engines/scumm/imuse/imuse_player.cpp
index b4224183ab..7ec557a768 100644
--- a/engines/scumm/imuse/imuse_player.cpp
+++ b/engines/scumm/imuse/imuse_player.cpp
@@ -163,7 +163,7 @@ void Player::clear() {
}
void Player::hook_clear() {
- memset(&_hook, 0, sizeof(_hook));
+ _hook.reset();
}
int Player::start_seq_sound(int sound, bool reset_vars) {
diff --git a/engines/scumm/imuse_digi/dimuse.cpp b/engines/scumm/imuse_digi/dimuse.cpp
index b6955212a9..de5b1634ed 100644
--- a/engines/scumm/imuse_digi/dimuse.cpp
+++ b/engines/scumm/imuse_digi/dimuse.cpp
@@ -55,7 +55,7 @@ IMuseDigital::IMuseDigital(ScummEngine_v7 *scumm, Audio::Mixer *mixer, int fps)
for (int l = 0; l < MAX_DIGITAL_TRACKS + MAX_DIGITAL_FADETRACKS; l++) {
_track[l] = new Track;
assert(_track[l]);
- memset(_track[l], 0, sizeof(Track));
+ _track[l]->reset();
_track[l]->trackId = l;
}
_vm->getTimerManager()->installTimerProc(timer_handler, 1000000 / _callbackFps, this, "IMuseDigital");
@@ -147,7 +147,7 @@ void IMuseDigital::saveLoadEarly(Common::Serializer &s) {
for (int l = 0; l < MAX_DIGITAL_TRACKS + MAX_DIGITAL_FADETRACKS; l++) {
Track *track = _track[l];
if (s.isLoading()) {
- memset(track, 0, sizeof(Track));
+ track->reset();
}
syncWithSerializer(s, *track);
if (s.isLoading()) {
@@ -210,7 +210,7 @@ void IMuseDigital::callback() {
// mark it as unused.
if (!track->stream) {
if (!_mixer->isSoundHandleActive(track->mixChanHandle))
- memset(track, 0, sizeof(Track));
+ track->reset();
continue;
}
diff --git a/engines/scumm/imuse_digi/dimuse_script.cpp b/engines/scumm/imuse_digi/dimuse_script.cpp
index 3913a1a1f0..8d1e7a4bfd 100644
--- a/engines/scumm/imuse_digi/dimuse_script.cpp
+++ b/engines/scumm/imuse_digi/dimuse_script.cpp
@@ -180,7 +180,7 @@ void IMuseDigital::flushTrack(Track *track) {
}
if (!_mixer->isSoundHandleActive(track->mixChanHandle)) {
- memset(track, 0, sizeof(Track));
+ track->reset();
}
}
@@ -191,7 +191,7 @@ void IMuseDigital::flushTracks() {
Track *track = _track[l];
if (track->used && track->toBeRemoved && !_mixer->isSoundHandleActive(track->mixChanHandle)) {
debug(5, "flushTracks() - soundId:%d", track->soundId);
- memset(track, 0, sizeof(Track));
+ track->reset();
}
}
}
@@ -438,7 +438,7 @@ void IMuseDigital::stopAllSounds() {
}
// Mark the track as unused
- memset(track, 0, sizeof(Track));
+ track->reset();
}
}
}
diff --git a/engines/scumm/imuse_digi/dimuse_track.cpp b/engines/scumm/imuse_digi/dimuse_track.cpp
index 28ad64670c..92ef823db1 100644
--- a/engines/scumm/imuse_digi/dimuse_track.cpp
+++ b/engines/scumm/imuse_digi/dimuse_track.cpp
@@ -67,7 +67,7 @@ int IMuseDigital::allocSlot(int priority) {
}
// Mark it as unused
- memset(track, 0, sizeof(Track));
+ track->reset();
debug(5, "IMuseDigital::allocSlot(): Removed sound %d from track %d", _track[trackId]->soundId, trackId);
} else {
@@ -93,7 +93,7 @@ void IMuseDigital::startSound(int soundId, const char *soundName, int soundType,
Track *track = _track[l];
// Reset the track
- memset(track, 0, sizeof(Track));
+ track->reset();
track->pan = 64;
track->vol = volume * 1000;
diff --git a/engines/scumm/imuse_digi/dimuse_track.h b/engines/scumm/imuse_digi/dimuse_track.h
index ef0a8adb21..9f62fe95b9 100644
--- a/engines/scumm/imuse_digi/dimuse_track.h
+++ b/engines/scumm/imuse_digi/dimuse_track.h
@@ -75,7 +75,34 @@ struct Track {
Audio::SoundHandle mixChanHandle; // sound mixer's channel handle
Audio::QueuingAudioStream *stream; // sound mixer's audio stream handle for *.la1 and *.bun
- Track() : soundId(-1), used(false), stream(NULL) {
+ Track() : soundId(-1), used(false), stream(nullptr) {
+ }
+
+ void reset() {
+ trackId = 0;
+ pan = 0;
+ vol = 0;
+ volFadeDest = 0;
+ volFadeStep = 0;
+ volFadeDelay = 0;
+ volFadeUsed = false;
+ soundId = 0;
+ memset(soundName, 0, sizeof(soundName));
+ used = false;
+ toBeRemoved = false;
+ souStreamUsed = false;
+ sndDataExtComp = false;
+ soundPriority = 0;
+ regionOffset = 0;
+ dataOffset = 0;
+ curRegion = 0;
+ curHookId = 0;
+ soundType = 0;
+ feedSize = 0;
+ dataMod12Bit = 0;
+ mixerFlags = 0;
+ soundDesc = nullptr;
+ stream = nullptr;
}
int getPan() const { return (pan != 64) ? 2 * pan - 127 : 0; }
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index 8d781a0ef1..1102890650 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -245,7 +245,7 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr)
_screenHeight = 0;
_screenWidth = 0;
memset(_virtscr, 0, sizeof(_virtscr));
- memset(&camera, 0, sizeof(CameraData));
+ camera.reset();
memset(_colorCycle, 0, sizeof(_colorCycle));
memset(_colorUsedByCycle, 0, sizeof(_colorUsedByCycle));
_ENCD_offs = 0;
@@ -331,8 +331,18 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr)
_townsPaletteFlags = 0;
_townsClearLayerFlag = 1;
_townsActiveLayerFlags = 3;
- memset(&_curStringRect, -1, sizeof(Common::Rect));
- memset(&_cyclRects, 0, 16 * sizeof(Common::Rect));
+ _curStringRect.top = -1;
+ _curStringRect.left = -1;
+ _curStringRect.bottom = -1;
+ _curStringRect.right = -1;
+
+ for (int i = 0; i < ARRAYSIZE(_cyclRects); i++) {
+ _cyclRects[i].top = 0;
+ _cyclRects[i].left = 0;
+ _cyclRects[i].bottom = 0;
+ _cyclRects[i].right = 0;
+ }
+
_numCyclRects = 0;
#endif
@@ -1781,7 +1791,7 @@ void ScummEngine_v90he::resetScumm() {
_hePaletteNum = 0;
_sprite->resetTables(0);
- memset(&_wizParams, 0, sizeof(_wizParams));
+ _wizParams.reset();
if (_game.heversion >= 98)
_logicHE = LogicHE::makeLogicHE(this);