#ifndef __TRACKER
#define __TRACKER

#include "gameinitexit.h"
#include "network.h"

typedef struct{
	char name[64];
	char car[64];
	char location[256];
	UInt32 startIdleTime;
} tGameListPlayerEntry;

enum{
	kJoinStateOK=0,
	kJoinStateReggie,
	kJoinStateFail
};

typedef struct{
	char host[32];
	char alias[32];
	char map[32];
	char name[256];
	int loaded;
	int password;
	int numPlayers;
	int numNetPlayers;
	int maxPlayers;
	int arcade;
	int locked;
	int joinState;
	int onlyRegistered;
	tFileRef mapRef;
	tGameListPlayerEntry players[kMaxPlayers];
} tGameListEntry;

extern int gWaitingForRegistry;
extern int gWaitingForRecord;

void NetworkStopAdvertising();
void NetworkAdvertiseIdle(tGameInfo *gInfo,int *showLonelyMessage,int locked,int forceUpdate);

//void NetworkSearchGames(tGameListEntry *games,int *numGames,int maxGames,int *updated,int *numPlayers);
void NetworkSearchGames(int *updated,tGameListEntry *games,int *numGames,int maxGames,tGameListPlayerEntry *players,int *numPlayers,int maxPlayers);
void NetworkSearchGamesStop();

int NetworkCountPlayers();
void NetworkCountPlayersStop();

void TrackerFetchRecord(tFileRef track,tFileRef car,int arcade,int reverse);
void TrackerRegisterLapTime(tFileRef track,tFileRef car,int time,int arcade,int reverse);
void TrackerWaitForLapTimeRegistry();
void TrackerLapTimeRegistryClose();

void TrackerMessageSend(char *message);
int TrackerMessageReceive(tChatMessage *msg);

void TrackerStartVersionCheck();
int TrackerVersionCheck(char **newVersion);
void TrackerGetNewVersion();

#endif