MACVENTURE: Add attribute set function
This commit is contained in:
parent
0fc3e90974
commit
e8725ae068
4 changed files with 69 additions and 1 deletions
|
@ -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);
|
||||
|
|
|
@ -151,6 +151,7 @@ public:
|
|||
void activateCommand(ControlReference id);
|
||||
void refreshReady();
|
||||
void preparedToRun();
|
||||
void gameChanged();
|
||||
|
||||
void enqueueObject(ObjID id);
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue