Debian Codegraph @

netcon/mtclient/mtgametrack.h

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 --- HISTORICAL COMMENTS FOLLOW ---
19
20 * $Logfile: /DescentIII/Main/mtclient/mtgametrack.h $
21 * $Revision: 1.1.1.1 $
22 * $Date: 2003-08-26 03:58:40 $
23 * $Author: kevinb $
24 *
25 * Game Tracker client code header
26 *
27 * $Log: not supported by cvs2svn $
28 *
29 * 14 10/03/01 12:44a Kevin
30 * Smaller version of pxo packets
31 *
32 * 13 4/29/99 10:13a Kevin
33 * reduced time between game updates
34 *
35 * 12 4/19/99 8:35p Jeff
36 * compile under Linux
37 *
38 * 11 4/17/99 3:44p Kevin
39 * Demo2 changes & fixes
40 *
41 * 10 4/07/99 9:15a Kevin
42 * Changed PXO server addresses for release builds
43 *
44 * 9 3/25/99 3:26p Kevin
45 * Made PXO games be based on your chat channel
46 *
47 * 8 2/16/99 12:36a Kevin
48 * Fixes for release builds of OEM V3 and KAtmai
49 *
50 * 7 2/03/99 6:14p Kevin
51 * OEM changes
52 *
53 * 6 1/07/99 11:51a Kevin
54 * Added support for joining servers on alternate ports and hosting behind
55 * a proxy/firewall
56 *
57 * 5 12/23/98 6:38p Kevin
58 * All UDP data (except gamespy) now uses one (registered) port number
59 *
60 * 4 10/09/98 2:56p Kevin
61 * Changed IP addresses for PXO demo
62 *
63 * 3 10/01/98 11:37a Kevin
64 * UI fixes and stuff
65 *
66 * 2 6/01/98 10:10a Kevin
67 * Added DLL connection interface and auto update DLL
68 *
69 * 1 5/21/98 11:08a Kevin
70 *
71 * 5 5/14/98 11:07a Kevin
72 * Made gameover packet to the tracker reliable
73 *
74 * 4 4/30/98 3:49p Kevin
75 * Mastertracker pilot stats
76 *
77 * 3 4/24/98 3:50p Kevin
78 * Added mastertracker game tracking support
79 *
80 * 2 4/23/98 4:49p Kevin
81 * Added Master tracker Game tracker support
82 *
83 * 1 4/23/98 3:28p Kevin
84 *
85 * $NoKeywords: $
86 */
87
88 #include "pstypes.h"
89
90 #ifndef _GAMETRACK_HEADER_DEFINED
91 #define _GAMETRACK_HEADER_DEFINED
92
93 #ifdef WIN32
94 #pragma pack(push, r_udp)
95 #endif
96 #pragma pack(1)
97
98 // Definitions
99 #define GAMETRACKERNAME "tracker.pxo.nottheeye.com"
100 #define GAMEPORT 3445
101
102 #define MAX_GAME_BUFFERS 20 // Thats a lot considering 20 games per game_list struct
103
104 #define TRACKER_UPDATE_INTERVAL 60.0 // 300 seconds
105 #define TRACKER_RESEND_TIME 2.0 // 2 seconds
106 #define TRACKER_TIMEOUT 20 // 20 seconds
107
108 #define MAX_NET_RETRIES 30
109 #define NET_ACK_TIMEOUT 1.5
110 #define NET_GAME_TIMEOUT 300.0 // time in seconds
111
112 #define MAX_GT_GAME_DATA_SIZE 1500
113
114 #define MAX_GENERIC_GAME_NAME_LEN 32
115
116 #define MAX_GAME_LISTS_PER_PACKET 20
117
118 #define MAX_D3_PLAYERS 32
119 #define MAX_D3_MISSION_NAME_LEN 32
120 #define MAX_D3_PLAYER_NAME_LEN 20
121 #define MAX_D3_MISSION_FILE_LEN 32
122 #define MAX_D3_MISSION_URL_LEN 100
123
124 #define GNT_SERVER_ACK 0
125 #define GNT_CLIENT_ACK 1
126 #define GNT_GAMESTARTED 2
127 #define GNT_GAMEOVER 3
128 #define GNT_GAMEUPDATE 4
129 #define GNT_GAMELIST_REQ 5
130 #define GNT_GAMELIST_DATA 6
131 #define GNT_GAMELIST_FILTER_REQ 7
132 #define GNT_GAMEUPDATE_SHORT 8
133 #define GNT_GAMEUPDATE_TINY 9
134 #define GNT_GAMELIST_LITE_DATA 10
135 #define GNT_GAMELIST_LITE_FILTER_REQ 11
136
137 #define GT_FREESPACE 1
138 #define GT_DESCENT3 2
139 #define GT_TUBERACER 3
140 #define GT_UNUSED 0
141 #define GT_D3TNG 42
142 #define GAME_HEADER_ONLY_SIZE (sizeof(game_packet_header) - MAX_GT_GAME_DATA_SIZE)
143
144 struct game_packet_header {
145 uint32_t len; // Length of entire packet;
146 uint8_t game_type; // 1==freespace (GT_FREESPACE), 2==D3, 3==tuberacer, etc.
147 SOCKADDR_IN addr;
148 int type; // Used to specify what to do ie. Add a new net game (GNT_GAMESTARTED), remove a net game (game over), etc.
149 uint32_t sig; // Unique identifier for client ACKs (The server always fills this in, the client responds)
150
151 char data[MAX_GT_GAME_DATA_SIZE];
152 };
153
154 struct d3_net_game_data {
155 char game_name[MAX_GENERIC_GAME_NAME_LEN];
156 int difficulty;
157 int type; // game type;
158 int state;
159 int max_players;
160 int current_num_players;
161 char mission_name[MAX_D3_MISSION_NAME_LEN];
162 char mission_file[MAX_D3_MISSION_FILE_LEN];
163 char mission_url[MAX_D3_MISSION_URL_LEN];
164 char players[MAX_D3_PLAYERS][MAX_D3_PLAYER_NAME_LEN];
165 int player_rank[MAX_D3_PLAYERS];
166 };
167
168 struct d3_net_game_data_short {
169 char game_name[MAX_GENERIC_GAME_NAME_LEN];
170 int type; // game type;
171 int state;
172 int max_players;
173 int current_num_players;
174 char mission_name[MAX_D3_MISSION_NAME_LEN];
175 char lobby[MAX_GENERIC_GAME_NAME_LEN * 2];
176 };
177
178 struct d3_net_game_data_tiny {
179 int options; // 1==force port to arg1
180 int arg1;
181 char lobby[MAX_GENERIC_GAME_NAME_LEN * 2];
182 };
183
184 /*
185 struct filter_game_list_struct {
186 int rank;
187 char preferred_players[][];
188
189 };
190 */
191
192 struct active_games {
193 int game_type; // ie. GT_FREESPACE GT_DESCENT3, etc.
194 SOCKADDR addr;
195 uint32_t last_update; // Time we last got an update from this game
196 char data[MAX_GT_GAME_DATA_SIZE]; // memory to hold the game specific data
197 active_games *next;
198 };
199 /*
200 struct game_list {
201 uint8_t game_type;
202 char game_name[MAX_GAME_LISTS_PER_PACKET][MAX_GENERIC_GAME_NAME_LEN];
203 uint32_t game_server[MAX_GAME_LISTS_PER_PACKET];
204 uint16_t game_port[MAX_GAME_LISTS_PER_PACKET];
205 };
206 */
207
208 struct game_list {
209 uint8_t game_type;
210 uint32_t game_server[MAX_GAME_LISTS_PER_PACKET * 4];
211 uint16_t game_port[MAX_GAME_LISTS_PER_PACKET * 4];
212 };
213
214 // Function prototypes
215
216 int InitGameTrackerClient(int gametype);
217 void IdleGameTracker();
218 void UpdateGameData(void *buffer);
219 game_list *GetGameList();
220 void RequestGameList();
221 int SendGameOver();
222 void StartTrackerGame(void *buffer);
223 void HandleGamePacket(uint8_t *data, int len, network_address *from);
224 void AckPacket(int sig);
225
226 #ifdef WIN32
227 #pragma pack(pop, r_udp)
228 #else
229 #pragma pack()
230 #endif
231 #endif