diff options
Diffstat (limited to 'engines/lab')
-rw-r--r-- | engines/lab/lab.h | 2 | ||||
-rw-r--r-- | engines/lab/processroom.cpp | 43 | ||||
-rw-r--r-- | engines/lab/resource.cpp | 17 |
3 files changed, 30 insertions, 32 deletions
diff --git a/engines/lab/lab.h b/engines/lab/lab.h index db3ae2a716..ce8bae464b 100644 --- a/engines/lab/lab.h +++ b/engines/lab/lab.h @@ -87,7 +87,7 @@ struct CrumbData { #define MAX_CRUMBS 128 typedef CloseData *CloseDataPtr; -typedef Common::List<Rule *> RuleList; +typedef Common::List<Rule> RuleList; // Direction defines #define NORTH 0 diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp index 2cc002ba6f..76592875c9 100644 --- a/engines/lab/processroom.cpp +++ b/engines/lab/processroom.cpp @@ -516,13 +516,13 @@ bool LabEngine::doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr closeP } for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) { - if (((*rule)->_ruleType == ACTION) && - (((*rule)->_param1 == action) || (((*rule)->_param1 == 0) && allowDefaults))) { - if ((((*rule)->_param2 == closePtr->_closeUpType) || - (((*rule)->_param2 == 0) && allowDefaults)) || - ((action == 1) && ((*rule)->_param2 == (-closePtr->_closeUpType)))) { - if (checkConditions((*rule)->_condition)) { - doActions((*rule)->_actionList, setCloseList); + if ((rule->_ruleType == ACTION) && + ((rule->_param1 == action) || ((rule->_param1 == 0) && allowDefaults))) { + if (((rule->_param2 == closePtr->_closeUpType) || + ((rule->_param2 == 0) && allowDefaults)) || + ((action == 1) && (rule->_param2 == -closePtr->_closeUpType))) { + if (checkConditions(rule->_condition)) { + doActions(rule->_actionList, setCloseList); return true; } } @@ -564,11 +564,11 @@ bool LabEngine::doOperateRuleSub(int16 itemNum, int16 roomNum, CloseDataPtr clos } for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) { - if (((*rule)->_ruleType == OPERATE) && - (((*rule)->_param1 == itemNum) || (((*rule)->_param1 == 0) && allowDefaults)) && - (((*rule)->_param2 == closePtr->_closeUpType) || (((*rule)->_param2 == 0) && allowDefaults))) { - if (checkConditions((*rule)->_condition)) { - doActions((*rule)->_actionList, setCloseList); + if ((rule->_ruleType == OPERATE) && + ((rule->_param1 == itemNum) || ((rule->_param1 == 0) && allowDefaults)) && + ((rule->_param2 == closePtr->_closeUpType) || ((rule->_param2 == 0) && allowDefaults))) { + if (checkConditions(rule->_condition)) { + doActions(rule->_actionList, setCloseList); return true; } } @@ -609,8 +609,7 @@ bool LabEngine::doOperateRule(Common::Point pos, int16 ItemNum, CloseDataPtr *cl bool LabEngine::doGoForward(CloseDataPtr *closePtrList) { RuleList *rules = _rooms[_roomNum]._rules; - for (RuleList::iterator ruleIter = rules->begin(); ruleIter != rules->end(); ++ruleIter) { - Rule *rule = *ruleIter; + 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, closePtrList); @@ -629,11 +628,11 @@ bool LabEngine::doTurn(uint16 from, uint16 to, CloseDataPtr *closePtrList) { RuleList *rules = _rooms[_roomNum]._rules; for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) { - if (((*rule)->_ruleType == TURN) || - (((*rule)->_ruleType == TURNFROMTO) && - ((*rule)->_param1 == from) && ((*rule)->_param2 == to))) { - if (checkConditions((*rule)->_condition)) { - doActions((*rule)->_actionList, closePtrList); + if ((rule->_ruleType == TURN) || + ((rule->_ruleType == TURNFROMTO) && + (rule->_param1 == from) && (rule->_param2 == to))) { + if (checkConditions(rule->_condition)) { + doActions(rule->_actionList, closePtrList); return true; } } @@ -645,9 +644,9 @@ bool LabEngine::doTurn(uint16 from, uint16 to, CloseDataPtr *closePtrList) { bool LabEngine::doMainView(CloseDataPtr *closePtrList) { RuleList *rules = _rooms[_roomNum]._rules; for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) { - if ((*rule)->_ruleType == GOMAINVIEW) { - if (checkConditions((*rule)->_condition)) { - doActions((*rule)->_actionList, closePtrList); + if (rule->_ruleType == GOMAINVIEW) { + if (checkConditions(rule->_condition)) { + doActions(rule->_actionList, closePtrList); return true; } } diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp index a679899acc..311f04659c 100644 --- a/engines/lab/resource.cpp +++ b/engines/lab/resource.cpp @@ -264,12 +264,12 @@ RuleList *Resource::readRule(Common::File *file) { c = file->readByte(); if (c == 1) { - Rule *rule = new Rule(); - rule->_ruleType = file->readSint16LE(); - rule->_param1 = file->readSint16LE(); - rule->_param2 = file->readSint16LE(); - rule->_condition = readConditions(file); - rule->_actionList = readAction(file); + Rule rule; + rule._ruleType = file->readSint16LE(); + rule._param1 = file->readSint16LE(); + rule._param2 = file->readSint16LE(); + rule._condition = readConditions(file); + rule._actionList = readAction(file); rules->push_back(rule); } } while (c == 1); @@ -282,9 +282,8 @@ void Resource::freeRule(RuleList *ruleList) { return; for (RuleList::iterator rule = ruleList->begin(); rule != ruleList->end(); ++rule) { - freeAction((*rule)->_actionList); - delete[](*rule)->_condition; - delete *rule; + freeAction(rule->_actionList); + delete[] rule->_condition; } delete ruleList; |