fixing server joining issues
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/hilnius@13356 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
8c6c1d2c4d
commit
0f469cd3d9
@ -53,10 +53,6 @@ void* waitInput(void* data)
|
||||
{
|
||||
ProtocolManager::getInstance()->requestStart(new ConnectToServer());
|
||||
}
|
||||
else if (sscanf(str.c_str(), "connect=%d", &n))
|
||||
{
|
||||
ProtocolManager::getInstance()->requestStart(new ConnectToServer(n));
|
||||
}
|
||||
else if (str == "select")
|
||||
{
|
||||
std::string str2;
|
||||
|
@ -66,7 +66,7 @@ void ClientLobbyRoomProtocol::notifyEvent(Event* event)
|
||||
assert(event->data.size()); // assert that data isn't empty
|
||||
uint8_t message_type = event->data.getAndRemoveUInt8();
|
||||
|
||||
Log::debug("ClientLobbyRoomProtocol", "Message of type %d", message_type);
|
||||
Log::info("ClientLobbyRoomProtocol", "Message of type %d", message_type);
|
||||
if (message_type == 0x01) // new player connected
|
||||
newPlayer(event);
|
||||
else if (message_type == 0x02) // player disconnected
|
||||
@ -110,6 +110,7 @@ void ClientLobbyRoomProtocol::update()
|
||||
NetworkString ns;
|
||||
// 1 (connection request), 4 (size of id), global id
|
||||
ns.ai8(1).ai8(4).ai32(Online::CurrentUser::acquire()->getUserID());
|
||||
Online::CurrentUser::release();
|
||||
m_listener->sendMessage(this, ns);
|
||||
m_state = REQUESTING_CONNECTION;
|
||||
} break;
|
||||
@ -117,6 +118,10 @@ void ClientLobbyRoomProtocol::update()
|
||||
break;
|
||||
case CONNECTED:
|
||||
break;
|
||||
case KART_SELECTION:
|
||||
StateManager::get()->pushScreen(NetworkKartSelectionScreen::getInstance());
|
||||
m_state = SELECTING_KARTS;
|
||||
break;
|
||||
case SELECTING_KARTS:
|
||||
break;
|
||||
case PLAYING:
|
||||
@ -428,8 +433,7 @@ void ClientLobbyRoomProtocol::startSelection(Event* event)
|
||||
uint8_t token = event->data.gui32(1);
|
||||
if (token == NetworkManager::getInstance()->getPeers()[0]->getClientServerToken())
|
||||
{
|
||||
m_state = SELECTING_KARTS;
|
||||
StateManager::get()->pushScreen(NetworkKartSelectionScreen::getInstance());
|
||||
m_state = KART_SELECTION;
|
||||
Log::info("ClientLobbyRoomProtocol", "Kart selection starts now");
|
||||
}
|
||||
else
|
||||
|
@ -37,6 +37,7 @@ class ClientLobbyRoomProtocol : public LobbyRoomProtocol
|
||||
LINKED,
|
||||
REQUESTING_CONNECTION,
|
||||
CONNECTED, // means in the lobby room
|
||||
KART_SELECTION,
|
||||
SELECTING_KARTS, // in the network kart selection screen
|
||||
PLAYING,
|
||||
DONE,
|
||||
|
@ -43,10 +43,11 @@ ConnectToServer::ConnectToServer() :
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
ConnectToServer::ConnectToServer(uint32_t server_id) :
|
||||
ConnectToServer::ConnectToServer(uint32_t server_id, uint32_t host_id) :
|
||||
Protocol(NULL, PROTOCOL_CONNECTION)
|
||||
{
|
||||
m_server_id = server_id;
|
||||
m_host_id = host_id;
|
||||
m_quick_join = false;
|
||||
m_state = NONE;
|
||||
}
|
||||
@ -122,7 +123,7 @@ void ConnectToServer::asynchronousUpdate()
|
||||
}
|
||||
else
|
||||
{
|
||||
m_current_protocol_id = m_listener->requestStart(new GetPeerAddress(m_server_id, &m_server_address));
|
||||
m_current_protocol_id = m_listener->requestStart(new GetPeerAddress(m_host_id, &m_server_address));
|
||||
m_state = GETTING_SERVER_ADDRESS;
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ class ConnectToServer : public Protocol, public CallbackObject
|
||||
{
|
||||
public:
|
||||
ConnectToServer(); //!< Quick join
|
||||
ConnectToServer(uint32_t server_id); //!< Specify server id
|
||||
ConnectToServer(uint32_t server_id, uint32_t host_id); //!< Specify server id
|
||||
virtual ~ConnectToServer();
|
||||
|
||||
virtual void notifyEvent(Event* event);
|
||||
@ -39,6 +39,7 @@ class ConnectToServer : public Protocol, public CallbackObject
|
||||
TransportAddress m_server_address;
|
||||
TransportAddress m_public_address;
|
||||
uint32_t m_server_id;
|
||||
uint32_t m_host_id;
|
||||
uint32_t m_current_protocol_id;
|
||||
bool m_quick_join;
|
||||
|
||||
|
@ -75,7 +75,7 @@ void RequestConnection::asynchronousUpdate()
|
||||
}
|
||||
else
|
||||
{
|
||||
Log::error("RequestConnection", "Fail to make a request.");
|
||||
Log::error("RequestConnection", "Fail to make a request to connecto to server %d", m_server_id);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -47,6 +47,7 @@ ServerInfoDialog::ServerInfoDialog(uint32_t server_id, uint32_t host_id,bool fro
|
||||
{
|
||||
m_server_id = server_id;
|
||||
m_host_id = host_id;
|
||||
Log::info("ServerInfoDialog", "Server id is %d, Host id is %d", server_id, host_id);
|
||||
m_self_destroy = false;
|
||||
m_enter_lobby = false;
|
||||
m_from_server_creation = from_server_creation;
|
||||
@ -84,7 +85,11 @@ ServerInfoDialog::~ServerInfoDialog()
|
||||
void ServerInfoDialog::requestJoin()
|
||||
{
|
||||
//m_server_join_request = Online::CurrentUser::acquire()->requestServerJoin(m_server_id);
|
||||
ProtocolManager::getInstance()->requestStart(new ConnectToServer(m_host_id));
|
||||
Online::ServersManager::acquire()->setJoinedServer(m_server_id);
|
||||
Online::ServersManager::release();
|
||||
ProtocolManager::getInstance()->requestStart(new ConnectToServer(m_server_id, m_host_id));
|
||||
ModalDialog::dismiss();
|
||||
StateManager::get()->pushScreen(NetworkingLobby::getInstance());
|
||||
//Online::CurrentUser::release();
|
||||
}
|
||||
|
||||
|
@ -396,6 +396,7 @@ public:
|
||||
|
||||
// ---- Kart name label
|
||||
m_kart_name = new LabelWidget();
|
||||
m_kart_name->add(); // add the widget
|
||||
m_kart_name->setText(props->getName(), false);
|
||||
m_kart_name->m_properties[PROP_TEXT_ALIGN] = "center";
|
||||
m_kart_name->m_properties[PROP_ID] =
|
||||
|
@ -1,11 +1,27 @@
|
||||
#include "network_kart_selection.hpp"
|
||||
#include "states_screens/network_kart_selection.hpp"
|
||||
|
||||
NetworkKartSelectionScreen::NetworkKartSelectionScreen()
|
||||
using namespace GUIEngine;
|
||||
|
||||
DEFINE_SCREEN_SINGLETON( NetworkKartSelectionScreen );
|
||||
|
||||
NetworkKartSelectionScreen::NetworkKartSelectionScreen() : KartSelectionScreen()
|
||||
{
|
||||
//ctor
|
||||
}
|
||||
|
||||
NetworkKartSelectionScreen::~NetworkKartSelectionScreen()
|
||||
{
|
||||
//dtor
|
||||
}
|
||||
|
||||
|
||||
void NetworkKartSelectionScreen::init()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback handling events from the kart selection menu
|
||||
*/
|
||||
void NetworkKartSelectionScreen::eventCallback(GUIEngine::Widget* widget, const std::string& name,
|
||||
const int playerID)
|
||||
{
|
||||
Log::info("NetworkKartSelectionScreen", "Fuck events !");
|
||||
} // eventCallback
|
||||
|
@ -3,15 +3,17 @@
|
||||
|
||||
#include "states_screens/kart_selection.hpp"
|
||||
|
||||
|
||||
class NetworkKartSelectionScreen : public KartSelectionScreen
|
||||
{
|
||||
protected:
|
||||
|
||||
NetworkKartSelectionScreen();
|
||||
virtual ~NetworkKartSelectionScreen();
|
||||
|
||||
public:
|
||||
|
||||
virtual void init() OVERRIDE;
|
||||
virtual void eventCallback(GUIEngine::Widget* widget, const std::string& name,
|
||||
const int playerID) OVERRIDE;
|
||||
};
|
||||
|
||||
#endif // NETWORK_KART_SELECTION_HPP
|
||||
|
@ -60,7 +60,9 @@ void NetworkingLobbySettings::loadedFromFile()
|
||||
// ----------------------------------------------------------------------------
|
||||
bool NetworkingLobbySettings::hasLostConnection()
|
||||
{
|
||||
return !Online::CurrentUser::acquire()->isSignedIn();
|
||||
bool return_value = !Online::CurrentUser::acquire()->isSignedIn();
|
||||
Online::CurrentUser::release();
|
||||
return return_value;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -247,7 +247,7 @@ void OnlineScreen::eventCallback(Widget* widget, const std::string& name, const
|
||||
{
|
||||
delete request2;
|
||||
StateManager::get()->pushScreen(NetworkingLobby::getInstance());
|
||||
ProtocolManager::getInstance()->requestStart(new ConnectToServer(server->getHostId()));
|
||||
ProtocolManager::getInstance()->requestStart(new ConnectToServer(server->getServerId(), server->getHostId()));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user