SAGA2: Reanme enums in contain.h

This commit is contained in:
Eugene Sandulenko 2022-10-27 14:06:11 +02:00
parent c97c7d7e0b
commit 7cc012e311
No known key found for this signature in database
GPG key ID: 014D387312D34F08
4 changed files with 66 additions and 66 deletions

View file

@ -168,7 +168,7 @@ bool ActorProto::closeAction(ObjectID dObj, ObjectID) {
assert(isActor(dObj)); assert(isActor(dObj));
GameObject *dObjPtr = GameObject::objectAddress(dObj); GameObject *dObjPtr = GameObject::objectAddress(dObj);
ContainerNode *cn = g_vm->_cnm->find(dObj, ContainerNode::deadType); ContainerNode *cn = g_vm->_cnm->find(dObj, ContainerNode::kDeadType);
assert(dObjPtr->isOpen()); assert(dObjPtr->isOpen());
assert(cn); assert(cn);

View file

@ -375,14 +375,14 @@ void ContainerView::drawClipped(
// check to see if selecting amount for this objec // check to see if selecting amount for this objec
if (g_vm->_cnm->_objToGet == item) { if (g_vm->_cnm->_objToGet == item) {
Point16 selectorPos = Point16(x + ((iconWidth - selectorX) >> 1), Point16 selectorPos = Point16(x + ((iconWidth - kSelectorX) >> 1),
y + ((iconHeight - selectorY) >> 1)); y + ((iconHeight - kSelectorY) >> 1));
// draw the selector thingy // draw the selector thingy
drawSelector(port, selectorPos); drawSelector(port, selectorPos);
// set the position of the inc center // set the position of the inc center
g_vm->_cnm->_amountIndY = y - (selectorY >> 1) - 12; g_vm->_cnm->_amountIndY = y - (kSelectorY >> 1) - 12;
} else drawQuantity(port, item, objProto, x, y); } else drawQuantity(port, item, objProto, x, y);
} }
} }
@ -1040,14 +1040,14 @@ void ReadyContainerView::drawClipped(
// check to see if selecting amount for this objec // check to see if selecting amount for this objec
if (g_vm->_cnm->_objToGet == item) { if (g_vm->_cnm->_objToGet == item) {
Point16 selectorPos = Point16(x + ((iconWidth - selectorX) >> 1), Point16 selectorPos = Point16(x + ((iconWidth - kSelectorX) >> 1),
y + ((iconHeight - selectorY) >> 1)); y + ((iconHeight - kSelectorY) >> 1));
// draw the selector thingy // draw the selector thingy
drawSelector(port, selectorPos); drawSelector(port, selectorPos);
// set the position of the inc center // set the position of the inc center
g_vm->_cnm->_amountIndY = y - (selectorY >> 1) + 28; // extent.y; g_vm->_cnm->_amountIndY = y - (kSelectorY >> 1) + 28; // extent.y;
} else drawQuantity(port, item, objProto, x, y); } else drawQuantity(port, item, objProto, x, y);
} }
} }
@ -1117,7 +1117,7 @@ TangibleContainerWindow::TangibleContainerWindow(
const int weightIndicatorType = 2; const int weightIndicatorType = 2;
_objRect = app.iconRect; _objRect = app.iconRect;
_deathFlag = nd.getType() == ContainerNode::deadType; _deathFlag = nd.getType() == ContainerNode::kDeadType;
_containerSpriteImg = nullptr; _containerSpriteImg = nullptr;
// setup the mass and weight indicator // setup the mass and weight indicator
@ -1268,33 +1268,33 @@ ContainerNode::ContainerNode(ContainerManager &cl, ObjectID id, int typ) {
// if it is indeed a player actor; Else set to "nobody". // if it is indeed a player actor; Else set to "nobody".
if (isActor(id)) { if (isActor(id)) {
if (actorIDToPlayerID(id, ownerID) == false) if (actorIDToPlayerID(id, ownerID) == false)
ownerID = ContainerNode::nobody; ownerID = ContainerNode::kNobody;
} else { } else {
ObjectID possessor = obj->possessor(); ObjectID possessor = obj->possessor();
if (possessor == Nothing || actorIDToPlayerID(possessor, ownerID) == false) if (possessor == Nothing || actorIDToPlayerID(possessor, ownerID) == false)
ownerID = ContainerNode::nobody; ownerID = ContainerNode::kNobody;
} }
// Compute the initial position of the container window // Compute the initial position of the container window
switch (typ) { switch (typ) {
case readyType: case kReadyType:
break; break;
case deadType: case kDeadType:
_position = deathContainerAppearance.defaultWindowPos; _position = deathContainerAppearance.defaultWindowPos;
break; break;
case mentalType: case kMentalType:
_mindType = 0; //protoClassIdeaContainer; _mindType = 0; //protoClassIdeaContainer;
_position = mentalContainerAppearance.defaultWindowPos; _position = mentalContainerAppearance.defaultWindowPos;
break; break;
case physicalType: case kPhysicalType:
_position = physicalContainerAppearance.defaultWindowPos; _position = physicalContainerAppearance.defaultWindowPos;
break; break;
case enchantType: case kEnchantType:
_position = enchantmentContainerAppearance.defaultWindowPos; _position = enchantmentContainerAppearance.defaultWindowPos;
break; break;
} }
@ -1374,7 +1374,7 @@ void ContainerNode::write(Common::MemoryWriteStreamDynamic *out) {
// Close the container window, but leave the node. // Close the container window, but leave the node.
void ContainerNode::hide() { void ContainerNode::hide() {
// close the window, but don't close the object. // close the window, but don't close the object.
if (_type != readyType && _window != nullptr) { if (_type != kReadyType && _window != nullptr) {
_position = _window->getExtent(); // Save old window position _position = _window->getExtent(); // Save old window position
_window->close(); _window->close();
delete _window; delete _window;
@ -1391,29 +1391,29 @@ void ContainerNode::show() {
// open the window; Object should already be "open" // open the window; Object should already be "open"
if (_window == nullptr) { if (_window == nullptr) {
switch (_type) { switch (_type) {
case physicalType: case kPhysicalType:
physicalContainerAppearance.rows = proto->getViewableRows(); physicalContainerAppearance.rows = proto->getViewableRows();
physicalContainerAppearance.cols = proto->getViewableCols(); physicalContainerAppearance.cols = proto->getViewableCols();
physicalContainerAppearance.totRows = proto->getMaxRows(); physicalContainerAppearance.totRows = proto->getMaxRows();
_window = new TangibleContainerWindow(*this, physicalContainerAppearance); _window = new TangibleContainerWindow(*this, physicalContainerAppearance);
break; break;
case deadType: case kDeadType:
deathContainerAppearance.rows = proto->getViewableRows(); deathContainerAppearance.rows = proto->getViewableRows();
deathContainerAppearance.cols = proto->getViewableCols(); deathContainerAppearance.cols = proto->getViewableCols();
deathContainerAppearance.totRows = proto->getMaxRows(); deathContainerAppearance.totRows = proto->getMaxRows();
_window = new TangibleContainerWindow(*this, deathContainerAppearance); _window = new TangibleContainerWindow(*this, deathContainerAppearance);
break; break;
case mentalType: case kMentalType:
_window = new IntangibleContainerWindow(*this, mentalContainerAppearance); _window = new IntangibleContainerWindow(*this, mentalContainerAppearance);
break; break;
case enchantType: case kEnchantType:
_window = new EnchantmentContainerWindow(*this, enchantmentContainerAppearance); _window = new EnchantmentContainerWindow(*this, enchantmentContainerAppearance);
break; break;
case readyType: case kReadyType:
default: default:
return; return;
} }
@ -1423,7 +1423,7 @@ void ContainerNode::show() {
} }
void ContainerNode::update() { void ContainerNode::update() {
if (_type == readyType) { if (_type == kReadyType) {
// Update ready containers if they are enabled // Update ready containers if they are enabled
if (TrioCviews[_owner]->getEnabled()) TrioCviews[_owner]->invalidate(); if (TrioCviews[_owner]->getEnabled()) TrioCviews[_owner]->invalidate();
if (indivCviewTop->getEnabled()) indivCviewTop->invalidate(); if (indivCviewTop->getEnabled()) indivCviewTop->invalidate();
@ -1499,7 +1499,7 @@ void ContainerManager::setPlayerNum(PlayerActorID playerNum) {
for (Common::List<ContainerNode *>::iterator it = _list.begin(); it != _list.end(); ++it) { for (Common::List<ContainerNode *>::iterator it = _list.begin(); it != _list.end(); ++it) {
ContainerNode *n = *it; ContainerNode *n = *it;
if (n->_owner != ContainerNode::nobody && n->_owner != playerNum) if (n->_owner != ContainerNode::kNobody && n->_owner != playerNum)
n->hide(); n->hide();
} }
@ -1526,7 +1526,7 @@ void ContainerManager::doDeferredActions() {
ContainerNode *n = *it; ContainerNode *n = *it;
// If the object is not in a player inventory (i.e. on the ground) // If the object is not in a player inventory (i.e. on the ground)
if (n->_owner == ContainerNode::nobody) { if (n->_owner == ContainerNode::kNobody) {
// If the object is in a different world, or too far away // If the object is in a different world, or too far away
// from the protagonist, then quietly close the object. // from the protagonist, then quietly close the object.
GameObject *obj = GameObject::objectAddress(n->_object); GameObject *obj = GameObject::objectAddress(n->_object);
@ -1539,16 +1539,16 @@ void ContainerManager::doDeferredActions() {
} }
} }
if (n->_action & ContainerNode::actionDelete) { if (n->_action & ContainerNode::kActionDelete) {
delete n; delete n;
continue; continue;
} }
if (n->_action & ContainerNode::actionHide) { if (n->_action & ContainerNode::kActionHide) {
n->hide(); n->hide();
} else { } else {
if (n->_action & ContainerNode::actionShow) n->show(); if (n->_action & ContainerNode::kActionShow) n->show();
if (n->_action & ContainerNode::actionUpdate) n->update(); if (n->_action & ContainerNode::kActionUpdate) n->update();
} }
n->_action = 0; n->_action = 0;
@ -1563,7 +1563,7 @@ void ContainerManager::setUpdate(ObjectID id) {
if (n->_object == id) if (n->_object == id)
n->update(); n->update();
else if (n->_type == ContainerNode::mentalType // Special case for mind containers else if (n->_type == ContainerNode::kMentalType // Special case for mind containers
&& n->_object == GameObject::objectAddress(id)->IDParent()) && n->_object == GameObject::objectAddress(id)->IDParent())
n->update(); n->update();
} }
@ -1581,30 +1581,30 @@ ContainerNode *CreateContainerNode(ObjectID id, bool open, int16) {
if (isActor(id)) { if (isActor(id)) {
if (actorIDToPlayerID(id, owner) == false) if (actorIDToPlayerID(id, owner) == false)
owner = ContainerNode::nobody; owner = ContainerNode::kNobody;
if (((Actor *)obj)->isDead()) { if (((Actor *)obj)->isDead()) {
// Open dead container for dead actor // Open dead container for dead actor
if (!(cn = g_vm->_cnm->find(owner, ContainerNode::deadType))) if (!(cn = g_vm->_cnm->find(owner, ContainerNode::kDeadType)))
cn = new ContainerNode(*g_vm->_cnm, id, ContainerNode::deadType); cn = new ContainerNode(*g_vm->_cnm, id, ContainerNode::kDeadType);
} else if (owner != ContainerNode::nobody) { } else if (owner != ContainerNode::kNobody) {
return OpenMindContainer(owner, open, /*mType*/ openMindType); return OpenMindContainer(owner, open, /*mType*/ openMindType);
} else { } else {
error("Attempt to open non-dead actor as a container"); error("Attempt to open non-dead actor as a container");
} }
} else { } else {
if (actorIDToPlayerID(obj->possessor(), owner) == false) if (actorIDToPlayerID(obj->possessor(), owner) == false)
owner = ContainerNode::nobody; owner = ContainerNode::kNobody;
if (!(cn = g_vm->_cnm->find(id, ContainerNode::physicalType))) if (!(cn = g_vm->_cnm->find(id, ContainerNode::kPhysicalType)))
cn = new ContainerNode(*g_vm->_cnm, id, ContainerNode::physicalType); cn = new ContainerNode(*g_vm->_cnm, id, ContainerNode::kPhysicalType);
} }
// If node was successfull created, and we wanted it open, and the owner // If node was successfull created, and we wanted it open, and the owner
// is the center actor or no-actor then make the container window visible. // is the center actor or no-actor then make the container window visible.
if (cn != nullptr if (cn != nullptr
&& open && open
&& (owner == getCenterActorID() || owner == ContainerNode::nobody)) { && (owner == getCenterActorID() || owner == ContainerNode::kNobody)) {
cn->show(); cn->show();
} }
@ -1614,15 +1614,15 @@ ContainerNode *CreateContainerNode(ObjectID id, bool open, int16) {
ContainerNode *CreateReadyContainerNode(PlayerActorID player) { ContainerNode *CreateReadyContainerNode(PlayerActorID player) {
return new ContainerNode(*g_vm->_cnm, return new ContainerNode(*g_vm->_cnm,
getPlayerActorAddress(player)->getActorID(), getPlayerActorAddress(player)->getActorID(),
ContainerNode::readyType); ContainerNode::kReadyType);
} }
ContainerNode *OpenMindContainer(PlayerActorID player, int16 open, int16 type) { ContainerNode *OpenMindContainer(PlayerActorID player, int16 open, int16 type) {
ContainerNode *cn; ContainerNode *cn;
ObjectID id = getPlayerActorAddress(player)->getActorID(); ObjectID id = getPlayerActorAddress(player)->getActorID();
if (!(cn = g_vm->_cnm->find(id, ContainerNode::mentalType))) { if (!(cn = g_vm->_cnm->find(id, ContainerNode::kMentalType))) {
cn = new ContainerNode(*g_vm->_cnm, id, ContainerNode::mentalType); cn = new ContainerNode(*g_vm->_cnm, id, ContainerNode::kMentalType);
cn->_mindType = type; cn->_mindType = type;
// If node was successfull created, and we wanted it open, and the owner // If node was successfull created, and we wanted it open, and the owner
@ -1674,8 +1674,8 @@ void initContainerNodes() {
Common::List<ContainerNode *>::iterator it; Common::List<ContainerNode *>::iterator it;
for (it = g_vm->_cnm->_list.begin(); it != g_vm->_cnm->_list.end(); ++it) { for (it = g_vm->_cnm->_list.begin(); it != g_vm->_cnm->_list.end(); ++it) {
if ((*it)->getType() != ContainerNode::readyType) { if ((*it)->getType() != ContainerNode::kReadyType) {
error("initContainerNodes: ContainerNode type not readyType (%d != %d)", (*it)->getType(), ContainerNode::readyType); error("initContainerNodes: ContainerNode type not readyType (%d != %d)", (*it)->getType(), ContainerNode::kReadyType);
} }
} }
} }
@ -1693,7 +1693,7 @@ void saveContainerNodes(Common::OutSaveFile *outS) {
for (Common::List<ContainerNode *>::iterator it = g_vm->_cnm->_list.begin(); it != g_vm->_cnm->_list.end(); ++it) { for (Common::List<ContainerNode *>::iterator it = g_vm->_cnm->_list.begin(); it != g_vm->_cnm->_list.end(); ++it) {
ContainerNode *n = *it; ContainerNode *n = *it;
if (n->getType() != ContainerNode::readyType) if (n->getType() != ContainerNode::kReadyType)
numNodes++; numNodes++;
} }
@ -1708,7 +1708,7 @@ void saveContainerNodes(Common::OutSaveFile *outS) {
for (Common::List<ContainerNode *>::iterator it = g_vm->_cnm->_list.begin(); it != g_vm->_cnm->_list.end(); ++it) { for (Common::List<ContainerNode *>::iterator it = g_vm->_cnm->_list.begin(); it != g_vm->_cnm->_list.end(); ++it) {
ContainerNode *n = *it; ContainerNode *n = *it;
if (n->getType() != ContainerNode::readyType) { if (n->getType() != ContainerNode::kReadyType) {
debugC(3, kDebugSaveload, "Saving ContainerNode %d", i++); debugC(3, kDebugSaveload, "Saving ContainerNode %d", i++);
n->write(out); n->write(out);
} }
@ -1751,7 +1751,7 @@ void cleanupContainerNodes() {
for (Common::List<ContainerNode *>::iterator it = g_vm->_cnm->_list.begin(); it != g_vm->_cnm->_list.end(); ++it) { for (Common::List<ContainerNode *>::iterator it = g_vm->_cnm->_list.begin(); it != g_vm->_cnm->_list.end(); ++it) {
ContainerNode *n = *it; ContainerNode *n = *it;
if (n->getType() != ContainerNode::readyType) if (n->getType() != ContainerNode::kReadyType)
deletionArray.push_back(*it); deletionArray.push_back(*it);
} }
@ -1871,7 +1871,7 @@ APPFUNC(cmdCloseButtonFunc) {
if (ev.eventType == gEventNewValue && ev.value == 1) { if (ev.eventType == gEventNewValue && ev.value == 1) {
ContainerWindow *win = (ContainerWindow *)ev.window; ContainerWindow *win = (ContainerWindow *)ev.window;
if (win->getView()._node.getType() == ContainerNode::mentalType) { if (win->getView()._node.getType() == ContainerNode::kMentalType) {
win->getView()._node.markForDelete(); win->getView()._node.markForDelete();
} else { } else {
win->containerObject()->close(getCenterActorID()); win->containerObject()->close(getCenterActorID());

View file

@ -69,8 +69,8 @@ class ContainerView : public gControl {
protected: protected:
enum imageData { enum imageData {
selectorX = 10, kSelectorX = 10,
selectorY = 25 kSelectorY = 25
}; };
public: public:
@ -359,22 +359,22 @@ class ContainerNode {
public: public:
enum ContainerNodeOwnerType { enum ContainerNodeOwnerType {
readyType = 0, // This is a player ready container kReadyType = 0, // This is a player ready container
deadType, // The "dead" container kDeadType, // The "dead" container
mentalType, // A player's mental container kMentalType, // A player's mental container
physicalType, // Physical container kPhysicalType, // Physical container
enchantType // Enchantment container kEnchantType // Enchantment container
}; };
enum ContainerNodeOwners { enum ContainerNodeOwners {
nobody = 255 // owner = 255 means it's on the ground kNobody = 255 // owner = 255 means it's on the ground
}; };
enum containerAction { enum containerAction {
actionUpdate = (1 << 0), // Refresh this window kActionUpdate = (1 << 0), // Refresh this window
actionDelete = (1 << 1), // Delete this window kActionDelete = (1 << 1), // Delete this window
actionHide = (1 << 2), // Refresh this window kActionHide = (1 << 2), // Refresh this window
actionShow = (1 << 3) // Refresh this window kActionShow = (1 << 3) // Refresh this window
}; };
private: private:
@ -424,18 +424,18 @@ public:
// Set for lazy deletion // Set for lazy deletion
void markForDelete() { void markForDelete() {
_action |= actionDelete; _action |= kActionDelete;
} }
void markForShow() { void markForShow() {
_action |= actionShow; _action |= kActionShow;
_action &= ~actionHide; _action &= ~kActionHide;
} }
void markForHide() { void markForHide() {
_action |= actionHide; _action |= kActionHide;
_action &= ~actionShow; _action &= ~kActionShow;
} }
void markForUpdate() { void markForUpdate() {
_action |= actionUpdate; _action |= kActionUpdate;
} }
// Find the address of the window and/or view // Find the address of the window and/or view

View file

@ -1264,7 +1264,7 @@ bool PhysicalContainerProto::openAction(ObjectID dObj, ObjectID) {
bool PhysicalContainerProto::closeAction(ObjectID dObj, ObjectID) { bool PhysicalContainerProto::closeAction(ObjectID dObj, ObjectID) {
GameObject *dObjPtr = GameObject::objectAddress(dObj); GameObject *dObjPtr = GameObject::objectAddress(dObj);
ContainerNode *cn = g_vm->_cnm->find(dObj, ContainerNode::physicalType); ContainerNode *cn = g_vm->_cnm->find(dObj, ContainerNode::kPhysicalType);
assert(dObjPtr->isOpen()); assert(dObjPtr->isOpen());
assert(cn); assert(cn);
@ -2926,7 +2926,7 @@ bool IntangibleContainerProto::openAction(ObjectID dObj, ObjectID enactor) {
} }
bool IntangibleContainerProto::closeAction(ObjectID dObj, ObjectID) { bool IntangibleContainerProto::closeAction(ObjectID dObj, ObjectID) {
ContainerNode *cn = g_vm->_cnm->find(dObj, ContainerNode::mentalType); ContainerNode *cn = g_vm->_cnm->find(dObj, ContainerNode::kMentalType);
assert(cn); assert(cn);