aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBorja Lorente2016-06-17 21:47:40 +0200
committerBorja Lorente2016-08-14 18:28:47 +0200
commite8725ae068a51fb6ccdfd9f7d2bd4e8e7a12f40a (patch)
tree29558ca60479a863985e89edaf7b17fc6490b154
parent0fc3e909749f3d1af3e617fbcbc83c3f7819c392 (diff)
downloadscummvm-rg350-e8725ae068a51fb6ccdfd9f7d2bd4e8e7a12f40a.tar.gz
scummvm-rg350-e8725ae068a51fb6ccdfd9f7d2bd4e8e7a12f40a.tar.bz2
scummvm-rg350-e8725ae068a51fb6ccdfd9f7d2bd4e8e7a12f40a.zip
MACVENTURE: Add attribute set function
-rw-r--r--engines/macventure/macventure.cpp12
-rw-r--r--engines/macventure/macventure.h1
-rw-r--r--engines/macventure/world.cpp52
-rw-r--r--engines/macventure/world.h5
4 files changed, 69 insertions, 1 deletions
diff --git a/engines/macventure/macventure.cpp b/engines/macventure/macventure.cpp
index da192628fe..75f2c33711 100644
--- a/engines/macventure/macventure.cpp
+++ b/engines/macventure/macventure.cpp
@@ -99,6 +99,14 @@ Common::Error MacVentureEngine::run() {
_cmdReady = false;
_haltedAtEnd = false;
_haltedInSelection = false;
+
+ //if !savegame
+ _cmdReady = true;
+ _selectedControl = kStartOrResume;
+ ObjID playerParent = _world->getObjAttr(1, kAttrParentObject);
+ _currentSelection.push_back(playerParent);// Push the parent of the player
+ _world->setObjAttr(playerParent, 6, 1);
+
_prepared = true;
while (!(_gameState == kGameStateQuitting)) {
processEvents();
@@ -181,6 +189,10 @@ void MacVentureEngine::preparedToRun() {
_prepared = true;
}
+void MacVentureEngine::gameChanged() {
+ _gameChanged = true;
+}
+
void MacVentureEngine::enqueueObject(ObjID id) {
QueuedObject obj;
obj.parent = _world->getObjAttr(id, kAttrParentObject);
diff --git a/engines/macventure/macventure.h b/engines/macventure/macventure.h
index a4340bf2bc..457d685992 100644
--- a/engines/macventure/macventure.h
+++ b/engines/macventure/macventure.h
@@ -151,6 +151,7 @@ public:
void activateCommand(ControlReference id);
void refreshReady();
void preparedToRun();
+ void gameChanged();
void enqueueObject(ObjID id);
diff --git a/engines/macventure/world.cpp b/engines/macventure/world.cpp
index abb0c55c04..feb8c0b7be 100644
--- a/engines/macventure/world.cpp
+++ b/engines/macventure/world.cpp
@@ -46,7 +46,7 @@ uint32 World::getObjAttr(ObjID objID, uint32 attrID) {
uint32 res;
uint32 index = _engine->getGlobalSettings().attrIndices[attrID];
if (!(index & 0x80)) { // It's not a constant
- res = _saveGame->getGroups()[attrID][objID];
+ res = _saveGame->getAttr(objID, index);
} else {
Common::SeekableReadStream *objStream = _objectConstants->getItem(objID);
index &= 0x7F;
@@ -59,6 +59,25 @@ uint32 World::getObjAttr(ObjID objID, uint32 attrID) {
return res;
}
+void World::setObjAttr(ObjID objID, uint32 attrID, Attribute value) {
+ if (attrID == kAttrPosX || attrID == kAttrPosY) {}
+ // Round to scale
+
+ if (attrID == kAttrParentObject)
+ setParent(objID, value);
+
+ if (attrID < kAttrOtherDoor)
+ _engine->enqueueObject(objID);
+
+ uint32 idx = _engine->getGlobalSettings().attrIndices[attrID];
+ value <<= _engine->getGlobalSettings().attrShifts[attrID];
+ value &= _engine->getGlobalSettings().attrMasks[attrID];
+ Attribute oldVal = _saveGame->getAttr(objID, idx);
+ oldVal &= ~_engine->getGlobalSettings().attrMasks[attrID];
+ _saveGame->setAttr(idx, objID, (value | oldVal));
+ _engine->gameChanged();
+}
+
bool MacVenture::World::isObjActive(ObjID obj) {
return false;
}
@@ -94,6 +113,28 @@ void World::calculateObjectRelations() {
}
}
+void World::setParent(ObjID child, ObjID newParent) {
+ ObjID old = _saveGame->getAttr(child, kAttrParentObject);
+ if (newParent == child)
+ return;
+
+ ObjID oldNdx = old * 2;
+ old = _relations[oldNdx];
+ while (old != child) {
+ oldNdx = (old * 2) + 1;
+ old = _relations[oldNdx];
+ }
+ _relations[oldNdx] = _relations[(old * 2) + 1];
+ oldNdx = newParent * 2;
+ old = _relations[oldNdx];
+ while (old && old <= child) {
+ oldNdx = (old * 2) + 1;
+ old = _relations[oldNdx];
+ }
+ _relations[child * 2 + 1] = old;
+ _relations[oldNdx] = child;
+}
+
// SaveGame
SaveGame::SaveGame(MacVentureEngine *engine, Common::SeekableReadStream *res) {
_groups = Common::Array<AttributeGroup>();
@@ -107,6 +148,15 @@ SaveGame::SaveGame(MacVentureEngine *engine, Common::SeekableReadStream *res) {
SaveGame::~SaveGame() {
}
+
+Attribute SaveGame::getAttr(ObjID objID, uint32 attrID) {
+ return _groups[attrID][objID];
+}
+
+void SaveGame::setAttr(uint32 attrID, ObjID objID, Attribute value) {
+ _groups[attrID][objID] = value;
+}
+
const Common::Array<AttributeGroup>& MacVenture::SaveGame::getGroups() {
return _groups;
}
diff --git a/engines/macventure/world.h b/engines/macventure/world.h
index fe93ef1395..58e9fc5ce5 100644
--- a/engines/macventure/world.h
+++ b/engines/macventure/world.h
@@ -65,6 +65,9 @@ public:
SaveGame(MacVentureEngine *engine, Common::SeekableReadStream *res);
~SaveGame();
+ Attribute getAttr(ObjID objID, uint32 attrID);
+ void setAttr(uint32 attrID, ObjID objID, Attribute value);
+
const Common::Array<AttributeGroup> &getGroups();
const AttributeGroup *getGroup(uint32 groupID);
const Common::Array<uint16> &getGlobals();
@@ -87,11 +90,13 @@ public:
~World();
uint32 getObjAttr(ObjID objID, uint32 attrID);
+ void setObjAttr(ObjID objID, uint32 attrID, Attribute value);
bool isObjActive(ObjID obj);
private:
bool loadStartGameFileName();
void calculateObjectRelations();
+ void setParent(ObjID child, ObjID newParent);
private:
MacVentureEngine *_engine;