]> icculus.org git repositories - taylor/freespace2.git/blob - include/gtrack.h
re-add PXO sources to project files
[taylor/freespace2.git] / include / gtrack.h
1 /*
2  * Copyright (C) Volition, Inc. 2005.  All rights reserved.
3  * 
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 
6  * source.
7  *
8 */
9
10 #ifndef _gtrack_header
11 #define _gtrack_header
12
13 //Game Tracker client code header
14
15 #define GAMEPORT        7802
16
17 #define MAX_NET_RETRIES 30
18 #define NET_ACK_TIMEOUT 2500
19 #define NET_GAME_TIMEOUT 300                    //time in seconds
20
21 #define MAX_GAME_DATA_SIZE      500
22
23 #define MAX_GENERIC_GAME_NAME_LEN       32
24
25 #define MAX_GAME_LISTS_PER_PACKET       10
26
27 #define CHANNEL_LEN     33
28
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
33
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
43
44 #define GT_FREESPACE                    1
45 #define GT_DESCENT3                             2
46 #define GT_TUBERACER                    3
47 #define GT_FREESPACE2                   4
48 #define GT_UNUSED                               0
49
50 #define GAME_HEADER_ONLY_SIZE           (sizeof(game_packet_header)-MAX_GAME_DATA_SIZE)
51
52 #pragma pack(push, 1)
53         typedef struct {
54                 unsigned int len;                               //Length of entire packet;
55                 unsigned char game_type;        //1==freespace (GT_FREESPACE), 2==D3, 3==tuberacer, etc.
56                 char junk[16];                          // not used but need constant size for compatibility (SOCKADDR_IN       addr);
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)
59
60                 char data[MAX_GAME_DATA_SIZE];
61         } game_packet_header;
62 #pragma pack(pop)
63
64 #ifdef MAKE_FS1
65
66 typedef struct {
67         char    game_name[MAX_GENERIC_GAME_NAME_LEN];
68         int     difficulty;
69         int     type;                   //game type;
70         int     state;
71         int     max_players;
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;
80
81 #else
82
83 typedef struct {
84         char    game_name[MAX_GENERIC_GAME_NAME_LEN];
85         int     difficulty;
86         int     type;                   //game type;
87         int     state;
88         int     max_players;
89         int     current_num_players;
90         char    mission_name[MAX_FREESPACE_MISSION_NAME_LEN];
91         char    channel[CHANNEL_LEN];
92 } freespace2_net_game_data;
93
94 #endif
95
96 typedef struct _active_games{
97         int game_type; //ie. GT_FREESPACE GT_DESCENT3, etc.
98         SOCKADDR        addr;
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
101         _active_games *next;
102 } active_games;
103
104 typedef struct {
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];
109 } game_list;
110
111 typedef struct {
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;
115
116
117 //Function prototypes
118
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);
126
127 // void SendGameOver();
128 //Start New 7-9-98
129 int SendGameOver();
130 //End New 7-9-98
131
132 void StartTrackerGame(void *buffer);
133
134 void AckPacket(int sig);
135
136 //Definitions
137 #define MAX_GAME_BUFFERS        20                                      //Thats a lot considering 20 games per game_list struct
138
139 #define TRACKER_UPDATE_INTERVAL                 300             //300 seconds
140 #define TRACKER_RESEND_TIME                             2000            //2000ms
141
142
143 #endif