]> icculus.org git repositories - taylor/freespace2.git/blob - include/gtrack.h
rendering functions mostly done; more complete shader setup
[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 #ifdef MAKE_FS1
16 #define GAMEPORT        3440
17 #else
18 #define GAMEPORT        7802
19 #endif
20
21 #define MAX_NET_RETRIES 30
22 #define NET_ACK_TIMEOUT 2500
23 #define NET_GAME_TIMEOUT 300                    //time in seconds
24
25 #ifndef MAKE_FS1
26 #define MAX_GAME_DATA_SIZE      500
27 #else
28 #define MAX_GAME_DATA_SIZE      700
29 #endif
30
31 #define MAX_GENERIC_GAME_NAME_LEN       32
32
33 #define MAX_GAME_LISTS_PER_PACKET       10
34
35 #define CHANNEL_LEN     33
36
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
41
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
51
52 #define GT_FREESPACE                    1
53 #define GT_DESCENT3                             2
54 #define GT_TUBERACER                    3
55 #define GT_FREESPACE2                   4
56 #define GT_UNUSED                               0
57
58 #ifndef MAKE_FS1
59 #define GAME_HEADER_ONLY_SIZE           (sizeof(game_packet_header)-MAX_GAME_DATA_SIZE)
60 #else
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)
63 #endif
64
65 #pragma pack(push, 1)
66         typedef struct {
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)
72
73                 char data[MAX_GAME_DATA_SIZE];
74         } game_packet_header;
75 #pragma pack(pop)
76
77 #ifdef MAKE_FS1
78
79 typedef struct {
80         char    game_name[MAX_GENERIC_GAME_NAME_LEN];
81         int     difficulty;
82         int     type;                   //game type;
83         int     state;
84         int     max_players;
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;
94
95 #define pxo_net_game_data freespace_net_game_data
96
97 #else
98
99 typedef struct {
100         char    game_name[MAX_GENERIC_GAME_NAME_LEN];
101         int     difficulty;
102         int     type;                   //game type;
103         int     state;
104         int     max_players;
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;
110
111 #define pxo_net_game_data freespace2_net_game_data
112
113 #endif
114
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
120         _active_games *next;
121 } active_games;
122
123 typedef struct {
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];
129 } game_list;
130
131 typedef struct {
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;
136
137
138 //Function prototypes
139
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);
147
148 // void SendGameOver();
149 //Start New 7-9-98
150 int SendGameOver();
151 //End New 7-9-98
152
153 void StartTrackerGame(void *buffer);
154
155 void AckPacket(int sig);
156
157 //Definitions
158 #define MAX_GAME_BUFFERS        20                                      //Thats a lot considering 20 games per game_list struct
159
160 #define TRACKER_UPDATE_INTERVAL                 300             //300 seconds
161 #define TRACKER_RESEND_TIME                             2000            //2000ms
162
163
164 #endif