Internet game lobby dialog shows now overview of games and whether they are private. Now showing connection progress before the internet game lobby.

This commit is contained in:
lotodore
2007-09-04 12:44:11 +00:00
parent b0ef569da0
commit 9ed217609b
15 changed files with 105 additions and 40 deletions
+2 -2
View File
@@ -36,8 +36,8 @@ public:
virtual void SignalNetClientGameInfo(int actionID) = 0;
virtual void SignalNetClientError(int errorID, int osErrorID) = 0;
virtual void SignalNetClientGameListNew(unsigned gameId, const std::string &gameName) = 0;
virtual void SignalNetClientGameListRemove(unsigned gameId, const std::string &gameName) = 0;
virtual void SignalNetClientGameListNew(unsigned gameId) = 0;
virtual void SignalNetClientGameListRemove(unsigned gameId) = 0;
virtual void SignalNetClientGameListPlayerJoined(unsigned gameId, unsigned playerId) = 0;
virtual void SignalNetClientGameListPlayerLeft(unsigned gameId, unsigned playerId) = 0;
+2 -2
View File
@@ -635,7 +635,7 @@ ClientThread::AddGameInfo(unsigned gameId, const GameInfo &info)
boost::mutex::scoped_lock lock(m_gameInfoMapMutex);
m_gameInfoMap.insert(GameInfoMap::value_type(gameId, info));
}
GetCallback().SignalNetClientGameListNew(gameId, info.name);
GetCallback().SignalNetClientGameListNew(gameId);
}
void
@@ -652,7 +652,7 @@ ClientThread::RemoveGameInfo(unsigned gameId)
}
}
if (!name.empty())
GetCallback().SignalNetClientGameListRemove(gameId, name);
GetCallback().SignalNetClientGameListRemove(gameId);
}
void
+9 -4
View File
@@ -50,8 +50,8 @@ private:
};
ServerGameThread::ServerGameThread(ServerLobbyThread &lobbyThread, u_int32_t id, const string &name, GuiInterface &gui, ConfigFile *playerConfig)
: m_lobbyThread(lobbyThread), m_gui(gui), m_id(id), m_name(name), m_playerConfig(playerConfig), m_curState(NULL), m_gameNum(1)
ServerGameThread::ServerGameThread(ServerLobbyThread &lobbyThread, u_int32_t id, const string &name, const string &pwd, GuiInterface &gui, ConfigFile *playerConfig)
: m_lobbyThread(lobbyThread), m_gui(gui), m_id(id), m_name(name), m_password(pwd), m_playerConfig(playerConfig), m_curState(NULL), m_gameNum(1)
{
m_senderCallback.reset(new ServerSenderCallback(*this));
m_sender.reset(new SenderThread(GetSenderCallback()));
@@ -63,9 +63,8 @@ ServerGameThread::~ServerGameThread()
}
void
ServerGameThread::Init(const string &pwd, const GameData &gameData)
ServerGameThread::Init(const GameData &gameData)
{
m_password = pwd;
m_gameData = gameData;
}
@@ -434,6 +433,12 @@ ServerGameThread::SetStartData(const StartData &startData)
m_startData = startData;
}
bool
ServerGameThread::IsPasswordProtected() const
{
return !m_password.empty();
}
bool
ServerGameThread::CheckPassword(const string &password) const
{
+8 -2
View File
@@ -337,8 +337,13 @@ ServerLobbyThread::HandleNetPacketCreateGame(SessionWrapper session, const NetPa
tmpPacket.GetData(createGameData);
boost::shared_ptr<ServerGameThread> game(
new ServerGameThread(*this, GetNextGameId(), createGameData.gameName, GetGui(), m_playerConfig));
game->Init(createGameData.password, createGameData.gameData);
new ServerGameThread(
*this, GetNextGameId(),
createGameData.gameName,
createGameData.password,
GetGui(),
m_playerConfig));
game->Init(createGameData.gameData);
// Remove session from the lobby.
m_sessionManager.RemoveSession(session.sessionData->GetSocket());
@@ -582,6 +587,7 @@ ServerLobbyThread::CreateNetPacketGameListNew(const ServerGameThread &game)
packetData.gameInfo.name = game.GetName();
packetData.gameInfo.data = game.GetGameData();
packetData.gameInfo.players = game.GetPlayerIdList();
packetData.gameInfo.isPasswordProtected = game.IsPasswordProtected();
static_cast<NetPacketGameListNew *>(packet.get())->SetData(packetData);
return packet;
}
+4 -3
View File
@@ -42,10 +42,10 @@ class Game;
class ServerGameThread : public Thread
{
public:
ServerGameThread(ServerLobbyThread &lobbyThread, u_int32_t id, const std::string &name, GuiInterface &gui, ConfigFile *playerConfig);
ServerGameThread(ServerLobbyThread &lobbyThread, u_int32_t id, const std::string &name, const std::string &pwd, GuiInterface &gui, ConfigFile *playerConfig);
virtual ~ServerGameThread();
void Init(const std::string &pwd, const GameData &gameData);
void Init(const GameData &gameData);
u_int32_t GetId() const;
const std::string &GetName() const;
@@ -57,6 +57,7 @@ public:
void SendToAllPlayers(boost::shared_ptr<NetPacket> packet, SessionData::State state);
bool IsPasswordProtected() const;
bool CheckPassword(const std::string &password) const;
const GameData &GetGameData() const;
@@ -130,7 +131,7 @@ private:
std::auto_ptr<Game> m_game;
const u_int32_t m_id;
const std::string m_name;
std::string m_password;
const std::string m_password;
ConfigFile *m_playerConfig;
ServerGameState *m_curState;
unsigned m_gameNum;