aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Kasak2009-07-02 15:08:42 +0000
committerDenis Kasak2009-07-02 15:08:42 +0000
commit936e5f4c5e5c70f9869ed8a986173c92b7f39d4a (patch)
treeb68395140ad04fa13d87a89821d3718a1b80be9f
parent35a677fb08402b5a9fd07366d60651bcc2f598ce (diff)
downloadscummvm-rg350-936e5f4c5e5c70f9869ed8a986173c92b7f39d4a.tar.gz
scummvm-rg350-936e5f4c5e5c70f9869ed8a986173c92b7f39d4a.tar.bz2
scummvm-rg350-936e5f4c5e5c70f9869ed8a986173c92b7f39d4a.zip
Merged the info available from _objectStatus with the GameObject struct. Made Game keep a list of all the game's objects. Added Game::getObject() method for fetching a pointer to a particular object. Changed Game::loadObject() to not accept a pointer to a GameObject struct anymore.
svn-id: r42026
-rw-r--r--engines/draci/game.cpp34
-rw-r--r--engines/draci/game.h8
2 files changed, 32 insertions, 10 deletions
diff --git a/engines/draci/game.cpp b/engines/draci/game.cpp
index 72e431bf44..d13883087c 100644
--- a/engines/draci/game.cpp
+++ b/engines/draci/game.cpp
@@ -113,19 +113,29 @@ Game::Game(DraciEngine *vm) : _vm(vm) {
file = initArchive[0];
unsigned int numObjects = file->_length;
- _objectStatus = new byte[numObjects];
- memcpy(_objectStatus, file->_data, file->_length);
+ _objects = new GameObject[numObjects];
+ Common::MemoryReadStream objStatus(file->_data, file->_length);
+ for (i = 0; i < numObjects; ++i) {
+ byte tmp = objStatus.readByte();
+
+ // Set object visibility
+ _objects[i]._visible = tmp & 1;
+
+ // Set object location
+ _objects[i]._location = tmp & ~1;
+ }
+
assert(numDialogs == _info->_numDialogs);
assert(numPersons == _info->_numPersons);
assert(numVariables == _info->_numVariables);
assert(numObjects == _info->_numObjects);
- loadObject(0, &_heroObj);
- _vm->_script->run(_heroObj._program, _heroObj._init);
+ loadObject(1);
+ _vm->_script->run(getObject(1)->_program, getObject(1)->_init);
}
-void Game::loadObject(uint16 objNum, GameObject *obj) {
+void Game::loadObject(uint16 objNum) {
Common::String path("OBJEKTY.DFW");
BArchive objArchive(path);
@@ -134,6 +144,8 @@ void Game::loadObject(uint16 objNum, GameObject *obj) {
file = objArchive[objNum * 3];
Common::MemoryReadStream objReader(file->_data, file->_length);
+ GameObject *obj = getObject(objNum);
+
obj->_init = objReader.readUint16LE();
obj->_look = objReader.readUint16LE();
obj->_use = objReader.readUint16LE();
@@ -166,13 +178,21 @@ void Game::loadObject(uint16 objNum, GameObject *obj) {
obj->_program._length = file->_length;
memcpy(obj->_program._bytecode, file->_data, file->_length);
}
-
+
+GameObject *Game::getObject(uint16 objNum) {
+
+ // Convert to real index (indexes begin with 1 in the data files)
+ objNum -= 1;
+
+ return &_objects[objNum];
+}
+
Game::~Game() {
delete[] _persons;
delete[] _variables;
delete[] _dialogOffsets;
delete[] _itemStatus;
- delete[] _objectStatus;
+ delete[] _objects;
delete _info;
}
diff --git a/engines/draci/game.h b/engines/draci/game.h
index abefb0f963..4b6ba17878 100644
--- a/engines/draci/game.h
+++ b/engines/draci/game.h
@@ -54,6 +54,8 @@ struct GameObject {
uint16 *_seqTab;
GPL2Program _program;
byte *_title;
+ byte _location;
+ bool _visible;
};
struct GameInfo {
@@ -89,10 +91,10 @@ private:
uint16 *_dialogOffsets;
int16 *_variables;
byte *_itemStatus;
- byte *_objectStatus;
- GameObject _heroObj;
+ GameObject *_objects;
- void loadObject(uint16 numObj, GameObject *obj);
+ void loadObject(uint16 numObj);
+ GameObject *getObject(uint16 objNum);
};
} // End of namespace Draci