summaryrefslogtreecommitdiff
path: root/src/commandhandler.cpp
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-02-22 13:02:26 +0100
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-02-22 14:32:45 +0100
commit81e4f170d8ba4ccbcfa1e6c07bd0522dfc3b6e08 (patch)
treee2619b16a5331e5760d94be389d0a3a01427293f /src/commandhandler.cpp
parentd047db79f7034e0e75a85a656d18f40716d197b9 (diff)
downloadmana-81e4f170d8ba4ccbcfa1e6c07bd0522dfc3b6e08.tar.gz
mana-81e4f170d8ba4ccbcfa1e6c07bd0522dfc3b6e08.tar.bz2
mana-81e4f170d8ba4ccbcfa1e6c07bd0522dfc3b6e08.tar.xz
mana-81e4f170d8ba4ccbcfa1e6c07bd0522dfc3b6e08.zip
General code cleanups
* Use default member initializers * Use range-based loops * Don't use 'else' after 'return' * Removed some unused includes * Construct empty strings with std::string() instead of "" * Clear strings with .clear() instead of assigning "" * Check whether strings are empty with .empty() instead of comparing to "" * Removed redundant initializations
Diffstat (limited to 'src/commandhandler.cpp')
-rw-r--r--src/commandhandler.cpp18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp
index c35e9ee3..01975d80 100644
--- a/src/commandhandler.cpp
+++ b/src/commandhandler.cpp
@@ -333,8 +333,8 @@ void CommandHandler::handleWho(const std::string &args, ChatTab *tab)
void CommandHandler::handleMsg(const std::string &args, ChatTab *tab)
{
- std::string recvnick = "";
- std::string msg = "";
+ std::string recvnick;
+ std::string msg;
if (args.substr(0, 1) == "\"")
{
@@ -358,7 +358,7 @@ void CommandHandler::handleMsg(const std::string &args, ChatTab *tab)
else
{
recvnick = std::string(args);
- msg = "";
+ msg.clear();
}
}
@@ -412,7 +412,7 @@ void CommandHandler::handleJoin(const std::string &args, ChatTab *tab)
{
std::string::size_type pos = args.find(' ');
std::string name(args, 0, pos);
- std::string password(args, pos+1);
+ std::string password(args, pos + 1);
tab->chatLog(strprintf(_("Requesting to join channel %s."), name.c_str()));
Net::getChatHandler()->enterChannel(name, password);
}
@@ -425,21 +425,17 @@ void CommandHandler::handleListChannels(const std::string &args, ChatTab *tab)
void CommandHandler::handleCreateParty(const std::string &args, ChatTab *tab)
{
if (args.empty())
- {
tab->chatLog(_("Party name is missing."), BY_SERVER);
- }
else
- {
Net::getPartyHandler()->create(args);
- }
}
void CommandHandler::handleParty(const std::string &args, ChatTab *tab)
{
- if (args != "")
- Net::getPartyHandler()->invite(args);
- else
+ if (args.empty())
tab->chatLog(_("Please specify a name."), BY_SERVER);
+ else
+ Net::getPartyHandler()->invite(args);
}
void CommandHandler::handleMe(const std::string &args, ChatTab *tab)