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.
This commit is contained in:
D G Turner 2019-05-07 23:16:50 +01:00
parent 74936020ec
commit 1c37569ce2
2 changed files with 7 additions and 3 deletions

View File

@ -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);
}

View File

@ -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);