LAB: Fix several cppcheck errors

This commit is contained in:
Strangerke 2015-11-27 21:52:31 +01:00 committed by Willem Jan Palenstijn
parent 93e3ba9edd
commit b76a624c9a
7 changed files with 26 additions and 32 deletions

View file

@ -99,7 +99,7 @@ static void freeRoom(uint16 RMarker) {
Rooms[RoomNum].WestView = NULL;
RuleList *rules = Rooms[RoomNum].rules;
for (RuleList::iterator rule = rules->begin(); rule != rules->end(); rule++)
for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule)
delete *rule;
Rooms[RoomNum].rules->clear();
delete Rooms[RoomNum].rules;
@ -119,28 +119,25 @@ static void freeRoom(uint16 RMarker) {
/* Gets a chunk of memory from the buffer. */
/*****************************************************************************/
static void *getCurMem(uint16 Size) {
uint16 counter;
void *Ptr, *Start0, *Start1, *End0, *End1;
if (((int32) Size) > MemLeftInBuffer) {
MemPlace = RoomBuffer;
MemLeftInBuffer = ROOMBUFFERSIZE;
NextMemPlace = NULL;
}
Ptr = MemPlace;
void *Ptr = MemPlace;
MemPlace = (char *)MemPlace + Size;
MemLeftInBuffer -= Size;
if (MemPlace > NextMemPlace) {
NextMemPlace = NULL;
for (counter = 0; counter < MAXMARKERS; counter++) {
for (uint16 counter = 0; counter < MAXMARKERS; counter++) {
if (RoomMarkers[counter].RoomNum != EMPTYROOM) {
Start0 = RoomMarkers[counter].Start0;
Start1 = RoomMarkers[counter].Start1;
End0 = RoomMarkers[counter].End0;
End1 = RoomMarkers[counter].End1;
void *Start0 = RoomMarkers[counter].Start0;
void *Start1 = RoomMarkers[counter].Start1;
void *End0 = RoomMarkers[counter].End0;
void *End1 = RoomMarkers[counter].End1;
if (((Start0 >= Ptr) && (Start0 < MemPlace)) ||
((End0 >= Ptr) && (End0 < MemPlace)) ||

View file

@ -186,7 +186,7 @@ SaveStateList LabMetaEngine::listSaves(const char *target) const {
SaveStateList saveList;
for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); file++) {
for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
// Obtain the last 3 digits of the filename, since they correspond to the save slot
int slotNum = atoi(file->c_str() + file->size() - 3);

View file

@ -1307,10 +1307,8 @@ from_crumbs:
void LabEngine::go() {
bool mem, dointro = false;
uint16 counter;
dointro = true;
bool dointro = true;
IsHiRes = ((getFeatures() & GF_LOWRES) == 0);
@ -1320,6 +1318,8 @@ void LabEngine::go() {
else
warning("Running in LowRes mode");
#endif
bool mem = false;
if (initBuffer(BUFFERSIZE, true)) {
mem = true;
} else {
@ -1345,7 +1345,6 @@ void LabEngine::go() {
if (dointro && mem) {
Intro intro;
intro.introSequence();
} else
DoBlack = true;

View file

@ -64,10 +64,10 @@ Gadget *createButton(uint16 x, uint16 y, uint16 id, uint16 key, Image *im, Image
void freeButtonList(Gadget *gptrlist) {
Gadget *gptr, *next = gptrlist;
Gadget *next = gptrlist;
while (next) {
gptr = next;
Gadget *gptr = next;
next = next->NextGadget;
free(gptr);

View file

@ -619,7 +619,7 @@ static bool doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr LCPtr, Clo
rules = Rooms[roomNum].rules;
}
for (RuleList::iterator rule = rules->begin(); rule != rules->end(); rule++) {
for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
if (((*rule)->RuleType == ACTION) &&
(((*rule)->Param1 == action) || (((*rule)->Param1 == 0) && AllowDefaults))) {
if ((((*rule)->Param2 == LCPtr->CloseUpType) ||
@ -676,7 +676,7 @@ static bool doOperateRuleSub(int16 ItemNum, int16 roomNum, CloseDataPtr LCPtr, C
rules = Rooms[roomNum].rules;
}
for (RuleList::iterator rule = rules->begin(); rule != rules->end(); rule++) {
for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
if (((*rule)->RuleType == OPERATE) &&
(((*rule)->Param1 == ItemNum) || (((*rule)->Param1 == 0) && AllowDefaults)) &&
(((*rule)->Param2 == LCPtr->CloseUpType) || (((*rule)->Param2 == 0) && AllowDefaults))) {
@ -731,7 +731,7 @@ bool doOperateRule(int16 x, int16 y, int16 ItemNum, CloseDataPtr *LCPtr) {
bool doGoForward(CloseDataPtr *LCPtr) {
RuleList *rules = Rooms[RoomNum].rules;
for (RuleList::iterator rule = rules->begin(); rule != rules->end(); rule++) {
for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
if (((*rule)->RuleType == GOFORWARD) && ((*rule)->Param1 == (Direction + 1))) {
if (checkConditions((*rule)->Condition)) {
doActions((*rule)->ActionList, LCPtr);
@ -752,7 +752,7 @@ bool doTurn(uint16 from, uint16 to, CloseDataPtr *LCPtr) {
RuleList *rules = Rooms[RoomNum].rules;
for (RuleList::iterator rule = rules->begin(); rule != rules->end(); rule++) {
for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
if (((*rule)->RuleType == TURN) ||
(((*rule)->RuleType == TURNFROMTO) &&
((*rule)->Param1 == from) && ((*rule)->Param2 == to))) {
@ -771,7 +771,7 @@ bool doTurn(uint16 from, uint16 to, CloseDataPtr *LCPtr) {
/*****************************************************************************/
bool doMainView(CloseDataPtr *LCPtr) {
RuleList *rules = Rooms[RoomNum].rules;
for (RuleList::iterator rule = rules->begin(); rule != rules->end(); rule++) {
for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
if ((*rule)->RuleType == GOMAINVIEW) {
if (checkConditions((*rule)->Condition)) {
doActions((*rule)->ActionList, LCPtr);

View file

@ -373,7 +373,6 @@ static void doTileScroll(uint16 col, uint16 row, uint16 scrolltype) {
/* Changes the combination number of one of the slots */
/*****************************************************************************/
static void changeTile(uint16 col, uint16 row) {
bool check;
int16 scrolltype = -1;
if (row > 0) {
@ -417,7 +416,7 @@ static void changeTile(uint16 col, uint16 row) {
return;
}
check = true;
bool check = true;
row = 0;
col = 0;

View file

@ -82,13 +82,10 @@ bool LabEngine::WSDL_HasNextChar() {
}
void LabEngine::WSDL_ProcessInput(bool can_delay) {
int n;
int lastMouseAtEdge;
int flags = 0;
Common::Event event;
if (1 /*!g_IgnoreProcessInput*/) {
int flags = 0;
while (g_system->getEventManager()->pollEvent(event)) {
switch (event.type) {
case Common::EVENT_RBUTTONDOWN:
@ -101,8 +98,8 @@ void LabEngine::WSDL_ProcessInput(bool can_delay) {
mouseHandler(flags, _mouseX, _mouseY);
break;
case Common::EVENT_MOUSEMOVE:
lastMouseAtEdge = _mouseAtEdge;
case Common::EVENT_MOUSEMOVE: {
int lastMouseAtEdge = _mouseAtEdge;
_mouseAtEdge = false;
_mouseX = event.mouse.x;
if (event.mouse.x <= 0) {
@ -127,6 +124,7 @@ void LabEngine::WSDL_ProcessInput(bool can_delay) {
if (!lastMouseAtEdge || !_mouseAtEdge)
mouseHandler(1, _mouseX, _mouseY);
}
break;
case Common::EVENT_KEYDOWN:
@ -143,14 +141,15 @@ void LabEngine::WSDL_ProcessInput(bool can_delay) {
//saveSettings();
break;
default:
n = ((((unsigned int)((_nextKeyIn + 1) >> 31) >> 26) + (byte)_nextKeyIn + 1) & 0x3F)
default: {
int n = ((((unsigned int)((_nextKeyIn + 1) >> 31) >> 26) + (byte)_nextKeyIn + 1) & 0x3F)
- ((unsigned int)((_nextKeyIn + 1) >> 31) >> 26);
if (n != _nextKeyOut) {
_keyBuf[_nextKeyIn] = event.kbd.keycode;
_nextKeyIn = n;
}
}
}
break;
case Common::EVENT_QUIT: