From 1c37569ce23ec053a683c8ab99ff40bbcaf5086d Mon Sep 17 00:00:00 2001 From: D G Turner Date: Tue, 7 May 2019 23:16:50 +0100 Subject: QUEEN: Fix GCC Compiler Warnings These are further warnings of the use of memset to clear a non-trivial structure / class. Since it is trivial to add a default constructor to these to initialise them instead, the memset calls can be removed. --- engines/queen/grid.cpp | 6 +++--- engines/queen/structs.h | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/engines/queen/grid.cpp b/engines/queen/grid.cpp index 467f341c0b..01a3716376 100644 --- a/engines/queen/grid.cpp +++ b/engines/queen/grid.cpp @@ -54,11 +54,11 @@ void Grid::readDataFrom(uint16 numObjects, uint16 numRooms, byte *&ptr) { _objMax[0] = 0; _areaMax[0] = 0; - memset(&_area[0], 0, sizeof(Area) * MAX_AREAS_NUMBER); + // _area[0][] cleared by default constructor for (i = 1; i <= _numRoomAreas; i++) { _objMax[i] = (int16)READ_BE_INT16(ptr); ptr += 2; _areaMax[i] = (int16)READ_BE_INT16(ptr); ptr += 2; - memset(&_area[i][0], 0, sizeof(Area)); + // _area[i][0] cleared by default constructor for (j = 1; j <= _areaMax[i]; j++) { assert(j < MAX_AREAS_NUMBER); _area[i][j].readFromBE(ptr); @@ -66,7 +66,7 @@ void Grid::readDataFrom(uint16 numObjects, uint16 numRooms, byte *&ptr) { } _objectBox = new Box[numObjects + 1]; - memset(&_objectBox[0], 0, sizeof(Box)); + // _objectBox[0] cleared by default constructor for (i = 1; i <= numObjects; i++) { _objectBox[i].readFromBE(ptr); } diff --git a/engines/queen/structs.h b/engines/queen/structs.h index 4f413d8c6d..4af75f39fa 100644 --- a/engines/queen/structs.h +++ b/engines/queen/structs.h @@ -85,6 +85,10 @@ struct Area { //! entry in ObjectData, object lying in this area uint16 object; + Area() + : mapNeighbors(0), bottomScaleFactor(0), topScaleFactor(0), object(0) { + } + void readFromBE(byte *&ptr) { mapNeighbors = (int16)READ_BE_UINT16(ptr); ptr += 2; box.readFromBE(ptr); -- cgit v1.2.3