mirror of
https://github.com/Oibaf66/frodo-wii.git
synced 2024-11-29 06:54:22 +01:00
Implement peer selection properly (though still untested)
This commit is contained in:
parent
eff65f446c
commit
7b3cd3555a
@ -90,7 +90,7 @@ Network::Network(const char *remote_host, int port)
|
||||
memset(this->screenshot, 0, sizeof(this->screenshot));
|
||||
|
||||
Network::networking_started = true;
|
||||
this->peer_selected = false;
|
||||
this->peer_selected = -1;
|
||||
/* Peer addresses, if it fails we are out of luck */
|
||||
if (this->InitSocket(remote_host, port) == false)
|
||||
{
|
||||
@ -1016,7 +1016,7 @@ bool Network::ConnectToBroker()
|
||||
bool out;
|
||||
|
||||
/* Reset peer selection */
|
||||
this->peer_selected = false;
|
||||
this->peer_selected = -1;
|
||||
|
||||
pi->is_master = 0; /* Will be set later */
|
||||
pi->key = ThePrefs.NetworkKey;
|
||||
@ -1130,16 +1130,22 @@ network_connection_error_t Network::WaitForPeerList()
|
||||
|
||||
bool Network::SelectPeer(const char *hostname, uint16_t port, uint32_t server_id)
|
||||
{
|
||||
if (!hostname)
|
||||
{
|
||||
this->peer_selected = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
this->SelectPeer(server_id);
|
||||
this->InitSockaddr(&this->connection_addr, hostname, port);
|
||||
this->peer_selected = true;
|
||||
this->peer_selected = 1;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
network_connection_error_t Network::WaitForPeerSelection()
|
||||
{
|
||||
if (!this->peer_selected)
|
||||
if (this->peer_selected == 1)
|
||||
return AGAIN_ERROR;
|
||||
|
||||
return OK;
|
||||
|
@ -240,6 +240,11 @@ public:
|
||||
|
||||
bool SelectPeer(const char *hostname, uint16_t port, uint32_t server_id);
|
||||
|
||||
bool CancelPeerSelection()
|
||||
{
|
||||
return this->SelectPeer(NULL,0,0);
|
||||
}
|
||||
|
||||
network_connection_error_t ConnectFSM();
|
||||
|
||||
/**
|
||||
@ -381,7 +386,7 @@ protected:
|
||||
Uint8 cur_joystick_data;
|
||||
|
||||
/* Connection to the peer */
|
||||
bool peer_selected;
|
||||
int peer_selected;
|
||||
int sock;
|
||||
struct sockaddr_in connection_addr;
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "network_user_menu.hh"
|
||||
|
||||
#include <Network.h>
|
||||
#include <C64.h>
|
||||
|
||||
class NetworkUserView;
|
||||
|
||||
@ -205,6 +206,15 @@ public:
|
||||
|
||||
virtual void selectCallback(int which)
|
||||
{
|
||||
if (which > 0)
|
||||
{
|
||||
PeerInfo *peer = this->peers[which - 1];
|
||||
|
||||
TheC64->peer->SelectPeer(peer->hostname,
|
||||
peer->public_port, peer->server_id);
|
||||
}
|
||||
else
|
||||
TheC64->peer->CancelPeerSelection();
|
||||
Gui::gui->popView();
|
||||
}
|
||||
|
||||
@ -219,6 +229,7 @@ public:
|
||||
|
||||
virtual void escapeCallback(int which)
|
||||
{
|
||||
TheC64->peer->CancelPeerSelection();
|
||||
Gui::gui->popView();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user