summaryrefslogtreecommitdiff
path: root/src/guildmanager.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-09-18 17:49:18 +0300
committerAndrei Karas <akaras@inbox.ru>2011-09-18 17:49:18 +0300
commit70b520b1e876f9698bb95baa2d274ea289a0c6bd (patch)
tree152c7519b0d9b8fb424af2373ec48db823a85575 /src/guildmanager.cpp
parent62ec17f6e489ec50f17219444468aeb8969dc961 (diff)
parent3b999f51c740d0541c53d223518e5e4bb482d996 (diff)
downloadplus-70b520b1e876f9698bb95baa2d274ea289a0c6bd.tar.gz
plus-70b520b1e876f9698bb95baa2d274ea289a0c6bd.tar.bz2
plus-70b520b1e876f9698bb95baa2d274ea289a0c6bd.tar.xz
plus-70b520b1e876f9698bb95baa2d274ea289a0c6bd.zip
Merge branch 'master' into strippedstripped1.1.9.18
Conflicts: src/guichan/cliprectangle.cpp src/guichan/focushandler.cpp src/guichan/gui.cpp src/guichan/include/guichan/cliprectangle.hpp src/guichan/include/guichan/inputevent.hpp src/guichan/include/guichan/keyevent.hpp src/guichan/include/guichan/mouseevent.hpp src/guichan/include/guichan/widgets/button.hpp src/guichan/include/guichan/widgets/checkbox.hpp src/guichan/include/guichan/widgets/dropdown.hpp src/guichan/include/guichan/widgets/radiobutton.hpp src/guichan/include/guichan/widgets/slider.hpp src/guichan/include/guichan/widgets/tab.hpp src/guichan/include/guichan/widgets/tabbedarea.hpp src/guichan/include/guichan/widgets/textfield.hpp src/guichan/include/guichan/widgets/window.hpp src/guichan/inputevent.cpp src/guichan/keyevent.cpp src/guichan/mouseevent.cpp src/guichan/widget.cpp src/guichan/widgets/button.cpp src/guichan/widgets/checkbox.cpp src/guichan/widgets/dropdown.cpp src/guichan/widgets/radiobutton.cpp src/guichan/widgets/slider.cpp src/guichan/widgets/tab.cpp src/guichan/widgets/tabbedarea.cpp src/guichan/widgets/textfield.cpp src/guichan/widgets/window.cpp
Diffstat (limited to 'src/guildmanager.cpp')
-rw-r--r--src/guildmanager.cpp43
1 files changed, 32 insertions, 11 deletions
diff --git a/src/guildmanager.cpp b/src/guildmanager.cpp
index 1a8d5b433..4620de742 100644
--- a/src/guildmanager.cpp
+++ b/src/guildmanager.cpp
@@ -43,6 +43,8 @@ bool GuildManager::mEnableGuildBot = false;
GuildManager::GuildManager() :
mGotInfo(false),
mGotName(false),
+ mSentInfoRequest(false),
+ mSentNameRequest(false),
mHavePower(false),
mTab(0),
mRequest(false)
@@ -57,9 +59,6 @@ GuildManager::~GuildManager()
void GuildManager::init()
{
- if (guildManager)
- return;
-
int val = serverConfig.getValue("enableGuildBot", -1);
if (val == -1)
{
@@ -71,7 +70,17 @@ void GuildManager::init()
}
mEnableGuildBot = val;
if (mEnableGuildBot)
- guildManager = new GuildManager();
+ {
+ if (!guildManager)
+ guildManager = new GuildManager();
+ else
+ guildManager->reload();
+ }
+ else if (guildManager)
+ {
+ delete guildManager;
+ guildManager = 0;
+ }
}
void GuildManager::reload()
@@ -80,12 +89,14 @@ void GuildManager::reload()
mGotName = false;
mHavePower = false;
mRequest = false;
+ mSentNameRequest = false;
+ mSentInfoRequest = false;
mTempList.clear();
if (socialWindow)
{
Guild *guild = Guild::getGuild(1);
- if (guild)
+ if (guild && socialWindow)
socialWindow->removeTab(guild);
}
delete mTab;
@@ -109,7 +120,8 @@ void GuildManager::chat(std::string msg)
void GuildManager::getNames(std::vector<std::string> &names)
{
Guild *guild = createGuild();
- guild->getNames(names);
+ if (guild)
+ guild->getNames(names);
}
void GuildManager::requestGuildInfo()
@@ -117,15 +129,21 @@ void GuildManager::requestGuildInfo()
if (mRequest)
return;
- if (!mGotName)
+ if (!mGotName && !mSentNameRequest)
{
+ if (!Client::limitPackets(PACKET_CHAT))
+ return;
send("!info " + toString(tick_time));
mRequest = true;
+ mSentNameRequest = true;
}
- else if (!mGotInfo)
+ else if (!mGotInfo && !mSentInfoRequest && !mSentNameRequest)
{
+ if (!Client::limitPackets(PACKET_CHAT))
+ return;
send("!getonlineinfo " + toString(tick_time));
mRequest = true;
+ mSentInfoRequest = true;
}
}
@@ -135,8 +153,8 @@ void GuildManager::updateList()
if (guild)
{
guild->setServerGuild(false);
- std::vector<std::string>::iterator it = mTempList.begin();
- std::vector<std::string>::iterator it_end = mTempList.end();
+ std::vector<std::string>::const_iterator it = mTempList.begin();
+ std::vector<std::string>::const_iterator it_end = mTempList.end();
int i = 0;
while (it != it_end)
{
@@ -174,6 +192,7 @@ void GuildManager::updateList()
}
}
mTempList.clear();
+ mSentInfoRequest = false;
mGotInfo = true;
}
@@ -262,6 +281,7 @@ bool GuildManager::process(std::string msg)
if (player_node)
player_node->setGuildName(msg);
mGotName = true;
+ mSentNameRequest = false;
mRequest = false;
return true;
}
@@ -300,6 +320,7 @@ bool GuildManager::process(std::string msg)
if (player_node)
player_node->setGuildName(msg);
mGotName = true;
+ mSentNameRequest = false;
mRequest = false;
return true;
}
@@ -338,7 +359,7 @@ bool GuildManager::process(std::string msg)
return true;
}
else if (!haveNick && (findCutLast(msg, " has been removed "
- "from the Guild.") || findCutLast(msg," has left the Guild.")))
+ "from the Guild.") || findCutLast(msg, " has left the Guild.")))
{
Guild *guild = createGuild();
if (!guild)