40 lines
603 B
C
40 lines
603 B
C
//Troy Rosin
|
|
#ifndef __my_net_h__
|
|
#define __my_net_h__
|
|
|
|
#include <SDL_net.h>
|
|
#include <game.h>
|
|
|
|
|
|
#define PORT 36911
|
|
|
|
#define SERVER "localhost"
|
|
|
|
#define PACKSZ 1024
|
|
|
|
|
|
enum pack_type{
|
|
G_STATE, S_STATE, HOSTS_REQ, NEW_HOST, JOIN_REQ, U_NAME
|
|
};
|
|
|
|
typedef struct packet{
|
|
enum pack_type type;
|
|
char payload[PACKSZ - sizeof(enum pack_type)];
|
|
} packet;
|
|
|
|
typedef struct host_info
|
|
{
|
|
char name[MAX_NAMESZ];
|
|
IPaddress ip;
|
|
}host_info;
|
|
|
|
|
|
int read_from_packet(Uint32 *buff, Uint32 *src, Uint32 sz);
|
|
int write_for_sending(Uint32 *buff, Uint32 *src, Uint32 sz);
|
|
|
|
|
|
int new_host(char l[MAX_NAMESZ]);
|
|
|
|
|
|
#endif
|