- when changing playername, we reset the irc client connection when entering the internet lobby

This commit is contained in:
Mark Vejvoda
2012-11-19 21:56:21 +00:00
parent 3f82137c03
commit f7ebba0301
3 changed files with 18 additions and 0 deletions

View File

@@ -308,11 +308,23 @@ MenuStateMasterserver::MenuStateMasterserver(Program *program, MainMenu *mainMen
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("#1 IRCCLient Cache check\n");
IRCThread * &ircThread = CacheManager::getCachedItem< IRCThread * >(GameConstants::ircClientCacheLookupKey);
// Playername changed so restart the IRC Thread
if(ircThread != NULL && netPlayerName != ircThread->getPlayerName()) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
ircThread->leaveChannel();
ircThread->setCallbackObj(NULL);
ircThread->signalQuit();
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
ircThread = NULL;
}
if(ircThread == NULL) {
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("#2 IRCCLient Cache check\n");
ircThread = new IRCThread(ircArgs,this);
ircClient = ircThread;
ircClient->setUniqueID(extractFileFromDirectoryPath(__FILE__).c_str());
ircClient->setPlayerName(netPlayerName);
ircClient->start();
}
else {

View File

@@ -65,6 +65,8 @@ protected:
string channel;
string nick;
string playerName;
bool hasJoinedChannel;
bool eventDataDone;
Mutex mutexNickList;
@@ -83,6 +85,9 @@ public:
virtual void signalQuit();
virtual bool shutdownAndWait();
void setPlayerName(string value) { playerName = value; }
string getPlayerName() const { return playerName; }
bool getWantToLeaveChannel() const { return wantToLeaveChannel; }
void SendIRCCmdMessage(string target, string msg);

View File

@@ -461,6 +461,7 @@ IRCThread::IRCThread(const std::vector<string> &argv, IRCCallbackInterface *call
hasJoinedChannel = false;
lastNickListUpdate = time(NULL);
wantToLeaveChannel = false;
playerName = "";
}
void IRCThread::signalQuit() {