2 * Copyright (C) Volition, Inc. 2005. All rights reserved.
4 * All source code herein is the property of Volition, Inc. You may not sell
5 * or otherwise commercially exploit the source or things you created based on the
10 #ifndef _gtrack_header
11 #define _gtrack_header
13 //Game Tracker client code header
17 #define MAX_NET_RETRIES 30
18 #define NET_ACK_TIMEOUT 2500
19 #define NET_GAME_TIMEOUT 300 //time in seconds
21 #define MAX_GAME_DATA_SIZE 500
23 #define MAX_GENERIC_GAME_NAME_LEN 32
25 #define MAX_GAME_LISTS_PER_PACKET 10
27 #define CHANNEL_LEN 33
29 #define MAX_FREESPACE_PLAYERS 16
30 #define MAX_FREESPACE_PLAYER_NAME_LEN 32
31 #define MAX_FREESPACE_MISSION_NAME_LEN 32
32 #define MAX_FREESPACE_PLAYERS 16
34 #define GNT_SERVER_ACK 0
35 #define GNT_CLIENT_ACK 1
36 #define GNT_GAMESTARTED 2
37 #define GNT_GAMEOVER 3
38 #define GNT_GAMEUPDATE 4
39 #define GNT_GAMELIST_REQ 5
40 #define GNT_GAMELIST_DATA 6
41 #define GNT_GAME_COUNT_REQ 7
42 #define GNT_GAME_COUNT_DATA 8
44 #define GT_FREESPACE 1
46 #define GT_TUBERACER 3
47 #define GT_FREESPACE2 4
50 #define GAME_HEADER_ONLY_SIZE (sizeof(game_packet_header)-MAX_GAME_DATA_SIZE)
54 unsigned int len; //Length of entire packet;
55 unsigned char game_type; //1==freespace (GT_FREESPACE), 2==D3, 3==tuberacer, etc.
57 int type; //Used to specify what to do ie. Add a new net game (GNT_GAMESTARTED), remove a net game (game over), etc.
58 unsigned int sig; //Unique identifier for client ACKs (The server always fills this in, the client responds)
60 char data[MAX_GAME_DATA_SIZE];
67 char game_name[MAX_GENERIC_GAME_NAME_LEN];
69 int type; //game type;
72 int current_num_players;
73 char mission_name[MAX_FREESPACE_MISSION_NAME_LEN];
74 // char mission_file[MAX_FREESPACE_MISSION_FILE_LEN];
75 // char mission_url[MAX_FREESPACE_MISSION_URL_LEN];
76 char players[MAX_FREESPACE_PLAYERS][MAX_FREESPACE_PLAYER_NAME_LEN];
77 int player_rank[MAX_FREESPACE_PLAYERS];
78 char channel[CHANNEL_LEN];
79 } freespace_net_game_data;
84 char game_name[MAX_GENERIC_GAME_NAME_LEN];
86 int type; //game type;
89 int current_num_players;
90 char mission_name[MAX_FREESPACE_MISSION_NAME_LEN];
91 char channel[CHANNEL_LEN];
92 } freespace2_net_game_data;
96 typedef struct _active_games{
97 int game_type; //ie. GT_FREESPACE GT_DESCENT3, etc.
99 unsigned int last_update; //Time we last got an update from this game
100 char data[MAX_GAME_DATA_SIZE]; //memory to hold the game specific data
105 unsigned char game_type;
106 char game_name[MAX_GAME_LISTS_PER_PACKET][MAX_GENERIC_GAME_NAME_LEN];
107 unsigned int game_server[MAX_GAME_LISTS_PER_PACKET];
108 unsigned short port[MAX_GAME_LISTS_PER_PACKET];
112 int rank; // Try to find opponents with a rank similar to this
113 char channel[CHANNEL_LEN]; // only give us games in this channel
114 } filter_game_list_struct;
117 //Function prototypes
119 int InitGameTrackerClient(int gametype);
120 void IdleGameTracker();
121 void UpdateGameData(void *buffer);
122 game_list * GetGameList();
123 void RequestGameList();
124 void RequestGameListWithFilter(void *filter);
125 void RequestGameCountWithFilter(void *filter);
127 // void SendGameOver();
132 void StartTrackerGame(void *buffer);
134 void AckPacket(int sig);
137 #define MAX_GAME_BUFFERS 20 //Thats a lot considering 20 games per game_list struct
139 #define TRACKER_UPDATE_INTERVAL 300 //300 seconds
140 #define TRACKER_RESEND_TIME 2000 //2000ms