Fixed leaving a game which has not yet been started.
This commit is contained in:
@@ -79,6 +79,10 @@ public:
|
||||
{return m_cacheDir;}
|
||||
void SetCacheDir(const std::string &cacheDir)
|
||||
{m_cacheDir = cacheDir;}
|
||||
bool GetSubscribeLobbyMsg() const
|
||||
{return m_hasSubscribedLobbyMsg;}
|
||||
void SetSubscribeLobbyMsg(bool setSubscribe)
|
||||
{m_hasSubscribedLobbyMsg = setSubscribe;}
|
||||
|
||||
int GetClientSockaddrSize() const
|
||||
{return m_addrFamily == AF_INET6 ? sizeof(sockaddr_in6) : sizeof(sockaddr_in);}
|
||||
@@ -99,6 +103,7 @@ private:
|
||||
std::string m_playerName;
|
||||
std::string m_avatarFile;
|
||||
std::string m_cacheDir;
|
||||
bool m_hasSubscribedLobbyMsg;
|
||||
ReceiveBuffer m_receiveBuffer;
|
||||
};
|
||||
|
||||
|
||||
@@ -20,7 +20,8 @@
|
||||
#include <net/clientcontext.h>
|
||||
|
||||
ClientContext::ClientContext()
|
||||
: m_protocol(0), m_addrFamily(AF_INET), m_useServerList(false), m_serverPort(0)
|
||||
: m_protocol(0), m_addrFamily(AF_INET), m_useServerList(false), m_serverPort(0),
|
||||
m_hasSubscribedLobbyMsg(true)
|
||||
{
|
||||
bzero(&m_clientSockaddr, sizeof(m_clientSockaddr));
|
||||
}
|
||||
|
||||
@@ -591,19 +591,27 @@ ClientThread::SetUnknownAvatar(unsigned playerId)
|
||||
void
|
||||
ClientThread::UnsubscribeLobbyMsg()
|
||||
{
|
||||
// Send unsubscribe request.
|
||||
boost::shared_ptr<NetPacket> unsubscr(new NetPacketUnsubscribeGameList);
|
||||
GetSender().Send(GetContext().GetSessionData(), unsubscr);
|
||||
if (GetContext().GetSubscribeLobbyMsg())
|
||||
{
|
||||
// Send unsubscribe request.
|
||||
boost::shared_ptr<NetPacket> unsubscr(new NetPacketUnsubscribeGameList);
|
||||
GetSender().Send(GetContext().GetSessionData(), unsubscr);
|
||||
GetContext().SetSubscribeLobbyMsg(false);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ClientThread::ResubscribeLobbyMsg()
|
||||
{
|
||||
// Clear game info map as it is outdated.
|
||||
ClearGameInfoMap();
|
||||
// Send resubscribe request.
|
||||
boost::shared_ptr<NetPacket> resubscr(new NetPacketResubscribeGameList);
|
||||
GetSender().Send(GetContext().GetSessionData(), resubscr);
|
||||
if (!GetContext().GetSubscribeLobbyMsg())
|
||||
{
|
||||
// Clear game info map as it is outdated.
|
||||
ClearGameInfoMap();
|
||||
// Send resubscribe request.
|
||||
boost::shared_ptr<NetPacket> resubscr(new NetPacketResubscribeGameList);
|
||||
GetSender().Send(GetContext().GetSessionData(), resubscr);
|
||||
GetContext().SetSubscribeLobbyMsg(true);
|
||||
}
|
||||
}
|
||||
|
||||
const ClientContext &
|
||||
|
||||
Reference in New Issue
Block a user