aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/hugo/display.cpp2
-rw-r--r--engines/hugo/display.h2
-rw-r--r--engines/hugo/file_v1d.cpp3
-rw-r--r--engines/hugo/file_v1w.cpp3
-rw-r--r--engines/hugo/file_v2d.cpp3
-rw-r--r--engines/hugo/file_v3d.cpp8
-rw-r--r--engines/hugo/hugo.cpp8
-rw-r--r--engines/hugo/hugo.h2
-rw-r--r--engines/hugo/intro.cpp7
-rw-r--r--engines/hugo/intro.h2
-rw-r--r--engines/hugo/inventory.cpp5
-rw-r--r--engines/hugo/inventory.h2
-rw-r--r--engines/hugo/mouse.cpp36
-rw-r--r--engines/hugo/mouse.h1
-rw-r--r--engines/hugo/object.cpp193
-rw-r--r--engines/hugo/object.h2
-rw-r--r--engines/hugo/parser.cpp111
-rw-r--r--engines/hugo/parser.h4
-rw-r--r--engines/hugo/schedule.cpp888
-rw-r--r--engines/hugo/schedule.h5
-rw-r--r--engines/hugo/text.h4
21 files changed, 495 insertions, 796 deletions
diff --git a/engines/hugo/display.cpp b/engines/hugo/display.cpp
index f2c4990f66..fffa5b207d 100644
--- a/engines/hugo/display.cpp
+++ b/engines/hugo/display.cpp
@@ -194,7 +194,7 @@ void Screen::savePal(Common::WriteStream *f) const {
/**
* Restore the current palette from a savegame
*/
-void Screen::restorePal(Common::SeekableReadStream *f) {
+void Screen::restorePal(Common::ReadStream *f) {
debugC(1, kDebugDisplay, "restorePal()");
byte pal[4];
diff --git a/engines/hugo/display.h b/engines/hugo/display.h
index b5a3c763bc..8c504cead4 100644
--- a/engines/hugo/display.h
+++ b/engines/hugo/display.h
@@ -73,7 +73,7 @@ public:
void moveImage(image_pt srcImage, const int16 x1, const int16 y1, const int16 dx, int16 dy, const int16 width1, image_pt dstImage, const int16 x2, const int16 y2, const int16 width2);
void remapPal(uint16 oldIndex, uint16 newIndex);
void resetInventoryObjId();
- void restorePal(Common::SeekableReadStream *f);
+ void restorePal(Common::ReadStream *f);
void savePal(Common::WriteStream *f) const;
void setBackgroundColor(const uint16 color);
void setCursorPal();
diff --git a/engines/hugo/file_v1d.cpp b/engines/hugo/file_v1d.cpp
index be23edb7b4..d8b3fa494f 100644
--- a/engines/hugo/file_v1d.cpp
+++ b/engines/hugo/file_v1d.cpp
@@ -63,8 +63,7 @@ void FileManager_v1d::readOverlay(const int screenNum, image_pt image, const ovl
Common::String buf = Common::String(_vm->_text->getScreenNames(screenNum)) + Common::String(ovl_ext[overlayType]);
if (!Common::File::exists(buf)) {
- for (int i = 0; i < kOvlSize; i++)
- image[i] = 0;
+ memset(image, 0, sizeof(image));
warning("File not found: %s", buf.c_str());
return;
}
diff --git a/engines/hugo/file_v1w.cpp b/engines/hugo/file_v1w.cpp
index b902e50f15..dbb093752a 100644
--- a/engines/hugo/file_v1w.cpp
+++ b/engines/hugo/file_v1w.cpp
@@ -81,8 +81,7 @@ void FileManager_v1w::readOverlay(const int screenNum, image_pt image, ovl_t ove
break;
}
if (i == 0) {
- for (int idx = 0; idx < kOvlSize; idx++)
- image[idx] = 0;
+ memset(image, 0, sizeof(image));
return;
}
_sceneryArchive1.read(tmpImage, kOvlSize);
diff --git a/engines/hugo/file_v2d.cpp b/engines/hugo/file_v2d.cpp
index 9c66f6375f..ffadd17481 100644
--- a/engines/hugo/file_v2d.cpp
+++ b/engines/hugo/file_v2d.cpp
@@ -137,8 +137,7 @@ void FileManager_v2d::readOverlay(const int screenNum, image_pt image, ovl_t ove
break;
}
if (i == 0) {
- for (int idx = 0; idx < kOvlSize; idx++)
- image[idx] = 0;
+ memset(image, 0, sizeof(image));
return;
}
diff --git a/engines/hugo/file_v3d.cpp b/engines/hugo/file_v3d.cpp
index ec0d736bb9..2f3e5af3f0 100644
--- a/engines/hugo/file_v3d.cpp
+++ b/engines/hugo/file_v3d.cpp
@@ -144,8 +144,7 @@ void FileManager_v3d::readOverlay(const int screenNum, image_pt image, ovl_t ove
break;
}
if (i == 0) {
- for (int idx = 0; idx < kOvlSize; idx++)
- image[idx] = 0;
+ memset(image, 0, sizeof(image));
return;
}
@@ -158,7 +157,7 @@ void FileManager_v3d::readOverlay(const int screenNum, image_pt image, ovl_t ove
else if (data >= 0) { // Copy next data+1 literally
for (i = 0; i <= (byte)data; i++, k++)
*tmpImage++ = _sceneryArchive1.readByte();
- } else { // Repeat next byte -data+1 times
+ } else { // Repeat next byte -data+1 times
int16 j = _sceneryArchive1.readByte();
for (i = 0; i < (byte)(-data + 1); i++, k++)
@@ -184,8 +183,7 @@ void FileManager_v3d::readOverlay(const int screenNum, image_pt image, ovl_t ove
break;
}
if (i == 0) {
- for (int idx = 0; idx < kOvlSize; idx++)
- image[idx] = 0;
+ memset(image, 0, sizeof(image));
return;
}
diff --git a/engines/hugo/hugo.cpp b/engines/hugo/hugo.cpp
index 9f64db83ff..831fd36a9f 100644
--- a/engines/hugo/hugo.cpp
+++ b/engines/hugo/hugo.cpp
@@ -399,8 +399,7 @@ bool HugoEngine::loadHugoDat() {
numElem = in.readUint16BE();
if (varnt == _gameVariant) {
_screenStates = (byte *)malloc(sizeof(byte) * numElem);
- for (int i = 0; i < numElem; i++)
- _screenStates[i] = 0;
+ memset(_screenStates, 0, sizeof(_screenStates));
}
}
@@ -426,7 +425,7 @@ bool HugoEngine::loadHugoDat() {
return true;
}
-uint16 **HugoEngine::loadLongArray(Common::ReadStream &in) {
+uint16 **HugoEngine::loadLongArray(Common::SeekableReadStream &in) {
uint16 **resArray = 0;
for (int varnt = 0; varnt < _numVariant; varnt++) {
@@ -443,8 +442,7 @@ uint16 **HugoEngine::loadLongArray(Common::ReadStream &in) {
resRow[j] = in.readUint16BE();
resArray[i] = resRow;
} else {
- for (int j = 0; j < numElems; j++)
- in.readUint16BE();
+ in.skip(numElems * sizeof(uint16));
}
}
}
diff --git a/engines/hugo/hugo.h b/engines/hugo/hugo.h
index 7c12fcd2ee..848001c4ef 100644
--- a/engines/hugo/hugo.h
+++ b/engines/hugo/hugo.h
@@ -323,7 +323,7 @@ public:
const char *getCopyrightString() const { return "Copyright 1989-1997 David P Gray, All Rights Reserved."; }
Common::String getSavegameFilename(int slot);
- uint16 **loadLongArray(Common::ReadStream &in);
+ uint16 **loadLongArray(Common::SeekableReadStream &in);
FileManager *_file;
Scheduler *_scheduler;
diff --git a/engines/hugo/intro.cpp b/engines/hugo/intro.cpp
index 4ee46f80b5..3a11baf620 100644
--- a/engines/hugo/intro.cpp
+++ b/engines/hugo/intro.cpp
@@ -51,7 +51,7 @@ IntroHandler::~IntroHandler() {
/**
* Read _introX and _introY from hugo.dat
*/
-void IntroHandler::loadIntroData(Common::ReadStream &in) {
+void IntroHandler::loadIntroData(Common::SeekableReadStream &in) {
for (int varnt = 0; varnt < _vm->_numVariant; varnt++) {
int numRows = in.readUint16BE();
if (varnt == _vm->_gameVariant) {
@@ -63,10 +63,7 @@ void IntroHandler::loadIntroData(Common::ReadStream &in) {
_introY[i] = in.readByte();
}
} else {
- for (int i = 0; i < numRows; i++) {
- in.readByte();
- in.readByte();
- }
+ in.skip(numRows * 2);
}
}
}
diff --git a/engines/hugo/intro.h b/engines/hugo/intro.h
index 351352554e..c743475644 100644
--- a/engines/hugo/intro.h
+++ b/engines/hugo/intro.h
@@ -55,7 +55,7 @@ public:
virtual bool introPlay() = 0;
void freeIntroData();
- void loadIntroData(Common::ReadStream &in);
+ void loadIntroData(Common::SeekableReadStream &in);
byte getIntroSize() const { return _introXSize; }
diff --git a/engines/hugo/inventory.cpp b/engines/hugo/inventory.cpp
index a45df7e077..7862805d8b 100644
--- a/engines/hugo/inventory.cpp
+++ b/engines/hugo/inventory.cpp
@@ -57,7 +57,7 @@ InventoryHandler::InventoryHandler(HugoEngine *vm) : _vm(vm), _invent(0) {
/**
* Read _invent from Hugo.dat
*/
-void InventoryHandler::loadInvent(Common::ReadStream &in) {
+void InventoryHandler::loadInvent(Common::SeekableReadStream &in) {
for (int varnt = 0; varnt < _vm->_numVariant; varnt++) {
int16 numElem = in.readUint16BE();
if (varnt == _vm->_gameVariant) {
@@ -66,8 +66,7 @@ void InventoryHandler::loadInvent(Common::ReadStream &in) {
for (int i = 0; i < numElem; i++)
_invent[i] = in.readSint16BE();
} else {
- for (int i = 0; i < numElem; i++)
- in.readSint16BE();
+ in.skip(numElem * sizeof(int16));
}
}
}
diff --git a/engines/hugo/inventory.h b/engines/hugo/inventory.h
index 8d60904c6f..7b1390a3ce 100644
--- a/engines/hugo/inventory.h
+++ b/engines/hugo/inventory.h
@@ -51,7 +51,7 @@ public:
istate_t getInventoryState() const { return _inventoryState; }
int16 findIconId(int16 objId);
- void loadInvent(Common::ReadStream &in);
+ void loadInvent(Common::SeekableReadStream &in);
int16 processInventory(const invact_t action, ...);
void runInventory();
diff --git a/engines/hugo/mouse.cpp b/engines/hugo/mouse.cpp
index 9bbc60f04b..3464fea869 100644
--- a/engines/hugo/mouse.cpp
+++ b/engines/hugo/mouse.cpp
@@ -293,31 +293,31 @@ void MouseHandler::mouseHandler() {
resetRightButton();
}
+void MouseHandler::readHotspot(Common::ReadStream &in, hotspot_t &hotspot) {
+ hotspot.screenIndex = in.readSint16BE();
+ hotspot.x1 = in.readSint16BE();
+ hotspot.y1 = in.readSint16BE();
+ hotspot.x2 = in.readSint16BE();
+ hotspot.y2 = in.readSint16BE();
+ hotspot.actIndex = in.readUint16BE();
+ hotspot.viewx = in.readSint16BE();
+ hotspot.viewy = in.readSint16BE();
+ hotspot.direction = in.readSint16BE();
+}
+
/**
* Load hotspots data from hugo.dat
*/
void MouseHandler::loadHotspots(Common::ReadStream &in) {
- // Read _hotspots
+ hotspot_t *wrkHotspots = 0;
+ hotspot_t tmp;
for (int varnt = 0; varnt < _vm->_numVariant; varnt++) {
int numRows = in.readUint16BE();
- hotspot_t *wrkHotspots = (hotspot_t *)malloc(sizeof(hotspot_t) * numRows);
-
- for (int i = 0; i < numRows; i++) {
- wrkHotspots[i].screenIndex = in.readSint16BE();
- wrkHotspots[i].x1 = in.readSint16BE();
- wrkHotspots[i].y1 = in.readSint16BE();
- wrkHotspots[i].x2 = in.readSint16BE();
- wrkHotspots[i].y2 = in.readSint16BE();
- wrkHotspots[i].actIndex = in.readUint16BE();
- wrkHotspots[i].viewx = in.readSint16BE();
- wrkHotspots[i].viewy = in.readSint16BE();
- wrkHotspots[i].direction = in.readSint16BE();
- }
-
if (varnt == _vm->_gameVariant)
- _hotspots = wrkHotspots;
- else
- free(wrkHotspots);
+ _hotspots = wrkHotspots = (hotspot_t *)malloc(sizeof(hotspot_t) * numRows);
+
+ for (int i = 0; i < numRows; i++)
+ readHotspot(in, (varnt == _vm->_gameVariant) ? wrkHotspots[i] : tmp);
}
}
diff --git a/engines/hugo/mouse.h b/engines/hugo/mouse.h
index eae13b48fb..d43ca054dd 100644
--- a/engines/hugo/mouse.h
+++ b/engines/hugo/mouse.h
@@ -83,6 +83,7 @@ private:
void cursorText(const char *buffer, const int16 cx, const int16 cy, const uif_t fontId, const int16 color);
void processRightClick(const int16 objId, const int16 cx, const int16 cy);
void processLeftClick(const int16 objId, const int16 cx, const int16 cy);
+ void readHotspot(Common::ReadStream &in, hotspot_t &hotspot);
};
} // End of namespace Hugo
diff --git a/engines/hugo/object.cpp b/engines/hugo/object.cpp
index 786ea4762a..f9364a8781 100644
--- a/engines/hugo/object.cpp
+++ b/engines/hugo/object.cpp
@@ -368,141 +368,114 @@ bool ObjectHandler::findObjectSpace(object_t *obj, int16 *destx, int16 *desty) {
return foundFl;
}
+void ObjectHandler::readUse(Common::ReadStream &in, uses_t &curUse) {
+ curUse.objId = in.readSint16BE();
+ curUse.dataIndex = in.readUint16BE();
+ uint16 numSubElem = in.readUint16BE();
+ curUse.targets = (target_t *)malloc(sizeof(target_t) * numSubElem);
+ for (int j = 0; j < numSubElem; j++) {
+ curUse.targets[j].nounIndex = in.readUint16BE();
+ curUse.targets[j].verbIndex = in.readUint16BE();
+ }
+}
/**
* Load _uses from Hugo.dat
*/
void ObjectHandler::loadObjectUses(Common::ReadStream &in) {
+ uses_t tmpUse;
//Read _uses
for (int varnt = 0; varnt < _vm->_numVariant; varnt++) {
+ tmpUse.targets = 0;
uint16 numElem = in.readUint16BE();
- uses_t *wrkUses = (uses_t *)malloc(sizeof(uses_t) * numElem);
-
- for (int i = 0; i < numElem; i++) {
- wrkUses[i].objId = in.readSint16BE();
- wrkUses[i].dataIndex = in.readUint16BE();
- uint16 numSubElem = in.readUint16BE();
- wrkUses[i].targets = (target_t *)malloc(sizeof(target_t) * numSubElem);
- for (int j = 0; j < numSubElem; j++) {
- wrkUses[i].targets[j].nounIndex = in.readUint16BE();
- wrkUses[i].targets[j].verbIndex = in.readUint16BE();
- }
- }
-
if (varnt == _vm->_gameVariant) {
_usesSize = numElem;
- _uses = wrkUses;
- } else {
- for (int i = 0; i < numElem; i++)
- free(wrkUses[i].targets);
- free(wrkUses);
+ _uses = (uses_t *)malloc(sizeof(uses_t) * numElem);
}
+
+ for (int i = 0; i < numElem; i++)
+ readUse(in, (varnt == _vm->_gameVariant) ? _uses[i] : tmpUse);
+
+ if (tmpUse.targets)
+ free(tmpUse.targets);
}
}
+void ObjectHandler::readObject(Common::ReadStream &in, object_t &curObject) {
+ curObject.nounIndex = in.readUint16BE();
+ curObject.dataIndex = in.readUint16BE();
+ uint16 numSubElem = in.readUint16BE();
+
+ if (numSubElem == 0)
+ curObject.stateDataIndex = 0;
+ else
+ curObject.stateDataIndex = (uint16 *)malloc(sizeof(uint16) * numSubElem);
+ for (int j = 0; j < numSubElem; j++)
+ curObject.stateDataIndex[j] = in.readUint16BE();
+
+ curObject.pathType = (path_t) in.readSint16BE();
+ curObject.vxPath = in.readSint16BE();
+ curObject.vyPath = in.readSint16BE();
+ curObject.actIndex = in.readUint16BE();
+ curObject.seqNumb = in.readByte();
+ curObject.currImagePtr = 0;
+
+ if (curObject.seqNumb == 0) {
+ curObject.seqList[0].imageNbr = 0;
+ curObject.seqList[0].seqPtr = 0;
+ }
+
+ for (int j = 0; j < curObject.seqNumb; j++) {
+ curObject.seqList[j].imageNbr = in.readUint16BE();
+ curObject.seqList[j].seqPtr = 0;
+ }
+
+ curObject.cycling = (cycle_t)in.readByte();
+ curObject.cycleNumb = in.readByte();
+ curObject.frameInterval = in.readByte();
+ curObject.frameTimer = in.readByte();
+ curObject.radius = in.readByte();
+ curObject.screenIndex = in.readByte();
+ curObject.x = in.readSint16BE();
+ curObject.y = in.readSint16BE();
+ curObject.oldx = in.readSint16BE();
+ curObject.oldy = in.readSint16BE();
+ curObject.vx = in.readByte();
+ curObject.vy = in.readByte();
+ curObject.objValue = in.readByte();
+ curObject.genericCmd = in.readSint16BE();
+ curObject.cmdIndex = in.readUint16BE();
+ curObject.carriedFl = (in.readByte() != 0);
+ curObject.state = in.readByte();
+ curObject.verbOnlyFl = (in.readByte() != 0);
+ curObject.priority = in.readByte();
+ curObject.viewx = in.readSint16BE();
+ curObject.viewy = in.readSint16BE();
+ curObject.direction = in.readSint16BE();
+ curObject.curSeqNum = in.readByte();
+ curObject.curImageNum = in.readByte();
+ curObject.oldvx = in.readByte();
+ curObject.oldvy = in.readByte();
+}
/**
* Load ObjectArr from Hugo.dat
*/
void ObjectHandler::loadObjectArr(Common::ReadStream &in) {
debugC(6, kDebugObject, "loadObject(&in)");
+ object_t tmpObject;
for (int varnt = 0; varnt < _vm->_numVariant; varnt++) {
uint16 numElem = in.readUint16BE();
+ tmpObject.stateDataIndex = 0;
if (varnt == _vm->_gameVariant) {
_objCount = numElem;
_objects = (object_t *)malloc(sizeof(object_t) * numElem);
- for (int i = 0; i < numElem; i++) {
- _objects[i].nounIndex = in.readUint16BE();
- _objects[i].dataIndex = in.readUint16BE();
- uint16 numSubElem = in.readUint16BE();
- if (numSubElem == 0)
- _objects[i].stateDataIndex = 0;
- else
- _objects[i].stateDataIndex = (uint16 *)malloc(sizeof(uint16) * numSubElem);
- for (int j = 0; j < numSubElem; j++)
- _objects[i].stateDataIndex[j] = in.readUint16BE();
- _objects[i].pathType = (path_t) in.readSint16BE();
- _objects[i].vxPath = in.readSint16BE();
- _objects[i].vyPath = in.readSint16BE();
- _objects[i].actIndex = in.readUint16BE();
- _objects[i].seqNumb = in.readByte();
- _objects[i].currImagePtr = 0;
- if (_objects[i].seqNumb == 0) {
- _objects[i].seqList[0].imageNbr = 0;
- _objects[i].seqList[0].seqPtr = 0;
- }
- for (int j = 0; j < _objects[i].seqNumb; j++) {
- _objects[i].seqList[j].imageNbr = in.readUint16BE();
- _objects[i].seqList[j].seqPtr = 0;
- }
- _objects[i].cycling = (cycle_t)in.readByte();
- _objects[i].cycleNumb = in.readByte();
- _objects[i].frameInterval = in.readByte();
- _objects[i].frameTimer = in.readByte();
- _objects[i].radius = in.readByte();
- _objects[i].screenIndex = in.readByte();
- _objects[i].x = in.readSint16BE();
- _objects[i].y = in.readSint16BE();
- _objects[i].oldx = in.readSint16BE();
- _objects[i].oldy = in.readSint16BE();
- _objects[i].vx = in.readByte();
- _objects[i].vy = in.readByte();
- _objects[i].objValue = in.readByte();
- _objects[i].genericCmd = in.readSint16BE();
- _objects[i].cmdIndex = in.readUint16BE();
- _objects[i].carriedFl = (in.readByte() != 0);
- _objects[i].state = in.readByte();
- _objects[i].verbOnlyFl = (in.readByte() != 0);
- _objects[i].priority = in.readByte();
- _objects[i].viewx = in.readSint16BE();
- _objects[i].viewy = in.readSint16BE();
- _objects[i].direction = in.readSint16BE();
- _objects[i].curSeqNum = in.readByte();
- _objects[i].curImageNum = in.readByte();
- _objects[i].oldvx = in.readByte();
- _objects[i].oldvy = in.readByte();
- }
- } else {
- for (int i = 0; i < numElem; i++) {
- in.readUint16BE();
- in.readUint16BE();
- uint16 numSubElem = in.readUint16BE();
- for (int j = 0; j < numSubElem; j++)
- in.readUint16BE();
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- in.readUint16BE();
- numSubElem = in.readByte();
- for (int j = 0; j < numSubElem; j++)
- in.readUint16BE();
- in.readByte();
- in.readByte();
- in.readByte();
- in.readByte();
- in.readByte();
- in.readByte();
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- in.readByte();
- in.readByte();
- in.readByte();
- in.readSint16BE();
- in.readUint16BE();
- in.readByte();
- in.readByte();
- in.readByte();
- in.readByte();
- in.readSint16BE();
- in.readSint16BE();
- in.readUint16BE();
- in.readByte();
- in.readByte();
- in.readByte();
- in.readByte();
- }
}
+
+ for (int i = 0; i < numElem; i++)
+ readObject(in, (varnt == _vm->_gameVariant) ? _objects[i] : tmpObject);
+
+ if (tmpObject.stateDataIndex)
+ free(tmpObject.stateDataIndex);
}
}
diff --git a/engines/hugo/object.h b/engines/hugo/object.h
index ef60e622f8..dc69411bfa 100644
--- a/engines/hugo/object.h
+++ b/engines/hugo/object.h
@@ -78,6 +78,8 @@ public:
void loadNumObj(Common::ReadStream &in);
void lookObject(object_t *obj);
void readObjectImages();
+ void readObject(Common::ReadStream &in, object_t &curObject);
+ void readUse(Common::ReadStream &in, uses_t &curUse);
void restoreAllSeq();
void restoreObjects(Common::SeekableReadStream *in);
void saveObjects(Common::WriteStream *out);
diff --git a/engines/hugo/parser.cpp b/engines/hugo/parser.cpp
index c7e252b012..2d5f6c99bb 100644
--- a/engines/hugo/parser.cpp
+++ b/engines/hugo/parser.cpp
@@ -65,75 +65,72 @@ Parser::~Parser() {
}
/**
- * Read _cmdList from Hugo.dat
+ * Read a cmd structure from Hugo.dat
+ */
+void Parser::readCmd(Common::ReadStream &in, cmd &curCmd) {
+ curCmd.verbIndex = in.readUint16BE();
+ curCmd.reqIndex = in.readUint16BE();
+ curCmd.textDataNoCarryIndex = in.readUint16BE();
+ curCmd.reqState = in.readByte();
+ curCmd.newState = in.readByte();
+ curCmd.textDataWrongIndex = in.readUint16BE();
+ curCmd.textDataDoneIndex = in.readUint16BE();
+ curCmd.actIndex = in.readUint16BE();
+}
+
+/**
+ * Load _cmdList from Hugo.dat
*/
void Parser::loadCmdList(Common::ReadStream &in) {
+ cmd tmpCmd;
for (int varnt = 0; varnt < _vm->_numVariant; varnt++) {
uint16 numElem = in.readUint16BE();
if (varnt == _vm->_gameVariant) {
_cmdListSize = numElem;
_cmdList = (cmd **)malloc(sizeof(cmd *) * _cmdListSize);
- for (int i = 0; i < _cmdListSize; i++) {
- uint16 numSubElem = in.readUint16BE();
+ }
+
+ for (int16 i = 0; i < numElem; i++) {
+ uint16 numSubElem = in.readUint16BE();
+ if (varnt == _vm->_gameVariant)
_cmdList[i] = (cmd *)malloc(sizeof(cmd) * numSubElem);
- for (int j = 0; j < numSubElem; j++) {
- _cmdList[i][j].verbIndex = in.readUint16BE();
- _cmdList[i][j].reqIndex = in.readUint16BE();
- _cmdList[i][j].textDataNoCarryIndex = in.readUint16BE();
- _cmdList[i][j].reqState = in.readByte();
- _cmdList[i][j].newState = in.readByte();
- _cmdList[i][j].textDataWrongIndex = in.readUint16BE();
- _cmdList[i][j].textDataDoneIndex = in.readUint16BE();
- _cmdList[i][j].actIndex = in.readUint16BE();
- }
- }
- } else {
- for (int i = 0; i < numElem; i++) {
- uint16 numSubElem = in.readUint16BE();
- for (int j = 0; j < numSubElem; j++) {
- in.readUint16BE();
- in.readUint16BE();
- in.readUint16BE();
- in.readByte();
- in.readByte();
- in.readUint16BE();
- in.readUint16BE();
- in.readUint16BE();
- }
- }
+ for (int16 j = 0; j < numSubElem; j++)
+ readCmd(in, (varnt == _vm->_gameVariant) ? _cmdList[i][j] : tmpCmd);
}
}
}
+
+void Parser::readBG(Common::ReadStream &in, background_t &curBG) {
+ curBG.verbIndex = in.readUint16BE();
+ curBG.nounIndex = in.readUint16BE();
+ curBG.commentIndex = in.readSint16BE();
+ curBG.matchFl = (in.readByte() != 0);
+ curBG.roomState = in.readByte();
+ curBG.bonusIndex = in.readByte();
+}
+
/**
* Read _backgrounObjects from Hugo.dat
*/
void Parser::loadBackgroundObjects(Common::ReadStream &in) {
+ background_t tmpBG;
+
for (int varnt = 0; varnt < _vm->_numVariant; varnt++) {
uint16 numElem = in.readUint16BE();
- background_t **wrkBackgroundObjects = (background_t **)malloc(sizeof(background_t *) * numElem);
+ if (varnt == _vm->_gameVariant) {
+ _backgroundObjectsSize = numElem;
+ _backgroundObjects = (background_t **)malloc(sizeof(background_t *) * numElem);
+ }
for (int i = 0; i < numElem; i++) {
uint16 numSubElem = in.readUint16BE();
- wrkBackgroundObjects[i] = (background_t *)malloc(sizeof(background_t) * numSubElem);
- for (int j = 0; j < numSubElem; j++) {
- wrkBackgroundObjects[i][j].verbIndex = in.readUint16BE();
- wrkBackgroundObjects[i][j].nounIndex = in.readUint16BE();
- wrkBackgroundObjects[i][j].commentIndex = in.readSint16BE();
- wrkBackgroundObjects[i][j].matchFl = (in.readByte() != 0);
- wrkBackgroundObjects[i][j].roomState = in.readByte();
- wrkBackgroundObjects[i][j].bonusIndex = in.readByte();
- }
- }
+ if (varnt == _vm->_gameVariant)
+ _backgroundObjects[i] = (background_t *)malloc(sizeof(background_t) * numSubElem);
- if (varnt == _vm->_gameVariant) {
- _backgroundObjectsSize = numElem;
- _backgroundObjects = wrkBackgroundObjects;
- } else {
- for (int i = 0; i < numElem; i++)
- free(wrkBackgroundObjects[i]);
- free(wrkBackgroundObjects);
+ for (int j = 0; j < numSubElem; j++)
+ readBG(in, (varnt == _vm->_gameVariant) ? _backgroundObjects[i][j] : tmpBG);
}
}
}
@@ -142,27 +139,21 @@ void Parser::loadBackgroundObjects(Common::ReadStream &in) {
* Read _catchallList from Hugo.dat
*/
void Parser::loadCatchallList(Common::ReadStream &in) {
+ background_t *wrkCatchallList = 0;
+ background_t tmpBG;
+
for (int varnt = 0; varnt < _vm->_numVariant; varnt++) {
uint16 numElem = in.readUint16BE();
- background_t *wrkCatchallList = (background_t *)malloc(sizeof(background_t) * numElem);
-
- for (int i = 0; i < numElem; i++) {
- wrkCatchallList[i].verbIndex = in.readUint16BE();
- wrkCatchallList[i].nounIndex = in.readUint16BE();
- wrkCatchallList[i].commentIndex = in.readSint16BE();
- wrkCatchallList[i].matchFl = (in.readByte() != 0);
- wrkCatchallList[i].roomState = in.readByte();
- wrkCatchallList[i].bonusIndex = in.readByte();
- }
if (varnt == _vm->_gameVariant)
- _catchallList = wrkCatchallList;
- else
- free(wrkCatchallList);
+ _catchallList = wrkCatchallList = (background_t *)malloc(sizeof(background_t) * numElem);
+
+ for (int i = 0; i < numElem; i++)
+ readBG(in, (varnt == _vm->_gameVariant) ? wrkCatchallList[i] : tmpBG);
}
}
-void Parser::loadArrayReqs(Common::ReadStream &in) {
+void Parser::loadArrayReqs(Common::SeekableReadStream &in) {
_arrayReqs = _vm->loadLongArray(in);
}
diff --git a/engines/hugo/parser.h b/engines/hugo/parser.h
index 5bc602fb9a..41b40f0527 100644
--- a/engines/hugo/parser.h
+++ b/engines/hugo/parser.h
@@ -55,7 +55,7 @@ public:
void command(const char *format, ...);
void freeParser();
void keyHandler(Common::Event event);
- void loadArrayReqs(Common::ReadStream &in);
+ void loadArrayReqs(Common::SeekableReadStream &in);
void loadBackgroundObjects(Common::ReadStream &in);
void loadCatchallList(Common::ReadStream &in);
void loadCmdList(Common::ReadStream &in);
@@ -82,6 +82,8 @@ protected:
const char *findNoun() const;
const char *findVerb() const;
+ void readBG(Common::ReadStream &in, background_t &curBG);
+ void readCmd(Common::ReadStream &in, cmd &curCmd);
void showDosInventory() const;
bool _checkDoubleF1Fl; // Flag used to display user help or instructions
diff --git a/engines/hugo/schedule.cpp b/engines/hugo/schedule.cpp
index c5d1683a96..93b1a75a5b 100644
--- a/engines/hugo/schedule.cpp
+++ b/engines/hugo/schedule.cpp
@@ -253,7 +253,7 @@ void Scheduler::loadAlNewscrIndex(Common::ReadStream &in) {
/**
* Load Points from Hugo.dat
*/
-void Scheduler::loadPoints(Common::ReadStream &in) {
+void Scheduler::loadPoints(Common::SeekableReadStream &in) {
debugC(6, kDebugSchedule, "loadPoints(&in)");
for (int varnt = 0; varnt < _vm->_numVariant; varnt++) {
@@ -266,610 +266,350 @@ void Scheduler::loadPoints(Common::ReadStream &in) {
_points[i].scoredFl = false;
}
} else {
- for (int i = 0; i < numElem; i++)
- in.readByte();
+ in.skip(numElem);
}
}
}
+void Scheduler::readAct(Common::ReadStream &in, act &curAct) {
+ uint16 numSubAct;
+
+ curAct.a0.actType = (action_t) in.readByte();
+ switch (curAct.a0.actType) {
+ case ANULL: // -1
+ break;
+ case ASCHEDULE: // 0
+ curAct.a0.timer = in.readSint16BE();
+ curAct.a0.actIndex = in.readUint16BE();
+ break;
+ case START_OBJ: // 1
+ curAct.a1.timer = in.readSint16BE();
+ curAct.a1.objIndex = in.readSint16BE();
+ curAct.a1.cycleNumb = in.readSint16BE();
+ curAct.a1.cycle = (cycle_t) in.readByte();
+ break;
+ case INIT_OBJXY: // 2
+ curAct.a2.timer = in.readSint16BE();
+ curAct.a2.objIndex = in.readSint16BE();
+ curAct.a2.x = in.readSint16BE();
+ curAct.a2.y = in.readSint16BE();
+ break;
+ case PROMPT: // 3
+ curAct.a3.timer = in.readSint16BE();
+ curAct.a3.promptIndex = in.readSint16BE();
+ numSubAct = in.readUint16BE();
+ curAct.a3.responsePtr = (int *) malloc(sizeof(int) * numSubAct);
+ for (int k = 0; k < numSubAct; k++)
+ curAct.a3.responsePtr[k] = in.readSint16BE();
+ curAct.a3.actPassIndex = in.readUint16BE();
+ curAct.a3.actFailIndex = in.readUint16BE();
+ curAct.a3.encodedFl = (in.readByte() == 1) ? true : false;
+ break;
+ case BKGD_COLOR: // 4
+ curAct.a4.timer = in.readSint16BE();
+ curAct.a4.newBackgroundColor = in.readUint32BE();
+ break;
+ case INIT_OBJVXY: // 5
+ curAct.a5.timer = in.readSint16BE();
+ curAct.a5.objIndex = in.readSint16BE();
+ curAct.a5.vx = in.readSint16BE();
+ curAct.a5.vy = in.readSint16BE();
+ break;
+ case INIT_CARRY: // 6
+ curAct.a6.timer = in.readSint16BE();
+ curAct.a6.objIndex = in.readSint16BE();
+ curAct.a6.carriedFl = (in.readByte() == 1) ? true : false;
+ break;
+ case INIT_HF_COORD: // 7
+ curAct.a7.timer = in.readSint16BE();
+ curAct.a7.objIndex = in.readSint16BE();
+ break;
+ case NEW_SCREEN: // 8
+ curAct.a8.timer = in.readSint16BE();
+ curAct.a8.screenIndex = in.readSint16BE();
+ break;
+ case INIT_OBJSTATE: // 9
+ curAct.a9.timer = in.readSint16BE();
+ curAct.a9.objIndex = in.readSint16BE();
+ curAct.a9.newState = in.readByte();
+ break;
+ case INIT_PATH: // 10
+ curAct.a10.timer = in.readSint16BE();
+ curAct.a10.objIndex = in.readSint16BE();
+ curAct.a10.newPathType = in.readSint16BE();
+ curAct.a10.vxPath = in.readByte();
+ curAct.a10.vyPath = in.readByte();
+ break;
+ case COND_R: // 11
+ curAct.a11.timer = in.readSint16BE();
+ curAct.a11.objIndex = in.readSint16BE();
+ curAct.a11.stateReq = in.readByte();
+ curAct.a11.actPassIndex = in.readUint16BE();
+ curAct.a11.actFailIndex = in.readUint16BE();
+ break;
+ case TEXT: // 12
+ curAct.a12.timer = in.readSint16BE();
+ curAct.a12.stringIndex = in.readSint16BE();
+ break;
+ case SWAP_IMAGES: // 13
+ curAct.a13.timer = in.readSint16BE();
+ curAct.a13.objIndex1 = in.readSint16BE();
+ curAct.a13.objIndex2 = in.readSint16BE();
+ break;
+ case COND_SCR: // 14
+ curAct.a14.timer = in.readSint16BE();
+ curAct.a14.objIndex = in.readSint16BE();
+ curAct.a14.screenReq = in.readSint16BE();
+ curAct.a14.actPassIndex = in.readUint16BE();
+ curAct.a14.actFailIndex = in.readUint16BE();
+ break;
+ case AUTOPILOT: // 15
+ curAct.a15.timer = in.readSint16BE();
+ curAct.a15.objIndex1 = in.readSint16BE();
+ curAct.a15.objIndex2 = in.readSint16BE();
+ curAct.a15.dx = in.readByte();
+ curAct.a15.dy = in.readByte();
+ break;
+ case INIT_OBJ_SEQ: // 16
+ curAct.a16.timer = in.readSint16BE();
+ curAct.a16.objIndex = in.readSint16BE();
+ curAct.a16.seqIndex = in.readSint16BE();
+ break;
+ case SET_STATE_BITS: // 17
+ curAct.a17.timer = in.readSint16BE();
+ curAct.a17.objIndex = in.readSint16BE();
+ curAct.a17.stateMask = in.readSint16BE();
+ break;
+ case CLEAR_STATE_BITS: // 18
+ curAct.a18.timer = in.readSint16BE();
+ curAct.a18.objIndex = in.readSint16BE();
+ curAct.a18.stateMask = in.readSint16BE();
+ break;
+ case TEST_STATE_BITS: // 19
+ curAct.a19.timer = in.readSint16BE();
+ curAct.a19.objIndex = in.readSint16BE();
+ curAct.a19.stateMask = in.readSint16BE();
+ curAct.a19.actPassIndex = in.readUint16BE();
+ curAct.a19.actFailIndex = in.readUint16BE();
+ break;
+ case DEL_EVENTS: // 20
+ curAct.a20.timer = in.readSint16BE();
+ curAct.a20.actTypeDel = (action_t) in.readByte();
+ break;
+ case GAMEOVER: // 21
+ curAct.a21.timer = in.readSint16BE();
+ break;
+ case INIT_HH_COORD: // 22
+ curAct.a22.timer = in.readSint16BE();
+ curAct.a22.objIndex = in.readSint16BE();
+ break;
+ case EXIT: // 23
+ curAct.a23.timer = in.readSint16BE();
+ break;
+ case BONUS: // 24
+ curAct.a24.timer = in.readSint16BE();
+ curAct.a24.pointIndex = in.readSint16BE();
+ break;
+ case COND_BOX: // 25
+ curAct.a25.timer = in.readSint16BE();
+ curAct.a25.objIndex = in.readSint16BE();
+ curAct.a25.x1 = in.readSint16BE();
+ curAct.a25.y1 = in.readSint16BE();
+ curAct.a25.x2 = in.readSint16BE();
+ curAct.a25.y2 = in.readSint16BE();
+ curAct.a25.actPassIndex = in.readUint16BE();
+ curAct.a25.actFailIndex = in.readUint16BE();
+ break;
+ case SOUND: // 26
+ curAct.a26.timer = in.readSint16BE();
+ curAct.a26.soundIndex = in.readSint16BE();
+ break;
+ case ADD_SCORE: // 27
+ curAct.a27.timer = in.readSint16BE();
+ curAct.a27.objIndex = in.readSint16BE();
+ break;
+ case SUB_SCORE: // 28
+ curAct.a28.timer = in.readSint16BE();
+ curAct.a28.objIndex = in.readSint16BE();
+ break;
+ case COND_CARRY: // 29
+ curAct.a29.timer = in.readSint16BE();
+ curAct.a29.objIndex = in.readSint16BE();
+ curAct.a29.actPassIndex = in.readUint16BE();
+ curAct.a29.actFailIndex = in.readUint16BE();
+ break;
+ case INIT_MAZE: // 30
+ curAct.a30.timer = in.readSint16BE();
+ curAct.a30.mazeSize = in.readByte();
+ curAct.a30.x1 = in.readSint16BE();
+ curAct.a30.y1 = in.readSint16BE();
+ curAct.a30.x2 = in.readSint16BE();
+ curAct.a30.y2 = in.readSint16BE();
+ curAct.a30.x3 = in.readSint16BE();
+ curAct.a30.x4 = in.readSint16BE();
+ curAct.a30.firstScreenIndex = in.readByte();
+ break;
+ case EXIT_MAZE: // 31
+ curAct.a31.timer = in.readSint16BE();
+ break;
+ case INIT_PRIORITY: // 32
+ curAct.a32.timer = in.readSint16BE();
+ curAct.a32.objIndex = in.readSint16BE();
+ curAct.a32.priority = in.readByte();
+ break;
+ case INIT_SCREEN: // 33
+ curAct.a33.timer = in.readSint16BE();
+ curAct.a33.objIndex = in.readSint16BE();
+ curAct.a33.screenIndex = in.readSint16BE();
+ break;
+ case AGSCHEDULE: // 34
+ curAct.a34.timer = in.readSint16BE();
+ curAct.a34.actIndex = in.readUint16BE();
+ break;
+ case REMAPPAL: // 35
+ curAct.a35.timer = in.readSint16BE();
+ curAct.a35.oldColorIndex = in.readSint16BE();
+ curAct.a35.newColorIndex = in.readSint16BE();
+ break;
+ case COND_NOUN: // 36
+ curAct.a36.timer = in.readSint16BE();
+ curAct.a36.nounIndex = in.readUint16BE();
+ curAct.a36.actPassIndex = in.readUint16BE();
+ curAct.a36.actFailIndex = in.readUint16BE();
+ break;
+ case SCREEN_STATE: // 37
+ curAct.a37.timer = in.readSint16BE();
+ curAct.a37.screenIndex = in.readSint16BE();
+ curAct.a37.newState = in.readByte();
+ break;
+ case INIT_LIPS: // 38
+ curAct.a38.timer = in.readSint16BE();
+ curAct.a38.lipsObjIndex = in.readSint16BE();
+ curAct.a38.objIndex = in.readSint16BE();
+ curAct.a38.dxLips = in.readByte();
+ curAct.a38.dyLips = in.readByte();
+ break;
+ case INIT_STORY_MODE: // 39
+ curAct.a39.timer = in.readSint16BE();
+ curAct.a39.storyModeFl = (in.readByte() == 1);
+ break;
+ case WARN: // 40
+ curAct.a40.timer = in.readSint16BE();
+ curAct.a40.stringIndex = in.readSint16BE();
+ break;
+ case COND_BONUS: // 41
+ curAct.a41.timer = in.readSint16BE();
+ curAct.a41.BonusIndex = in.readSint16BE();
+ curAct.a41.actPassIndex = in.readUint16BE();
+ curAct.a41.actFailIndex = in.readUint16BE();
+ break;
+ case TEXT_TAKE: // 42
+ curAct.a42.timer = in.readSint16BE();
+ curAct.a42.objIndex = in.readSint16BE();
+ break;
+ case YESNO: // 43
+ curAct.a43.timer = in.readSint16BE();
+ curAct.a43.promptIndex = in.readSint16BE();
+ curAct.a43.actYesIndex = in.readUint16BE();
+ curAct.a43.actNoIndex = in.readUint16BE();
+ break;
+ case STOP_ROUTE: // 44
+ curAct.a44.timer = in.readSint16BE();
+ break;
+ case COND_ROUTE: // 45
+ curAct.a45.timer = in.readSint16BE();
+ curAct.a45.routeIndex = in.readSint16BE();
+ curAct.a45.actPassIndex = in.readUint16BE();
+ curAct.a45.actFailIndex = in.readUint16BE();
+ break;
+ case INIT_JUMPEXIT: // 46
+ curAct.a46.timer = in.readSint16BE();
+ curAct.a46.jumpExitFl = (in.readByte() == 1);
+ break;
+ case INIT_VIEW: // 47
+ curAct.a47.timer = in.readSint16BE();
+ curAct.a47.objIndex = in.readSint16BE();
+ curAct.a47.viewx = in.readSint16BE();
+ curAct.a47.viewy = in.readSint16BE();
+ curAct.a47.direction = in.readSint16BE();
+ break;
+ case INIT_OBJ_FRAME: // 48
+ curAct.a48.timer = in.readSint16BE();
+ curAct.a48.objIndex = in.readSint16BE();
+ curAct.a48.seqIndex = in.readSint16BE();
+ curAct.a48.frameIndex = in.readSint16BE();
+ break;
+ case OLD_SONG: //49
+ curAct.a49.timer = in.readSint16BE();
+ curAct.a49.songIndex = in.readUint16BE();
+ break;
+ default:
+ error("Engine - Unknown action type encountered: %d", curAct.a0.actType);
+ }
+}
+
/**
* Load actListArr from Hugo.dat
*/
void Scheduler::loadActListArr(Common::ReadStream &in) {
debugC(6, kDebugSchedule, "loadActListArr(&in)");
- int numElem, numSubElem, numSubAct;
+ act tmpAct;
+
+ int numElem, numSubElem;
for (int varnt = 0; varnt < _vm->_numVariant; varnt++) {
numElem = in.readUint16BE();
if (varnt == _vm->_gameVariant) {
_actListArrSize = numElem;
_actListArr = (act **)malloc(sizeof(act *) * _actListArrSize);
- for (int i = 0; i < _actListArrSize; i++) {
- numSubElem = in.readUint16BE();
+ }
+
+ for (int i = 0; i < numElem; i++) {
+ numSubElem = in.readUint16BE();
+ if (varnt == _vm->_gameVariant)
_actListArr[i] = (act *) malloc(sizeof(act) * (numSubElem + 1));
- for (int j = 0; j < numSubElem; j++) {
- _actListArr[i][j].a0.actType = (action_t) in.readByte();
- switch (_actListArr[i][j].a0.actType) {
- case ANULL: // -1
- break;
- case ASCHEDULE: // 0
- _actListArr[i][j].a0.timer = in.readSint16BE();
- _actListArr[i][j].a0.actIndex = in.readUint16BE();
- break;
- case START_OBJ: // 1
- _actListArr[i][j].a1.timer = in.readSint16BE();
- _actListArr[i][j].a1.objIndex = in.readSint16BE();
- _actListArr[i][j].a1.cycleNumb = in.readSint16BE();
- _actListArr[i][j].a1.cycle = (cycle_t) in.readByte();
- break;
- case INIT_OBJXY: // 2
- _actListArr[i][j].a2.timer = in.readSint16BE();
- _actListArr[i][j].a2.objIndex = in.readSint16BE();
- _actListArr[i][j].a2.x = in.readSint16BE();
- _actListArr[i][j].a2.y = in.readSint16BE();
- break;
- case PROMPT: // 3
- _actListArr[i][j].a3.timer = in.readSint16BE();
- _actListArr[i][j].a3.promptIndex = in.readSint16BE();
- numSubAct = in.readUint16BE();
- _actListArr[i][j].a3.responsePtr = (int *) malloc(sizeof(int) * numSubAct);
- for (int k = 0; k < numSubAct; k++)
- _actListArr[i][j].a3.responsePtr[k] = in.readSint16BE();
- _actListArr[i][j].a3.actPassIndex = in.readUint16BE();
- _actListArr[i][j].a3.actFailIndex = in.readUint16BE();
- _actListArr[i][j].a3.encodedFl = (in.readByte() == 1) ? true : false;
- break;
- case BKGD_COLOR: // 4
- _actListArr[i][j].a4.timer = in.readSint16BE();
- _actListArr[i][j].a4.newBackgroundColor = in.readUint32BE();
- break;
- case INIT_OBJVXY: // 5
- _actListArr[i][j].a5.timer = in.readSint16BE();
- _actListArr[i][j].a5.objIndex = in.readSint16BE();
- _actListArr[i][j].a5.vx = in.readSint16BE();
- _actListArr[i][j].a5.vy = in.readSint16BE();
- break;
- case INIT_CARRY: // 6
- _actListArr[i][j].a6.timer = in.readSint16BE();
- _actListArr[i][j].a6.objIndex = in.readSint16BE();
- _actListArr[i][j].a6.carriedFl = (in.readByte() == 1) ? true : false;
- break;
- case INIT_HF_COORD: // 7
- _actListArr[i][j].a7.timer = in.readSint16BE();
- _actListArr[i][j].a7.objIndex = in.readSint16BE();
- break;
- case NEW_SCREEN: // 8
- _actListArr[i][j].a8.timer = in.readSint16BE();
- _actListArr[i][j].a8.screenIndex = in.readSint16BE();
- break;
- case INIT_OBJSTATE: // 9
- _actListArr[i][j].a9.timer = in.readSint16BE();
- _actListArr[i][j].a9.objIndex = in.readSint16BE();
- _actListArr[i][j].a9.newState = in.readByte();
- break;
- case INIT_PATH: // 10
- _actListArr[i][j].a10.timer = in.readSint16BE();
- _actListArr[i][j].a10.objIndex = in.readSint16BE();
- _actListArr[i][j].a10.newPathType = in.readSint16BE();
- _actListArr[i][j].a10.vxPath = in.readByte();
- _actListArr[i][j].a10.vyPath = in.readByte();
- break;
- case COND_R: // 11
- _actListArr[i][j].a11.timer = in.readSint16BE();
- _actListArr[i][j].a11.objIndex = in.readSint16BE();
- _actListArr[i][j].a11.stateReq = in.readByte();
- _actListArr[i][j].a11.actPassIndex = in.readUint16BE();
- _actListArr[i][j].a11.actFailIndex = in.readUint16BE();
- break;
- case TEXT: // 12
- _actListArr[i][j].a12.timer = in.readSint16BE();
- _actListArr[i][j].a12.stringIndex = in.readSint16BE();
- break;
- case SWAP_IMAGES: // 13
- _actListArr[i][j].a13.timer = in.readSint16BE();
- _actListArr[i][j].a13.objIndex1 = in.readSint16BE();
- _actListArr[i][j].a13.objIndex2 = in.readSint16BE();
- break;
- case COND_SCR: // 14
- _actListArr[i][j].a14.timer = in.readSint16BE();
- _actListArr[i][j].a14.objIndex = in.readSint16BE();
- _actListArr[i][j].a14.screenReq = in.readSint16BE();
- _actListArr[i][j].a14.actPassIndex = in.readUint16BE();
- _actListArr[i][j].a14.actFailIndex = in.readUint16BE();
- break;
- case AUTOPILOT: // 15
- _actListArr[i][j].a15.timer = in.readSint16BE();
- _actListArr[i][j].a15.objIndex1 = in.readSint16BE();
- _actListArr[i][j].a15.objIndex2 = in.readSint16BE();
- _actListArr[i][j].a15.dx = in.readByte();
- _actListArr[i][j].a15.dy = in.readByte();
- break;
- case INIT_OBJ_SEQ: // 16
- _actListArr[i][j].a16.timer = in.readSint16BE();
- _actListArr[i][j].a16.objIndex = in.readSint16BE();
- _actListArr[i][j].a16.seqIndex = in.readSint16BE();
- break;
- case SET_STATE_BITS: // 17
- _actListArr[i][j].a17.timer = in.readSint16BE();
- _actListArr[i][j].a17.objIndex = in.readSint16BE();
- _actListArr[i][j].a17.stateMask = in.readSint16BE();
- break;
- case CLEAR_STATE_BITS: // 18
- _actListArr[i][j].a18.timer = in.readSint16BE();
- _actListArr[i][j].a18.objIndex = in.readSint16BE();
- _actListArr[i][j].a18.stateMask = in.readSint16BE();
- break;
- case TEST_STATE_BITS: // 19
- _actListArr[i][j].a19.timer = in.readSint16BE();
- _actListArr[i][j].a19.objIndex = in.readSint16BE();
- _actListArr[i][j].a19.stateMask = in.readSint16BE();
- _actListArr[i][j].a19.actPassIndex = in.readUint16BE();
- _actListArr[i][j].a19.actFailIndex = in.readUint16BE();
- break;
- case DEL_EVENTS: // 20
- _actListArr[i][j].a20.timer = in.readSint16BE();
- _actListArr[i][j].a20.actTypeDel = (action_t) in.readByte();
- break;
- case GAMEOVER: // 21
- _actListArr[i][j].a21.timer = in.readSint16BE();
- break;
- case INIT_HH_COORD: // 22
- _actListArr[i][j].a22.timer = in.readSint16BE();
- _actListArr[i][j].a22.objIndex = in.readSint16BE();
- break;
- case EXIT: // 23
- _actListArr[i][j].a23.timer = in.readSint16BE();
- break;
- case BONUS: // 24
- _actListArr[i][j].a24.timer = in.readSint16BE();
- _actListArr[i][j].a24.pointIndex = in.readSint16BE();
- break;
- case COND_BOX: // 25
- _actListArr[i][j].a25.timer = in.readSint16BE();
- _actListArr[i][j].a25.objIndex = in.readSint16BE();
- _actListArr[i][j].a25.x1 = in.readSint16BE();
- _actListArr[i][j].a25.y1 = in.readSint16BE();
- _actListArr[i][j].a25.x2 = in.readSint16BE();
- _actListArr[i][j].a25.y2 = in.readSint16BE();
- _actListArr[i][j].a25.actPassIndex = in.readUint16BE();
- _actListArr[i][j].a25.actFailIndex = in.readUint16BE();
- break;
- case SOUND: // 26
- _actListArr[i][j].a26.timer = in.readSint16BE();
- _actListArr[i][j].a26.soundIndex = in.readSint16BE();
- break;
- case ADD_SCORE: // 27
- _actListArr[i][j].a27.timer = in.readSint16BE();
- _actListArr[i][j].a27.objIndex = in.readSint16BE();
- break;
- case SUB_SCORE: // 28
- _actListArr[i][j].a28.timer = in.readSint16BE();
- _actListArr[i][j].a28.objIndex = in.readSint16BE();
- break;
- case COND_CARRY: // 29
- _actListArr[i][j].a29.timer = in.readSint16BE();
- _actListArr[i][j].a29.objIndex = in.readSint16BE();
- _actListArr[i][j].a29.actPassIndex = in.readUint16BE();
- _actListArr[i][j].a29.actFailIndex = in.readUint16BE();
- break;
- case INIT_MAZE: // 30
- _actListArr[i][j].a30.timer = in.readSint16BE();
- _actListArr[i][j].a30.mazeSize = in.readByte();
- _actListArr[i][j].a30.x1 = in.readSint16BE();
- _actListArr[i][j].a30.y1 = in.readSint16BE();
- _actListArr[i][j].a30.x2 = in.readSint16BE();
- _actListArr[i][j].a30.y2 = in.readSint16BE();
- _actListArr[i][j].a30.x3 = in.readSint16BE();
- _actListArr[i][j].a30.x4 = in.readSint16BE();
- _actListArr[i][j].a30.firstScreenIndex = in.readByte();
- break;
- case EXIT_MAZE: // 31
- _actListArr[i][j].a31.timer = in.readSint16BE();
- break;
- case INIT_PRIORITY: // 32
- _actListArr[i][j].a32.timer = in.readSint16BE();
- _actListArr[i][j].a32.objIndex = in.readSint16BE();
- _actListArr[i][j].a32.priority = in.readByte();
- break;
- case INIT_SCREEN: // 33
- _actListArr[i][j].a33.timer = in.readSint16BE();
- _actListArr[i][j].a33.objIndex = in.readSint16BE();
- _actListArr[i][j].a33.screenIndex = in.readSint16BE();
- break;
- case AGSCHEDULE: // 34
- _actListArr[i][j].a34.timer = in.readSint16BE();
- _actListArr[i][j].a34.actIndex = in.readUint16BE();
- break;
- case REMAPPAL: // 35
- _actListArr[i][j].a35.timer = in.readSint16BE();
- _actListArr[i][j].a35.oldColorIndex = in.readSint16BE();
- _actListArr[i][j].a35.newColorIndex = in.readSint16BE();
- break;
- case COND_NOUN: // 36
- _actListArr[i][j].a36.timer = in.readSint16BE();
- _actListArr[i][j].a36.nounIndex = in.readUint16BE();
- _actListArr[i][j].a36.actPassIndex = in.readUint16BE();
- _actListArr[i][j].a36.actFailIndex = in.readUint16BE();
- break;
- case SCREEN_STATE: // 37
- _actListArr[i][j].a37.timer = in.readSint16BE();
- _actListArr[i][j].a37.screenIndex = in.readSint16BE();
- _actListArr[i][j].a37.newState = in.readByte();
- break;
- case INIT_LIPS: // 38
- _actListArr[i][j].a38.timer = in.readSint16BE();
- _actListArr[i][j].a38.lipsObjIndex = in.readSint16BE();
- _actListArr[i][j].a38.objIndex = in.readSint16BE();
- _actListArr[i][j].a38.dxLips = in.readByte();
- _actListArr[i][j].a38.dyLips = in.readByte();
- break;
- case INIT_STORY_MODE: // 39
- _actListArr[i][j].a39.timer = in.readSint16BE();
- _actListArr[i][j].a39.storyModeFl = (in.readByte() == 1);
- break;
- case WARN: // 40
- _actListArr[i][j].a40.timer = in.readSint16BE();
- _actListArr[i][j].a40.stringIndex = in.readSint16BE();
- break;
- case COND_BONUS: // 41
- _actListArr[i][j].a41.timer = in.readSint16BE();
- _actListArr[i][j].a41.BonusIndex = in.readSint16BE();
- _actListArr[i][j].a41.actPassIndex = in.readUint16BE();
- _actListArr[i][j].a41.actFailIndex = in.readUint16BE();
- break;
- case TEXT_TAKE: // 42
- _actListArr[i][j].a42.timer = in.readSint16BE();
- _actListArr[i][j].a42.objIndex = in.readSint16BE();
- break;
- case YESNO: // 43
- _actListArr[i][j].a43.timer = in.readSint16BE();
- _actListArr[i][j].a43.promptIndex = in.readSint16BE();
- _actListArr[i][j].a43.actYesIndex = in.readUint16BE();
- _actListArr[i][j].a43.actNoIndex = in.readUint16BE();
- break;
- case STOP_ROUTE: // 44
- _actListArr[i][j].a44.timer = in.readSint16BE();
- break;
- case COND_ROUTE: // 45
- _actListArr[i][j].a45.timer = in.readSint16BE();
- _actListArr[i][j].a45.routeIndex = in.readSint16BE();
- _actListArr[i][j].a45.actPassIndex = in.readUint16BE();
- _actListArr[i][j].a45.actFailIndex = in.readUint16BE();
- break;
- case INIT_JUMPEXIT: // 46
- _actListArr[i][j].a46.timer = in.readSint16BE();
- _actListArr[i][j].a46.jumpExitFl = (in.readByte() == 1);
- break;
- case INIT_VIEW: // 47
- _actListArr[i][j].a47.timer = in.readSint16BE();
- _actListArr[i][j].a47.objIndex = in.readSint16BE();
- _actListArr[i][j].a47.viewx = in.readSint16BE();
- _actListArr[i][j].a47.viewy = in.readSint16BE();
- _actListArr[i][j].a47.direction = in.readSint16BE();
- break;
- case INIT_OBJ_FRAME: // 48
- _actListArr[i][j].a48.timer = in.readSint16BE();
- _actListArr[i][j].a48.objIndex = in.readSint16BE();
- _actListArr[i][j].a48.seqIndex = in.readSint16BE();
- _actListArr[i][j].a48.frameIndex = in.readSint16BE();
- break;
- case OLD_SONG: //49
- _actListArr[i][j].a49.timer = in.readSint16BE();
- _actListArr[i][j].a49.songIndex = in.readUint16BE();
- break;
- default:
- error("Engine - Unknown action type encountered: %d", _actListArr[i][j].a0.actType);
- }
- }
- _actListArr[i][numSubElem].a0.actType = ANULL;
- }
- } else {
- for (int i = 0; i < numElem; i++) {
- numSubElem = in.readUint16BE();
- for (int j = 0; j < numSubElem; j++) {
- numSubAct = in.readByte();
- switch (numSubAct) {
- case ANULL: // -1
- break;
- case ASCHEDULE: // 0
- in.readSint16BE();
- in.readUint16BE();
- break;
- case START_OBJ: // 1
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- in.readByte();
- break;
- case INIT_OBJXY: // 2
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- break;
- case PROMPT: // 3
- in.readSint16BE();
- in.readSint16BE();
- numSubAct = in.readUint16BE();
- for (int k = 0; k < numSubAct; k++)
- in.readSint16BE();
- in.readUint16BE();
- in.readUint16BE();
- in.readByte();
- break;
- case BKGD_COLOR: // 4
- in.readSint16BE();
- in.readUint32BE();
- break;
- case INIT_OBJVXY: // 5
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- break;
- case INIT_CARRY: // 6
- in.readSint16BE();
- in.readSint16BE();
- in.readByte();
- break;
- case INIT_HF_COORD: // 7
- in.readSint16BE();
- in.readSint16BE();
- break;
- case NEW_SCREEN: // 8
- in.readSint16BE();
- in.readSint16BE();
- break;
- case INIT_OBJSTATE: // 9
- in.readSint16BE();
- in.readSint16BE();
- in.readByte();
- break;
- case INIT_PATH: // 10
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- in.readByte();
- in.readByte();
- break;
- case COND_R: // 11
- in.readSint16BE();
- in.readSint16BE();
- in.readByte();
- in.readUint16BE();
- in.readUint16BE();
- break;
- case TEXT: // 12
- in.readSint16BE();
- in.readSint16BE();
- break;
- case SWAP_IMAGES: // 13
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- break;
- case COND_SCR: // 14
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- in.readUint16BE();
- in.readUint16BE();
- break;
- case AUTOPILOT: // 15
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- in.readByte();
- in.readByte();
- break;
- case INIT_OBJ_SEQ: // 16
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- break;
- case SET_STATE_BITS: // 17
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- break;
- case CLEAR_STATE_BITS: // 18
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- break;
- case TEST_STATE_BITS: // 19
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- in.readUint16BE();
- in.readUint16BE();
- break;
- case DEL_EVENTS: // 20
- in.readSint16BE();
- in.readByte();
- break;
- case GAMEOVER: // 21
- in.readSint16BE();
- break;
- case INIT_HH_COORD: // 22
- in.readSint16BE();
- in.readSint16BE();
- break;
- case EXIT: // 23
- in.readSint16BE();
- break;
- case BONUS: // 24
- in.readSint16BE();
- in.readSint16BE();
- break;
- case COND_BOX: // 25
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- in.readUint16BE();
- in.readUint16BE();
- break;
- case SOUND: // 26
- in.readSint16BE();
- in.readSint16BE();
- break;
- case ADD_SCORE: // 27
- in.readSint16BE();
- in.readSint16BE();
- break;
- case SUB_SCORE: // 28
- in.readSint16BE();
- in.readSint16BE();
- break;
- case COND_CARRY: // 29
- in.readSint16BE();
- in.readSint16BE();
- in.readUint16BE();
- in.readUint16BE();
- break;
- case INIT_MAZE: // 30
- in.readSint16BE();
- in.readByte();
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- in.readByte();
- break;
- case EXIT_MAZE: // 31
- in.readSint16BE();
- break;
- case INIT_PRIORITY: // 32
- in.readSint16BE();
- in.readSint16BE();
- in.readByte();
- break;
- case INIT_SCREEN: // 33
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- break;
- case AGSCHEDULE: // 34
- in.readSint16BE();
- in.readUint16BE();
- break;
- case REMAPPAL: // 35
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- break;
- case COND_NOUN: // 36
- in.readSint16BE();
- in.readUint16BE();
- in.readUint16BE();
- in.readUint16BE();
- break;
- case SCREEN_STATE: // 37
- in.readSint16BE();
- in.readSint16BE();
- in.readByte();
- break;
- case INIT_LIPS: // 38
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- in.readByte();
- in.readByte();
- break;
- case INIT_STORY_MODE: // 39
- in.readSint16BE();
- in.readByte();
- break;
- case WARN: // 40
- in.readSint16BE();
- in.readSint16BE();
- break;
- case COND_BONUS: // 41
- in.readSint16BE();
- in.readSint16BE();
- in.readUint16BE();
- in.readUint16BE();
- break;
- case TEXT_TAKE: // 42
- in.readSint16BE();
- in.readSint16BE();
- break;
- case YESNO: // 43
- in.readSint16BE();
- in.readSint16BE();
- in.readUint16BE();
- in.readUint16BE();
- break;
- case STOP_ROUTE: // 44
- in.readSint16BE();
- break;
- case COND_ROUTE: // 45
- in.readSint16BE();
- in.readSint16BE();
- in.readUint16BE();
- in.readUint16BE();
- break;
- case INIT_JUMPEXIT: // 46
- in.readSint16BE();
- in.readByte();
- break;
- case INIT_VIEW: // 47
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- break;
- case INIT_OBJ_FRAME: // 48
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- in.readSint16BE();
- break;
- case OLD_SONG: //49
- in.readSint16BE();
- in.readUint16BE();
- break;
- default:
- error("Engine - Unknown action type encountered %d - variante %d pos %d.%d", numSubAct, varnt, i, j);
- }
+ for (int j = 0; j < numSubElem; j++) {
+ if (varnt == _vm->_gameVariant) {
+ readAct(in, _actListArr[i][j]);
+ } else {
+ readAct(in, tmpAct);
+ if (tmpAct.a0.actType == PROMPT)
+ free(tmpAct.a3.responsePtr);
}
}
+
+ if (varnt == _vm->_gameVariant)
+ _actListArr[i][numSubElem].a0.actType = ANULL;
}
}
}
+
/**
* Read _screenActs
*/
-void Scheduler::loadScreenAct(Common::ReadStream &in) {
+void Scheduler::loadScreenAct(Common::SeekableReadStream &in) {
for (int varnt = 0; varnt < _vm->_numVariant; varnt++) {
uint16 numElem = in.readUint16BE();
- uint16 **wrkScreenActs = (uint16 **)malloc(sizeof(uint16 *) * numElem);
- for (int i = 0; i < numElem; i++) {
- uint16 numSubElem = in.readUint16BE();
- if (numSubElem == 0) {
- wrkScreenActs[i] = 0;
- } else {
- wrkScreenActs[i] = (uint16 *)malloc(sizeof(uint16) * numSubElem);
- for (int j = 0; j < numSubElem; j++)
- wrkScreenActs[i][j] = in.readUint16BE();
- }
- }
-
if (varnt == _vm->_gameVariant) {
_screenActsSize = numElem;
- _screenActs = wrkScreenActs;
+ _screenActs = (uint16 **)malloc(sizeof(uint16 *) * numElem);
+ for (int i = 0; i < numElem; i++) {
+ uint16 numSubElem = in.readUint16BE();
+ if (numSubElem == 0) {
+ _screenActs[i] = 0;
+ } else {
+ _screenActs[i] = (uint16 *)malloc(sizeof(uint16) * numSubElem);
+ for (int j = 0; j < numSubElem; j++)
+ _screenActs[i][j] = in.readUint16BE();
+ }
+ }
} else {
- for (int i = 0; i < numElem; i++)
- free(wrkScreenActs[i]);
- free(wrkScreenActs);
+ for (int i = 0; i < numElem; i++) {
+ uint16 numSubElem = in.readUint16BE();
+ in.skip(numSubElem * sizeof(uint16));
+ }
}
}
}
diff --git a/engines/hugo/schedule.h b/engines/hugo/schedule.h
index e2169a0aa9..c7a6003ddf 100644
--- a/engines/hugo/schedule.h
+++ b/engines/hugo/schedule.h
@@ -466,11 +466,12 @@ public:
void insertActionList(const uint16 actIndex);
void loadActListArr(Common::ReadStream &in);
void loadAlNewscrIndex(Common::ReadStream &in);
- void loadPoints(Common::ReadStream &in);
- void loadScreenAct(Common::ReadStream &in);
+ void loadPoints(Common::SeekableReadStream &in);
+ void loadScreenAct(Common::SeekableReadStream &in);
void newScreen(const int screenIndex);
void processBonus(const int bonusIndex);
void processMaze(const int x1, const int x2, const int y1, const int y2);
+ void readAct(Common::ReadStream &in, act &curAct);
void restoreSchedulerData(Common::ReadStream *in);
void restoreScreen(const int screenIndex);
void saveSchedulerData(Common::WriteStream *out);
diff --git a/engines/hugo/text.h b/engines/hugo/text.h
index cf728f6ad4..ec4001567d 100644
--- a/engines/hugo/text.h
+++ b/engines/hugo/text.h
@@ -42,8 +42,8 @@ public:
const char *getTextParser(int parserIndex) const { return _textParser[parserIndex]; }
const char *getTextUtil(int utilIndex) const { return _textUtil[utilIndex]; }
const char *getVerb(int idx1, int idx2) const { return _arrayVerbs[idx1][idx2]; }
- char **getNounArray(int idx1) { return _arrayNouns[idx1]; }
- char **getVerbArray(int idx1) { return _arrayVerbs[idx1]; }
+ char **getNounArray(int idx1) const { return _arrayNouns[idx1]; }
+ char **getVerbArray(int idx1) const { return _arrayVerbs[idx1]; }
void loadAllTexts(Common::ReadStream &in);
void freeAllTexts();