From 0aed9de1042c212ae3edc00994d3efaf26176202 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 28 Dec 2014 19:48:10 +0300 Subject: Improve function localPetSay. --- src/gui/windows/chatwindow.cpp | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'src/gui/windows') diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index a707ac8c4..a3c7f703f 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -1655,17 +1655,20 @@ void ChatWindow::channelChatLog(const std::string &channel, tab->chatLog(line, own, ignoreRecord, tryRemoveColors); } -void ChatWindow::localPetSay(const std::string &nick, const std::string &text) +static Being *getPetForNick(const std::string &nick) { Being *const being = actorManager->findBeingByName( nick, ActorType::Player); - Being *pet = nullptr; if (being) - { - pet = being->getFirstPet(); - if (pet) - pet->setSpeech(text, GENERAL_CHANNEL); - } + return being->getFirstPet(); + return nullptr; +} + +void ChatWindow::localPetSay(const std::string &nick, const std::string &text) +{ + Being *const pet = getPetForNick(nick); + if (pet) + pet->setSpeech(text, GENERAL_CHANNEL); if (!localChatTab) return; @@ -1680,15 +1683,6 @@ void ChatWindow::localPetSay(const std::string &nick, const std::string &text) } } -static Being *getPetForNick(const std::string &nick) -{ - Being *const being = actorManager->findBeingByName( - nick, ActorType::Player); - if (being) - return being->getFirstPet(); - return nullptr; -} - void ChatWindow::localPetEmote(const std::string &nick, const uint8_t emoteId) { Being *const pet = getPetForNick(nick); -- cgit v1.2.3-70-g09d2