]> icculus.org git repositories - btb/d2x.git/blob - main/network.h
fix bugfix for 1067
[btb/d2x.git] / main / network.h
1 /* $Id: network.h,v 1.12 2003-10-10 09:36:35 btb Exp $ */
2 /*
3 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
4 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
5 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
6 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
7 IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
8 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
9 FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
10 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
11 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
12 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
13 */
14
15 /*
16  *
17  * Prototypes for network management functions.
18  *
19  * Old Log:
20  * Revision 1.7  1995/10/31  10:20:04  allender
21  * shareware stuff
22  *
23  * Revision 1.6  1995/09/21  14:31:18  allender
24  * new appltalk type packet which contains shortpos
25  *
26  * Revision 1.5  1995/09/18  08:07:08  allender
27  * added function prototype to remove netgame NBP
28  *
29  * Revision 1.4  1995/08/31  15:51:55  allender
30  * new prototypes for join and start games
31  *
32  * Revision 1.3  1995/07/26  17:02:29  allender
33  * implemented and working on mac
34  *
35  * Revision 1.2  1995/06/02  07:42:34  allender
36  * fixed prototype for network_endlevel_poll2
37  *
38  * Revision 1.1  1995/05/16  16:00:15  allender
39  * Initial revision
40  *
41  * Revision 2.2  1995/03/21  14:58:09  john
42  * *** empty log message ***
43  *
44  * Revision 2.1  1995/03/21  14:39:43  john
45  * Ifdef'd out the NETWORK code.
46  *
47  * Revision 2.0  1995/02/27  11:29:48  john
48  * New version 2.0, which has no anonymous unions, builds with
49  * Watcom 10.0, and doesn't require parsing BITMAPS.TBL.
50  *
51  * Revision 1.72  1995/02/11  14:24:39  rob
52  * Added suppor for invul. cntrlcen.
53  *
54  * Revision 1.71  1995/02/08  19:18:43  rob
55  * Added extern for segments checksum.
56  *
57  * Revision 1.70  1995/02/08  11:01:16  rob
58  * Fixed a bug.
59  *
60  * Revision 1.69  1995/02/07  21:16:49  rob
61  * Added flag for automap.
62  *
63  * Revision 1.68  1995/02/06  18:18:33  rob
64  * Extern'ed Packet Urgent.
65  *
66  * Revision 1.67  1995/02/05  14:36:29  rob
67  * Moved defines to network.h.
68  *
69  * Revision 1.66  1995/02/01  16:34:09  john
70  * Linted.
71  *
72  * Revision 1.65  1995/01/30  21:14:35  rob
73  * Fixed a bug in join menu.
74  * Simplified mission load support.
75  *
76  * Revision 1.64  1995/01/30  18:19:40  rob
77  * Added mission title to gameinfo packet.
78  *
79  * Revision 1.63  1995/01/28  17:02:39  rob
80  * Fixed monitor syncing bug (minor 19).
81  *
82  * Revision 1.62  1995/01/27  11:15:25  rob
83  * removed extern of variable no longer in network.c
84  *
85  * Revision 1.61  1995/01/26  12:17:34  rob
86  * Added new param to network_do_frame.
87  *
88  * Revision 1.60  1995/01/22  17:32:11  rob
89  * Added mission support for network games.
90  *
91  * Revision 1.59  1995/01/17  17:10:33  rob
92  * Added some flags to netgame struct.
93  *
94  * Revision 1.58  1995/01/12  18:57:15  rob
95  * Added score resync stuff.
96  *
97  * Revision 1.57  1995/01/12  16:42:18  rob
98  * Added new prototypes.
99  *
100  * Revision 1.56  1995/01/05  12:12:10  rob
101  * Fixed a problem with packet size.
102  *
103  * Revision 1.55  1995/01/05  11:12:36  rob
104  * Reduced packet size by 1 byte just to be safe.
105  *
106  * Revision 1.54  1995/01/04  21:39:32  rob
107  * New framedata packet for registered.
108  *
109  * Revision 1.53  1995/01/04  08:47:04  rob
110  * JOHN CHECKED IN FOR ROB !!!
111  *
112  * Revision 1.52  1994/12/30  20:09:07  rob
113  * ADded a toggle for showing player names on HUD.
114  *
115  * Revision 1.51  1994/12/29  15:59:52  rob
116  * Centralized network disconnects.
117  *
118  * Revision 1.50  1994/12/09  21:21:57  rob
119  * rolled back changes.
120  *
121  * Revision 1.48  1994/12/05  22:59:27  rob
122  * added prototype for send_endlevel_packet.
123  *
124  * Revision 1.47  1994/12/05  21:47:34  rob
125  * Added a new field to netgame struct.
126  *
127  * Revision 1.46  1994/12/05  14:39:16  rob
128  * Added new variable to indicate new net game starting.
129  *
130  * Revision 1.45  1994/12/04  15:37:18  rob
131  * Fixed a typo.
132  *
133  * Revision 1.44  1994/12/04  15:30:42  rob
134  * Added new fields to netgame struct.
135  *
136  * Revision 1.43  1994/12/03  18:03:19  rob
137  * ADded team kill syncing.
138  *
139  * Revision 1.42  1994/12/01  21:21:27  rob
140  * Added new system for object sync on rejoin.
141  *
142  * Revision 1.41  1994/11/29  13:07:33  rob
143  * Changed structure defs to .h files.
144  *
145  * Revision 1.40  1994/11/22  17:10:48  rob
146  * Fix for secret levels in network play mode.
147  *
148  * Revision 1.39  1994/11/18  16:36:31  rob
149  * Added variable network_rejoined to enable random placement
150  * of rejoining palyers.
151  *
152  * Revision 1.38  1994/11/12  19:51:13  rob
153  * Changed prototype for network_send_data to pass
154  * urgent flag.
155  *
156  * Revision 1.37  1994/11/10  21:48:26  rob
157  * Changed net_endlevel to return an int.
158  *
159  * Revision 1.36  1994/11/10  20:32:49  rob
160  * Added extern for LastPacketTime.
161  *
162  * Revision 1.35  1994/11/09  11:36:34  rob
163  * ADded return value to network_level_sync for success/fail.
164  *
165  * Revision 1.34  1994/11/08  21:22:31  rob
166  * Added proto for network_endlevel_snyc
167  *
168  * Revision 1.33  1994/11/08  15:20:00  rob
169  * added proto for change_playernum_to
170  *
171  * Revision 1.32  1994/11/07  17:45:40  rob
172  * Added prototype for network_endlevel (called from multi.c)
173  *
174  * Revision 1.31  1994/11/04  19:52:37  rob
175  * Removed a function from network.h (network_show_player_list)
176  *
177  * Revision 1.30  1994/11/01  19:39:26  rob
178  * Removed a couple of variables that should be externed from multi.c
179  * (remnants of the changover)
180  *
181  * Revision 1.29  1994/10/31  19:18:24  rob
182  * Changed prototype for network_do_frame to add a parameter if you wish
183  * to force the frame to be sent.  Important if this is a leave_game frame.
184  *
185  * Revision 1.28  1994/10/08  19:59:20  rob
186  * Removed network message variables.
187  *
188  * Revision 1.27  1994/10/08  11:08:38  john
189  * Moved network_delete_unused objects into multi.c,
190  * took out network callsign stuff and used Matt's net
191  * players[.].callsign stuff.
192  *
193  * Revision 1.26  1994/10/07  11:26:20  rob
194  * Changed network_start_frame to network_do_frame,.
195  *
196  *
197  * Revision 1.25  1994/10/05  13:58:10  rob
198  * Added a new function net_endlevel that is called after each level is
199  * completed.  Currently it only does anything if SERIAL game is in effect.
200  *
201  * Revision 1.24  1994/10/04  19:34:57  rob
202  * export network_find_max_net_players.
203  *
204  * Revision 1.23  1994/10/04  17:31:10  rob
205  * Exported MaxNumNetPlayers.
206  *
207  * Revision 1.22  1994/10/03  22:57:30  matt
208  * Took out redundant definition of callsign_len
209  *
210  * Revision 1.21  1994/10/03  15:12:48  rob
211  * Boosted MAX_CREATE_OBJECTS to 15.
212  *
213  * Revision 1.20  1994/09/30  18:19:51  rob
214  * Added two new variables for tracking object creation.
215  *
216  * Revision 1.19  1994/09/27  15:03:18  rob
217  * Added prototype for network_delete_extra_objects used by modem.c
218  *
219  * Revision 1.18  1994/09/27  14:36:45  rob
220  * Added two new varaibles for network/serial weapon firing.
221  *
222  * Revision 1.17  1994/09/07  17:10:57  john
223  * Started adding code to sync powerups.
224  *
225  * Revision 1.16  1994/09/06  19:29:05  john
226  * Added trial version of rejoin function.
227  *
228  * Revision 1.15  1994/08/26  13:01:54  john
229  * Put high score system in.
230  *
231  * Revision 1.14  1994/08/25  18:12:04  matt
232  * Made player's weapons and flares fire from the positions on the 3d model.
233  * Also added support for quad lasers.
234  *
235  * Revision 1.13  1994/08/17  16:50:00  john
236  * Added damaging fireballs, missiles.
237  *
238  * Revision 1.12  1994/08/16  12:25:22  john
239  * Added hooks for sending messages.
240  *
241  * Revision 1.11  1994/08/13  12:20:18  john
242  * Made the networking uise the Players array.
243  *
244  * Revision 1.10  1994/08/12  22:41:27  john
245  * Took away Player_stats; add Players array.
246  *
247  * Revision 1.9  1994/08/12  03:10:22  john
248  * Made network be default off; Moved network options into
249  * main menu.  Made starting net game check that mines are the
250  * same.
251  *
252  * Revision 1.8  1994/08/11  21:57:08  john
253  * Moved network options to main menu.
254  *
255  * Revision 1.7  1994/08/10  11:29:20  john
256  * *** empty log message ***
257  *
258  * Revision 1.6  1994/08/10  10:44:12  john
259  * Made net players fire..
260  *
261  * Revision 1.5  1994/08/09  19:31:46  john
262  * Networking changes.
263  *
264  * Revision 1.4  1994/08/05  16:30:26  john
265  * Added capability to turn off network.
266  *
267  * Revision 1.3  1994/08/05  16:11:43  john
268  * Psuedo working version of networking.
269  *
270  * Revision 1.2  1994/07/25  12:33:34  john
271  * Network "pinging" in.
272  *
273  * Revision 1.1  1994/07/20  16:09:05  john
274  * Initial revision
275  *
276  *
277  */
278
279
280 #ifndef _NETWORK_H
281 #define _NETWORK_H
282
283 #include "gameseq.h"
284 #include "multi.h"
285 #include "newmenu.h"
286
287 #define NETSTAT_MENU                0
288 #define NETSTAT_PLAYING             1
289 #define NETSTAT_BROWSING            2
290 #define NETSTAT_WAITING             3
291 #define NETSTAT_STARTING            4
292 #define NETSTAT_ENDLEVEL            5
293
294 #define CONNECT_DISCONNECTED        0
295 #define CONNECT_PLAYING             1
296 #define CONNECT_WAITING             2
297 #define CONNECT_DIED_IN_MINE        3
298 #define CONNECT_FOUND_SECRET        4
299 #define CONNECT_ESCAPE_TUNNEL       5
300 #define CONNECT_END_MENU            6
301
302 #define NETGAMEIPX                  1
303 #define NETGAMETCP                  2
304
305 // defines and other things for appletalk/ipx games on mac
306
307 #define IPX_GAME        1
308 #define APPLETALK_GAME  2
309 #ifdef MACINTOSH
310 extern int Network_game_type;
311 #else
312 #define Network_game_type IPX_GAME
313 #endif
314
315 typedef struct sequence_packet {
316         ubyte           type;
317         int             Security;
318         ubyte           pad1[3];
319         netplayer_info  player;
320 } __pack__ sequence_packet;
321
322 #define NET_XDATA_SIZE 454
323
324
325 // frame info is aligned -- 01/18/96 -- MWA
326 // if you change this structure -- be sure to keep
327 // alignment:
328 //      bytes on byte boundries
329 //      shorts on even byte boundries
330 //      ints on even byte boundries
331
332 typedef struct frame_info {
333         ubyte       type;                   // What type of packet
334         ubyte       pad[3];                 // Pad out length of frame_info packet
335         int         numpackets;
336         vms_vector  obj_pos;
337         vms_matrix  obj_orient;
338         vms_vector  phys_velocity;
339         vms_vector  phys_rotvel;
340         short       obj_segnum;
341         ushort      data_size;          // Size of data appended to the net packet
342         ubyte       playernum;
343         ubyte       obj_render_type;
344         ubyte       level_num;
345         ubyte       data[NET_XDATA_SIZE];   // extra data to be tacked on the end
346 } __pack__ frame_info;
347
348 // short_frame_info is not aligned -- 01/18/96 -- MWA
349 // won't align because of shortpos.  Shortpos needs
350 // to stay in current form.
351
352 typedef struct short_frame_info {
353         ubyte       type;                   // What type of packet
354         ubyte       pad[3];                 // Pad out length of frame_info packet
355         int         numpackets;
356         shortpos    thepos;
357         ushort      data_size;          // Size of data appended to the net packet
358         ubyte       playernum;
359         ubyte       obj_render_type;
360         ubyte       level_num;
361         ubyte       data[NET_XDATA_SIZE];   // extra data to be tacked on the end
362 } __pack__ short_frame_info;
363
364 void network_start_game();
365 void network_join_game();
366 void network_rejoin_game();
367 void network_leave_game();
368 int network_endlevel(int *secret);
369 void network_endlevel_poll2(int nitems, struct newmenu_item * menus, int * key, int citem);
370
371
372 int network_level_sync();
373 void network_send_endlevel_packet();
374
375 int network_delete_extra_objects();
376 int network_find_max_net_players();
377 int network_objnum_is_past(int objnum);
378 char * network_get_player_name(int objnum);
379 void network_send_endlevel_sub(int player_num);
380 void network_disconnect_player(int playernum);
381
382 extern void network_dump_player(ubyte * server, ubyte *node, int why);
383 extern void network_send_netgame_update();
384
385 extern int GetMyNetRanking();
386
387 extern int NetGameType;
388 extern int Network_send_objects;
389 extern int Network_send_objnum;
390 extern int PacketUrgent;
391 extern int Network_rejoined;
392
393 extern int Network_new_game;
394 extern int Network_status;
395
396 extern fix LastPacketTime[MAX_PLAYERS];
397
398 extern ushort my_segments_checksum;
399 // By putting an up-to-20-char-message into Network_message and
400 // setting Network_message_reciever to the player num you want to
401 // send it to (100 for broadcast) the next frame the player will
402 // get your message.
403
404 // Call once at the beginning of a frame
405 void network_do_frame(int force, int listen);
406
407 // Tacks data of length 'len' onto the end of the next
408 // packet that we're transmitting.
409 void network_send_data(ubyte * ptr, int len, int urgent);
410
411 // returns 1 if hoard.ham available
412 extern int HoardEquipped();
413
414 #endif /* _NETWORK_H */