mirror of
https://github.com/Oibaf66/frodo-wii.git
synced 2024-11-10 21:55:11 +01:00
Split send and receive buffers to be able to answer pings
This commit is contained in:
parent
695f3b9471
commit
dcf255f1e2
@ -59,8 +59,8 @@ Network::Network(const char *remote_host, int port)
|
|||||||
this->connected = false;
|
this->connected = false;
|
||||||
|
|
||||||
/* "big enough" buffer */
|
/* "big enough" buffer */
|
||||||
this->ud = (NetworkUpdate*)malloc( size );
|
this->ud = (NetworkUpdate*)xmalloc( size );
|
||||||
assert(this->ud);
|
this->receive_ud = (NetworkUpdate*)xmalloc( size );
|
||||||
|
|
||||||
this->ResetNetworkUpdate();
|
this->ResetNetworkUpdate();
|
||||||
this->traffic = 0;
|
this->traffic = 0;
|
||||||
@ -108,6 +108,7 @@ Network::Network(const char *remote_host, int port)
|
|||||||
Network::~Network()
|
Network::~Network()
|
||||||
{
|
{
|
||||||
free(this->ud);
|
free(this->ud);
|
||||||
|
free(this->receive_ud);
|
||||||
free(this->square_updated);
|
free(this->square_updated);
|
||||||
free(this->raw_buf);
|
free(this->raw_buf);
|
||||||
free(this->rle_buf);
|
free(this->rle_buf);
|
||||||
@ -485,6 +486,7 @@ void Network::EncodeJoystickUpdate(Uint8 v)
|
|||||||
void Network::ResetNetworkUpdate(void)
|
void Network::ResetNetworkUpdate(void)
|
||||||
{
|
{
|
||||||
memset(this->ud, 0, NETWORK_UPDATE_SIZE);
|
memset(this->ud, 0, NETWORK_UPDATE_SIZE);
|
||||||
|
memset(this->receive_ud, 0, NETWORK_UPDATE_SIZE);
|
||||||
|
|
||||||
this->cur_ud = InitNetworkUpdate(this->ud, STOP, sizeof(NetworkUpdate));
|
this->cur_ud = InitNetworkUpdate(this->ud, STOP, sizeof(NetworkUpdate));
|
||||||
}
|
}
|
||||||
@ -531,12 +533,12 @@ bool Network::ReceiveUpdate()
|
|||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
|
|
||||||
memset(&tv, 0, sizeof(tv));
|
memset(&tv, 0, sizeof(tv));
|
||||||
return this->ReceiveUpdate(this->ud, NETWORK_UPDATE_SIZE, &tv);
|
return this->ReceiveUpdate(this->receive_ud, NETWORK_UPDATE_SIZE, &tv);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Network::ReceiveUpdate(struct timeval *tv)
|
bool Network::ReceiveUpdate(struct timeval *tv)
|
||||||
{
|
{
|
||||||
return this->ReceiveUpdate(this->ud, NETWORK_UPDATE_SIZE, tv);
|
return this->ReceiveUpdate(this->receive_ud, NETWORK_UPDATE_SIZE, tv);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Network::ReceiveUpdate(NetworkUpdate *dst, size_t total_sz,
|
bool Network::ReceiveUpdate(NetworkUpdate *dst, size_t total_sz,
|
||||||
@ -910,7 +912,7 @@ bool Network::ScanDataForStop(NetworkUpdate *ud, size_t max_size)
|
|||||||
|
|
||||||
bool Network::DecodeUpdate(C64Display *display, uint8 *js, MOS6581 *dst)
|
bool Network::DecodeUpdate(C64Display *display, uint8 *js, MOS6581 *dst)
|
||||||
{
|
{
|
||||||
NetworkUpdate *p = this->ud;
|
NetworkUpdate *p = this->receive_ud;
|
||||||
bool out = true;
|
bool out = true;
|
||||||
|
|
||||||
while (p->type != STOP)
|
while (p->type != STOP)
|
||||||
@ -970,15 +972,13 @@ bool Network::DecodeUpdate(C64Display *display, uint8 *js, MOS6581 *dst)
|
|||||||
NetworkUpdatePingAck *ping = (NetworkUpdatePingAck *)p->data;
|
NetworkUpdatePingAck *ping = (NetworkUpdatePingAck *)p->data;
|
||||||
uint16 type = ACK;
|
uint16 type = ACK;
|
||||||
|
|
||||||
if (ud->type == BANDWIDTH_PING)
|
if (p->type == BANDWIDTH_PING)
|
||||||
type = BANDWIDTH_ACK;
|
type = BANDWIDTH_ACK;
|
||||||
this->SendPingAck(&this->server_addr, ping->seq, type, ud->size);
|
this->SendPingAck(&this->server_addr, ping->seq, type, p->size);
|
||||||
/* FIXME! Temporary crash fix */
|
|
||||||
this->ResetNetworkUpdate();
|
|
||||||
} break;
|
} break;
|
||||||
case LIST_PEERS:
|
case LIST_PEERS:
|
||||||
{
|
{
|
||||||
NetworkUpdateListPeers *lp = (NetworkUpdateListPeers *)this->ud->data;
|
NetworkUpdateListPeers *lp = (NetworkUpdateListPeers *)p->data;
|
||||||
|
|
||||||
if (lp->n_peers == 1 && (lp->flags & NETWORK_UPDATE_LIST_PEERS_IS_CONNECT))
|
if (lp->n_peers == 1 && (lp->flags & NETWORK_UPDATE_LIST_PEERS_IS_CONNECT))
|
||||||
{
|
{
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
#define FRODO_NETWORK_MAGIC 0x1976
|
#define FRODO_NETWORK_MAGIC 0x1976
|
||||||
|
|
||||||
#define NETWORK_UPDATE_SIZE (256 * 1024)
|
#define NETWORK_UPDATE_SIZE (128 * 1024)
|
||||||
#define NETWORK_SOUND_BUF_SIZE 8192
|
#define NETWORK_SOUND_BUF_SIZE 8192
|
||||||
|
|
||||||
#define SCREENSHOT_FACTOR 4
|
#define SCREENSHOT_FACTOR 4
|
||||||
@ -384,6 +384,7 @@ protected:
|
|||||||
return (NetworkUpdate*)((Uint8*)p + p->size);
|
return (NetworkUpdate*)((Uint8*)p + p->size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NetworkUpdate *receive_ud;
|
||||||
NetworkUpdate *ud;
|
NetworkUpdate *ud;
|
||||||
NetworkUpdate *cur_ud;
|
NetworkUpdate *cur_ud;
|
||||||
Uint8 *raw_buf;
|
Uint8 *raw_buf;
|
||||||
|
Loading…
Reference in New Issue
Block a user