aboutsummaryrefslogtreecommitdiff
path: root/engines/macventure/world.cpp
diff options
context:
space:
mode:
authorBorja Lorente2016-06-17 21:47:40 +0200
committerBorja Lorente2016-08-14 18:28:47 +0200
commite8725ae068a51fb6ccdfd9f7d2bd4e8e7a12f40a (patch)
tree29558ca60479a863985e89edaf7b17fc6490b154 /engines/macventure/world.cpp
parent0fc3e909749f3d1af3e617fbcbc83c3f7819c392 (diff)
downloadscummvm-rg350-e8725ae068a51fb6ccdfd9f7d2bd4e8e7a12f40a.tar.gz
scummvm-rg350-e8725ae068a51fb6ccdfd9f7d2bd4e8e7a12f40a.tar.bz2
scummvm-rg350-e8725ae068a51fb6ccdfd9f7d2bd4e8e7a12f40a.zip
MACVENTURE: Add attribute set function
Diffstat (limited to 'engines/macventure/world.cpp')
-rw-r--r--engines/macventure/world.cpp52
1 files changed, 51 insertions, 1 deletions
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;
}