diff options
author | Torbjörn Andersson | 2019-01-05 20:09:23 +0100 |
---|---|---|
committer | Filippos Karapetis | 2019-07-14 14:58:19 +0300 |
commit | 1e23d43006705a1d25e04d9cc90674044789cb92 (patch) | |
tree | 74982033219756724bc69b27cfc962531682b502 /engines/scumm/he | |
parent | 4eef7a42e3f45a18a57674898f5fb5409f6daf5d (diff) | |
download | scummvm-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/he')
-rw-r--r-- | engines/scumm/he/floodfill_he.h | 7 | ||||
-rw-r--r-- | engines/scumm/he/script_v100he.cpp | 2 | ||||
-rw-r--r-- | engines/scumm/he/script_v90he.cpp | 4 | ||||
-rw-r--r-- | engines/scumm/he/sprite_he.cpp | 9 | ||||
-rw-r--r-- | engines/scumm/he/sprite_he.h | 51 | ||||
-rw-r--r-- | engines/scumm/he/wiz_he.cpp | 4 | ||||
-rw-r--r-- | engines/scumm/he/wiz_he.h | 50 |
7 files changed, 120 insertions, 7 deletions
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 { |