summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-08-30 01:57:05 +0300
committerAndrei Karas <akaras@inbox.ru>2011-08-30 02:32:13 +0300
commit9f752d5431364c052b364045015d3574da2c320c (patch)
tree9278797f892129e42fde74656db032dc480c4490
parent8158669fde4f4a32191d6b052586e7cf0889ab7e (diff)
downloadmanaplus-9f752d5431364c052b364045015d3574da2c320c.tar.gz
manaplus-9f752d5431364c052b364045015d3574da2c320c.tar.bz2
manaplus-9f752d5431364c052b364045015d3574da2c320c.tar.xz
manaplus-9f752d5431364c052b364045015d3574da2c320c.zip
Dont create guild manager instance if guild bot support not enabled.
-rw-r--r--src/client.cpp4
-rw-r--r--src/game.cpp11
-rw-r--r--src/gui/setup_other.cpp3
-rw-r--r--src/gui/socialwindow.cpp4
-rw-r--r--src/guildmanager.cpp7
-rw-r--r--src/guildmanager.h6
-rw-r--r--src/net/ea/beinghandler.cpp2
-rw-r--r--src/net/ea/chathandler.cpp2
8 files changed, 21 insertions, 18 deletions
diff --git a/src/client.cpp b/src/client.cpp
index 60af41ed3..2e3652188 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -794,9 +794,7 @@ int Client::exec()
if (mumbleManager)
mumbleManager->setServer(mCurrentServer.hostname);
- if (!guildManager)
- guildManager = new GuildManager();
- guildManager->init();
+ GuildManager::init();
if (!mConfigAutoSaved)
{
diff --git a/src/game.cpp b/src/game.cpp
index 8df48b775..303c59edb 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -177,11 +177,7 @@ static void initEngines()
commandHandler = new CommandHandler;
channelManager = new ChannelManager;
effectManager = new EffectManager;
- if (!guildManager)
- {
- guildManager = new GuildManager;
- guildManager->init();
- }
+ GuildManager::init();
particleEngine = new Particle(NULL);
particleEngine->setupEngine();
@@ -338,7 +334,7 @@ static void destroyGuiWindows()
Mana::Event::trigger(CHANNEL_GAME, Mana::Event(EVENT_GUIWINDOWSUNLOADED));
- if (guildManager && guildManager->getEnableGuildBot())
+ if (guildManager && GuildManager::getEnableGuildBot())
guildManager->reload();
}
@@ -406,7 +402,7 @@ Game::Game():
setupWindow->setInGame(true);
clearKeysArray();
- if (guildManager && guildManager->getEnableGuildBot())
+ if (guildManager && GuildManager::getEnableGuildBot())
guildManager->requestGuildInfo();
Mana::Event::trigger(CHANNEL_GAME, Mana::Event(EVENT_CONSTRUCTED));
@@ -437,6 +433,7 @@ Game::~Game()
del_0(mCurrentMap)
del_0(spellManager)
del_0(spellShortcut)
+ del_0(guildManager)
del_0(mumbleManager)
Being::clearCache();
diff --git a/src/gui/setup_other.cpp b/src/gui/setup_other.cpp
index 05ec9d672..1cad4c594 100644
--- a/src/gui/setup_other.cpp
+++ b/src/gui/setup_other.cpp
@@ -147,6 +147,9 @@ Setup_Other::Setup_Other()
new SetupItemLabel(_("Bots support"), "", this);
+ new SetupItemCheckBox(_("Enable auction bot support"), "",
+ "enableAuctionBot", this, "enableAuctionBotEvent", false);
+
new SetupItemCheckBox(_("Enable guild bot support and disable native "
"guild support"), "", "enableGuildBot", this,
"enableGuildBotEvent", false);
diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp
index ca52ea283..b9c8cb365 100644
--- a/src/gui/socialwindow.cpp
+++ b/src/gui/socialwindow.cpp
@@ -1311,7 +1311,7 @@ void SocialWindow::action(const gcn::ActionEvent &event)
strprintf(_("Accepted guild invite from %s."),
mPartyInviter.c_str()));
}
- if (!guildManager || !guildManager->getEnableGuildBot())
+ if (!guildManager || !GuildManager::getEnableGuildBot())
Net::getGuildHandler()->inviteResponse(mGuildInvited, true);
else
guildManager->inviteResponse(true);
@@ -1324,7 +1324,7 @@ void SocialWindow::action(const gcn::ActionEvent &event)
strprintf(_("Rejected guild invite from %s."),
mPartyInviter.c_str()));
}
- if (!guildManager || !guildManager->getEnableGuildBot())
+ if (!guildManager || !GuildManager::getEnableGuildBot())
Net::getGuildHandler()->inviteResponse(mGuildInvited, false);
else
guildManager->inviteResponse(false);
diff --git a/src/guildmanager.cpp b/src/guildmanager.cpp
index 77324e67e..2c55caefa 100644
--- a/src/guildmanager.cpp
+++ b/src/guildmanager.cpp
@@ -38,9 +38,9 @@
#include "debug.h"
+bool GuildManager::mEnableGuildBot = false;
GuildManager::GuildManager() :
- mEnableGuildBot(false),
mGotInfo(false),
mGotName(false),
mHavePower(false),
@@ -57,6 +57,9 @@ GuildManager::~GuildManager()
void GuildManager::init()
{
+ if (guildManager)
+ return;
+
int val = serverConfig.getValue("enableGuildBot", -1);
if (val == -1)
{
@@ -67,6 +70,8 @@ void GuildManager::init()
serverConfig.setValue("enableGuildBot", val);
}
mEnableGuildBot = val;
+ if (mEnableGuildBot)
+ guildManager = new GuildManager();
}
void GuildManager::reload()
diff --git a/src/guildmanager.h b/src/guildmanager.h
index d0ee7fb62..80014e352 100644
--- a/src/guildmanager.h
+++ b/src/guildmanager.h
@@ -37,7 +37,7 @@ class GuildManager
~GuildManager();
- void init();
+ static void init();
void chat(std::string msg);
@@ -51,7 +51,7 @@ class GuildManager
void updateList();
- bool getEnableGuildBot()
+ static bool getEnableGuildBot()
{ return mEnableGuildBot; }
void kick(std::string msg);
@@ -80,7 +80,7 @@ class GuildManager
private:
bool process(std::string msg);
- bool mEnableGuildBot;
+ static bool mEnableGuildBot;
bool mGotInfo;
bool mGotName;
bool mHavePower;
diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp
index 2714f94ce..4a5cfb841 100644
--- a/src/net/ea/beinghandler.cpp
+++ b/src/net/ea/beinghandler.cpp
@@ -662,7 +662,7 @@ void BeingHandler::processPlayerGuilPartyInfo(Net::MessageIn &msg)
if ((dstBeing = actorSpriteManager->findBeing(msg.readInt32())))
{
dstBeing->setPartyName(msg.readString(24));
- if (!guildManager || !guildManager->getEnableGuildBot())
+ if (!guildManager || !GuildManager::getEnableGuildBot())
dstBeing->setGuildName(msg.readString(24));
dstBeing->setGuildPos(msg.readString(24));
dstBeing->addToCache();
diff --git a/src/net/ea/chathandler.cpp b/src/net/ea/chathandler.cpp
index e430dfc0f..5737cc2b2 100644
--- a/src/net/ea/chathandler.cpp
+++ b/src/net/ea/chathandler.cpp
@@ -162,7 +162,7 @@ void ChatHandler::processWhisper(Net::MessageIn &msg)
if (nick != "Server")
{
- if (guildManager && guildManager->getEnableGuildBot()
+ if (guildManager && GuildManager::getEnableGuildBot()
&& nick == "guild" && guildManager->processGuildMessage(chatMsg))
{
return;