added being able to create a host on the game server now need to work on joining that game
This commit is contained in:
@@ -2,12 +2,17 @@
|
||||
#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
|
||||
};
|
||||
@@ -17,32 +22,18 @@ typedef struct packet{
|
||||
char payload[PACKSZ - sizeof(enum pack_type)];
|
||||
} packet;
|
||||
|
||||
|
||||
int read_to_buff(Uint32 *buff, Uint32 *src, Uint32 sz)
|
||||
typedef struct host_info
|
||||
{
|
||||
if(sz%32){
|
||||
puts("error size must be div by 32");
|
||||
return 0;
|
||||
}
|
||||
for(Uint32 i = 0; i < (sz >> 2); i += 1)
|
||||
{
|
||||
*(buff + i) = SDLNet_Read32(src + i);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
char name[MAX_NAMESZ];
|
||||
IPaddress ip;
|
||||
}host_info;
|
||||
|
||||
int write_to_buff(Uint32 *buff, Uint32 *src, Uint32 sz)
|
||||
{
|
||||
if(sz%32){
|
||||
puts("error size must be div by 32");
|
||||
return 0;
|
||||
}
|
||||
for(Uint32 i = 0; i < (sz >> 2); i += 1)
|
||||
{
|
||||
SDLNet_Write32(*(src + i), (buff + i));
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user