Skip to content

Commit

Permalink
AGI: Fix Remaining GCC Compiler Warnings
Browse files Browse the repository at this point in the history
These were the remaining memset on non-trivial structure warnings.
  • Loading branch information
digitall committed Aug 25, 2019
1 parent 482f835 commit 50c5177
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 16 deletions.
16 changes: 8 additions & 8 deletions engines/agi/agi.cpp
Expand Up @@ -91,14 +91,14 @@ int AgiEngine::agiInit() {

// clear all resources and events
for (i = 0; i < MAX_DIRECTORY_ENTRIES; i++) {
memset(&_game.views[i], 0, sizeof(struct AgiView));
memset(&_game.pictures[i], 0, sizeof(struct AgiPicture));
memset(&_game.logics[i], 0, sizeof(struct AgiLogic));
memset(&_game.sounds[i], 0, sizeof(class AgiSound *)); // _game.sounds contains pointers now
memset(&_game.dirView[i], 0, sizeof(struct AgiDir));
memset(&_game.dirPic[i], 0, sizeof(struct AgiDir));
memset(&_game.dirLogic[i], 0, sizeof(struct AgiDir));
memset(&_game.dirSound[i], 0, sizeof(struct AgiDir));
_game.views[i].reset();
_game.pictures[i].reset();
_game.logics[i].reset();
_game.sounds[i] = nullptr; // _game.sounds contains pointers now
_game.dirView[i].reset();
_game.dirPic[i].reset();
_game.dirLogic[i].reset();
_game.dirSound[i].reset();
}

// clear view table
Expand Down
10 changes: 9 additions & 1 deletion engines/agi/agi.h
Expand Up @@ -375,7 +375,15 @@ struct AgiDir {
// 0x40 = was compressed
uint8 flags;

AgiDir() : volume(0), offset(0), len(0), clen(0), flags(0) {}
void reset() {
volume = 0;
offset = 0;
len = 0;
clen = 0;
flags = 0;
}

AgiDir() { reset(); }
};

struct AgiBlock {
Expand Down
11 changes: 10 additions & 1 deletion engines/agi/logic.h
Expand Up @@ -36,7 +36,16 @@ struct AgiLogic {
int numTexts; /**< number of messages */
const char **texts; /**< message list */

AgiLogic() : data(nullptr), size(0), sIP(0), cIP(0), numTexts(0), texts(nullptr) {}
void reset() {
data = nullptr;
size = 0;
sIP = 0;
cIP = 0;
numTexts = 0;
texts = nullptr;
}

AgiLogic() { reset(); }
};

} // End of namespace Agi
Expand Down
7 changes: 6 additions & 1 deletion engines/agi/picture.h
Expand Up @@ -35,7 +35,12 @@ struct AgiPicture {
uint32 flen; /**< size of raw data */
uint8 *rdata; /**< raw vector image data */

AgiPicture() : flen(0), rdata(nullptr) {}
void reset() {
flen = 0;
rdata = nullptr;
}

AgiPicture() { reset(); }
};

// AGI picture version
Expand Down
8 changes: 4 additions & 4 deletions engines/agi/preagi.cpp
Expand Up @@ -82,10 +82,10 @@ void PreAgiEngine::initialize() {

// clear all resources and events
for (int i = 0; i < MAX_DIRECTORY_ENTRIES; i++) {
memset(&_game.pictures[i], 0, sizeof(struct AgiPicture));
memset(&_game.sounds[i], 0, sizeof(class AgiSound *)); // _game.sounds contains pointers now
memset(&_game.dirPic[i], 0, sizeof(struct AgiDir));
memset(&_game.dirSound[i], 0, sizeof(struct AgiDir));
_game.pictures[i].reset();
_game.sounds[i] = nullptr; // _game.sounds contains pointers now
_game.dirPic[i].reset();
_game.dirSound[i].reset();
}
}

Expand Down
4 changes: 3 additions & 1 deletion engines/agi/view.h
Expand Up @@ -48,13 +48,15 @@ struct AgiView {
int16 loopCount;
AgiViewLoop *loop;

AgiView() {
void reset() {
headerStepSize = 0;
headerCycleTime = 0;
description = nullptr;
loopCount = 0;
loop = nullptr;
}

AgiView() { reset(); }
};

enum MotionType {
Expand Down

0 comments on commit 50c5177

Please sign in to comment.