From abeecf1255d28a7870aef9f70dc3353d9b5f4f2d Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 3 Aug 2016 20:03:30 +0300 Subject: Replace some ifs to switches. --- src/actormanager.cpp | 58 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 24 deletions(-) (limited to 'src/actormanager.cpp') diff --git a/src/actormanager.cpp b/src/actormanager.cpp index befd952e6..b557f3e36 100644 --- a/src/actormanager.cpp +++ b/src/actormanager.cpp @@ -276,31 +276,41 @@ Being *ActorManager::createBeing(const BeingId id, mActorsIdMap[being->getId()] = being; - if (type == ActorType::Player - || type == ActorType::Mercenary - || type == ActorType::Pet - || type == ActorType::Homunculus - || type == ActorType::Npc) + switch (type) { - being->updateFromCache(); - if (beingHandler) - beingHandler->requestNameById(id); - if (localPlayer) - localPlayer->checkNewName(being); - } - else if (type == ActorType::Monster) - { - if (serverFeatures && serverFeatures->haveMonsterName()) - beingHandler->requestNameById(id); - } - else if (type == ActorType::Portal) - { - if (beingHandler && - serverFeatures && - serverFeatures->haveServerWarpNames()) - { - beingHandler->requestNameById(id); - } + case ActorType::Player: + case ActorType::Mercenary: + case ActorType::Pet: + case ActorType::Homunculus: + case ActorType::Npc: + being->updateFromCache(); + if (beingHandler) + beingHandler->requestNameById(id); + if (localPlayer) + localPlayer->checkNewName(being); + break; + case ActorType::Monster: + if (serverFeatures && serverFeatures->haveMonsterName()) + beingHandler->requestNameById(id); + break; + case ActorType::Portal: + if (beingHandler && + serverFeatures && + serverFeatures->haveServerWarpNames()) + { + beingHandler->requestNameById(id); + } + break; + case ActorType::SkillUnit: + case ActorType::Elemental: + break; + default: + case ActorType::FloorItem: + case ActorType::LocalPet: + case ActorType::Avatar: + case ActorType::Unknown: + reportAlways("CreateBeing for unknown type %d", CAST_S32(type)); + break; } if (type == ActorType::Player) -- cgit v1.2.3-70-g09d2