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
21 #define MAX_NET_RETRIES 30
22 #define NET_ACK_TIMEOUT 2500
23 #define NET_GAME_TIMEOUT 300 //time in seconds
26 #define MAX_GAME_DATA_SIZE 500
28 #define MAX_GAME_DATA_SIZE 700
31 #define MAX_GENERIC_GAME_NAME_LEN 32
33 #define MAX_GAME_LISTS_PER_PACKET 10
35 #define CHANNEL_LEN 33
37 #define MAX_FREESPACE_PLAYERS 16
38 #define MAX_FREESPACE_PLAYER_NAME_LEN 32
39 #define MAX_FREESPACE_MISSION_NAME_LEN 32
40 #define MAX_FREESPACE_PLAYERS 16
42 #define GNT_SERVER_ACK 0
43 #define GNT_CLIENT_ACK 1
44 #define GNT_GAMESTARTED 2
45 #define GNT_GAMEOVER 3
46 #define GNT_GAMEUPDATE 4
47 #define GNT_GAMELIST_REQ 5
48 #define GNT_GAMELIST_DATA 6
49 #define GNT_GAME_COUNT_REQ 7
50 #define GNT_GAME_COUNT_DATA 8
52 #define GT_FREESPACE 1
54 #define GT_TUBERACER 3
55 #define GT_FREESPACE2 4
59 #define GAME_HEADER_ONLY_SIZE (sizeof(game_packet_header)-MAX_GAME_DATA_SIZE)
61 // header struct not packed in FS1, add 3 bytes padding
62 #define GAME_HEADER_ONLY_SIZE (sizeof(game_packet_header)-MAX_GAME_DATA_SIZE+3)
67 unsigned int len; //Length of entire packet;
68 unsigned char game_type; //1==freespace (GT_FREESPACE), 2==D3, 3==tuberacer, etc.
69 char junk[16]; // not used but need constant size for compatibility (SOCKADDR_IN addr);
70 int type; //Used to specify what to do ie. Add a new net game (GNT_GAMESTARTED), remove a net game (game over), etc.
71 unsigned int sig; //Unique identifier for client ACKs (The server always fills this in, the client responds)
73 char data[MAX_GAME_DATA_SIZE];
80 char game_name[MAX_GENERIC_GAME_NAME_LEN];
82 int type; //game type;
85 int current_num_players;
86 char mission_name[MAX_FREESPACE_MISSION_NAME_LEN];
87 // char mission_file[MAX_FREESPACE_MISSION_FILE_LEN];
88 // char mission_url[MAX_FREESPACE_MISSION_URL_LEN];
89 char players[MAX_FREESPACE_PLAYERS][MAX_FREESPACE_PLAYER_NAME_LEN];
90 int player_rank[MAX_FREESPACE_PLAYERS];
91 char channel[CHANNEL_LEN];
92 char pad[3]; // 3-byte padding for size/alignment
93 } freespace_net_game_data;
95 #define pxo_net_game_data freespace_net_game_data
100 char game_name[MAX_GENERIC_GAME_NAME_LEN];
102 int type; //game type;
105 int current_num_players;
106 char mission_name[MAX_FREESPACE_MISSION_NAME_LEN];
107 char channel[CHANNEL_LEN];
108 char pad[3]; // 3-byte padding for size/alignment
109 } freespace2_net_game_data;
111 #define pxo_net_game_data freespace2_net_game_data
115 typedef struct _active_games{
116 int game_type; //ie. GT_FREESPACE GT_DESCENT3, etc.
117 struct sockaddr addr;
118 unsigned int last_update; //Time we last got an update from this game
119 char data[MAX_GAME_DATA_SIZE]; //memory to hold the game specific data
124 unsigned char game_type;
125 char game_name[MAX_GAME_LISTS_PER_PACKET][MAX_GENERIC_GAME_NAME_LEN];
126 char pad[3]; // ..needs 3-byte padding here for alignment..
127 unsigned int game_server[MAX_GAME_LISTS_PER_PACKET];
128 unsigned short port[MAX_GAME_LISTS_PER_PACKET];
132 int rank; // Try to find opponents with a rank similar to this
133 char channel[CHANNEL_LEN]; // only give us games in this channel
134 char pad[3]; // 3-bytes padding for size/alignment
135 } filter_game_list_struct;
138 //Function prototypes
140 int InitGameTrackerClient(int gametype);
141 void IdleGameTracker();
142 void UpdateGameData(void *buffer);
143 game_list * GetGameList();
144 void RequestGameList();
145 void RequestGameListWithFilter(void *filter);
146 void RequestGameCountWithFilter(void *filter);
148 // void SendGameOver();
153 void StartTrackerGame(void *buffer);
155 void AckPacket(int sig);
158 #define MAX_GAME_BUFFERS 20 //Thats a lot considering 20 games per game_list struct
160 #define TRACKER_UPDATE_INTERVAL 240 //300 seconds
161 #define TRACKER_RESEND_TIME 2000 //2000ms