NetPlay: Allow building a server without a game
This isn't hooked up in the UI yet, but it will allow us to basically start the server and chat system without choosing a game.
This commit is contained in:
parent
2631ec3cff
commit
6d463d1b67
|
@ -183,7 +183,7 @@ class NetPlayServer : public NetPlay
|
|||
public:
|
||||
void ThreadFunc();
|
||||
|
||||
NetPlayServer(const u16 port, const std::string& name, NetPlayUI* dialog, const std::string& game = "");
|
||||
NetPlayServer(const u16 port, const std::string& name, NetPlayUI* dialog);
|
||||
~NetPlayServer();
|
||||
|
||||
void GetPlayerList(std::string& list, std::vector<int>& pid_list);
|
||||
|
|
|
@ -22,10 +22,8 @@ NetPlayServer::~NetPlayServer()
|
|||
}
|
||||
|
||||
// called from ---GUI--- thread
|
||||
NetPlayServer::NetPlayServer(const u16 port, const std::string& name, NetPlayUI* dialog, const std::string& game) : NetPlay(dialog)
|
||||
NetPlayServer::NetPlayServer(const u16 port, const std::string& name, NetPlayUI* dialog) : NetPlay(dialog)
|
||||
{
|
||||
m_selected_game = game;
|
||||
|
||||
m_update_pings = true;
|
||||
|
||||
if (m_socket.Listen(port))
|
||||
|
@ -229,10 +227,13 @@ unsigned int NetPlayServer::OnConnect(sf::SocketTCP& socket)
|
|||
socket.Send(spac);
|
||||
|
||||
// send new client the selected game
|
||||
spac.Clear();
|
||||
spac << (MessageId)NP_MSG_CHANGE_GAME;
|
||||
spac << m_selected_game;
|
||||
socket.Send(spac);
|
||||
if (m_selected_game != "")
|
||||
{
|
||||
spac.Clear();
|
||||
spac << (MessageId)NP_MSG_CHANGE_GAME;
|
||||
spac << m_selected_game;
|
||||
socket.Send(spac);
|
||||
}
|
||||
|
||||
// sync values with new client
|
||||
for (i = m_players.begin(); i!=e; ++i)
|
||||
|
@ -801,4 +802,3 @@ bool NetPlayServer::UPnPUnmapPort(const u16 port)
|
|||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -220,8 +220,8 @@ void NetPlaySetupDiag::OnHost(wxCommandEvent&)
|
|||
npd = new NetPlayDiag(m_parent, m_game_list, game, true);
|
||||
unsigned long port = 0;
|
||||
m_host_port_text->GetValue().ToULong(&port);
|
||||
netplay_ptr = new NetPlayServer(u16(port)
|
||||
, WxStrToStr(m_nickname_text->GetValue()), npd, game);
|
||||
netplay_ptr = new NetPlayServer(u16(port), WxStrToStr(m_nickname_text->GetValue()), npd);
|
||||
netplay_ptr->ChangeGame(game);
|
||||
if (netplay_ptr->is_connected)
|
||||
{
|
||||
#ifdef USE_UPNP
|
||||
|
|
Loading…
Reference in New Issue