diff options
author | Jared Adams <jaxad0127@gmail.com> | 2010-03-25 23:45:27 -0600 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2010-03-26 06:53:05 -0600 |
commit | 3be9cace41bcef4b7bf55bffea5d3596bd588e7e (patch) | |
tree | 174cb77c11ddf755eaea52bba836b496d177ff91 /src/net/ea | |
parent | 48754058d7be3f433734cb1524e9e74cfd4fd55f (diff) | |
download | mana-3be9cace41bcef4b7bf55bffea5d3596bd588e7e.tar.gz mana-3be9cace41bcef4b7bf55bffea5d3596bd588e7e.tar.bz2 mana-3be9cace41bcef4b7bf55bffea5d3596bd588e7e.tar.xz mana-3be9cace41bcef4b7bf55bffea5d3596bd588e7e.zip |
Replace most dynamic_casts with static_casts
The remaining instances can't easily or safely be changed as the classes
involved don't have type information like Being does.
Reviewed-by: Freeyorp
Diffstat (limited to 'src/net/ea')
-rw-r--r-- | src/net/ea/beinghandler.cpp | 11 | ||||
-rw-r--r-- | src/net/ea/partyhandler.cpp | 10 |
2 files changed, 12 insertions, 9 deletions
diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp index d3f6dd0e..90831e9f 100644 --- a/src/net/ea/beinghandler.cpp +++ b/src/net/ea/beinghandler.cpp @@ -107,7 +107,7 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) int type, guild; Uint16 status; Being *srcBeing, *dstBeing; - Player *player; + Player *player = 0; int hairStyle, hairColor, flag; std::string player_followed; @@ -140,7 +140,8 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) dstBeing = createBeing(id, job); } - player = dynamic_cast<Player*>(dstBeing); + if (dstBeing->getType() == Being::PLAYER) + player = static_cast<Player*>(dstBeing); // Fix monster jobs if (dstBeing->getType() == Being::MONSTER) @@ -420,7 +421,8 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) break; } - player = dynamic_cast<Player*>(dstBeing); + if (dstBeing->getType() == Being::PLAYER) + player = static_cast<Player*>(dstBeing); int type = msg.readInt8(); int id = 0; @@ -529,7 +531,8 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) dstBeing = createBeing(id, job); } - player = dynamic_cast<Player*>(dstBeing); + if (dstBeing->getType() == Being::PLAYER) + player = static_cast<Player*>(dstBeing); if (Party *party = player_node->getParty()){ if (party->isMember(id)) diff --git a/src/net/ea/partyhandler.cpp b/src/net/ea/partyhandler.cpp index f2f27936..f27318d6 100644 --- a/src/net/ea/partyhandler.cpp +++ b/src/net/ea/partyhandler.cpp @@ -251,11 +251,11 @@ void PartyHandler::handleMessage(Net::MessageIn &msg) { partyTab->chatLog(strprintf(_("%s has left your party."), nick.c_str()), BY_SERVER); - Player *p = dynamic_cast<Player*>(beingManager->findBeing(id)); - if (p) - { - p->setParty(NULL); - } + + Being *b = beingManager->findBeing(id); + if (b->getType() == Being::PLAYER) + static_cast<Player*>(b)->setParty(NULL); + eaParty->removeMember(id); } break; |