Skip to content

Commit

Permalink
TITANIC: Renamings and clarifications for mail methods
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Dec 2, 2016
1 parent 94e2c67 commit 475289f
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 40 deletions.
22 changes: 11 additions & 11 deletions engines/titanic/core/game_object.cpp
Expand Up @@ -64,7 +64,7 @@ CGameObject::CGameObject(): CNamedItem() {
_field48 = 0xF0;
_field4C = 0xFF;
_isMail = false;
_id = 0;
_destRoomFlags = 0;
_roomFlags = 0;
_visible = true;
_field60 = 0;
Expand Down Expand Up @@ -120,7 +120,7 @@ void CGameObject::save(SimpleFile *file, int indent) {
file->writeNumberLine(_fieldB8, indent + 1);
file->writeNumberLine(_visible, indent + 1);
file->writeNumberLine(_isMail, indent + 1);
file->writeNumberLine(_id, indent + 1);
file->writeNumberLine(_destRoomFlags, indent + 1);
file->writeNumberLine(_roomFlags, indent + 1);

if (_surface) {
Expand Down Expand Up @@ -175,7 +175,7 @@ void CGameObject::load(SimpleFile *file) {
_fieldB8 = file->readNumber();
_visible = file->readNumber() != 0;
_isMail = file->readNumber();
_id = file->readNumber();
_destRoomFlags = file->readNumber();
_roomFlags = file->readNumber();

resourceKey.load(file);
Expand Down Expand Up @@ -1434,27 +1434,27 @@ void CGameObject::addMail(int mailId) {
}
}

void CGameObject::setMailId(int mailId) {
void CGameObject::setMailDest(uint roomFlags) {
CMailMan *mailMan = getMailMan();
if (mailMan) {
makeDirty();
mailMan->setMailId(this, mailId);
mailMan->setMailDest(this, roomFlags);
}
}

bool CGameObject::mailExists(int id) const {
return findMail(id) != nullptr;
bool CGameObject::mailExists(uint roomFlags) const {
return findMail(roomFlags) != nullptr;
}

CGameObject *CGameObject::findMail(int id) const {
CGameObject *CGameObject::findMail(uint roomFlags) const {
CMailMan *mailMan = getMailMan();
return mailMan ? mailMan->findMail(id) : nullptr;
return mailMan ? mailMan->findMail(roomFlags) : nullptr;
}

void CGameObject::removeMail(int id, int v) {
void CGameObject::removeMail(uint destRoomFlags, uint newRoomFlags) {
CMailMan *mailMan = getMailMan();
if (mailMan)
mailMan->removeMail(id, v);
mailMan->removeMail(destRoomFlags, newRoomFlags);
}

void CGameObject::resetMail() {
Expand Down
10 changes: 5 additions & 5 deletions engines/titanic/core/game_object.h
Expand Up @@ -486,12 +486,12 @@ class CGameObject : public CNamedItem {
/**
* Returns true if a mail with a specified Id exists
*/
bool mailExists(int id) const;
bool mailExists(uint roomFlags) const;

/**
* Returns a specified mail, if one exists
*/
CGameObject *findMail(int id) const;
CGameObject *findMail(uint roomFlags) const;

/**
* Resets the Mail Man value
Expand Down Expand Up @@ -570,7 +570,7 @@ class CGameObject : public CNamedItem {
public:
Rect _bounds;
bool _isMail;
int _id;
uint _destRoomFlags;
uint _roomFlags;
int _field60;
CursorId _cursorId;
Expand Down Expand Up @@ -729,7 +729,7 @@ class CGameObject : public CNamedItem {
/**
* Sets the mail identifier for an object
*/
void setMailId(int mailId);
void setMailDest(uint roomFlags);

/**
* Returns true if there's an attached surface which has a frame
Expand Down Expand Up @@ -799,7 +799,7 @@ class CGameObject : public CNamedItem {
/**
* Remove an object from the mail list
*/
void removeMail(int id, int v);
void removeMail(uint destRoomFlags, uint newRoomFlags);

/**
* Return the full Id of the current view in a
Expand Down
18 changes: 9 additions & 9 deletions engines/titanic/core/mail_man.cpp
Expand Up @@ -47,32 +47,32 @@ CGameObject *CMailMan::getNextObject(CGameObject *prior) const {
return dynamic_cast<CGameObject *>(prior->getNextSibling());
}

void CMailMan::addMail(CGameObject *obj, int id) {
void CMailMan::addMail(CGameObject *obj, uint destRoomFlags) {
obj->detach();
obj->addUnder(this);
setMailId(obj, id);
setMailDest(obj, destRoomFlags);
}

void CMailMan::setMailId(CGameObject *obj, int id) {
obj->_id = id;
void CMailMan::setMailDest(CGameObject *obj, uint roomFlags) {
obj->_destRoomFlags = roomFlags;
obj->_roomFlags = 0;
obj->_isMail = true;
}

CGameObject *CMailMan::findMail(int id) const {
CGameObject *CMailMan::findMail(uint roomFlags) const {
for (CGameObject *obj = getFirstObject(); obj; obj = getNextObject(obj)) {
if (obj->_isMail && obj->_id == id)
if (obj->_isMail && obj->_destRoomFlags == roomFlags)
return obj;
}

return nullptr;
}

void CMailMan::removeMail(int id, int roomFlags) {
void CMailMan::removeMail(uint destRoomFlags, uint newRoomFlags) {
for (CGameObject *obj = getFirstObject(); obj; obj = getNextObject(obj)) {
if (obj->_isMail && obj->_id == id) {
if (obj->_isMail && obj->_destRoomFlags == destRoomFlags) {
obj->_isMail = false;
obj->_roomFlags = roomFlags;
obj->_roomFlags = newRoomFlags;
break;
}
}
Expand Down
10 changes: 5 additions & 5 deletions engines/titanic/core/mail_man.h
Expand Up @@ -58,22 +58,22 @@ class CMailMan : public CGameObject {
/**
* Add an object to the mail list
*/
void addMail(CGameObject *obj, int id);
void addMail(CGameObject *obj, uint destRoomFlags);

/**
* Sets the mail identifier for an object
* Sets the mail destination for an object
*/
static void setMailId(CGameObject *obj, int id);
static void setMailDest(CGameObject *obj, uint roomFlags);

/**
* Scan the mail list for a specified item
*/
CGameObject *findMail(int id) const;
CGameObject *findMail(uint roomFlags) const;

/**
* Remove a mail item
*/
void removeMail(int id, int v);
void removeMail(uint destRoomFlags, uint newRoomFlags);

void resetValue() { _value = 0; }
};
Expand Down
4 changes: 2 additions & 2 deletions engines/titanic/game/chev_code.cpp
Expand Up @@ -94,8 +94,8 @@ bool CChevCode::SetChevFloorBits(CSetChevFloorBits *msg) {

bool CChevCode::SetChevRoomBits(CSetChevRoomBits *msg) {
_chevCode &= ~0xff;
if (msg->_roomNum > 0 && msg->_roomNum < 128)
_chevCode |= msg->_roomNum * 2;
if (msg->_roomFlags > 0 && msg->_roomFlags < 128)
_chevCode |= msg->_roomFlags * 2;

return true;
}
Expand Down
2 changes: 1 addition & 1 deletion engines/titanic/messages/messages.h
Expand Up @@ -310,7 +310,7 @@ MESSAGE1(CSetChevFloorBits, int, floorNum, 0);
MESSAGE1(CSetChevLiftBits, int, liftNum, 0);
MESSAGE2(CSetChevPanelBitMsg, int, value1, 0, int, value2, 0);
MESSAGE1(CSetChevPanelButtonsMsg, int, chevCode, 0);
MESSAGE1(CSetChevRoomBits, int, roomNum, 0);
MESSAGE1(CSetChevRoomBits, int, roomFlags, 0);
MESSAGE1(CSetFrameMsg, int, frameNumber, 0);
MESSAGE0(CSetMusicControlsMsg);
MESSAGE2(CSetVarMsg, CString, varName, "", int, value, 0);
Expand Down
9 changes: 5 additions & 4 deletions engines/titanic/npcs/succubus.cpp
Expand Up @@ -378,7 +378,8 @@ bool CSuccUBus::PETDeliverMsg(CPETDeliverMsg *msg) {
if (!pet)
return true;

CGameObject *mailObject = findMail(pet->getRoomFlags());
uint destRoomFlags = pet->getRoomFlags();
CGameObject *mailObject = findMail(destRoomFlags);
if (!mailObject) {
switch (getRandomNumber(2)) {
case 0:
Expand Down Expand Up @@ -415,7 +416,7 @@ bool CSuccUBus::PETDeliverMsg(CPETDeliverMsg *msg) {

if (_isFeathers) {
_field19C = 0;
removeMail(roomFlags, roomFlags);
removeMail(destRoomFlags, roomFlags);
pet->phonographAction("");

if (_startFrame2 >= 0) {
Expand Down Expand Up @@ -609,7 +610,7 @@ bool CSuccUBus::MovieEndMsg(CMovieEndMsg *msg) {

if (msg->_endFrame == _endFrame4) {
if (pet && _mailP) {
_mailP->setMailId(petRoomFlags);
_mailP->setMailDest(petRoomFlags);
}

_field188 = 1;
Expand Down Expand Up @@ -726,7 +727,7 @@ bool CSuccUBus::SUBTransition(CSUBTransition *msg) {

bool CSuccUBus::SetChevRoomBits(CSetChevRoomBits *msg) {
if (_enabled) {
_roomFlags = msg->_roomNum;
_roomFlags = msg->_roomFlags;
playSound("z#98.wav", 100);
}

Expand Down
2 changes: 1 addition & 1 deletion engines/titanic/pet_control/pet_drag_chev.cpp
Expand Up @@ -57,7 +57,7 @@ bool CPetDragChev::MouseDragEndMsg(CMouseDragEndMsg *msg) {
CSuccUBus *succubus = dynamic_cast<CSuccUBus *>(msg->_dropTarget);

if (succubus) {
CSetChevRoomBits chevMsg(_id);
CSetChevRoomBits chevMsg(_destRoomFlags);
chevMsg.execute(succubus);
} else {
CPetControl *petControl = getPetControl();
Expand Down
2 changes: 1 addition & 1 deletion engines/titanic/pet_control/pet_rooms.cpp
Expand Up @@ -101,7 +101,7 @@ bool CPetRooms::checkDragEnd(CGameObject *item) {
if (!item->_isMail)
return false;

uint roomFlags = item->_id;
uint roomFlags = item->_destRoomFlags;
CPetRoomsGlyph *glyph = _glyphs.findGlyphByFlags(roomFlags);
if (glyph) {
if (_glyphs.findGlyphByFlags(0)) {
Expand Down
2 changes: 1 addition & 1 deletion engines/titanic/pet_control/pet_rooms_glyphs.cpp
Expand Up @@ -123,7 +123,7 @@ bool CPetRoomsGlyph::dragGlyph(const Point &topLeft, CMouseDragStartMsg *msg) {
CGameObject *chevron = petControl->getHiddenObject("3PetChevron");

if (chevron) {
chevron->_id = _roomFlags;
chevron->_destRoomFlags = _roomFlags;
chevron->_isMail = _mailFlag != 0;
petControl->removeFromInventory(chevron, false, false);
chevron->loadSurface();
Expand Down

0 comments on commit 475289f

Please sign in to comment.