More fixes. Using player name as base for game name now. Removing games which have no players left. Check collision of all player names on connect (kind of slow, but name needs to be unique).

This commit is contained in:
lotodore
2007-08-21 17:27:13 +00:00
parent 3e4b134faa
commit 3a2f3255af
10 changed files with 120 additions and 15 deletions
+10
View File
@@ -53,6 +53,8 @@ public:
void AddConnection(boost::shared_ptr<ConnectData> data);
void CloseSessionDelayed(SessionWrapper session);
void RemoveGame(unsigned id);
u_int32_t GetNextUniquePlayerId();
u_int32_t GetNextGameId();
ServerCallback &GetCallback();
@@ -63,6 +65,7 @@ protected:
typedef std::list<SessionWrapper> SessionList;
typedef std::list<std::pair<boost::microsec_timer, boost::shared_ptr<SessionData> > > CloseSessionList;
typedef std::map<unsigned, boost::shared_ptr<ServerGameThread> > GameMap;
typedef std::list<unsigned> RemoveGameList;
// Main function of the thread.
virtual void Main();
@@ -72,6 +75,8 @@ protected:
void HandleNetPacketCreateGame(SessionWrapper session, const NetPacketCreateGame &tmpPacket);
void HandleNetPacketJoinGame(SessionWrapper session, const NetPacketJoinGame &tmpPacket);
void CloseSessionLoop();
void RemoveGameLoop();
void TerminateGames();
void HandleNewConnection(boost::shared_ptr<ConnectData> connData);
@@ -92,6 +97,8 @@ protected:
ServerSenderCallback &GetSenderCallback();
GuiInterface &GetGui();
bool IsPlayerConnected(const std::string &name);
static boost::shared_ptr<NetPacket> CreateNetPacketGameListNew(const ServerGameThread &game);
private:
@@ -104,6 +111,9 @@ private:
CloseSessionList m_closeSessionList;
mutable boost::mutex m_closeSessionListMutex;
RemoveGameList m_removeGameList;
mutable boost::mutex m_removeGameListMutex;
GameMap m_gameMap;
std::auto_ptr<ReceiverHelper> m_receiver;