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;
|
_cmdReady = false;
|
||||||
_haltedAtEnd = false;
|
_haltedAtEnd = false;
|
||||||
_haltedInSelection = 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;
|
_prepared = true;
|
||||||
while (!(_gameState == kGameStateQuitting)) {
|
while (!(_gameState == kGameStateQuitting)) {
|
||||||
processEvents();
|
processEvents();
|
||||||
|
@ -181,6 +189,10 @@ void MacVentureEngine::preparedToRun() {
|
||||||
_prepared = true;
|
_prepared = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MacVentureEngine::gameChanged() {
|
||||||
|
_gameChanged = true;
|
||||||
|
}
|
||||||
|
|
||||||
void MacVentureEngine::enqueueObject(ObjID id) {
|
void MacVentureEngine::enqueueObject(ObjID id) {
|
||||||
QueuedObject obj;
|
QueuedObject obj;
|
||||||
obj.parent = _world->getObjAttr(id, kAttrParentObject);
|
obj.parent = _world->getObjAttr(id, kAttrParentObject);
|
||||||
|
|
|
@ -151,6 +151,7 @@ public:
|
||||||
void activateCommand(ControlReference id);
|
void activateCommand(ControlReference id);
|
||||||
void refreshReady();
|
void refreshReady();
|
||||||
void preparedToRun();
|
void preparedToRun();
|
||||||
|
void gameChanged();
|
||||||
|
|
||||||
void enqueueObject(ObjID id);
|
void enqueueObject(ObjID id);
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ uint32 World::getObjAttr(ObjID objID, uint32 attrID) {
|
||||||
uint32 res;
|
uint32 res;
|
||||||
uint32 index = _engine->getGlobalSettings().attrIndices[attrID];
|
uint32 index = _engine->getGlobalSettings().attrIndices[attrID];
|
||||||
if (!(index & 0x80)) { // It's not a constant
|
if (!(index & 0x80)) { // It's not a constant
|
||||||
res = _saveGame->getGroups()[attrID][objID];
|
res = _saveGame->getAttr(objID, index);
|
||||||
} else {
|
} else {
|
||||||
Common::SeekableReadStream *objStream = _objectConstants->getItem(objID);
|
Common::SeekableReadStream *objStream = _objectConstants->getItem(objID);
|
||||||
index &= 0x7F;
|
index &= 0x7F;
|
||||||
|
@ -59,6 +59,25 @@ uint32 World::getObjAttr(ObjID objID, uint32 attrID) {
|
||||||
return res;
|
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) {
|
bool MacVenture::World::isObjActive(ObjID obj) {
|
||||||
return false;
|
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::SaveGame(MacVentureEngine *engine, Common::SeekableReadStream *res) {
|
SaveGame::SaveGame(MacVentureEngine *engine, Common::SeekableReadStream *res) {
|
||||||
_groups = Common::Array<AttributeGroup>();
|
_groups = Common::Array<AttributeGroup>();
|
||||||
|
@ -107,6 +148,15 @@ SaveGame::SaveGame(MacVentureEngine *engine, Common::SeekableReadStream *res) {
|
||||||
SaveGame::~SaveGame() {
|
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() {
|
const Common::Array<AttributeGroup>& MacVenture::SaveGame::getGroups() {
|
||||||
return _groups;
|
return _groups;
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,6 +65,9 @@ public:
|
||||||
SaveGame(MacVentureEngine *engine, Common::SeekableReadStream *res);
|
SaveGame(MacVentureEngine *engine, Common::SeekableReadStream *res);
|
||||||
~SaveGame();
|
~SaveGame();
|
||||||
|
|
||||||
|
Attribute getAttr(ObjID objID, uint32 attrID);
|
||||||
|
void setAttr(uint32 attrID, ObjID objID, Attribute value);
|
||||||
|
|
||||||
const Common::Array<AttributeGroup> &getGroups();
|
const Common::Array<AttributeGroup> &getGroups();
|
||||||
const AttributeGroup *getGroup(uint32 groupID);
|
const AttributeGroup *getGroup(uint32 groupID);
|
||||||
const Common::Array<uint16> &getGlobals();
|
const Common::Array<uint16> &getGlobals();
|
||||||
|
@ -87,11 +90,13 @@ public:
|
||||||
~World();
|
~World();
|
||||||
|
|
||||||
uint32 getObjAttr(ObjID objID, uint32 attrID);
|
uint32 getObjAttr(ObjID objID, uint32 attrID);
|
||||||
|
void setObjAttr(ObjID objID, uint32 attrID, Attribute value);
|
||||||
bool isObjActive(ObjID obj);
|
bool isObjActive(ObjID obj);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool loadStartGameFileName();
|
bool loadStartGameFileName();
|
||||||
void calculateObjectRelations();
|
void calculateObjectRelations();
|
||||||
|
void setParent(ObjID child, ObjID newParent);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MacVentureEngine *_engine;
|
MacVentureEngine *_engine;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue