From d8d06e4c4ff2b84fbe74c902ac4bf50d349dc018 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 19 Aug 2016 22:40:15 +0300 Subject: Add chat command for show/change share item drops in party. --- src/actions/commands.cpp | 68 +++++++++++++++++++++++++++++++++++++++++++++++- src/actions/commands.h | 1 + 2 files changed, 68 insertions(+), 1 deletion(-) (limited to 'src/actions') diff --git a/src/actions/commands.cpp b/src/actions/commands.cpp index f2acaea56..7ec1d8bf8 100644 --- a/src/actions/commands.cpp +++ b/src/actions/commands.cpp @@ -71,8 +71,8 @@ #include "resources/map/map.h" +#include "utils/booleanoptions.h" #include "utils/chatutils.h" -#include "utils/gettext.h" #include "utils/gmfunctions.h" #include "utils/parameters.h" #include "utils/process.h" @@ -1690,4 +1690,70 @@ impHandler(setSkillOffsetY) return false; } +impHandler(partyItemShare) +{ + if (!localPlayer) + return false; + + if (localPlayer->isInParty() == false) + return true; + + ChatTab *tab = event.tab; + if (tab == nullptr) + tab = localChatTab; + if (tab == nullptr) + return true; + + const std::string args = event.args; + if (args.empty()) + { + switch (partyHandler->getShareItems()) + { + case PartyShare::YES: + // TRANSLATORS: chat message + tab->chatLog(_("Item sharing enabled."), + ChatMsgType::BY_SERVER); + return true; + case PartyShare::NO: + // TRANSLATORS: chat message + tab->chatLog(_("Item sharing disabled."), + ChatMsgType::BY_SERVER); + return true; + case PartyShare::NOT_POSSIBLE: + // TRANSLATORS: chat message + tab->chatLog(_("Item sharing not possible."), + ChatMsgType::BY_SERVER); + return true; + case PartyShare::UNKNOWN: + // TRANSLATORS: chat message + tab->chatLog(_("Item sharing unknown."), + ChatMsgType::BY_SERVER); + return true; + default: + break; + } + } + + const signed char opt = parseBoolean(args); + + switch (opt) + { + case 1: + partyHandler->setShareItems( + PartyShare::YES); + break; + case 0: + partyHandler->setShareItems( + PartyShare::NO); + break; + case -1: + tab->chatLog(strprintf(BOOLEAN_OPTIONS, "item"), + ChatMsgType::BY_SERVER); + break; + default: + break; + } + return true; +} + } // namespace Actions diff --git a/src/actions/commands.h b/src/actions/commands.h index acc13af75..e0892f384 100644 --- a/src/actions/commands.h +++ b/src/actions/commands.h @@ -149,6 +149,7 @@ namespace Actions decHandler(showSkillOffsetY); decHandler(setSkillOffsetX); decHandler(setSkillOffsetY); + decHandler(partyItemShare); } // namespace Actions #undef decHandler -- cgit v1.2.3-70-g09d2