diff options
author | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-03-24 19:17:41 +0100 |
---|---|---|
committer | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-04-02 20:57:16 +0200 |
commit | 59919635523d41f3a15120c83db4b7d080c155de (patch) | |
tree | 0da989bd2342b5a53d49c26893a3a544e7432fcc /src/being.cpp | |
parent | 7ea1c4574d6e845f95f2c4c3a1dd4a5d730bc6ba (diff) | |
download | mana-59919635523d41f3a15120c83db4b7d080c155de.tar.gz mana-59919635523d41f3a15120c83db4b7d080c155de.tar.bz2 mana-59919635523d41f3a15120c83db4b7d080c155de.tar.xz mana-59919635523d41f3a15120c83db4b7d080c155de.zip |
General code cleanups
* Removed some unused includes
* Removed unused ListBox::mFont
* Removed wrong cast to SDL_Scancode
* Removed superfluous .c_str()
* Removed superfluous explicit std::string construction
* Removed unused variable
* Use more emplace_back
* Turned FindBeingFunctor into a lambda
* Avoid needless pointer references for ambient layers and use a vector
Diffstat (limited to 'src/being.cpp')
-rw-r--r-- | src/being.cpp | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/src/being.cpp b/src/being.cpp index 2d198dbd..985faa83 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -477,20 +477,21 @@ void Being::addGuild(Guild *guild) guild->addMember(mId, mName); if (this == local_player && socialWindow) - { socialWindow->addTab(guild); - } } void Being::removeGuild(int id) { + const auto it = mGuilds.find(id); + assert(it != mGuilds.end()); + + auto [_, guild] = *it; + if (this == local_player && socialWindow) - { - socialWindow->removeTab(mGuilds[id]); - } + socialWindow->removeTab(guild); - mGuilds[id]->removeMember(mId); - mGuilds.erase(id); + guild->removeMember(mId); + mGuilds.erase(it); } Guild *Being::getGuild(const std::string &guildName) const @@ -504,12 +505,9 @@ Guild *Being::getGuild(const std::string &guildName) const Guild *Being::getGuild(int id) const { - std::map<int, Guild*>::const_iterator itr; - itr = mGuilds.find(id); + auto itr = mGuilds.find(id); if (itr != mGuilds.end()) - { return itr->second; - } return nullptr; } @@ -941,8 +939,7 @@ void Being::showName() mDispName = nullptr; std::string mDisplayName(mName); - auto* player = static_cast<Being*>(this); - if (player) + if (getType() == PLAYER) { if (config.getBoolValue("showgender")) { @@ -954,9 +951,9 @@ void Being::showName() // Display the IP when under tmw-Athena (GM only). if (Net::getNetworkType() == ServerType::TMWATHENA && local_player - && local_player->getShowIp() && player->getIp()) + && local_player->getShowIp() && getIp()) { - mDisplayName += strprintf(" %s", ipToString(player->getIp())); + mDisplayName += strprintf(" %s", ipToString(getIp())); } } |