//Troy Rosin
#ifndef __my_net_h__
#define __my_net_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;


int read_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)
  {
    *(buff + i) = SDLNet_Read32(src + i);
  }
  return 1;
}

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;
}


#endif
