1 /* $Id: multi.h,v 1.13 2003-10-21 09:50:56 schaffner Exp $ */
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.
17 * Defines and exported variables for multi.c
20 * Revision 2.3 1995/04/03 08:49:50 john
21 * Added code to get someone's player struct.
23 * Revision 2.2 1995/03/27 12:59:17 john
24 * Initial version of multiplayer save games.
26 * Revision 2.1 1995/03/21 14:39:06 john
27 * Ifdef'd out the NETWORK code.
29 * Revision 2.0 1995/02/27 11:28:34 john
30 * New version 2.0, which has no anonymous unions, builds with
31 * Watcom 10.0, and doesn't require parsing BITMAPS.TBL.
33 * Revision 1.74 1995/02/11 11:36:42 rob
36 * Revision 1.73 1995/02/08 18:17:41 rob
37 * Added prototype for reset function.
39 * Revision 1.72 1995/02/05 14:37:42 rob
40 * Made object mapping more efficient.
42 * Revision 1.71 1995/02/01 18:07:36 rob
43 * Change object mapping to int functions.
45 * Revision 1.70 1995/02/01 12:55:00 rob
46 * Changed message type.
48 * Revision 1.69 1995/01/31 12:46:12 rob
49 * Fixed a bug with object overflow handling.
51 * Revision 1.68 1995/01/27 11:15:13 rob
52 * removed extern of variable no longer in multi.c
54 * Revision 1.67 1995/01/24 11:53:13 john
55 * Added better macro defining code.
57 * Revision 1.66 1995/01/24 11:32:03 john
58 * Added new defining macro method.
60 * Revision 1.65 1995/01/23 17:17:06 john
61 * Added multi_sending_message.
63 * Revision 1.64 1995/01/23 16:02:42 rob
64 * Added prototype for mission select function.
66 * Revision 1.63 1995/01/18 19:01:21 rob
67 * Added new message for hostage door sync.
69 * Revision 1.62 1995/01/14 18:39:57 rob
70 * Added new message type for dropping robot powerups.
72 * Revision 1.61 1995/01/12 21:41:13 rob
73 * Fixed incompat. with 1.0 and 1.1.
75 * Revision 1.60 1995/01/04 21:40:55 rob
76 * Added new type for boss actions in coop.
78 * Revision 1.59 1995/01/04 11:38:09 rob
79 * Fixed problem with lost character in messages.
81 * Revision 1.58 1995/01/03 20:12:44 rob
82 * Made max message length in shareware = 40.
84 * Revision 1.57 1995/01/03 14:27:25 rob
85 * ADded trigger messages.
87 * Revision 1.56 1995/01/02 20:08:21 rob
88 * Added robot creation.
90 * Revision 1.55 1995/01/02 14:41:30 rob
91 * Added score syncing.
93 * Revision 1.54 1994/12/21 21:02:01 rob
94 * Added new message type for ROBOT_FIRE
96 * Revision 1.53 1994/12/21 17:27:25 rob
97 * Changed the format for send_create_powerup messages.
100 * Revision 1.52 1994/12/20 20:41:39 rob
101 * ADded robot release message type.
103 * Revision 1.51 1994/12/19 19:00:12 rob
104 * Changed buf to multibuf so it can be safely externed.
106 * Revision 1.50 1994/12/19 16:41:14 rob
107 * Added new message types for robot support.
108 * Added prototype for external use of multi_send_data (from multibot.c)
110 * Revision 1.49 1994/12/11 13:30:13 rob
111 * Added new variables to get players out of nested menus.
113 * Revision 1.48 1994/12/11 01:58:57 rob
114 * Added variable to track menu deth..
116 * Revision 1.47 1994/12/08 12:41:17 rob
117 * Added audio taunts.
119 * Revision 1.46 1994/12/07 21:53:12 rob
120 * Fixing sequencing bugginess in modem/serial.
122 * Revision 1.45 1994/12/07 16:46:58 rob
125 * Revision 1.44 1994/12/01 12:22:31 rob
126 * Added de-cloak message for demo.
128 * Revision 1.43 1994/12/01 00:54:14 rob
129 * Added variable for tracking homing missiles.
131 * Revision 1.42 1994/11/30 16:04:39 rob
132 * Added show reticle name variable for team games.
134 * Revision 1.41 1994/11/29 19:33:38 rob
137 * Revision 1.40 1994/11/29 12:49:37 rob
138 * Added more team support stuff.
140 * Revision 1.39 1994/11/28 21:20:49 rob
141 * Cleaned up the .h file, removed an unused function.
143 * Revision 1.38 1994/11/28 21:04:50 rob
144 * Added support for network sound-casting.
146 * Revision 1.37 1994/11/28 14:02:08 rob
147 * Added protocol versioning for registered versus shareware.
149 * Revision 1.36 1994/11/28 13:30:04 rob
150 * Added a define for protocol version.
152 * Revision 1.35 1994/11/22 19:19:48 rob
153 * remove unused function.
155 * Revision 1.34 1994/11/22 18:47:34 rob
156 * Added hooks for modem support for secret levels.
158 * Revision 1.33 1994/11/22 17:10:50 rob
159 * Fix for secret levels in network play mode.
161 * Revision 1.32 1994/11/21 16:00:28 rob
162 * Added secret-level hooks.
164 * Revision 1.31 1994/11/18 18:28:50 rob
165 * Added new function for multiplayer score screen.
167 * Revision 1.30 1994/11/18 16:31:05 rob
168 * Added kill list timer variable.
170 * Revision 1.29 1994/11/17 16:38:15 rob
171 * Added creation of net powerups.
173 * Revision 1.28 1994/11/17 13:37:33 rob
174 * Added prototype for multi_new_game.
176 * Revision 1.27 1994/11/17 12:58:45 rob
179 * Revision 1.26 1994/11/16 20:35:24 rob
180 * Changed explosion hook.
182 * Revision 1.25 1994/11/15 21:31:13 rob
183 * Bumped max message size, was giving modem.c fits.
185 * Revision 1.24 1994/11/15 19:28:37 matt
188 * Revision 1.23 1994/11/14 17:22:19 rob
189 * Added extern for message macros.
191 * Revision 1.22 1994/11/11 18:16:44 rob
192 * Made multi_menu_poll return a value to exit menus.
194 * Revision 1.21 1994/11/11 11:06:19 rob
195 * Added prototype for multi_menu_poll.
197 * Revision 1.20 1994/11/10 21:48:41 rob
198 * Changed multi_endlevel to return an int.
200 * Revision 1.19 1994/11/08 17:48:14 rob
201 * Fixing endlevel stuff.
203 * Revision 1.18 1994/11/07 17:49:07 rob
204 * Changed prototype for object mapping funcs.
206 * Revision 1.17 1994/11/07 15:46:32 rob
207 * Changed the way remote object number mapping works, and it was a real
208 * pain in the ass.. I think it will work more reliably now.
210 * Revision 1.16 1994/11/04 19:53:01 rob
211 * Added a new message type for Player_leave 'explosions'.
212 * Added a prototype for function moved over from network.c
214 * Revision 1.15 1994/11/02 18:02:33 rob
215 * Added message type for control center firing.
217 * Revision 1.14 1994/11/02 11:38:00 rob
218 * Added player-in-process-of-dying explosions to network game.
220 * Revision 1.13 1994/11/01 19:31:44 rob
221 * Bumped max_net_create_objects to 20 to accomodate a fully equipped
222 * character blowing up.
224 * Revision 1.12 1994/10/31 13:48:02 rob
225 * Fixed bug in opening doors over network/modem. Added a new message
226 * type to multi.c that communicates door openings across the net.
227 * Changed includes in multi.c and wall.c to accomplish this.
229 * Revision 1.11 1994/10/09 20:08:20 rob
230 * Added some exported func prototypes.
231 * Changed max net message length to 25 (from 30).
232 * Removed some message types no longer used.
234 * Revision 1.10 1994/10/08 20:06:10 rob
237 * Revision 1.9 1994/10/08 19:59:43 rob
238 * Moved MAX_MESSAGE_LEN to here.
240 * Revision 1.8 1994/10/07 23:09:54 rob
241 * Fixed some prototypes.
243 * Revision 1.7 1994/10/07 18:11:19 rob
244 * Added multi_do_death to multi.c.
246 * Revision 1.6 1994/10/07 16:14:32 rob
247 * Added new message type for player reappear
249 * Revision 1.5 1994/10/07 12:58:17 rob
250 * Added multi_leave_game.
252 * Revision 1.4 1994/10/07 12:17:17 rob
253 * Fixed some stuff in multi_do_frame and exported the message_length
256 * Revision 1.3 1994/10/07 11:10:17 john
257 * Added function to parse multiple messages into individual
260 * Revision 1.2 1994/10/07 10:28:06 rob
261 * Headers and stuff for multi.c (obviously)
263 * Revision 1.1 1994/10/06 16:07:39 rob
272 #define MAX_MESSAGE_LEN 35
278 // What version of the multiplayer protocol is this?
281 #define MULTI_PROTO_VERSION 3
283 #define MULTI_PROTO_VERSION 4
286 // Protocol versions:
287 // 1 Descent Shareware
288 // 2 Descent Registered/Commercial
289 // 3 Descent II Shareware
290 // 4 Descent II Commercial
292 // Save multiplayer games?
296 // How many simultaneous network players do we support?
298 #define MAX_NUM_NET_PLAYERS 8
300 #define MULTI_POSITION 0
301 #define MULTI_REAPPEAR 1
304 #define MULTI_REMOVE_OBJECT 4
305 #define MULTI_PLAYER_EXPLODE 5
306 #define MULTI_MESSAGE 6
308 #define MULTI_PLAY_SOUND 8
309 #define MULTI_BEGIN_SYNC 9
310 #define MULTI_CONTROLCEN 10
311 #define MULTI_ROBOT_CLAIM 11
312 #define MULTI_END_SYNC 12
313 #define MULTI_CLOAK 13
314 #define MULTI_ENDLEVEL_START 14
315 #define MULTI_DOOR_OPEN 15
316 #define MULTI_CREATE_EXPLOSION 16
317 #define MULTI_CONTROLCEN_FIRE 17
318 #define MULTI_PLAYER_DROP 18
319 #define MULTI_CREATE_POWERUP 19
320 #define MULTI_CONSISTENCY 20
321 #define MULTI_DECLOAK 21
322 #define MULTI_MENU_CHOICE 22
323 #define MULTI_ROBOT_POSITION 23
324 #define MULTI_ROBOT_EXPLODE 24
325 #define MULTI_ROBOT_RELEASE 25
326 #define MULTI_ROBOT_FIRE 26
327 #define MULTI_SCORE 27
328 #define MULTI_CREATE_ROBOT 28
329 #define MULTI_TRIGGER 29
330 #define MULTI_BOSS_ACTIONS 30
331 #define MULTI_CREATE_ROBOT_POWERUPS 31
332 #define MULTI_HOSTAGE_DOOR 32
334 #define MULTI_SAVE_GAME 33
335 #define MULTI_RESTORE_GAME 34
337 #define MULTI_REQ_PLAYER 35 // Someone requests my player structure
338 #define MULTI_SEND_PLAYER 36 // Sending someone my player structure
339 #define MULTI_MARKER 37
340 #define MULTI_DROP_WEAPON 38
341 #define MULTI_GUIDED 39
342 #define MULTI_STOLEN_ITEMS 40
343 #define MULTI_WALL_STATUS 41 // send to new players
344 #define MULTI_HEARTBEAT 42
345 #define MULTI_KILLGOALS 43
346 #define MULTI_SEISMIC 44
347 #define MULTI_LIGHT 45
348 #define MULTI_START_TRIGGER 46
349 #define MULTI_FLAGS 47
350 #define MULTI_DROP_BLOB 48
351 #define MULTI_POWERUP_UPDATE 49
352 #define MULTI_ACTIVE_DOOR 50
353 #define MULTI_SOUND_FUNCTION 51
354 #define MULTI_CAPTURE_BONUS 52
355 #define MULTI_GOT_FLAG 53
356 #define MULTI_DROP_FLAG 54
357 #define MULTI_ROBOT_CONTROLS 55
358 #define MULTI_FINISH_GAME 56
359 #define MULTI_RANK 57
360 #define MULTI_MODEM_PING 58
361 #define MULTI_MODEM_PING_RETURN 59
362 #define MULTI_ORB_BONUS 60
363 #define MULTI_GOT_ORB 61
364 #define MULTI_DROP_ORB 62
365 #define MULTI_PLAY_BY_PLAY 63
367 #define MULTI_MAX_TYPE 63
369 #define MAX_NET_CREATE_OBJECTS 40
371 #define MAX_MULTI_MESSAGE_LEN 120
373 // Exported functions
375 int objnum_remote_to_local(int remote_obj, int owner);
376 int objnum_local_to_remote(int local_obj, sbyte *owner);
377 void map_objnum_local_to_remote(int local, int remote, int owner);
378 void map_objnum_local_to_local(int objnum);
379 void reset_network_objects();
381 void multi_init_objects(void);
382 void multi_show_player_list(void);
383 void multi_do_frame(void);
386 void multi_send_flags(char);
387 void multi_send_fire(void);
388 void multi_send_destroy_controlcen(int objnum, int player);
389 void multi_send_endlevel_start(int);
390 void multi_send_player_explode(char type);
391 void multi_send_message(void);
392 void multi_send_position(int objnum);
393 void multi_send_reappear();
394 void multi_send_kill(int objnum);
395 void multi_send_remobj(int objnum);
396 void multi_send_quit(int why);
397 void multi_send_door_open(int segnum, int side,ubyte flag);
398 void multi_send_create_explosion(int player_num);
399 void multi_send_controlcen_fire(vms_vector *to_target, int gun_num, int objnum);
400 void multi_send_cloak(void);
401 void multi_send_decloak(void);
402 void multi_send_create_powerup(int powerup_type, int segnum, int objnum, vms_vector *pos);
403 void multi_send_play_sound(int sound_num, fix volume);
404 void multi_send_audio_taunt(int taunt_num);
405 void multi_send_score(void);
406 void multi_send_trigger(int trigger);
407 void multi_send_hostage_door_status(int wallnum);
408 void multi_send_netplayer_stats_request(ubyte player_num);
409 void multi_send_drop_weapon (int objnum,int seed);
410 void multi_send_drop_marker (int player,vms_vector position,char messagenum,char text[]);
411 void multi_send_guided_info (object *miss,char);
414 void multi_endlevel_score(void);
415 void multi_prep_level(void);
416 int multi_endlevel(int *secret);
417 int multi_menu_poll(void);
418 void multi_leave_game(void);
419 void multi_process_data(char *dat, int len);
420 void multi_process_bigdata(char *buf, int len);
421 void multi_do_death(int objnum);
422 void multi_send_message_dialog(void);
423 int multi_delete_extra_objects(void);
424 void multi_make_ghost_player(int objnum);
425 void multi_make_player_ghost(int objnum);
426 void multi_define_macro(int key);
427 void multi_send_macro(int key);
428 int multi_get_kill_list(int *plist);
429 void multi_new_game(void);
430 void multi_sort_kill_list(void);
431 int multi_choose_mission(int *anarchy_only);
432 void multi_reset_stuff(void);
434 void multi_send_data(char *buf, int len, int repeat);
436 int get_team(int pnum);
438 // Exported variables
441 extern int Network_active;
442 extern int Network_laser_gun;
443 extern int Network_laser_fired;
444 extern int Network_laser_level;
445 extern int Network_laser_flags;
446 extern int Netlife_kills,Netlife_killed;
448 extern int message_length[MULTI_MAX_TYPE+1];
449 extern char multibuf[MAX_MULTI_MESSAGE_LEN+4];
450 extern short Network_laser_track;
452 extern int who_killed_controlcen;
454 extern int Net_create_objnums[MAX_NET_CREATE_OBJECTS];
455 extern int Net_create_loc;
457 extern short kill_matrix[MAX_NUM_NET_PLAYERS][MAX_NUM_NET_PLAYERS];
458 extern short team_kills[2];
460 extern int multi_goto_secret;
462 //do we draw the kill list on the HUD?
463 extern int Show_kill_list;
464 extern int Show_reticle_name;
465 extern fix Show_kill_list_timer;
467 // Used to send network messages
469 extern char Network_message[MAX_MESSAGE_LEN];
470 extern char Network_message_macro[4][MAX_MESSAGE_LEN];
471 extern int Network_message_reciever;
473 // Which player 'owns' each local object for network purposes
474 extern sbyte object_owner[MAX_OBJECTS];
476 extern int multi_in_menu; // Flag to tell if we're executing GameLoop from within a newmenu.
477 extern int multi_leave_menu;
478 extern int multi_quit_game;
480 extern int multi_sending_message;
481 extern int multi_defining_message;
482 extern void multi_message_input_sub( int key );
483 extern void multi_send_message_start();
485 extern int multi_powerup_is_4pack(int );
486 extern void multi_send_orb_bonus( char pnum );
487 extern void multi_send_got_orb( char pnum );
488 extern void multi_add_lifetime_kills(void);
490 extern int control_invul_time;
492 #define N_PLAYER_SHIP_TEXTURES 6
494 extern bitmap_index multi_player_textures[MAX_NUM_NET_PLAYERS][N_PLAYER_SHIP_TEXTURES];
496 #define NETGAME_FLAG_CLOSED 1
497 #define NETGAME_FLAG_SHOW_ID 2
498 #define NETGAME_FLAG_SHOW_MAP 4
499 #define NETGAME_FLAG_HOARD 8
500 #define NETGAME_FLAG_TEAM_HOARD 16
501 #define NETGAME_FLAG_REALLY_ENDLEVEL 32
502 #define NETGAME_FLAG_REALLY_FORMING 64
504 #define NETGAME_NAME_LEN 15
505 #define NETGAME_AUX_SIZE 20 // Amount of extra data for the network protocol to store in the netgame packet
507 enum comp_type {DOS,WIN_32,WIN_95,MAC} __pack__ ;
509 // sigh...the socket structure member was moved away from it's friends.
510 // I'll have to create a union for appletalk network info with just
511 // the server and node members since I cannot change the order ot these
514 typedef struct netplayer_info {
515 char callsign[CALLSIGN_LEN+1];
530 enum comp_type computer_type;
537 } __pack__ netplayer_info;
539 typedef struct AllNetPlayers_info
543 struct netplayer_info players[MAX_PLAYERS+4];
544 } __pack__ AllNetPlayers_info;
546 typedef struct netgame_info {
549 char game_name[NETGAME_NAME_LEN+1];
550 char mission_title[MISSION_NAME_LEN+1];
551 char mission_name[9];
558 ubyte max_numplayers;
561 ubyte protocol_version;
566 // change the order of the bit fields for the mac compiler.
567 // doing so will mean I don't have to do screwy things to
568 // send this as network information
570 #ifndef WORDS_BIGENDIAN
576 short DoAfterburner:1;
577 short DoInvulnerability:1;
583 short DoSuperLaser:1;
589 short DoEarthShaker:1;
591 short Allow_marker_view:1;
592 short AlwaysLighting:1;
597 short DoLaserUpgrade:1;
598 short DoQuadLasers:1;
599 short ShowAllNames:1;
600 short BrightPlayers:1;
602 short bitfield_not_used2:1;
607 short DoSuperLaser:1;
613 short DoInvulnerability:1;
614 short DoAfterburner:1;
621 short bitfield_not_used2:1;
623 short BrightPlayers:1;
624 short ShowAllNames:1;
625 short DoQuadLasers:1;
626 short DoLaserUpgrade:1;
631 short AlwaysLighting:1;
632 short Allow_marker_view:1;
634 short DoEarthShaker:1;
639 char team_name[2][CALLSIGN_LEN+1];
640 int locations[MAX_PLAYERS];
641 short kills[MAX_PLAYERS][MAX_PLAYERS];
642 ushort segments_checksum;
644 short killed[MAX_PLAYERS];
645 short player_kills[MAX_PLAYERS];
649 int control_invul_time;
651 int player_score[MAX_PLAYERS];
652 ubyte player_flags[MAX_PLAYERS];
655 ubyte AuxData[NETGAME_AUX_SIZE]; // Storage for protocol-specific data (e.g., multicast session and port)
657 } __pack__ netgame_info;
659 extern struct netgame_info Netgame;
660 extern struct AllNetPlayers_info NetPlayers;
662 int network_i_am_master(void);
663 void change_playernum_to(int new_pnum);
665 //how to encode missiles & flares in weapon packets
666 #define MISSILE_ADJUST 100
667 #define FLARE_ADJUST 127
669 #endif /* _MULTI_H */