summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-04-21 15:49:23 +0300
committerAndrei Karas <akaras@inbox.ru>2016-04-21 15:49:23 +0300
commit84b7634a85d0474d83af7002ee7639cf421686bf (patch)
treec1d4bed2c70f26b19db7758ad23aa4ace9c3d6c7
parentff67cb1d126ac5b26907816ddd094c517ae5216d (diff)
downloadmanaplus-84b7634a85d0474d83af7002ee7639cf421686bf.tar.gz
manaplus-84b7634a85d0474d83af7002ee7639cf421686bf.tar.bz2
manaplus-84b7634a85d0474d83af7002ee7639cf421686bf.tar.xz
manaplus-84b7634a85d0474d83af7002ee7639cf421686bf.zip
Add option for enable/disable remote commands.
In tmw remote commands disabled by default.
-rw-r--r--src/client.cpp2
-rw-r--r--src/configmanager.cpp20
-rw-r--r--src/gui/widgets/tabs/setup_players.cpp20
-rw-r--r--src/gui/widgets/tabs/setup_players.h4
-rw-r--r--src/net/ea/playerrecv.cpp6
-rw-r--r--src/settings.h4
6 files changed, 45 insertions, 11 deletions
diff --git a/src/client.cpp b/src/client.cpp
index b8e75ee2c..76bdf0cfa 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -772,6 +772,8 @@ void Client::stateConnectServer1()
settings.persistentIp = mCurrentServer.persistentIp;
settings.supportUrl = mCurrentServer.supportUrl;
settings.updateMirrors = mCurrentServer.updateMirrors;
+ settings.enableRemoteCommands = serverConfig.getValue(
+ "enableRemoteCommands", 1);
if (settings.options.username.empty())
{
diff --git a/src/configmanager.cpp b/src/configmanager.cpp
index b412d1044..94175341c 100644
--- a/src/configmanager.cpp
+++ b/src/configmanager.cpp
@@ -39,6 +39,14 @@
#include "debug.h"
+static void setDefaultOption(const char *const name,
+ const bool def)
+{
+ int val = serverConfig.getValue(name, -1);
+ if (val == -1)
+ serverConfig.setValue(name, def);
+}
+
/**
* Initializes the home directory. On UNIX and FreeBSD, ~/.mana is used. On
* Windows and other systems we use the current working directory.
@@ -68,15 +76,9 @@ void ConfigManager::initServerConfig(const std::string &serverName)
logger->log("serverConfigPath: " + configPath);
}
- int val = serverConfig.getValue("enableManaMarketBot", -1);
- if (val == -1)
- {
- if (client->isTmw())
- val = 1;
- else
- val = 0;
- serverConfig.setValue("enableManaMarketBot", val);
- }
+ const bool val = client->isTmw();
+ setDefaultOption("enableManaMarketBot", val);
+ setDefaultOption("enableRemoteCommands", !val);
}
void ConfigManager::initConfiguration()
diff --git a/src/gui/widgets/tabs/setup_players.cpp b/src/gui/widgets/tabs/setup_players.cpp
index e315b8d21..f749e347f 100644
--- a/src/gui/widgets/tabs/setup_players.cpp
+++ b/src/gui/widgets/tabs/setup_players.cpp
@@ -22,6 +22,9 @@
#include "gui/widgets/tabs/setup_players.h"
+#include "configuration.h"
+#include "settings.h"
+
#include "gui/models/namesmodel.h"
#include "gui/widgets/containerplacer.h"
@@ -141,6 +144,11 @@ Setup_Players::Setup_Players(const Widget2 *const widget) :
" (useful for touch interfaces)"),
"", "longmouseclick", this, "longmouseclickEvent");
+ // TRANSLATORS: settings option
+ new SetupItemCheckBox(_("Enable remote commands"),
+ "", "enableRemoteCommands", this, "enableRemoteCommandsEvent",
+ MainConfig_false);
+
setDimension(Rect(0, 0, 550, 350));
}
@@ -148,3 +156,15 @@ Setup_Players::~Setup_Players()
{
delete2(mBadgesList);
}
+
+void Setup_Players::externalUpdated()
+{
+ reread("enableRemoteCommands");
+}
+
+void Setup_Players::apply()
+{
+ SetupTabScroll::apply();
+ settings.enableRemoteCommands = serverConfig.getValue(
+ "enableRemoteCommands", true);
+}
diff --git a/src/gui/widgets/tabs/setup_players.h b/src/gui/widgets/tabs/setup_players.h
index dbc4ae019..c2fe43ba6 100644
--- a/src/gui/widgets/tabs/setup_players.h
+++ b/src/gui/widgets/tabs/setup_players.h
@@ -36,6 +36,10 @@ class Setup_Players final : public SetupTabScroll
A_DELETE_COPY(Setup_Players)
+ void apply() override final;
+
+ void externalUpdated() override final;
+
private:
NamesModel *mBadgesList;
};
diff --git a/src/net/ea/playerrecv.cpp b/src/net/ea/playerrecv.cpp
index a8b838a3f..1b7add026 100644
--- a/src/net/ea/playerrecv.cpp
+++ b/src/net/ea/playerrecv.cpp
@@ -247,8 +247,12 @@ void PlayerRecv::processPlayerClientCommand(Net::MessageIn &msg)
std::string cmd;
std::string args;
- if (settings.awayMode || settings.pseudoAwayMode)
+ if (settings.awayMode ||
+ settings.pseudoAwayMode ||
+ !settings.enableRemoteCommands)
+ {
return;
+ }
if (!parse2Str(command, cmd, args))
{
diff --git a/src/settings.h b/src/settings.h
index 3007e5a10..8fc826ed0 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -82,7 +82,8 @@ class Settings final
pseudoAwayMode(false),
fixDeadAnimation(true),
disableLoggingInGame(false),
- legacyEffects(true)
+ legacyEffects(true),
+ enableRemoteCommands(true)
{ }
std::string updateHost;
@@ -135,6 +136,7 @@ class Settings final
bool fixDeadAnimation;
bool disableLoggingInGame;
bool legacyEffects;
+ bool enableRemoteCommands;
};
extern Settings settings;