diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-02-18 18:15:17 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-02-18 18:15:17 +0300 |
commit | 772daf48072915d598014c25a33ff3dc96e43bce (patch) | |
tree | 3db4df447d4edfb9ee5866d6400ea1ed7dcd45db /src | |
parent | 0b236e4e04a6d89d34925ce9d2875c002e135b23 (diff) | |
download | manaverse-772daf48072915d598014c25a33ff3dc96e43bce.tar.gz manaverse-772daf48072915d598014c25a33ff3dc96e43bce.tar.bz2 manaverse-772daf48072915d598014c25a33ff3dc96e43bce.tar.xz manaverse-772daf48072915d598014c25a33ff3dc96e43bce.zip |
Fix random not working guild tab with guild bot integration.
Diffstat (limited to 'src')
-rw-r--r-- | src/game.cpp | 2 | ||||
-rw-r--r-- | src/guildmanager.cpp | 27 | ||||
-rw-r--r-- | src/guildmanager.h | 4 |
3 files changed, 31 insertions, 2 deletions
diff --git a/src/game.cpp b/src/game.cpp index e599d5459..c024c41dc 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -586,6 +586,8 @@ void Game::slowLogic() shopWindow->updateTimes(); if (mainGraphics->getOpenGL()) ResourceManager::delayedLoad(); + if (guildManager) + guildManager->slowLogic(); PacketCounters::update(); // Handle network stuff diff --git a/src/guildmanager.cpp b/src/guildmanager.cpp index 22e6f5672..7ec8ae95b 100644 --- a/src/guildmanager.cpp +++ b/src/guildmanager.cpp @@ -37,6 +37,8 @@ #include "debug.h" +static const int requestTimeout = 5; + bool GuildManager::mEnableGuildBot = false; GuildManager::GuildManager() : @@ -46,7 +48,9 @@ GuildManager::GuildManager() : mSentNameRequest(false), mHavePower(false), mTab(nullptr), - mRequest(false) + mRequest(false), + mRequestTime(cur_time + 3), + mGotOnlineInfo(false) { } @@ -90,6 +94,8 @@ void GuildManager::reload() mRequest = false; mSentNameRequest = false; mSentInfoRequest = false; + mGotOnlineInfo = false; + mRequestTime = 0; mTempList.clear(); if (socialWindow) @@ -125,7 +131,7 @@ void GuildManager::getNames(StringVect &names) const void GuildManager::requestGuildInfo() { - if (mRequest) + if (mRequest && mRequestTime + 15 < cur_time) return; if (!mGotName && !mSentNameRequest) @@ -135,6 +141,7 @@ void GuildManager::requestGuildInfo() send("!info " + toString(tick_time)); mRequest = true; mSentNameRequest = true; + mRequestTime = cur_time + requestTimeout; } else if (!mGotInfo && !mSentInfoRequest && !mSentNameRequest) { @@ -143,6 +150,20 @@ void GuildManager::requestGuildInfo() send("!getonlineinfo " + toString(tick_time)); mRequest = true; mSentInfoRequest = true; + mRequestTime = cur_time + requestTimeout; + } +} + +void GuildManager::slowLogic() +{ + if (!mGotOnlineInfo && mGotName && mRequestTime < cur_time) + { + if (!Client::limitPackets(PACKET_WHISPER)) + return; + send("!getonlineinfo " + toString(tick_time)); + mRequest = true; + mSentInfoRequest = true; + mRequestTime = cur_time + requestTimeout; } } @@ -332,6 +353,7 @@ bool GuildManager::process(std::string msg) if (msg.size() < 1 || msg[msg.size() - 1] != '#') updateList(); mRequest = false; + mGotOnlineInfo = true; return true; } else if (findCutFirst(msg, "oL#")) @@ -341,6 +363,7 @@ bool GuildManager::process(std::string msg) if (msg.size() < 1 || msg[msg.size() - 1] != '#') updateList(); mRequest = false; + mGotOnlineInfo = true; return true; } else if (msg == "You are currently not in a guild. For more information " diff --git a/src/guildmanager.h b/src/guildmanager.h index de8af03eb..e9b05526d 100644 --- a/src/guildmanager.h +++ b/src/guildmanager.h @@ -76,6 +76,8 @@ class GuildManager final bool afterRemove(); + void slowLogic(); + bool havePower() const A_WARN_UNUSED { return mHavePower; } @@ -91,6 +93,8 @@ class GuildManager final StringVect mTempList; GuildChatTab *mTab; bool mRequest; + int mRequestTime; + bool mGotOnlineInfo; }; extern GuildManager *guildManager; |