diff options
author | Jared Adams <jaxad0127@gmail.com> | 2010-07-28 09:48:16 -0600 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2010-07-28 09:51:49 -0600 |
commit | 07abd88c7e3d606aaa0c8c7387c398d93daae445 (patch) | |
tree | a497b93f613222f9447f820222c775909b760e74 /src/net | |
parent | 04cefb857e2738c103b81f8ac1502f344d84c16f (diff) | |
download | mana-client-07abd88c7e3d606aaa0c8c7387c398d93daae445.tar.gz mana-client-07abd88c7e3d606aaa0c8c7387c398d93daae445.tar.bz2 mana-client-07abd88c7e3d606aaa0c8c7387c398d93daae445.tar.xz mana-client-07abd88c7e3d606aaa0c8c7387c398d93daae445.zip |
Add some null being checks and cleanup some related code
Reviewed-by: Chuck Miller
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/tmwa/beinghandler.cpp | 43 | ||||
-rw-r--r-- | src/net/tmwa/partyhandler.cpp | 6 |
2 files changed, 23 insertions, 26 deletions
diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp index 5c89cd31..8e6d81b3 100644 --- a/src/net/tmwa/beinghandler.cpp +++ b/src/net/tmwa/beinghandler.cpp @@ -235,31 +235,29 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) */ dstBeing = actorSpriteManager->findBeing(msg.readInt32()); - Uint16 srcX, srcY, dstX, dstY; - msg.readCoordinatePair(srcX, srcY, dstX, dstY); - msg.readInt32(); // Server tick - /* * This packet doesn't have enough info to actually * create a new being, so if the being isn't found, * we'll just pretend the packet didn't happen */ - if (dstBeing) - { - dstBeing->setAction(Being::STAND); - dstBeing->setTileCoords(srcX, srcY); - dstBeing->setDestination(dstX, dstY); - } + if (!dstBeing) + break; + + Uint16 srcX, srcY, dstX, dstY; + msg.readCoordinatePair(srcX, srcY, dstX, dstY); + msg.readInt32(); // Server tick + + dstBeing->setAction(Being::STAND); + dstBeing->setTileCoords(srcX, srcY); + dstBeing->setDestination(dstX, dstY); break; case SMSG_BEING_REMOVE: // A being should be removed or has died id = msg.readInt32(); - dstBeing = actorSpriteManager->findBeing(id); - if (!dstBeing) break; @@ -287,9 +285,7 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) case SMSG_BEING_RESURRECT: // A being changed mortality status id = msg.readInt32(); - dstBeing = actorSpriteManager->findBeing(id); - if (!dstBeing) break; @@ -363,14 +359,13 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) case SMSG_BEING_SELFEFFECT: { id = (Uint32)msg.readInt32(); - if (!actorSpriteManager->findBeing(id)) + Being* being = actorSpriteManager->findBeing(id); + if (!being) break; int effectType = msg.readInt32(); - Being* being = actorSpriteManager->findBeing(id); effectManager->trigger(effectType, being); - break; } @@ -665,17 +660,17 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) // Change in players' flags id = msg.readInt32(); dstBeing = actorSpriteManager->findBeing(id); + if (!dstBeing) + break; + stunMode = msg.readInt16(); statusEffects = msg.readInt16(); statusEffects |= ((Uint32) msg.readInt16()) << 16; - msg.readInt8(); + msg.readInt8(); // Unused? - if (dstBeing) - { - dstBeing->setStunMode(stunMode); - dstBeing->setStatusEffectBlock(0, (statusEffects >> 16) & 0xffff); - dstBeing->setStatusEffectBlock(16, statusEffects & 0xffff); - } + dstBeing->setStunMode(stunMode); + dstBeing->setStatusEffectBlock(0, (statusEffects >> 16) & 0xffff); + dstBeing->setStatusEffectBlock(16, statusEffects & 0xffff); break; case SMSG_BEING_STATUS_CHANGE: diff --git a/src/net/tmwa/partyhandler.cpp b/src/net/tmwa/partyhandler.cpp index 6983b731..fa3d63f1 100644 --- a/src/net/tmwa/partyhandler.cpp +++ b/src/net/tmwa/partyhandler.cpp @@ -246,8 +246,10 @@ void PartyHandler::handleMessage(Net::MessageIn &msg) partyTab->chatLog(strprintf(_("%s has left your party."), nick.c_str()), BY_SERVER); - Being *b = actorSpriteManager->findBeing(id); - b->setParty(NULL); + if (Being *b = actorSpriteManager->findBeing(id)) + { + b->setParty(NULL); + } taParty->removeMember(id); } |