1 /* $Id: multi.h,v 1.10 2003-10-04 02:58:23 btb 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);
380 void multi_init_objects(void);
381 void multi_show_player_list(void);
382 void multi_do_frame(void);
385 void multi_send_flags(char);
386 void multi_send_fire(void);
387 void multi_send_destroy_controlcen(int objnum, int player);
388 void multi_send_endlevel_start(int);
389 void multi_send_player_explode(char type);
390 void multi_send_message(void);
391 void multi_send_position(int objnum);
392 void multi_send_reappear();
393 void multi_send_kill(int objnum);
394 void multi_send_remobj(int objnum);
395 void multi_send_quit(int why);
396 void multi_send_door_open(int segnum, int side,ubyte flag);
397 void multi_send_create_explosion(int player_num);
398 void multi_send_controlcen_fire(vms_vector *to_target, int gun_num, int objnum);
399 void multi_send_cloak(void);
400 void multi_send_decloak(void);
401 void multi_send_create_powerup(int powerup_type, int segnum, int objnum, vms_vector *pos);
402 void multi_send_play_sound(int sound_num, fix volume);
403 void multi_send_audio_taunt(int taunt_num);
404 void multi_send_score(void);
405 void multi_send_trigger(int trigger);
406 void multi_send_hostage_door_status(int wallnum);
407 void multi_send_netplayer_stats_request(ubyte player_num);
408 void multi_send_drop_weapon (int objnum,int seed);
409 void multi_send_drop_marker (int player,vms_vector position,char messagenum,char text[]);
410 void multi_send_guided_info (object *miss,char);
413 void multi_endlevel_score(void);
414 void multi_prep_level(void);
415 int multi_endlevel(int *secret);
416 int multi_menu_poll(void);
417 void multi_leave_game(void);
418 void multi_process_data(char *dat, int len);
419 void multi_process_bigdata(char *buf, int len);
420 void multi_do_death(int objnum);
421 void multi_send_message_dialog(void);
422 int multi_delete_extra_objects(void);
423 void multi_make_ghost_player(int objnum);
424 void multi_make_player_ghost(int objnum);
425 void multi_define_macro(int key);
426 void multi_send_macro(int key);
427 int multi_get_kill_list(int *plist);
428 void multi_new_game(void);
429 void multi_sort_kill_list(void);
430 int multi_choose_mission(int *anarchy_only);
431 void multi_reset_stuff(void);
433 void multi_send_data(char *buf, int len, int repeat);
435 int get_team(int pnum);
437 // Exported variables
440 extern int Network_active;
441 extern int Network_laser_gun;
442 extern int Network_laser_fired;
443 extern int Network_laser_level;
444 extern int Network_laser_flags;
445 extern int Netlife_kills,Netlife_killed;
447 extern int message_length[MULTI_MAX_TYPE+1];
448 extern char multibuf[MAX_MULTI_MESSAGE_LEN+4];
449 extern short Network_laser_track;
451 extern int who_killed_controlcen;
453 extern int Net_create_objnums[MAX_NET_CREATE_OBJECTS];
454 extern int Net_create_loc;
456 extern short kill_matrix[MAX_NUM_NET_PLAYERS][MAX_NUM_NET_PLAYERS];
457 extern short team_kills[2];
459 extern int multi_goto_secret;
461 //do we draw the kill list on the HUD?
462 extern int Show_kill_list;
463 extern int Show_reticle_name;
464 extern fix Show_kill_list_timer;
466 // Used to send network messages
468 extern char Network_message[MAX_MESSAGE_LEN];
469 extern char Network_message_macro[4][MAX_MESSAGE_LEN];
470 extern int Network_message_reciever;
472 // Used to map network to local object numbers
474 extern short remote_to_local[MAX_NUM_NET_PLAYERS][MAX_OBJECTS]; // Network object num for each
475 extern short local_to_remote[MAX_OBJECTS]; // Local object num for each network objnum
476 extern sbyte object_owner[MAX_OBJECTS]; // Who 'owns' each local object for network purposes
478 extern int multi_in_menu; // Flag to tell if we're executing GameLoop from within a newmenu.
479 extern int multi_leave_menu;
480 extern int multi_quit_game;
482 extern int multi_sending_message;
483 extern int multi_defining_message;
484 extern void multi_message_input_sub( int key );
485 extern void multi_send_message_start();
487 extern int multi_powerup_is_4pack(int );
488 extern void multi_send_orb_bonus( char pnum );
489 extern void multi_send_got_orb( char pnum );
490 extern void multi_add_lifetime_kills(void);
492 extern int control_invul_time;
494 #define N_PLAYER_SHIP_TEXTURES 6
496 extern bitmap_index multi_player_textures[MAX_NUM_NET_PLAYERS][N_PLAYER_SHIP_TEXTURES];
498 #define NETGAME_FLAG_CLOSED 1
499 #define NETGAME_FLAG_SHOW_ID 2
500 #define NETGAME_FLAG_SHOW_MAP 4
501 #define NETGAME_FLAG_HOARD 8
502 #define NETGAME_FLAG_TEAM_HOARD 16
503 #define NETGAME_FLAG_REALLY_ENDLEVEL 32
504 #define NETGAME_FLAG_REALLY_FORMING 64
506 #define NETGAME_NAME_LEN 15
508 enum __pack__ comp_type {DOS,WIN_32,WIN_95,MAC};
510 // sigh...the socket structure member was moved away from it's friends.
511 // I'll have to create a union for appletalk network info with just
512 // the server and node members since I cannot change the order ot these
515 typedef struct netplayer_info {
516 char callsign[CALLSIGN_LEN+1];
531 enum comp_type computer_type;
538 } __pack__ netplayer_info;
540 typedef struct AllNetPlayers_info
544 struct netplayer_info players[MAX_PLAYERS+4];
545 } __pack__ AllNetPlayers_info;
547 typedef struct netgame_info {
550 char game_name[NETGAME_NAME_LEN+1];
551 char mission_title[MISSION_NAME_LEN+1];
552 char mission_name[9];
559 ubyte max_numplayers;
562 ubyte protocol_version;
567 // change the order of the bit fields for the mac compiler.
568 // doing so will mean I don't have to do screwy things to
569 // send this as network information
571 #ifndef WORDS_BIGENDIAN
577 short DoAfterburner:1;
578 short DoInvulnerability:1;
584 short DoSuperLaser:1;
590 short DoEarthShaker:1;
592 short Allow_marker_view:1;
593 short AlwaysLighting:1;
598 short DoLaserUpgrade:1;
599 short DoQuadLasers:1;
600 short ShowAllNames:1;
601 short BrightPlayers:1;
603 short bitfield_not_used2:1;
608 short DoSuperLaser:1;
614 short DoInvulnerability:1;
615 short DoAfterburner:1;
622 short bitfield_not_used2:1;
624 short BrightPlayers:1;
625 short ShowAllNames:1;
626 short DoQuadLasers:1;
627 short DoLaserUpgrade:1;
632 short AlwaysLighting:1;
633 short Allow_marker_view:1;
635 short DoEarthShaker:1;
640 char team_name[2][CALLSIGN_LEN+1];
641 int locations[MAX_PLAYERS];
642 short kills[MAX_PLAYERS][MAX_PLAYERS];
643 ushort segments_checksum;
645 short killed[MAX_PLAYERS];
646 short player_kills[MAX_PLAYERS];
650 int control_invul_time;
652 int player_score[MAX_PLAYERS];
653 ubyte player_flags[MAX_PLAYERS];
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