aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/lab/console.cpp6
-rw-r--r--engines/lab/processroom.cpp20
-rw-r--r--engines/lab/processroom.h2
-rw-r--r--engines/lab/resource.cpp16
-rw-r--r--engines/lab/resource.h2
5 files changed, 19 insertions, 27 deletions
diff --git a/engines/lab/console.cpp b/engines/lab/console.cpp
index 936f91f51c..31b52da0ba 100644
--- a/engines/lab/console.cpp
+++ b/engines/lab/console.cpp
@@ -60,7 +60,7 @@ bool Console::Cmd_DumpSceneResources(int argc, const char **argv) {
int scene = atoi(argv[1]);
_vm->_resource->readViews(scene);
RoomData *roomData = &_vm->_rooms[scene];
- RuleList *rules = roomData->_rules;
+ RuleList &rules = roomData->_rules;
const char *transitions[] = { "None", "Wipe", "ScrollWipe", "ScrollBlack", "ScrollBounce", "Transporter", "ReadFirstFrame", "ReadNextFrame" };
const char *ruleTypes[] = { "None", "Action", "Operate", "Go forward", "Conditions", "Turn", "Go main view", "Turn from to" };
const char *directions[] = { "", "North", "South", "East", "West" };
@@ -76,7 +76,7 @@ bool Console::Cmd_DumpSceneResources(int argc, const char **argv) {
debugPrintf("Script:\n");
- for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
+ for (RuleList::iterator rule = rules.begin(); rule != rules.end(); ++rule) {
debugPrintf("Rule type: %s", ruleTypes[rule->_ruleType]);
if (rule->_ruleType == kRuleTypeAction || rule->_ruleType == kRuleTypeOperate)
debugPrintf(" (item %d, closeup %d)", rule->_param1, rule->_param2);
@@ -109,7 +109,7 @@ bool Console::Cmd_FindAction(int argc, const char **argv) {
for (int i = 1; i <= _vm->_manyRooms; i++) {
_vm->_resource->readViews(i);
- for (RuleList::iterator rule = _vm->_rooms[i]._rules->begin(); rule != _vm->_rooms[i]._rules->end(); ++rule) {
+ for (RuleList::iterator rule = _vm->_rooms[i]._rules.begin(); rule != _vm->_rooms[i]._rules.end(); ++rule) {
Common::List<Action>::iterator action;
for (action = rule->_actionList.begin(); action != rule->_actionList.end(); ++action) {
if (action->_actionType == actionId &&
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index b9de824612..e49d2acd02 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -482,11 +482,11 @@ bool LabEngine::doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr closeP
action++;
if (closePtr) {
- RuleList *rules = _rooms[_roomNum]._rules;
+ RuleList *rules = &(_rooms[_roomNum]._rules);
if (!rules && (roomNum == 0)) {
_resource->readViews(roomNum);
- rules = _rooms[roomNum]._rules;
+ rules = &(_rooms[roomNum]._rules);
}
for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
@@ -530,11 +530,11 @@ bool LabEngine::doActionRule(Common::Point pos, int16 action, int16 roomNum, Clo
bool LabEngine::doOperateRuleSub(int16 itemNum, int16 roomNum, CloseDataPtr closePtr, CloseDataPtr *setCloseList, bool allowDefaults) {
if (closePtr)
if (closePtr->_closeUpType > 0) {
- RuleList *rules = _rooms[roomNum]._rules;
+ RuleList *rules = &(_rooms[roomNum]._rules);
if (!rules && (roomNum == 0)) {
_resource->readViews(roomNum);
- rules = _rooms[roomNum]._rules;
+ rules = &(_rooms[roomNum]._rules);
}
for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
@@ -581,9 +581,9 @@ bool LabEngine::doOperateRule(Common::Point pos, int16 ItemNum, CloseDataPtr *cl
}
bool LabEngine::doGoForward(CloseDataPtr *closePtrList) {
- RuleList *rules = _rooms[_roomNum]._rules;
+ 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 == kRuleTypeGoForward) && (rule->_param1 == (_direction + 1))) {
if (checkConditions(rule->_condition)) {
doActions(rule->_actionList, closePtrList);
@@ -599,9 +599,9 @@ bool LabEngine::doTurn(uint16 from, uint16 to, CloseDataPtr *closePtrList) {
from++;
to++;
- RuleList *rules = _rooms[_roomNum]._rules;
+ 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 == kRuleTypeTurn) ||
((rule->_ruleType == kRuleTypeTurnFromTo) &&
(rule->_param1 == from) && (rule->_param2 == to))) {
@@ -616,8 +616,8 @@ 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) {
+ RuleList &rules = _rooms[_roomNum]._rules;
+ for (RuleList::iterator rule = rules.begin(); rule != rules.end(); ++rule) {
if (rule->_ruleType == kRuleTypeGoMainView) {
if (checkConditions(rule->_condition)) {
doActions(rule->_actionList, closePtrList);
diff --git a/engines/lab/processroom.h b/engines/lab/processroom.h
index c9f4fa9a20..0cfe98f9df 100644
--- a/engines/lab/processroom.h
+++ b/engines/lab/processroom.h
@@ -174,7 +174,7 @@ struct RoomData {
uint16 _doors[4];
byte _transitionType;
ViewData *_view[4];
- RuleList *_rules;
+ RuleList _rules;
Common::String _roomMsg;
};
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index a3572036de..bd86cd3f4d 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -100,7 +100,6 @@ void Resource::readRoomData(const Common::String fileName) {
_vm->_manyRooms = dataFile->readUint16LE();
_vm->_highestCondition = dataFile->readUint16LE();
_vm->_rooms = new RoomData[_vm->_manyRooms + 1];
- memset(_vm->_rooms, 0, (_vm->_manyRooms + 1) * sizeof(RoomData));
for (int i = 1; i <= _vm->_manyRooms; i++) {
RoomData *curRoom = &_vm->_rooms[i];
@@ -114,8 +113,6 @@ void Resource::readRoomData(const Common::String fileName) {
curRoom->_view[kDirectionSouth] = nullptr;
curRoom->_view[kDirectionEast] = nullptr;
curRoom->_view[kDirectionWest] = nullptr;
- curRoom->_rules = nullptr;
- curRoom->_roomMsg = "";
}
delete dataFile;
@@ -149,7 +146,7 @@ void Resource::readViews(uint16 roomNum) {
curRoom->_view[kDirectionSouth] = readView(dataFile);
curRoom->_view[kDirectionEast] = readView(dataFile);
curRoom->_view[kDirectionWest] = readView(dataFile);
- curRoom->_rules = readRule(dataFile);
+ readRule(dataFile, curRoom->_rules);
_vm->updateMusicAndEvents();
delete dataFile;
@@ -161,8 +158,6 @@ void Resource::freeViews(uint16 roomNum) {
for (int i = 0; i < 4; i++)
freeView(_vm->_rooms[roomNum]._view[i]);
-
- delete _vm->_rooms[roomNum]._rules;
}
Common::String Resource::translateFileName(const Common::String filename) {
@@ -258,9 +253,8 @@ Common::Array<int16> Resource::readConditions(Common::File *file) {
return list;
}
-RuleList *Resource::readRule(Common::File *file) {
- RuleList *rules = new RuleList();
-
+void Resource::readRule(Common::File *file, RuleList &rules) {
+ rules.clear();
while (file->readByte() == 1) {
Rule rule;
rule._ruleType = (RuleType)file->readSint16LE();
@@ -268,10 +262,8 @@ RuleList *Resource::readRule(Common::File *file) {
rule._param2 = file->readSint16LE();
rule._condition = readConditions(file);
rule._actionList = readAction(file);
- rules->push_back(rule);
+ rules.push_back(rule);
}
-
- return rules;
}
Common::List<Action> Resource::readAction(Common::File *file) {
diff --git a/engines/lab/resource.h b/engines/lab/resource.h
index b869ac15ad..d3ed3633df 100644
--- a/engines/lab/resource.h
+++ b/engines/lab/resource.h
@@ -110,7 +110,7 @@ private:
LabEngine *_vm;
Common::String readString(Common::File *file);
Common::Array<int16> readConditions(Common::File *file);
- RuleList *readRule(Common::File *file);
+ void readRule(Common::File *file, RuleList &rules);
Common::List<Action> readAction(Common::File *file);
void freeAction(Action *action);
CloseData *readCloseUps(uint16 depth, Common::File *file);