aboutsummaryrefslogtreecommitdiff
path: root/engines/draci/game.cpp
diff options
context:
space:
mode:
authorDenis Kasak2009-07-02 15:08:42 +0000
committerDenis Kasak2009-07-02 15:08:42 +0000
commit936e5f4c5e5c70f9869ed8a986173c92b7f39d4a (patch)
treeb68395140ad04fa13d87a89821d3718a1b80be9f /engines/draci/game.cpp
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
Diffstat (limited to 'engines/draci/game.cpp')
-rw-r--r--engines/draci/game.cpp34
1 files changed, 27 insertions, 7 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;
}