From 33737ea2dcd97026706dd75f8c2c27fa148c165a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 1 Sep 2016 19:10:36 -0400 Subject: [PATCH] TITANIC: Convert many static_casts to dynamic_cast --- engines/titanic/carry/arm.cpp | 4 +-- engines/titanic/carry/brain.cpp | 2 +- engines/titanic/carry/bridge_piece.cpp | 2 +- engines/titanic/carry/carry.cpp | 4 +-- engines/titanic/carry/carry_parrot.cpp | 12 ++++---- engines/titanic/carry/chicken.cpp | 4 +-- engines/titanic/carry/magazine.cpp | 2 +- engines/titanic/carry/napkin.cpp | 2 +- engines/titanic/carry/phonograph_cylinder.cpp | 2 +- engines/titanic/core/game_object.cpp | 28 +++++++++---------- engines/titanic/core/mail_man.cpp | 4 +-- engines/titanic/core/project_item.cpp | 2 +- engines/titanic/core/view_item.cpp | 2 +- engines/titanic/debugger.cpp | 2 +- .../game/maitred/maitred_prod_receptor.cpp | 8 +++--- engines/titanic/game/sauce_dispensor.cpp | 4 +-- engines/titanic/input_handler.cpp | 2 +- engines/titanic/npcs/parrot.cpp | 2 +- engines/titanic/pet_control/pet_control.cpp | 16 +++++------ engines/titanic/pet_control/pet_drag_chev.cpp | 2 +- .../pet_control/pet_inventory_glyphs.cpp | 12 ++++---- .../titanic/pet_control/pet_remote_glyphs.cpp | 6 ++-- engines/titanic/pet_control/pet_rooms.cpp | 4 +-- .../titanic/pet_control/pet_rooms_glyphs.cpp | 8 +++--- engines/titanic/support/avi_surface.cpp | 2 +- engines/titanic/true_talk/tt_parser.cpp | 8 +++--- engines/titanic/true_talk/tt_sentence.cpp | 4 +-- engines/titanic/true_talk/tt_string_node.cpp | 2 +- engines/titanic/true_talk/tt_synonym.cpp | 2 +- engines/titanic/true_talk/tt_vocab.cpp | 16 +++++------ engines/titanic/true_talk/tt_word.cpp | 2 +- 31 files changed, 86 insertions(+), 86 deletions(-) diff --git a/engines/titanic/carry/arm.cpp b/engines/titanic/carry/arm.cpp index 880c93d30919..a67937ebdf1c 100644 --- a/engines/titanic/carry/arm.cpp +++ b/engines/titanic/carry/arm.cpp @@ -163,7 +163,7 @@ bool CArm::MaitreDHappyMsg(CMaitreDHappyMsg *msg) { if (!_field158) playSound("z#47.wav", 100, 0, 0); if (_string6 == "Key" || _string6 == "AuditoryCentre") { - CGameObject *child = static_cast(getFirstChild()); + CGameObject *child = dynamic_cast(getFirstChild()); if (child) { child->setVisible(true); petAddToInventory(); @@ -184,7 +184,7 @@ bool CArm::MaitreDHappyMsg(CMaitreDHappyMsg *msg) { bool CArm::PETGainedObjectMsg(CPETGainedObjectMsg *msg) { if (_field158) { if (_string6 == "Key" || _string6 == "AuditoryCentre") { - CCarry *child = static_cast(getFirstChild()); + CCarry *child = dynamic_cast(getFirstChild()); if (child) { _visibleFrame = _field170; loadFrame(_visibleFrame); diff --git a/engines/titanic/carry/brain.cpp b/engines/titanic/carry/brain.cpp index 8df0de996139..102d8d90496c 100644 --- a/engines/titanic/carry/brain.cpp +++ b/engines/titanic/carry/brain.cpp @@ -55,7 +55,7 @@ void CBrain::load(SimpleFile *file) { } bool CBrain::UseWithOtherMsg(CUseWithOtherMsg *msg) { - CBrainSlot *slot = static_cast(msg->_other); + CBrainSlot *slot = dynamic_cast(msg->_other); if (slot) { if (slot->getName() == "CentralCore") { setVisible(false); diff --git a/engines/titanic/carry/bridge_piece.cpp b/engines/titanic/carry/bridge_piece.cpp index 6a22df324308..a2cb23add630 100644 --- a/engines/titanic/carry/bridge_piece.cpp +++ b/engines/titanic/carry/bridge_piece.cpp @@ -52,7 +52,7 @@ void CBridgePiece::load(SimpleFile *file) { } bool CBridgePiece::UseWithOtherMsg(CUseWithOtherMsg *msg) { - CShipSetting *shipSetting = static_cast(msg->_other); + CShipSetting *shipSetting = dynamic_cast(msg->_other); if (!shipSetting) { return CCarry::UseWithOtherMsg(msg); } else if (shipSetting->_itemName != "NULL") { diff --git a/engines/titanic/carry/carry.cpp b/engines/titanic/carry/carry.cpp index 75b3b6f35bce..03798e871390 100644 --- a/engines/titanic/carry/carry.cpp +++ b/engines/titanic/carry/carry.cpp @@ -127,7 +127,7 @@ bool CCarry::MouseDragEndMsg(CMouseDragEndMsg *msg) { return true; } - CCharacter *npc = static_cast(msg->_dropTarget); + CCharacter *npc = dynamic_cast(msg->_dropTarget); if (npc) { CUseWithCharMsg charMsg(npc); charMsg.execute(this, nullptr, 0); @@ -157,7 +157,7 @@ bool CCarry::MouseDragEndMsg(CMouseDragEndMsg *msg) { } bool CCarry::UseWithCharMsg(CUseWithCharMsg *msg) { - CSuccUBus *succubus = static_cast(msg->_character); + CSuccUBus *succubus = dynamic_cast(msg->_character); if (succubus) { CSubAcceptCCarryMsg carryMsg; carryMsg._item = this; diff --git a/engines/titanic/carry/carry_parrot.cpp b/engines/titanic/carry/carry_parrot.cpp index 8a453e348ca2..b0461ded2663 100644 --- a/engines/titanic/carry/carry_parrot.cpp +++ b/engines/titanic/carry/carry_parrot.cpp @@ -133,7 +133,7 @@ bool CCarryParrot::MouseDragEndMsg(CMouseDragEndMsg *msg) { actMsg.execute("ParrotCage"); } } else { - CCharacter *character = static_cast(msg->_dropTarget); + CCharacter *character = dynamic_cast(msg->_dropTarget); if (character) { CUseWithCharMsg charMsg(character); charMsg.execute(this, nullptr, 0); @@ -167,7 +167,7 @@ bool CCarryParrot::PassOnDragStartMsg(CPassOnDragStartMsg *msg) { return CCarry::PassOnDragStartMsg(msg); } - CTrueTalkNPC *npc = static_cast(getRoot()->findByName(_string6)); + CTrueTalkNPC *npc = dynamic_cast(getRoot()->findByName(_string6)); if (npc) startTalking(npc, 0x446BF); @@ -181,7 +181,7 @@ bool CCarryParrot::PassOnDragStartMsg(CPassOnDragStartMsg *msg) { bool CCarryParrot::PreEnterViewMsg(CPreEnterViewMsg *msg) { loadSurface(); - CCarryParrot *parrot = static_cast(getRoot()->findByName("CarryParrot")); + CCarryParrot *parrot = dynamic_cast(getRoot()->findByName("CarryParrot")); if (parrot) parrot->_fieldE0 = 0; @@ -189,7 +189,7 @@ bool CCarryParrot::PreEnterViewMsg(CPreEnterViewMsg *msg) { } bool CCarryParrot::UseWithCharMsg(CUseWithCharMsg *msg) { - CSuccUBus *succubus = static_cast(msg->_character); + CSuccUBus *succubus = dynamic_cast(msg->_character); if (succubus) CParrot::_v4 = 3; @@ -198,7 +198,7 @@ bool CCarryParrot::UseWithCharMsg(CUseWithCharMsg *msg) { bool CCarryParrot::ActMsg(CActMsg *msg) { if (msg->_action == "FreeParrot" && (CParrot::_v4 == 4 || CParrot::_v4 == 1)) { - CTrueTalkNPC *npc = static_cast(getRoot()->findByName(_string6)); + CTrueTalkNPC *npc = dynamic_cast(getRoot()->findByName(_string6)); if (npc) startTalking(npc, 0x446BF); @@ -212,7 +212,7 @@ bool CCarryParrot::ActMsg(CActMsg *msg) { playSound("z#475.wav", 100, 0, 0); if (!_field140) { - CCarry *feathers = static_cast(getRoot()->findByName("Feathers")); + CCarry *feathers = dynamic_cast(getRoot()->findByName("Feathers")); if (feathers) { feathers->setVisible(true); feathers->petAddToInventory(); diff --git a/engines/titanic/carry/chicken.cpp b/engines/titanic/carry/chicken.cpp index 65404dc65d8a..0e8f6b365397 100644 --- a/engines/titanic/carry/chicken.cpp +++ b/engines/titanic/carry/chicken.cpp @@ -80,7 +80,7 @@ bool CChicken::UseWithOtherMsg(CUseWithOtherMsg *msg) { petAddToInventory(); } else { - CSauceDispensor *dispensor = static_cast(msg->_other); + CSauceDispensor *dispensor = dynamic_cast(msg->_other); if (!dispensor || _string6 == "None") { return CCarry::UseWithOtherMsg(msg); } else { @@ -94,7 +94,7 @@ bool CChicken::UseWithOtherMsg(CUseWithOtherMsg *msg) { } bool CChicken::UseWithCharMsg(CUseWithCharMsg *msg) { - CSuccUBus *succubus = static_cast(msg->_character); + CSuccUBus *succubus = dynamic_cast(msg->_character); if (succubus) { setPosition(Point(330, 300)); CSubAcceptCCarryMsg acceptMsg; diff --git a/engines/titanic/carry/magazine.cpp b/engines/titanic/carry/magazine.cpp index cdf92fc707f0..e68c63f8f9c3 100644 --- a/engines/titanic/carry/magazine.cpp +++ b/engines/titanic/carry/magazine.cpp @@ -52,7 +52,7 @@ void CMagazine::load(SimpleFile *file) { } bool CMagazine::UseWithCharMsg(CUseWithCharMsg *msg) { - CDeskbot *deskbot = static_cast(msg->_character); + CDeskbot *deskbot = dynamic_cast(msg->_character); if (deskbot) { if (deskbot->_deskbotActive) { setVisible(false); diff --git a/engines/titanic/carry/napkin.cpp b/engines/titanic/carry/napkin.cpp index d25e8b5975f8..d0ee9acc1ab2 100644 --- a/engines/titanic/carry/napkin.cpp +++ b/engines/titanic/carry/napkin.cpp @@ -43,7 +43,7 @@ void CNapkin::load(SimpleFile *file) { } bool CNapkin::UseWithOtherMsg(CUseWithOtherMsg *msg) { - CChicken *chicken = static_cast(msg->_other); + CChicken *chicken = dynamic_cast(msg->_other); if (chicken) { if (chicken->_string6 == "None" || chicken->_field12C) { CActMsg actMsg("Clean"); diff --git a/engines/titanic/carry/phonograph_cylinder.cpp b/engines/titanic/carry/phonograph_cylinder.cpp index de0ed0a67c6f..3dedbc4ac9d0 100644 --- a/engines/titanic/carry/phonograph_cylinder.cpp +++ b/engines/titanic/carry/phonograph_cylinder.cpp @@ -102,7 +102,7 @@ void CPhonographCylinder::load(SimpleFile *file) { } bool CPhonographCylinder::UseWithOtherMsg(CUseWithOtherMsg *msg) { - CPhonograph *phonograph = static_cast(msg->_other); + CPhonograph *phonograph = dynamic_cast(msg->_other); if (phonograph) { CSetVarMsg varMsg("m_RecordStatus", 1); return true; diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp index 07358b811566..aa6ffda0e369 100644 --- a/engines/titanic/core/game_object.cpp +++ b/engines/titanic/core/game_object.cpp @@ -871,15 +871,15 @@ CViewItem *CGameObject::parseView(const CString &viewString) { return nullptr; // Find the designated node within the room - CNodeItem *node = static_cast(room->findChildInstanceOf(CNodeItem::_type)); + CNodeItem *node = dynamic_cast(room->findChildInstanceOf(CNodeItem::_type)); while (node && node->getName() != nodeName) - node = static_cast(room->findNextInstanceOf(CNodeItem::_type, node)); + node = dynamic_cast(room->findNextInstanceOf(CNodeItem::_type, node)); if (!node) return nullptr; - CViewItem *view = static_cast(node->findChildInstanceOf(CViewItem::_type)); + CViewItem *view = dynamic_cast(node->findChildInstanceOf(CViewItem::_type)); while (view && view->getName() != viewName) - view = static_cast(node->findNextInstanceOf(CViewItem::_type, view)); + view = dynamic_cast(node->findNextInstanceOf(CViewItem::_type, view)); if (!view) return nullptr; @@ -964,12 +964,12 @@ CGameObject *CGameObject::getNextMail(CGameObject *prior) { } CGameObject *CGameObject::findRoomObject(const CString &name) const { - return static_cast(findRoom()->findByName(name)); + return dynamic_cast(findRoom()->findByName(name)); } CGameObject *CGameObject::findInRoom(const CString &name) { CRoomItem *room = getRoom(); - return room ? static_cast(room->findByName(name)) : nullptr; + return room ? dynamic_cast(room->findByName(name)) : nullptr; } Found CGameObject::find(const CString &name, CGameObject **item, int findAreas) { @@ -996,7 +996,7 @@ Found CGameObject::find(const CString &name, CGameObject **item, int findAreas) } if (findAreas & FIND_GLOBAL) { - go = static_cast(getRoot()->findByName(name)); + go = dynamic_cast(getRoot()->findByName(name)); if (go) { *item = go; return FOUND_GLOBAL; @@ -1227,7 +1227,7 @@ void CGameObject::dragMove(const Point &pt) { CGameObject *CGameObject::getDraggingObject() const { CTreeItem *item = getGameManager()->_dragItem; - return static_cast(item); + return dynamic_cast(item); } Point CGameObject::getControid() const { @@ -1255,7 +1255,7 @@ CDontSaveFileItem *CGameObject::getDontSave() const { } CPetControl *CGameObject::getPetControl() const { - return static_cast(getDontSaveChild(CPetControl::_type)); + return dynamic_cast(getDontSaveChild(CPetControl::_type)); } CMailMan *CGameObject::getMailMan() const { @@ -1294,7 +1294,7 @@ CRoomItem *CGameObject::locateRoom(const CString &name) const { CGameObject *CGameObject::getHiddenObject(const CString &name) const { CRoomItem *room = getHiddenRoom(); - return room ? static_cast(findUnder(room, name)) : nullptr; + return room ? dynamic_cast(findUnder(room, name)) : nullptr; } CTreeItem *CGameObject::findUnder(CTreeItem *parent, const CString &name) const { @@ -1506,7 +1506,7 @@ CTreeItem *CGameObject::petContainerRemove(CGameObject *obj) { if (!obj->compareRoomNameTo("CarryParcel")) return obj; - CGameObject *item = static_cast(pet->getLastChild()); + CGameObject *item = dynamic_cast(pet->getLastChild()); if (item) item->detach(); @@ -1601,11 +1601,11 @@ void CGameObject::petUnlockInput() { /*------------------------------------------------------------------------*/ CStarControl *CGameObject::getStarControl() const { - CStarControl *starControl = static_cast(getDontSaveChild(CStarControl::_type)); + CStarControl *starControl = dynamic_cast(getDontSaveChild(CStarControl::_type)); if (!starControl) { CViewItem *view = getGameManager()->getView(); if (view) - starControl = static_cast(view->findChildInstanceOf(CStarControl::_type)); + starControl = dynamic_cast(view->findChildInstanceOf(CStarControl::_type)); } return starControl; @@ -1625,7 +1625,7 @@ bool CGameObject::starFn2() { /*------------------------------------------------------------------------*/ void CGameObject::startTalking(const CString &npcName, uint id, CViewItem *view) { - CTrueTalkNPC *npc = static_cast(getRoot()->findByName(npcName)); + CTrueTalkNPC *npc = dynamic_cast(getRoot()->findByName(npcName)); startTalking(npc, id, view); } diff --git a/engines/titanic/core/mail_man.cpp b/engines/titanic/core/mail_man.cpp index afe13bebad09..11e17fc4e557 100644 --- a/engines/titanic/core/mail_man.cpp +++ b/engines/titanic/core/mail_man.cpp @@ -37,14 +37,14 @@ void CMailMan::load(SimpleFile *file) { } CGameObject *CMailMan::getFirstObject() const { - return static_cast(getFirstChild()); + return dynamic_cast(getFirstChild()); } CGameObject *CMailMan::getNextObject(CGameObject *prior) const { if (!prior || prior->getParent() != this) return nullptr; - return static_cast(prior->getNextSibling()); + return dynamic_cast(prior->getNextSibling()); } void CMailMan::addMail(CGameObject *obj, int id) { diff --git a/engines/titanic/core/project_item.cpp b/engines/titanic/core/project_item.cpp index 76293233b082..df48bad50149 100644 --- a/engines/titanic/core/project_item.cpp +++ b/engines/titanic/core/project_item.cpp @@ -85,7 +85,7 @@ void CProjectItem::buildFilesList() { CTreeItem *treeItem = getFirstChild(); while (treeItem) { if (treeItem->isFileItem()) { - CString name = static_cast(treeItem)->getFilename(); + CString name = dynamic_cast(treeItem)->getFilename(); _files.add()->_name = name; } diff --git a/engines/titanic/core/view_item.cpp b/engines/titanic/core/view_item.cpp index 03e2753839ef..333b092ea437 100644 --- a/engines/titanic/core/view_item.cpp +++ b/engines/titanic/core/view_item.cpp @@ -169,7 +169,7 @@ void CViewItem::enterView(CViewItem *newView) { CLinkItem *CViewItem::findLink(CViewItem *newView) { for (CTreeItem *treeItem = getFirstChild(); treeItem; treeItem = scan(treeItem)) { - CLinkItem *link = static_cast(treeItem); + CLinkItem *link = dynamic_cast(treeItem); if (link && link->connectsTo(newView)) return link; } diff --git a/engines/titanic/debugger.cpp b/engines/titanic/debugger.cpp index 37fc54685108..a9da83f7243c 100644 --- a/engines/titanic/debugger.cpp +++ b/engines/titanic/debugger.cpp @@ -231,7 +231,7 @@ bool Debugger::cmdItem(int argc, const char **argv) { } // Get the item - CCarry *item = static_cast( + CCarry *item = dynamic_cast( g_vm->_window->_project->findByName(argv[1])); assert(item); diff --git a/engines/titanic/game/maitred/maitred_prod_receptor.cpp b/engines/titanic/game/maitred/maitred_prod_receptor.cpp index 66533a542fdf..2977d417a20d 100644 --- a/engines/titanic/game/maitred/maitred_prod_receptor.cpp +++ b/engines/titanic/game/maitred/maitred_prod_receptor.cpp @@ -51,7 +51,7 @@ void CMaitreDProdReceptor::load(SimpleFile *file) { } bool CMaitreDProdReceptor::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { - if (_fieldBC == 2 && static_cast(getParent())->hasActiveMovie()) { + if (_fieldBC == 2 && dynamic_cast(getParent())->hasActiveMovie()) { return false; } else { CProdMaitreDMsg prodMsg(126); @@ -61,7 +61,7 @@ bool CMaitreDProdReceptor::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { } bool CMaitreDProdReceptor::MouseMoveMsg(CMouseMoveMsg *msg) { - if (_fieldBC == 2 && static_cast(getParent())->hasActiveMovie()) + if (_fieldBC == 2 && dynamic_cast(getParent())->hasActiveMovie()) return false; else if (++_counter < 20) return true; @@ -80,7 +80,7 @@ bool CMaitreDProdReceptor::MouseMoveMsg(CMouseMoveMsg *msg) { else if (isEquals("Perch")) prodMsg._value = 125; - CMaitreD *maitreD = static_cast(findRoomObject("MaitreD")); + CMaitreD *maitreD = dynamic_cast(findRoomObject("MaitreD")); if (maitreD->_field100 <= 0) prodMsg.execute(this); @@ -89,7 +89,7 @@ bool CMaitreDProdReceptor::MouseMoveMsg(CMouseMoveMsg *msg) { bool CMaitreDProdReceptor::ProdMaitreDMsg(CProdMaitreDMsg *msg) { if (_fieldC4) { - CMaitreD *maitreD = static_cast(findRoomObject("MaitreD")); + CMaitreD *maitreD = dynamic_cast(findRoomObject("MaitreD")); if (maitreD->_field100 <= 0) { CViewItem *view = findView(); startTalking(maitreD, msg->_value, view); diff --git a/engines/titanic/game/sauce_dispensor.cpp b/engines/titanic/game/sauce_dispensor.cpp index 29f0be7ee4e2..adc0b828a27d 100644 --- a/engines/titanic/game/sauce_dispensor.cpp +++ b/engines/titanic/game/sauce_dispensor.cpp @@ -69,7 +69,7 @@ bool CSauceDispensor::Use(CUse *msg) { CVisibleMsg visibleMsg(true); if (msg->_item->isEquals("Chicken")) { - CChicken *chicken = static_cast(msg->_item); + CChicken *chicken = dynamic_cast(msg->_item); _field104 = true; if (_fieldF0) { playSound("b#15.wav", 50); @@ -98,7 +98,7 @@ bool CSauceDispensor::Use(CUse *msg) { petDisplayMessage(1, "Sadly, this dispenser is currently empty."); } else if (msg->_item->isEquals("BeerGlass")) { - CGlass *glass = static_cast(msg->_item); + CGlass *glass = dynamic_cast(msg->_item); _field108 = true; if (_field104 || _fieldF0) { diff --git a/engines/titanic/input_handler.cpp b/engines/titanic/input_handler.cpp index 7c35a5d855d5..2c51f3ece7a0 100644 --- a/engines/titanic/input_handler.cpp +++ b/engines/titanic/input_handler.cpp @@ -150,7 +150,7 @@ CGameObject *CInputHandler::dragEnd(const Point &pt, CTreeItem *dragItem) { // Scan through the view items to find the item being dropped on CGameObject *target = nullptr; for (CTreeItem *treeItem = view->scan(view); treeItem; treeItem = treeItem->scan(view)) { - CGameObject *gameObject = static_cast(treeItem); + CGameObject *gameObject = dynamic_cast(treeItem); if (gameObject && gameObject != dragItem) { if (gameObject->checkPoint(pt)) target = gameObject; diff --git a/engines/titanic/npcs/parrot.cpp b/engines/titanic/npcs/parrot.cpp index 53e6884415ab..6e7aa4ec578e 100644 --- a/engines/titanic/npcs/parrot.cpp +++ b/engines/titanic/npcs/parrot.cpp @@ -386,7 +386,7 @@ bool CParrot::MouseDragStartMsg(CMouseDragStartMsg *msg) { startTalking(this, 280129); performAction(true); - CCarry *item = static_cast(getRoot()->findByName(_string2)); + CCarry *item = dynamic_cast(getRoot()->findByName(_string2)); if (item) { item->_fieldE0 = 1; CPassOnDragStartMsg passMsg; diff --git a/engines/titanic/pet_control/pet_control.cpp b/engines/titanic/pet_control/pet_control.cpp index a0f8fab26770..7ab76ddc1d5a 100644 --- a/engines/titanic/pet_control/pet_control.cpp +++ b/engines/titanic/pet_control/pet_control.cpp @@ -152,7 +152,7 @@ void CPetControl::postLoad() { if (!_activeNPCName.empty() && root) _activeNPC = root->findByName(_activeNPCName); if (!_remoteTargetName.empty() && root) - _remoteTarget = static_cast(root->findByName(_remoteTargetName)); + _remoteTarget = dynamic_cast(root->findByName(_remoteTargetName)); setArea(_currentArea); loaded(); @@ -255,7 +255,7 @@ CRoomItem *CPetControl::getHiddenRoom() { CGameObject *CPetControl::getHiddenObject(const CString &name) { CRoomItem *room = getHiddenRoom(); - return room ? static_cast(findUnder(room, name)) : nullptr; + return room ? dynamic_cast(findUnder(room, name)) : nullptr; } bool CPetControl::containsPt(const Common::Point &pt) const { @@ -381,21 +381,21 @@ void CPetControl::displayMessage(const CString &msg) const { } CGameObject *CPetControl::getFirstObject() const { - return static_cast(getFirstChild()); + return dynamic_cast(getFirstChild()); } CGameObject *CPetControl::getNextObject(CGameObject *prior) const { if (!prior || prior->getParent() != this) return nullptr; - return static_cast(prior->getNextSibling()); + return dynamic_cast(prior->getNextSibling()); } void CPetControl::addToInventory(CGameObject *item) { item->detach(); if (item->getName() == "CarryParcel") { - CCarry *child = static_cast(getLastChild()); + CCarry *child = dynamic_cast(getLastChild()); if (child) child->detach(); @@ -546,7 +546,7 @@ bool CPetControl::isBotInView(const CString &name) const { // Iterate to find NPC for (CTreeItem *child = view->getFirstChild(); child; child = child->scan(view)) { - CGameObject *gameObject = static_cast(child); + CGameObject *gameObject = dynamic_cast(child); if (gameObject) { if (!gameObject->getName().compareToIgnoreCase(name)) return true; @@ -614,7 +614,7 @@ bool CPetControl::isDoorOrBellbotPresent() const { for (CTreeItem *treeItem = view->getFirstChild(); treeItem; treeItem = treeItem->scan(view)) { CString name = treeItem->getName(); - if (static_cast(treeItem) && + if (dynamic_cast(treeItem) && (name.contains("Doorbot") || name.contains("BellBot"))) return true; } @@ -643,7 +643,7 @@ void CPetControl::setTimerPersisent(int id, bool flag) { CGameObject *CPetControl::findBot(const CString &name, CTreeItem *root) { for (CTreeItem *item = root; item; item = item->scan(root)) { if (!item->getName().compareToIgnoreCase(name)) { - CGameObject *obj = static_cast(item); + CGameObject *obj = dynamic_cast(item); if (obj) return obj; } diff --git a/engines/titanic/pet_control/pet_drag_chev.cpp b/engines/titanic/pet_control/pet_drag_chev.cpp index d437d4379986..7816570a233c 100644 --- a/engines/titanic/pet_control/pet_drag_chev.cpp +++ b/engines/titanic/pet_control/pet_drag_chev.cpp @@ -55,7 +55,7 @@ bool CPetDragChev::MouseDragMoveMsg(CMouseDragMoveMsg *msg) { bool CPetDragChev::MouseDragEndMsg(CMouseDragEndMsg *msg) { if (msg->_dropTarget) { - CSuccUBus *succubus = static_cast(msg->_dropTarget); + CSuccUBus *succubus = dynamic_cast(msg->_dropTarget); if (succubus) { CSetChevRoomBits chevMsg(_id); diff --git a/engines/titanic/pet_control/pet_inventory_glyphs.cpp b/engines/titanic/pet_control/pet_inventory_glyphs.cpp index ae306649a282..783a8a9717f7 100644 --- a/engines/titanic/pet_control/pet_inventory_glyphs.cpp +++ b/engines/titanic/pet_control/pet_inventory_glyphs.cpp @@ -165,7 +165,7 @@ void CPetInventoryGlyph::getTooltip(CPetText *text) { bool CPetInventoryGlyph::doAction(CGlyphAction *action) { CInventoryGlyphAction *invAction = static_cast(action); - CPetInventoryGlyphs *owner = static_cast(_owner); + CPetInventoryGlyphs *owner = dynamic_cast(_owner); if (!invAction) return false; @@ -203,8 +203,8 @@ void CPetInventoryGlyph::setItem(CGameObject *item, int val) { if (_owner && item) { int v1 = populateItem(item, val); - _background = static_cast(_owner)->getBackground(v1); - _image = static_cast(getPetSection())->getImage(v1); + _background = dynamic_cast(_owner)->getBackground(v1); + _image = dynamic_cast(getPetSection())->getImage(v1); } } @@ -293,7 +293,7 @@ int CPetInventoryGlyph::subMode(CGameObject *item, int val) { void CPetInventoryGlyph::startBackgroundMovie() { if (_owner) { - CPetInventory *section = static_cast(_owner->getOwner()); + CPetInventory *section = dynamic_cast(_owner->getOwner()); if (section) section->playMovie(_background, 1); } @@ -301,7 +301,7 @@ void CPetInventoryGlyph::startBackgroundMovie() { void CPetInventoryGlyph::startForegroundMovie() { if (_owner) { - CPetInventory *section = static_cast(_owner->getOwner()); + CPetInventory *section = dynamic_cast(_owner->getOwner()); if (section) section->playMovie(_image, 1); } @@ -309,7 +309,7 @@ void CPetInventoryGlyph::startForegroundMovie() { void CPetInventoryGlyph::stopMovie() { if (_owner) { - CPetInventory *section = static_cast(_owner->getOwner()); + CPetInventory *section = dynamic_cast(_owner->getOwner()); if (section) section->playMovie(nullptr, 1); } diff --git a/engines/titanic/pet_control/pet_remote_glyphs.cpp b/engines/titanic/pet_control/pet_remote_glyphs.cpp index 6b7c8cb4aeb3..35a7ab39ac98 100644 --- a/engines/titanic/pet_control/pet_remote_glyphs.cpp +++ b/engines/titanic/pet_control/pet_remote_glyphs.cpp @@ -29,7 +29,7 @@ namespace Titanic { CPetRemote *CPetRemoteGlyphs::getOwner() const { - return static_cast(_owner); + return dynamic_cast(_owner); } void CPetRemoteGlyphs::generateMessage(RemoteMessage msgNum, const CString &name, int num) { @@ -44,11 +44,11 @@ void CPetRemoteGlyph::setDefaults(const CString &name, CPetControl *petControl) } CPetRemoteGlyphs *CPetRemoteGlyph::getOwner() const { - return static_cast(_owner); + return dynamic_cast(_owner); } CPetGfxElement *CPetRemoteGlyph::getElement(uint id) const { - CPetRemote *remote = static_cast(_owner->getOwner()); + CPetRemote *remote = dynamic_cast(_owner->getOwner()); return remote->getElement(id); } diff --git a/engines/titanic/pet_control/pet_rooms.cpp b/engines/titanic/pet_control/pet_rooms.cpp index 2415c9696632..2ec66b08e2a3 100644 --- a/engines/titanic/pet_control/pet_rooms.cpp +++ b/engines/titanic/pet_control/pet_rooms.cpp @@ -304,7 +304,7 @@ CPetRoomsGlyph *CPetRooms::addRoom(uint roomFlags, bool highlight_) { // Do a preliminary scan of the glyph list for any glyph that is // no longer valid, and thus can be removed for (CPetRoomsGlyphs::iterator i = _glyphs.begin(); i != _glyphs.end(); ++i) { - CPetRoomsGlyph *glyph = static_cast(*i); + CPetRoomsGlyph *glyph = dynamic_cast(*i); if (!glyph->isAssigned()) { _glyphs.erase(i); break; @@ -340,7 +340,7 @@ bool CPetRooms::changeLocationClass(int newClassNum) { bool CPetRooms::hasRoomFlags(uint roomFlags) const { for (CPetRoomsGlyphs::const_iterator i = _glyphs.begin(); i != _glyphs.end(); ++i) { - const CPetRoomsGlyph *glyph = static_cast(*i); + const CPetRoomsGlyph *glyph = dynamic_cast(*i); if (glyph->isAssigned() && glyph->getRoomFlags() == roomFlags) return true; } diff --git a/engines/titanic/pet_control/pet_rooms_glyphs.cpp b/engines/titanic/pet_control/pet_rooms_glyphs.cpp index d9e19b1f67aa..d7ac634f5dfa 100644 --- a/engines/titanic/pet_control/pet_rooms_glyphs.cpp +++ b/engines/titanic/pet_control/pet_rooms_glyphs.cpp @@ -141,7 +141,7 @@ bool CPetRoomsGlyph::dragGlyph(const Point &topLeft, CMouseDragStartMsg *msg) { void CPetRoomsGlyph::getTooltip(CPetText *text) { CRoomFlags roomFlags(_roomFlags); - CPetRooms *owner = static_cast(getPetSection()); + CPetRooms *owner = dynamic_cast(getPetSection()); CString msg; if (isCurrentlyAssigned()) { @@ -172,7 +172,7 @@ void CPetRoomsGlyph::saveGlyph(SimpleFile *file, int indent) { } bool CPetRoomsGlyph::proc33(CPetGlyph *glyph) { - CPetRoomsGlyph *roomGlyph = static_cast(glyph); + CPetRoomsGlyph *roomGlyph = dynamic_cast(glyph); return CPetGlyph::proc33(glyph) && _roomFlags == roomGlyph->_roomFlags; } @@ -236,7 +236,7 @@ void CPetRoomsGlyphs::saveGlyphs(SimpleFile *file, int indent) { CPetRoomsGlyph *CPetRoomsGlyphs::findAssignedRoom() const { for (const_iterator i = begin(); i != end(); ++i) { - CPetRoomsGlyph *glyph = static_cast(*i); + CPetRoomsGlyph *glyph = dynamic_cast(*i); if (glyph->isCurrentlyAssigned()) return glyph; } @@ -246,7 +246,7 @@ CPetRoomsGlyph *CPetRoomsGlyphs::findAssignedRoom() const { CPetRoomsGlyph *CPetRoomsGlyphs::findGlyphByFlags(uint flags) const { for (const_iterator i = begin(); i != end(); ++i) { - CPetRoomsGlyph *glyph = static_cast(*i); + CPetRoomsGlyph *glyph = dynamic_cast(*i); if (glyph->getRoomFlags() == flags) return glyph; } diff --git a/engines/titanic/support/avi_surface.cpp b/engines/titanic/support/avi_surface.cpp index ac6cc6dbe711..d4ebd5cef1be 100644 --- a/engines/titanic/support/avi_surface.cpp +++ b/engines/titanic/support/avi_surface.cpp @@ -33,7 +33,7 @@ namespace Titanic { Video::AVIDecoder::AVIVideoTrack &AVIDecoder::getVideoTrack() { for (TrackListIterator it = getTrackListBegin(); it != getTrackListEnd(); it++) if ((*it)->getTrackType() == Track::kTrackTypeVideo) - return *static_cast(*it); + return *dynamic_cast(*it); error("Could not find video track"); } diff --git a/engines/titanic/true_talk/tt_parser.cpp b/engines/titanic/true_talk/tt_parser.cpp index 1d9c1990540f..95a302d53c99 100644 --- a/engines/titanic/true_talk/tt_parser.cpp +++ b/engines/titanic/true_talk/tt_parser.cpp @@ -575,7 +575,7 @@ int TTparser::loadRequests(TTword *word) { if (_sentenceConcept) { if (_sentenceConcept->get18() == 0 || _sentenceConcept->get18() == 2) { - TTaction *action = static_cast(word); + TTaction *action = dynamic_cast(word); _sentenceConcept->set18(action->getVal()); } } @@ -1273,7 +1273,7 @@ int TTparser::considerRequests(TTword *word) { break; } - TTparserNode *nextP = static_cast(nodeP->_nextP); + TTparserNode *nextP = dynamic_cast(nodeP->_nextP); if (flag) delete nodeP; nodeP = nextP; @@ -1375,7 +1375,7 @@ void TTparser::removeConcept(TTconcept *concept) { void TTparser::removeNode(TTparserNode *node) { if (!node->_priorP) // Node is the head of the chain, so reset parser's nodes pointer - _nodesP = static_cast(node->_nextP); + _nodesP = dynamic_cast(node->_nextP); delete node; } @@ -1525,7 +1525,7 @@ int TTparser::fn2(TTword *word) { case 602: case 607: - return checkReferent(static_cast(word)); + return checkReferent(dynamic_cast(word)); case 608: return 1; diff --git a/engines/titanic/true_talk/tt_sentence.cpp b/engines/titanic/true_talk/tt_sentence.cpp index 9588ee021ec2..f187710de702 100644 --- a/engines/titanic/true_talk/tt_sentence.cpp +++ b/engines/titanic/true_talk/tt_sentence.cpp @@ -83,7 +83,7 @@ void TTsentence::copyFrom(const TTsentence &src) { if (src._nodesP) { // Source has processed nodes, so duplicate them for (TTsentenceNode *node = src._nodesP; node; - node = static_cast(node->_nextP)) { + node = dynamic_cast(node->_nextP)) { TTsentenceNode *newNode = new TTsentenceNode(node->_wordP); if (_nodesP) _nodesP->addToTail(newNode); @@ -319,7 +319,7 @@ bool TTsentence::localWord(const char *str) const { bool result = false; for (TTsentenceNode *nodeP = _nodesP; nodeP && !result; - nodeP = static_cast(nodeP->_nextP)) { + nodeP = dynamic_cast(nodeP->_nextP)) { TTsynonym syn; if (!nodeP->_wordP) continue; diff --git a/engines/titanic/true_talk/tt_string_node.cpp b/engines/titanic/true_talk/tt_string_node.cpp index 2bb0c5a74bd3..5a21d73a9b56 100644 --- a/engines/titanic/true_talk/tt_string_node.cpp +++ b/engines/titanic/true_talk/tt_string_node.cpp @@ -55,7 +55,7 @@ void TTstringNode::initialize(TTstringNode *oldNode) { } TTstringNode *TTstringNode::findByName(const TTstring &str, int mode) { - for (TTstringNode *nodeP = this; nodeP; nodeP = static_cast(nodeP->_nextP)) { + for (TTstringNode *nodeP = this; nodeP; nodeP = dynamic_cast(nodeP->_nextP)) { if (nodeP->_mode == mode || (mode == 3 && nodeP->_mode < 3)) { if (nodeP->_string == str) return nodeP; diff --git a/engines/titanic/true_talk/tt_synonym.cpp b/engines/titanic/true_talk/tt_synonym.cpp index 0f56c5cb220d..b476efefcbbb 100644 --- a/engines/titanic/true_talk/tt_synonym.cpp +++ b/engines/titanic/true_talk/tt_synonym.cpp @@ -60,7 +60,7 @@ TTsynonym *TTsynonym::copyFrom(const TTsynonym *src) { } int TTsynonym::save(SimpleFile *file) { - for (TTstringNode *synP = this; synP; synP = static_cast(synP->_nextP)) { + for (TTstringNode *synP = this; synP; synP = dynamic_cast(synP->_nextP)) { file->writeFormat("%s", " 0 "); synP->_string.save(file); file->writeFormat("%c", ' '); diff --git a/engines/titanic/true_talk/tt_vocab.cpp b/engines/titanic/true_talk/tt_vocab.cpp index 08d6e9e1a713..1d4d2ebbf2cb 100644 --- a/engines/titanic/true_talk/tt_vocab.cpp +++ b/engines/titanic/true_talk/tt_vocab.cpp @@ -288,7 +288,7 @@ TTword *TTvocab::getSuffixedWord(TTstring &str) const { if (word) { if (word->_wordClass == WC_ACTION) { - static_cast(word)->setVal(1); + dynamic_cast(word)->setVal(1); } } else { tempStr = str; @@ -311,7 +311,7 @@ TTword *TTvocab::getSuffixedWord(TTstring &str) const { if (word) { if (word->_wordClass == WC_ADJECTIVE) { - TTadj *adj = static_cast(word); + TTadj *adj = dynamic_cast(word); int val1 = word->proc15(); int val2 = word->proc15(); @@ -331,7 +331,7 @@ TTword *TTvocab::getSuffixedWord(TTstring &str) const { if (word) { if (word->_wordClass == WC_ADJECTIVE) { - TTadj *adj = static_cast(word); + TTadj *adj = dynamic_cast(word); int val1 = word->proc15(); int val2 = word->proc15(); @@ -350,7 +350,7 @@ TTword *TTvocab::getSuffixedWord(TTstring &str) const { word = getPrimeWord(tempStr); if (word && word->_wordClass == WC_ADJECTIVE) { - TTadj *adj = static_cast(word); + TTadj *adj = dynamic_cast(word); int val1 = word->proc15(); int val2 = word->proc15(); @@ -373,7 +373,7 @@ TTword *TTvocab::getSuffixedWord(TTstring &str) const { if (word) { if (word->_wordClass == WC_ADJECTIVE) { - TTadj *adj = static_cast(word); + TTadj *adj = dynamic_cast(word); int val1 = word->proc15(); int val2 = word->proc15(); @@ -393,7 +393,7 @@ TTword *TTvocab::getSuffixedWord(TTstring &str) const { if (word) { if (word->_wordClass == WC_ADJECTIVE) { - TTadj *adj = static_cast(word); + TTadj *adj = dynamic_cast(word); int val1 = word->proc15(); int val2 = word->proc15(); @@ -412,7 +412,7 @@ TTword *TTvocab::getSuffixedWord(TTstring &str) const { word = getPrimeWord(tempStr); if (word) { - TTadj *adj = static_cast(word); + TTadj *adj = dynamic_cast(word); int val1 = word->proc15(); int val2 = word->proc15(); @@ -529,7 +529,7 @@ TTword *TTvocab::getPrefixedWord(TTstring &str) const { if (!word) tempStr = str; else if (word->_wordClass == WC_ADJECTIVE) { - TTadj *adj = static_cast(word); + TTadj *adj = dynamic_cast(word); int val1 = word->proc15(); int val2 = word->proc15(); diff --git a/engines/titanic/true_talk/tt_word.cpp b/engines/titanic/true_talk/tt_word.cpp index df6ee5c7bc62..c8676e4b1e04 100644 --- a/engines/titanic/true_talk/tt_word.cpp +++ b/engines/titanic/true_talk/tt_word.cpp @@ -173,7 +173,7 @@ bool TTword::findSynByName(const TTstring &str, TTsynonym *dest, int mode) const if (!_synP) return false; - const TTsynonym *synP = static_cast(_synP->findByName(str, mode)); + const TTsynonym *synP = dynamic_cast(_synP->findByName(str, mode)); if (synP) { dest->copyFrom(synP); dest->_priorP = nullptr;