2009-01-19 06:44:19 +00:00
|
|
|
#ifndef NETWORK_H
|
|
|
|
#define NETWORK_H
|
|
|
|
|
2009-01-29 20:26:40 +00:00
|
|
|
#if defined(GEKKO)
|
|
|
|
# include <network.h>
|
|
|
|
#else
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
#endif
|
2009-01-19 06:44:19 +00:00
|
|
|
#include <SDL.h>
|
|
|
|
|
2009-04-09 13:42:49 +00:00
|
|
|
#include "SID.h"
|
2009-04-13 06:31:12 +00:00
|
|
|
#include "Display.h"
|
2009-04-09 13:42:49 +00:00
|
|
|
|
2009-10-28 17:49:30 +00:00
|
|
|
#define FRODO_NETWORK_PROTOCOL_VERSION 4
|
2009-04-04 07:40:17 +00:00
|
|
|
|
2009-02-03 18:10:09 +00:00
|
|
|
#define FRODO_NETWORK_MAGIC 0x1976
|
2009-02-01 19:47:21 +00:00
|
|
|
|
2010-02-24 18:53:07 +00:00
|
|
|
#define NETWORK_UPDATE_SIZE (128 * 1024)
|
2009-11-04 17:41:54 +00:00
|
|
|
#define NETWORK_SOUND_BUF_SIZE 8192
|
2009-04-13 05:45:20 +00:00
|
|
|
|
2009-11-01 08:38:13 +00:00
|
|
|
#define SCREENSHOT_FACTOR 4
|
|
|
|
#define SCREENSHOT_X (DISPLAY_X / SCREENSHOT_FACTOR)
|
|
|
|
#define SCREENSHOT_Y (DISPLAY_Y / SCREENSHOT_FACTOR)
|
|
|
|
|
2010-02-21 10:25:39 +00:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
REGION_UNKNOWN = 0,
|
|
|
|
REGION_EUROPE = 1,
|
|
|
|
REGION_AFRICA = 2,
|
|
|
|
REGION_NORTH_AMERICA = 3,
|
|
|
|
REGION_SOUTH_AMERICA = 4,
|
|
|
|
REGION_MIDDLE_EAST = 5,
|
|
|
|
REGION_SOUTH_ASIA = 6,
|
|
|
|
REGION_EAST_ASIA = 7,
|
|
|
|
REGION_OCEANIA = 8,
|
|
|
|
REGION_ANTARTICA = 9,
|
|
|
|
} network_region_t;
|
|
|
|
|
2009-02-16 19:20:00 +00:00
|
|
|
typedef enum
|
2009-01-19 06:44:19 +00:00
|
|
|
{
|
2009-02-07 11:08:50 +00:00
|
|
|
/* Connection-related messages */
|
2009-02-13 07:57:40 +00:00
|
|
|
CONNECT_TO_BROKER = 99, /* Hello, broker */
|
2009-02-07 11:08:50 +00:00
|
|
|
LIST_PEERS = 98, /* List of peers */
|
2009-02-13 07:57:40 +00:00
|
|
|
CONNECT_TO_PEER = 97, /* A peer wants to connect */
|
2009-02-07 11:08:50 +00:00
|
|
|
DISCONNECT = 96, /* Disconnect from a peer */
|
2009-02-28 18:45:26 +00:00
|
|
|
SELECT_PEER = 93, /* (client) Select who to connect to */
|
2009-02-07 11:08:50 +00:00
|
|
|
PING = 95, /* (broker) are you alive? */
|
|
|
|
ACK = 94, /* Answer to broker */
|
2009-11-08 12:50:56 +00:00
|
|
|
BANDWIDTH_PING = 92, /* Large packet to calculate bandwidth */
|
|
|
|
BANDWIDTH_ACK = 91, /* Answer to BANDWIDTH_PING */
|
2010-02-06 16:22:52 +00:00
|
|
|
REGISTER_DATA = 90, /* Register data (screenshots typically) */
|
2009-02-07 11:08:50 +00:00
|
|
|
/* Non-data messages */
|
|
|
|
STOP = 55, /* End of this update sequence */
|
|
|
|
/* Data transfer of various kinds */
|
2009-01-19 06:44:19 +00:00
|
|
|
DISPLAY_UPDATE_RAW = 1,
|
|
|
|
DISPLAY_UPDATE_RLE = 2,
|
2009-01-25 10:07:51 +00:00
|
|
|
DISPLAY_UPDATE_DIFF= 3,
|
|
|
|
SOUND_UPDATE_RAW = 4,
|
|
|
|
SOUND_UPDATE_RLE = 5,
|
|
|
|
KEYBOARD_UPDATE = 6,
|
|
|
|
JOYSTICK_UPDATE = 7,
|
2009-02-01 10:52:32 +00:00
|
|
|
ENTER_MENU = 8,
|
2009-04-13 06:31:12 +00:00
|
|
|
TEXT_MESSAGE = 9,
|
2009-11-04 17:12:20 +00:00
|
|
|
SOUND_UPDATE = 10,
|
2009-02-16 19:20:00 +00:00
|
|
|
} network_message_type_t;
|
2009-01-19 06:44:19 +00:00
|
|
|
|
2009-02-11 20:07:28 +00:00
|
|
|
|
2009-04-04 07:40:17 +00:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
OK = 0,
|
|
|
|
AGAIN_ERROR,
|
|
|
|
VERSION_ERROR,
|
|
|
|
SERVER_GARBAGE_ERROR,
|
2009-04-04 11:18:03 +00:00
|
|
|
NO_PEERS_ERROR,
|
2009-04-04 07:40:17 +00:00
|
|
|
} network_connection_error_t;
|
|
|
|
|
2009-01-26 21:00:23 +00:00
|
|
|
struct NetworkUpdate
|
2009-01-19 06:44:19 +00:00
|
|
|
{
|
2009-02-03 18:10:09 +00:00
|
|
|
uint16 magic; /* Should be 0x1976 */
|
|
|
|
uint16 type; /* See above */
|
|
|
|
uint32 size;
|
2009-01-19 06:44:19 +00:00
|
|
|
|
|
|
|
/* The rest is just data of some type */
|
2009-02-07 11:08:50 +00:00
|
|
|
uint8 data[];
|
2009-01-19 06:44:19 +00:00
|
|
|
};
|
|
|
|
|
2009-02-03 18:10:09 +00:00
|
|
|
struct NetworkUpdateDisplay
|
|
|
|
{
|
2009-02-07 11:08:50 +00:00
|
|
|
uint8 square;
|
|
|
|
uint8 data[];
|
2009-02-03 18:10:09 +00:00
|
|
|
};
|
|
|
|
|
2010-02-21 15:36:30 +00:00
|
|
|
#define NETWORK_UPDATE_TEXT_MESSAGE_BROADCAST 1
|
|
|
|
struct NetworkUpdateTextMessage
|
|
|
|
{
|
|
|
|
uint8 flags; /* Broadcast or not */
|
|
|
|
uint8 data[]; /* NULL-terminated string */
|
|
|
|
};
|
|
|
|
|
2009-02-03 18:10:09 +00:00
|
|
|
struct NetworkUpdateJoystick
|
|
|
|
{
|
2009-02-07 11:08:50 +00:00
|
|
|
uint8 val;
|
2009-02-03 18:10:09 +00:00
|
|
|
};
|
|
|
|
|
2009-02-28 18:45:26 +00:00
|
|
|
struct NetworkUpdateSelectPeer
|
|
|
|
{
|
|
|
|
uint32 server_id;
|
|
|
|
};
|
|
|
|
|
2009-02-07 11:08:50 +00:00
|
|
|
struct NetworkUpdatePingAck
|
|
|
|
{
|
2009-03-28 15:18:50 +00:00
|
|
|
uint32 seq;
|
2009-11-08 12:50:56 +00:00
|
|
|
uint8 data[]; /* Only used for bandwidth ping/acks */
|
2009-02-07 11:08:50 +00:00
|
|
|
};
|
|
|
|
|
2010-02-07 09:22:37 +00:00
|
|
|
struct NetworkUpdateRegisterData
|
2010-02-06 14:00:12 +00:00
|
|
|
{
|
|
|
|
uint32_t key;
|
|
|
|
uint32_t metadata; /* Type etc */
|
|
|
|
uint8_t data[];
|
|
|
|
};
|
|
|
|
|
2009-11-03 17:27:21 +00:00
|
|
|
struct NetworkUpdateSoundInfo
|
|
|
|
{
|
2009-11-04 17:00:56 +00:00
|
|
|
uint16 delay_cycles;
|
2009-11-03 17:27:21 +00:00
|
|
|
uint8 adr;
|
|
|
|
uint8 val;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct NetworkUpdateSound
|
|
|
|
{
|
|
|
|
uint16 n_items;
|
|
|
|
uint16 flags;
|
|
|
|
NetworkUpdateSoundInfo info[];
|
|
|
|
};
|
|
|
|
|
2009-02-07 11:08:50 +00:00
|
|
|
/*
|
|
|
|
* Sent by the third-party broker server when someone wants to connect
|
|
|
|
* to this machine.
|
|
|
|
*
|
|
|
|
* See http://www.brynosaurus.com/pub/net/p2pnat/ for how the UDP hole
|
|
|
|
* punching actually works.
|
|
|
|
*/
|
|
|
|
struct NetworkUpdatePeerInfo
|
|
|
|
{
|
|
|
|
uint16 private_port;
|
|
|
|
uint16 public_port;
|
|
|
|
|
2009-02-13 07:57:40 +00:00
|
|
|
/* Encoded as hex numbers in a string - c0a80a02\0 -> 192.168.10.2.
|
|
|
|
* Some more space to fit IPv6 stuff */
|
|
|
|
uint8 private_ip[16];
|
|
|
|
uint8 public_ip[16];
|
2009-02-07 11:08:50 +00:00
|
|
|
|
|
|
|
uint16 key; /* Random value to separate same names */
|
|
|
|
uint16 is_master;
|
|
|
|
uint8 name[32]; /* "SIMON", "LINDA" etc */
|
2009-02-28 18:45:26 +00:00
|
|
|
uint32 server_id; /* Used by the server */
|
2009-04-04 07:40:17 +00:00
|
|
|
uint32 version; /* Version number */
|
2009-11-01 08:38:13 +00:00
|
|
|
|
2010-02-21 10:43:54 +00:00
|
|
|
uint8 region; /* Europe, africa etc */
|
|
|
|
uint8 d; /* Dummy */
|
|
|
|
uint16 avatar; /* Hash of the avatar */
|
2010-02-06 14:00:12 +00:00
|
|
|
uint32 screenshot_key; /* Key number of the screenshot */
|
2009-02-07 11:08:50 +00:00
|
|
|
};
|
|
|
|
|
2010-02-20 13:01:23 +00:00
|
|
|
#define NETWORK_UPDATE_LIST_PEERS_IS_CONNECT 1
|
2009-02-07 11:08:50 +00:00
|
|
|
struct NetworkUpdateListPeers
|
|
|
|
{
|
|
|
|
uint32 n_peers;
|
2009-02-13 07:57:40 +00:00
|
|
|
uint8 your_ip[16];
|
2009-02-07 11:08:50 +00:00
|
|
|
uint16 your_port;
|
2010-02-20 13:01:23 +00:00
|
|
|
uint8 flags;
|
|
|
|
uint8 d; /* Pad to 4 bytes */
|
2009-02-07 11:08:50 +00:00
|
|
|
|
|
|
|
/* Followed by the actual peers */
|
|
|
|
NetworkUpdatePeerInfo peers[];
|
|
|
|
};
|
|
|
|
|
2009-02-03 18:10:09 +00:00
|
|
|
static inline NetworkUpdate *InitNetworkUpdate(NetworkUpdate *ud, uint16 type, uint32 size)
|
|
|
|
{
|
|
|
|
ud->magic = FRODO_NETWORK_MAGIC;
|
|
|
|
ud->size = size;
|
|
|
|
ud->type = type;
|
|
|
|
|
|
|
|
return ud;
|
|
|
|
}
|
2009-01-26 21:00:23 +00:00
|
|
|
|
2009-01-19 06:44:19 +00:00
|
|
|
class Network
|
|
|
|
{
|
|
|
|
public:
|
2009-10-28 18:04:30 +00:00
|
|
|
Network(const char *remote_host, int port);
|
2009-01-24 15:48:43 +00:00
|
|
|
|
|
|
|
~Network();
|
|
|
|
|
2009-02-01 19:47:21 +00:00
|
|
|
void EncodeDisplay(Uint8 *master, Uint8 *remote);
|
2009-01-25 10:07:51 +00:00
|
|
|
|
2009-01-29 21:11:04 +00:00
|
|
|
void EncodeJoystickUpdate(Uint8 v);
|
|
|
|
|
2010-02-21 15:36:30 +00:00
|
|
|
void EncodeTextMessage(const char *str, bool broadcast = false);
|
2009-01-29 21:11:04 +00:00
|
|
|
|
2009-11-06 17:16:35 +00:00
|
|
|
void EnqueueSound(uint32 linecnt, uint8 addr, uint8 val);
|
|
|
|
|
|
|
|
void RegisterSidWrite(uint32 linecnt, uint8 addr, uint8 val);
|
2009-11-04 17:41:54 +00:00
|
|
|
|
|
|
|
void FlushSound(void);
|
|
|
|
|
2009-11-06 17:16:35 +00:00
|
|
|
struct NetworkUpdateSoundInfo *DequeueSound();
|
2009-11-05 06:24:36 +00:00
|
|
|
|
2009-04-13 06:31:12 +00:00
|
|
|
|
|
|
|
bool DecodeUpdate(C64Display *display, uint8 *js, MOS6581 *dst);
|
2009-01-25 10:07:51 +00:00
|
|
|
|
|
|
|
void ResetNetworkUpdate(void);
|
|
|
|
|
|
|
|
void DrawTransferredBlocks(SDL_Surface *screen);
|
|
|
|
|
2009-01-30 17:49:47 +00:00
|
|
|
size_t GetKbps() {
|
|
|
|
return this->kbps;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ThrottleTraffic() {
|
|
|
|
return this->kbps > this->target_kbps;
|
2009-01-25 10:07:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ResetBytesSent() {
|
2009-01-30 17:49:47 +00:00
|
|
|
this->traffic = 0;
|
2009-01-25 10:07:51 +00:00
|
|
|
}
|
|
|
|
|
2009-01-30 17:49:47 +00:00
|
|
|
void Tick(int ms);
|
|
|
|
|
2009-02-01 19:47:21 +00:00
|
|
|
void CloseSocket();
|
|
|
|
|
2010-02-21 16:33:25 +00:00
|
|
|
bool SendUpdateDirect(struct sockaddr_in *addr, NetworkUpdate *what);
|
|
|
|
|
2010-02-14 08:57:55 +00:00
|
|
|
bool SendUpdate(struct sockaddr_in *addr);
|
|
|
|
|
|
|
|
bool SendPeerUpdate()
|
|
|
|
{
|
|
|
|
return this->SendUpdate(&this->peer_addr);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SendServerUpdate()
|
|
|
|
{
|
|
|
|
return this->SendUpdate(&this->server_addr);
|
|
|
|
}
|
2009-02-01 19:47:21 +00:00
|
|
|
|
|
|
|
bool ReceiveUpdate();
|
|
|
|
|
2009-02-08 11:52:09 +00:00
|
|
|
bool ReceiveUpdate(struct timeval *tv);
|
2009-02-08 11:27:56 +00:00
|
|
|
|
2009-02-08 08:22:15 +00:00
|
|
|
static bool StartNetworkServer(int port);
|
2009-01-29 20:35:06 +00:00
|
|
|
|
2009-02-01 19:47:21 +00:00
|
|
|
static bool CheckNewConnection();
|
2009-01-25 10:07:51 +00:00
|
|
|
|
2009-02-01 19:47:21 +00:00
|
|
|
Uint8 *GetScreen()
|
|
|
|
{
|
|
|
|
return this->screen;
|
|
|
|
}
|
|
|
|
|
2010-02-12 06:35:24 +00:00
|
|
|
bool SelectPeer(const char *hostname, uint16_t port, uint32_t server_id);
|
|
|
|
|
2010-02-14 08:05:08 +00:00
|
|
|
bool CancelPeerSelection()
|
|
|
|
{
|
|
|
|
return this->SelectPeer(NULL,0,0);
|
|
|
|
}
|
|
|
|
|
2009-04-04 07:40:17 +00:00
|
|
|
network_connection_error_t ConnectFSM();
|
|
|
|
|
2009-02-01 19:47:21 +00:00
|
|
|
/**
|
|
|
|
* Disconnect from the other end. You should delete the object
|
|
|
|
* after having done this.
|
|
|
|
*/
|
|
|
|
void Disconnect();
|
|
|
|
|
2009-11-04 16:43:47 +00:00
|
|
|
bool is_master; /* Some peers are more equal than others */
|
2010-02-20 13:01:23 +00:00
|
|
|
|
2009-03-08 19:02:19 +00:00
|
|
|
void InitNetwork();
|
|
|
|
|
2009-03-28 09:34:31 +00:00
|
|
|
void ShutdownNetwork();
|
|
|
|
|
2010-02-20 13:01:23 +00:00
|
|
|
|
|
|
|
bool ConnectToBroker();
|
|
|
|
|
|
|
|
bool ConnectToPeer();
|
|
|
|
|
|
|
|
bool WaitForPeerReply();
|
|
|
|
|
|
|
|
bool SendBandWidthTest();
|
|
|
|
|
|
|
|
network_connection_error_t WaitForBandWidthReply();
|
|
|
|
|
|
|
|
network_connection_error_t WaitForPeerList();
|
|
|
|
|
|
|
|
network_connection_error_t WaitForPeerAddress();
|
|
|
|
|
|
|
|
network_connection_error_t WaitForPeerSelection();
|
|
|
|
|
|
|
|
bool SelectPeer(uint32 id);
|
|
|
|
|
|
|
|
protected:
|
2009-01-28 20:57:48 +00:00
|
|
|
/** Encode part of a screen into @a dst in a single sweep
|
|
|
|
*
|
|
|
|
* @param dst the destination update structure
|
|
|
|
* @param screen the screen to encode
|
|
|
|
* @param remote the current remote screen
|
|
|
|
* @param square the square index of the screen to encode
|
|
|
|
*
|
|
|
|
* @return the size of the encoded message
|
|
|
|
*/
|
|
|
|
size_t EncodeDisplaySquare(struct NetworkUpdate *dst,
|
2009-03-28 12:37:06 +00:00
|
|
|
Uint8 *screen, Uint8 *remote, int square,
|
|
|
|
bool use_diff = true);
|
2009-01-28 20:57:48 +00:00
|
|
|
|
2009-01-19 06:44:19 +00:00
|
|
|
/**
|
|
|
|
* Decode a display update message onto @a screen
|
|
|
|
*
|
|
|
|
* @param src the message to decode
|
|
|
|
*/
|
2009-04-13 06:31:12 +00:00
|
|
|
bool DecodeDisplayUpdate(struct NetworkUpdate *src);
|
2009-01-24 15:48:43 +00:00
|
|
|
|
2009-01-24 20:57:23 +00:00
|
|
|
void AddNetworkUpdate(struct NetworkUpdate *update);
|
|
|
|
|
2009-01-26 21:00:23 +00:00
|
|
|
size_t GetNetworkUpdateSize(void)
|
|
|
|
{
|
|
|
|
return (Uint8*)this->cur_ud - (Uint8*)this->ud;
|
|
|
|
}
|
|
|
|
|
2009-01-24 15:48:43 +00:00
|
|
|
/**
|
|
|
|
* Compare two display squares.
|
|
|
|
*
|
|
|
|
* @param a the first square (first byte)
|
|
|
|
* @param b the second square (first byte)
|
|
|
|
*
|
|
|
|
* @return true if they are equal
|
|
|
|
*/
|
|
|
|
bool CompareSquare(Uint8 *a, Uint8 *b);
|
|
|
|
|
2009-04-13 06:31:12 +00:00
|
|
|
bool DecodeDisplayDiff(struct NetworkUpdate *src,
|
2009-01-25 10:07:51 +00:00
|
|
|
int x, int y);
|
2009-04-13 06:31:12 +00:00
|
|
|
bool DecodeDisplayRLE(struct NetworkUpdate *src,
|
2009-01-19 06:44:19 +00:00
|
|
|
int x, int y);
|
2009-04-13 06:31:12 +00:00
|
|
|
bool DecodeDisplayRaw(struct NetworkUpdate *src,
|
2009-01-19 06:44:19 +00:00
|
|
|
int x, int y);
|
|
|
|
|
2010-02-22 19:17:49 +00:00
|
|
|
void SendPingAck(struct sockaddr_in *addr, int seq, uint16 type, size_t data_size);
|
2009-03-28 15:18:50 +00:00
|
|
|
|
2009-02-07 11:08:50 +00:00
|
|
|
bool ReceiveUpdate(NetworkUpdate *dst, size_t sz, struct timeval *tv);
|
2009-01-19 06:44:19 +00:00
|
|
|
|
2009-01-26 21:00:23 +00:00
|
|
|
bool ReceiveData(void *dst, int sock, size_t sz);
|
|
|
|
|
2010-02-14 08:57:55 +00:00
|
|
|
bool InitSocket();
|
2009-02-08 11:27:56 +00:00
|
|
|
|
2009-02-07 11:08:50 +00:00
|
|
|
/* Simple wrapper around our friend recvfrom */
|
|
|
|
ssize_t ReceiveFrom(void *dst, int sock, size_t sz,
|
|
|
|
struct sockaddr_in *from);
|
|
|
|
|
|
|
|
ssize_t SendTo(void *src, int sock, size_t sz,
|
|
|
|
struct sockaddr_in *to);
|
|
|
|
|
2009-01-26 21:00:23 +00:00
|
|
|
bool SendData(void *src, int sock, size_t sz);
|
|
|
|
|
|
|
|
virtual bool Select(int sock, struct timeval *tv);
|
2009-01-19 06:44:19 +00:00
|
|
|
|
2009-02-13 07:57:40 +00:00
|
|
|
bool IpToStr(char *dst, uint8 *ip);
|
|
|
|
|
|
|
|
bool InitSockaddr (struct sockaddr_in *name,
|
|
|
|
const char *hostname, uint16_t port);
|
2009-02-07 11:08:50 +00:00
|
|
|
|
2009-01-26 21:00:23 +00:00
|
|
|
bool MarshalData(NetworkUpdate *ud);
|
2009-01-24 15:48:43 +00:00
|
|
|
|
2009-01-26 21:00:23 +00:00
|
|
|
bool MarshalAllData(NetworkUpdate *p);
|
|
|
|
|
2009-11-07 13:52:22 +00:00
|
|
|
bool DeMarshalAllData(NetworkUpdate *ud, size_t max_size);
|
2009-02-07 18:24:50 +00:00
|
|
|
|
2009-01-26 21:00:23 +00:00
|
|
|
bool DeMarshalData(NetworkUpdate *ud);
|
|
|
|
|
2009-11-07 13:52:22 +00:00
|
|
|
bool ScanDataForStop(NetworkUpdate *ud, size_t max_size);
|
|
|
|
|
2010-02-06 14:00:12 +00:00
|
|
|
bool AppendScreenshot(NetworkUpdatePeerInfo *pi);
|
|
|
|
|
2009-03-16 20:56:04 +00:00
|
|
|
size_t FillNetworkBuffer(NetworkUpdate *p);
|
|
|
|
|
2009-01-26 21:00:23 +00:00
|
|
|
NetworkUpdate *GetNext(NetworkUpdate *p)
|
|
|
|
{
|
|
|
|
return (NetworkUpdate*)((Uint8*)p + p->size);
|
|
|
|
}
|
|
|
|
|
2010-02-24 18:53:07 +00:00
|
|
|
NetworkUpdate *receive_ud;
|
2009-01-24 15:48:43 +00:00
|
|
|
NetworkUpdate *ud;
|
2009-01-26 21:00:23 +00:00
|
|
|
NetworkUpdate *cur_ud;
|
2009-01-28 20:57:48 +00:00
|
|
|
Uint8 *raw_buf;
|
|
|
|
Uint8 *rle_buf;
|
|
|
|
Uint8 *diff_buf;
|
2009-11-01 08:38:13 +00:00
|
|
|
Uint8 screenshot[SCREENSHOT_X * SCREENSHOT_Y / 2];
|
2009-01-25 10:07:51 +00:00
|
|
|
Uint32 *square_updated;
|
2009-01-30 17:49:47 +00:00
|
|
|
|
|
|
|
size_t traffic, last_traffic;
|
|
|
|
int time_since_last_reset;
|
|
|
|
int target_kbps;
|
|
|
|
int kbps;
|
2009-01-29 18:04:31 +00:00
|
|
|
|
2009-03-28 12:37:06 +00:00
|
|
|
/* The current square to refresh */
|
|
|
|
int refresh_square;
|
|
|
|
|
2009-01-19 06:44:19 +00:00
|
|
|
Uint8 *screen;
|
|
|
|
int joystick_port;
|
2009-02-08 11:27:56 +00:00
|
|
|
bool connected;
|
2009-01-30 15:37:15 +00:00
|
|
|
Uint8 cur_joystick_data;
|
|
|
|
|
2009-02-01 19:47:21 +00:00
|
|
|
/* Connection to the peer */
|
2010-02-14 08:05:08 +00:00
|
|
|
int peer_selected;
|
2009-01-19 06:44:19 +00:00
|
|
|
int sock;
|
2010-02-14 08:28:40 +00:00
|
|
|
struct sockaddr_in peer_addr;
|
2010-02-14 08:57:55 +00:00
|
|
|
struct sockaddr_in server_addr;
|
2009-02-13 07:57:40 +00:00
|
|
|
|
2009-04-04 07:40:17 +00:00
|
|
|
const char *connection_error_message;
|
|
|
|
|
2009-11-08 12:50:56 +00:00
|
|
|
uint32 bandwidth_ping_ms;
|
2009-02-02 19:51:58 +00:00
|
|
|
|
2009-11-04 17:41:54 +00:00
|
|
|
NetworkUpdateSoundInfo sound_active[NETWORK_SOUND_BUF_SIZE];
|
|
|
|
int sound_head;
|
|
|
|
int sound_tail;
|
|
|
|
uint32 sound_last_cycles;
|
2009-11-04 20:09:04 +00:00
|
|
|
uint32 sound_last_send;
|
2009-11-04 17:41:54 +00:00
|
|
|
|
2009-04-26 06:02:57 +00:00
|
|
|
public:
|
|
|
|
static bool networking_started;
|
2009-01-19 06:44:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* NETWORK_H */
|