home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #6 / amigaacscoverdisc1998-061998.iso / games / descent / source / main / multi.h < prev    next >
Text File  |  1998-06-08  |  16KB  |  523 lines

  1. /*
  2. THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
  3. SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
  4. END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
  5. ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
  6. IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
  7. SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
  8. FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
  9. CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
  10. AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.  
  11. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
  12. */
  13. /*
  14.  * $Source: f:/miner/source/main/rcs/multi.h $
  15.  * $Revision: 2.3 $
  16.  * $Author: john $
  17.  * $Date: 1995/04/03 08:49:50 $
  18.  * 
  19.  * Defines and exported variables for multi.c
  20.  * 
  21.  * $Log: multi.h $
  22.  * Revision 2.3  1995/04/03  08:49:50  john
  23.  * Added code to get someone's player struct.
  24.  * 
  25.  * Revision 2.2  1995/03/27  12:59:17  john
  26.  * Initial version of multiplayer save games.
  27.  * 
  28.  * Revision 2.1  1995/03/21  14:39:06  john
  29.  * Ifdef'd out the NETWORK code.
  30.  * 
  31.  * Revision 2.0  1995/02/27  11:28:34  john
  32.  * New version 2.0, which has no anonymous unions, builds with
  33.  * Watcom 10.0, and doesn't require parsing BITMAPS.TBL.
  34.  * 
  35.  * Revision 1.74  1995/02/11  11:36:42  rob
  36.  * Added new var.
  37.  * 
  38.  * Revision 1.73  1995/02/08  18:17:41  rob
  39.  * Added prototype for reset function.
  40.  * 
  41.  * Revision 1.72  1995/02/05  14:37:42  rob
  42.  * Made object mapping more efficient.
  43.  * 
  44.  * Revision 1.71  1995/02/01  18:07:36  rob
  45.  * Change object mapping to int functions.
  46.  * 
  47.  * Revision 1.70  1995/02/01  12:55:00  rob
  48.  * Changed message type.
  49.  * 
  50.  * Revision 1.69  1995/01/31  12:46:12  rob
  51.  * Fixed a bug with object overflow handling.
  52.  * 
  53.  * Revision 1.68  1995/01/27  11:15:13  rob
  54.  * removed extern of variable no longer in multi.c
  55.  * 
  56.  * Revision 1.67  1995/01/24  11:53:13  john
  57.  * Added better macro defining code.
  58.  * 
  59.  * Revision 1.66  1995/01/24  11:32:03  john
  60.  * Added new defining macro method.
  61.  * 
  62.  * Revision 1.65  1995/01/23  17:17:06  john
  63.  * Added multi_sending_message.
  64.  * 
  65.  * Revision 1.64  1995/01/23  16:02:42  rob
  66.  * Added prototype for mission select function.
  67.  * 
  68.  * Revision 1.63  1995/01/18  19:01:21  rob
  69.  * Added new message for hostage door sync.
  70.  * 
  71.  * Revision 1.62  1995/01/14  18:39:57  rob
  72.  * Added new message type for dropping robot powerups.
  73.  * 
  74.  * Revision 1.61  1995/01/12  21:41:13  rob
  75.  * Fixed incompat. with 1.0 and 1.1.
  76.  * 
  77.  * Revision 1.60  1995/01/04  21:40:55  rob
  78.  * Added new type for boss actions in coop.
  79.  * 
  80.  * Revision 1.59  1995/01/04  11:38:09  rob
  81.  * Fixed problem with lost character in messages.
  82.  * 
  83.  * Revision 1.58  1995/01/03  20:12:44  rob
  84.  * Made max message length in shareware = 40.
  85.  * 
  86.  * Revision 1.57  1995/01/03  14:27:25  rob
  87.  * ADded trigger messages.
  88.  * 
  89.  * Revision 1.56  1995/01/02  20:08:21  rob
  90.  * Added robot creation.
  91.  * 
  92.  * Revision 1.55  1995/01/02  14:41:30  rob
  93.  * Added score syncing.
  94.  * 
  95.  * Revision 1.54  1994/12/21  21:02:01  rob
  96.  * Added new message type for ROBOT_FIRE
  97.  * 
  98.  * Revision 1.53  1994/12/21  17:27:25  rob
  99.  * Changed the format for send_create_powerup messages.
  100.  * 
  101.  * 
  102.  * Revision 1.52  1994/12/20  20:41:39  rob
  103.  * ADded robot release message type.
  104.  * 
  105.  * Revision 1.51  1994/12/19  19:00:12  rob
  106.  * Changed buf to multibuf so it can be safely externed.
  107.  * 
  108.  * Revision 1.50  1994/12/19  16:41:14  rob
  109.  * Added new message types for robot support.
  110.  * Added prototype for external use of multi_send_data (from multibot.c)
  111.  * 
  112.  * Revision 1.49  1994/12/11  13:30:13  rob
  113.  * Added new variables to get players out of nested menus.
  114.  * 
  115.  * Revision 1.48  1994/12/11  01:58:57  rob
  116.  * Added variable to track menu deth..
  117.  * 
  118.  * Revision 1.47  1994/12/08  12:41:17  rob
  119.  * Added audio taunts.
  120.  * 
  121.  * Revision 1.46  1994/12/07  21:53:12  rob
  122.  * Fixing sequencing bugginess in modem/serial.
  123.  * 
  124.  * Revision 1.45  1994/12/07  16:46:58  rob
  125.  * Added prototype.
  126.  * 
  127.  * Revision 1.44  1994/12/01  12:22:31  rob
  128.  * Added de-cloak message for demo.
  129.  * 
  130.  * Revision 1.43  1994/12/01  00:54:14  rob
  131.  * Added variable for tracking homing missiles.
  132.  * 
  133.  * Revision 1.42  1994/11/30  16:04:39  rob
  134.  * Added show reticle name variable for team games.
  135.  * 
  136.  * Revision 1.41  1994/11/29  19:33:38  rob
  137.  * Team support.
  138.  * 
  139.  * Revision 1.40  1994/11/29  12:49:37  rob
  140.  * Added more team support stuff.
  141.  * 
  142.  * Revision 1.39  1994/11/28  21:20:49  rob
  143.  * Cleaned up the .h file, removed an unused function.
  144.  * 
  145.  * Revision 1.38  1994/11/28  21:04:50  rob
  146.  * Added support for network sound-casting.
  147.  * 
  148.  * Revision 1.37  1994/11/28  14:02:08  rob
  149.  * Added protocol versioning for registered versus shareware.
  150.  * 
  151.  * Revision 1.36  1994/11/28  13:30:04  rob
  152.  * Added a define for protocol version.
  153.  * 
  154.  * Revision 1.35  1994/11/22  19:19:48  rob
  155.  * remove unused function.
  156.  * 
  157.  * Revision 1.34  1994/11/22  18:47:34  rob
  158.  * Added hooks for modem support for secret levels.
  159.  * 
  160.  * Revision 1.33  1994/11/22  17:10:50  rob
  161.  * Fix for secret levels in network play mode.
  162.  * 
  163.  * Revision 1.32  1994/11/21  16:00:28  rob
  164.  * Added secret-level hooks.
  165.  * 
  166.  * Revision 1.31  1994/11/18  18:28:50  rob
  167.  * Added new function for multiplayer score screen.
  168.  * 
  169.  * Revision 1.30  1994/11/18  16:31:05  rob
  170.  * Added kill list timer variable.
  171.  * 
  172.  * Revision 1.29  1994/11/17  16:38:15  rob
  173.  * Added creation of net powerups.
  174.  * 
  175.  * Revision 1.28  1994/11/17  13:37:33  rob
  176.  * Added prototype for multi_new_game.
  177.  * 
  178.  * Revision 1.27  1994/11/17  12:58:45  rob
  179.  * Added kill matrix.
  180.  * 
  181.  * Revision 1.26  1994/11/16  20:35:24  rob
  182.  * Changed explosion hook.
  183.  * 
  184.  * Revision 1.25  1994/11/15  21:31:13  rob
  185.  * Bumped max message size, was giving modem.c fits.
  186.  * 
  187.  * Revision 1.24  1994/11/15  19:28:37  matt
  188.  * Added prototypes
  189.  * 
  190.  * Revision 1.23  1994/11/14  17:22:19  rob
  191.  * Added extern for message macros.
  192.  * 
  193.  * Revision 1.22  1994/11/11  18:16:44  rob
  194.  * Made multi_menu_poll return a value to exit menus.
  195.  * 
  196.  * Revision 1.21  1994/11/11  11:06:19  rob
  197.  * Added prototype for multi_menu_poll.
  198.  * 
  199.  * Revision 1.20  1994/11/10  21:48:41  rob
  200.  * Changed multi_endlevel to return an int.
  201.  * 
  202.  * Revision 1.19  1994/11/08  17:48:14  rob
  203.  * Fixing endlevel stuff.
  204.  * 
  205.  * Revision 1.18  1994/11/07  17:49:07  rob
  206.  * Changed prototype for object mapping funcs.
  207.  * 
  208.  * Revision 1.17  1994/11/07  15:46:32  rob
  209.  * Changed the way remote object number mapping works, and it was a real
  210.  * pain in the ass..  I think it will work more reliably now.
  211.  * 
  212.  * Revision 1.16  1994/11/04  19:53:01  rob
  213.  * Added a new message type for Player_leave 'explosions'.
  214.  * Added a prototype for function moved over from network.c
  215.  * 
  216.  * Revision 1.15  1994/11/02  18:02:33  rob
  217.  * Added message type for control center firing.
  218.  * 
  219.  * Revision 1.14  1994/11/02  11:38:00  rob
  220.  * Added player-in-process-of-dying explosions to network game.
  221.  * 
  222.  * Revision 1.13  1994/11/01  19:31:44  rob
  223.  * Bumped max_net_create_objects to 20 to accomodate a fully equipped
  224.  * character blowing up.
  225.  * 
  226.  * Revision 1.12  1994/10/31  13:48:02  rob
  227.  * Fixed bug in opening doors over network/modem.  Added a new message
  228.  * type to multi.c that communicates door openings across the net. 
  229.  * Changed includes in multi.c and wall.c to accomplish this.
  230.  * 
  231.  * Revision 1.11  1994/10/09  20:08:20  rob
  232.  * Added some exported func prototypes.
  233.  * Changed max net message length to 25 (from 30).
  234.  * Removed some message types no longer used.
  235.  * 
  236.  * Revision 1.10  1994/10/08  20:06:10  rob
  237.  * fixed a typo.
  238.  * 
  239.  * Revision 1.9  1994/10/08  19:59:43  rob
  240.  * Moved MAX_MESSAGE_LEN to here.
  241.  * 
  242.  * Revision 1.8  1994/10/07  23:09:54  rob
  243.  * Fixed some prototypes.
  244.  * 
  245.  * Revision 1.7  1994/10/07  18:11:19  rob
  246.  * Added multi_do_death to multi.c.
  247.  * 
  248.  * Revision 1.6  1994/10/07  16:14:32  rob
  249.  * Added new message type for player reappear
  250.  * 
  251.  * Revision 1.5  1994/10/07  12:58:17  rob
  252.  * Added multi_leave_game.
  253.  * 
  254.  * Revision 1.4  1994/10/07  12:17:17  rob
  255.  * Fixed some stuff in multi_do_frame and exported the message_length
  256.  * array.
  257.  * 
  258.  * Revision 1.3  1994/10/07  11:10:17  john
  259.  * Added function to parse multiple messages into individual
  260.  * messages.
  261.  * 
  262.  * Revision 1.2  1994/10/07  10:28:06  rob
  263.  * Headers and stuff for multi.c (obviously)
  264.  * 
  265.  * Revision 1.1  1994/10/06  16:07:39  rob
  266.  * Initial revision
  267.  * 
  268.  * 
  269.  */
  270.  
  271.  
  272.  
  273. #ifndef _MULTI_H
  274. #define _MULTI_H
  275.  
  276. #ifdef SHAREWARE
  277. #define MAX_MESSAGE_LEN 25
  278. #else
  279. #define MAX_MESSAGE_LEN 35
  280. #define SHAREWARE_MAX_MESSAGE_LEN 25
  281. #endif
  282.  
  283. #ifdef NETWORK
  284.  
  285. // Defines
  286. #include "gameseq.h"
  287. #include "piggy.h"
  288.  
  289. // What version of the multiplayer protocol is this?
  290.  
  291. #ifdef SHAREWARE
  292. #define MULTI_PROTO_VERSION     1
  293. #else
  294. #define MULTI_PROTO_VERSION    2
  295. #endif
  296.  
  297. // How many simultaneous network players do we support?
  298.  
  299. #define MAX_NUM_NET_PLAYERS 8
  300.  
  301. #define MULTI_POSITION            0
  302. #define MULTI_REAPPEAR           1
  303. #define MULTI_FIRE                2
  304. #define MULTI_KILL                 3
  305. #define MULTI_REMOVE_OBJECT    4
  306. #define MULTI_PLAYER_EXPLODE    5
  307. #define MULTI_MESSAGE            6
  308. #define MULTI_QUIT                7
  309. #define MULTI_PLAY_SOUND        8
  310. #define MULTI_BEGIN_SYNC        9
  311. #define MULTI_CONTROLCEN        10
  312. #define MULTI_ROBOT_CLAIM        11
  313. #define MULTI_END_SYNC            12
  314. #define MULTI_CLOAK                13
  315. #define MULTI_ENDLEVEL_START    14
  316. #define MULTI_DOOR_OPEN            15
  317. #define MULTI_CREATE_EXPLOSION 16
  318. #define MULTI_CONTROLCEN_FIRE    17
  319. #define MULTI_PLAYER_DROP        18
  320. #define MULTI_CREATE_POWERUP    19
  321. #define MULTI_CONSISTENCY        20
  322. #define MULTI_DECLOAK            21
  323. #define MULTI_MENU_CHOICE        22
  324. #ifndef SHAREWARE
  325. #define MULTI_ROBOT_POSITION    23
  326. #define MULTI_ROBOT_EXPLODE    24
  327. #define MULTI_ROBOT_RELEASE    25
  328. #define MULTI_ROBOT_FIRE        26
  329. #define MULTI_SCORE                27
  330. #define MULTI_CREATE_ROBOT        28
  331. #define MULTI_TRIGGER            29
  332. #define MULTI_BOSS_ACTIONS        30
  333. #define MULTI_CREATE_ROBOT_POWERUPS    31
  334. #define MULTI_HOSTAGE_DOOR        32
  335. #endif
  336.  
  337. #define MULTI_SAVE_GAME            33
  338. #define MULTI_RESTORE_GAME        34
  339.  
  340. #define MULTI_REQ_PLAYER        35        // Someone requests my player structure
  341. #define MULTI_SEND_PLAYER        36        // Sending someone my player structure
  342.  
  343. #ifndef SHAREWARE
  344. #define MULTI_MAX_TYPE            36
  345. #else
  346. #define MULTI_MAX_TYPE            22
  347. #endif
  348.  
  349. #ifdef SHAREWARE
  350. #define MAX_NET_CREATE_OBJECTS 19 
  351. #else
  352. #define MAX_NET_CREATE_OBJECTS 20
  353. #endif
  354.  
  355. #define MAX_MULTI_MESSAGE_LEN 90
  356.  
  357. // Exported functions
  358.  
  359. int objnum_remote_to_local(int remote_obj, int owner);
  360. int objnum_local_to_remote(int local_obj, byte *owner);
  361. void map_objnum_local_to_remote(int local, int remote, int owner);
  362. void map_objnum_local_to_local(int objnum);
  363.  
  364. void multi_init_objects(void);
  365. void multi_show_player_list(void);
  366. void multi_do_frame(void);
  367.  
  368. void multi_send_fire(void);
  369. void multi_send_destroy_controlcen(int objnum, int player);
  370. void multi_send_endlevel_start(int);
  371. void multi_send_player_explode(char type);
  372. void multi_send_message(void);
  373. void multi_send_position(int objnum);
  374. void multi_send_reappear();
  375. void multi_send_kill(int objnum);
  376. void multi_send_remobj(int objnum);
  377. void multi_send_quit(int why);
  378. void multi_send_door_open(int segnum, int side);
  379. void multi_send_create_explosion(int player_num);
  380. void multi_send_controlcen_fire(vms_vector *to_target, int gun_num, int objnum);
  381. void multi_send_cloak(void);
  382. void multi_send_decloak(void);
  383. void multi_send_create_powerup(int powerup_type, int segnum, int objnum, vms_vector *pos);
  384. void multi_send_play_sound(int sound_num, fix volume);
  385. void multi_send_audio_taunt(int taunt_num);
  386. void multi_send_score(void);
  387. void multi_send_trigger(int trigger);
  388. void multi_send_hostage_door_status(int wallnum);
  389. void multi_send_netplayer_stats_request(ubyte player_num);
  390.  
  391. void multi_endlevel_score(void);
  392. void multi_prep_level(void);
  393. int multi_endlevel(int *secret);
  394. int multi_menu_poll(void);
  395. void multi_leave_game(void);
  396. void multi_process_data(char *dat, int len);
  397. void multi_process_bigdata(char *buf, int len);        
  398. void multi_do_death(int objnum);
  399. void multi_send_message_dialog(void);
  400. int multi_delete_extra_objects(void);
  401. void multi_make_ghost_player(int objnum);
  402. void multi_make_player_ghost(int objnum);
  403. void multi_define_macro(int key);
  404. void multi_send_macro(int key);
  405. int multi_get_kill_list(int *plist);
  406. void multi_new_game(void);
  407. void multi_sort_kill_list(void);
  408. int multi_choose_mission(int *anarchy_only);
  409. void multi_reset_stuff(void);
  410.  
  411. void multi_send_data(char *buf, int len, int repeat);
  412.  
  413. int get_team(int pnum);
  414.  
  415. // Exported variables
  416.  
  417. extern int Network_active;
  418. extern int Network_laser_gun;
  419. extern int Network_laser_fired;
  420. extern int Network_laser_level;
  421. extern int Network_laser_flags;
  422.  
  423. extern int message_length[MULTI_MAX_TYPE+1];
  424. extern char multibuf[MAX_MULTI_MESSAGE_LEN+4];
  425. extern short Network_laser_track;
  426.  
  427. extern int who_killed_controlcen;
  428.  
  429. extern int Net_create_objnums[MAX_NET_CREATE_OBJECTS];
  430. extern int Net_create_loc;
  431.  
  432. extern short kill_matrix[MAX_NUM_NET_PLAYERS][MAX_NUM_NET_PLAYERS];
  433. extern short team_kills[2];
  434.  
  435. extern int multi_goto_secret;
  436.  
  437. //do we draw the kill list on the HUD?
  438. extern int Show_kill_list;
  439. extern int Show_reticle_name;
  440. extern fix Show_kill_list_timer;
  441.  
  442. // Used to send network messages
  443.  
  444. extern char    Network_message[MAX_MESSAGE_LEN];
  445. extern char Network_message_macro[4][MAX_MESSAGE_LEN];
  446. extern int Network_message_reciever;
  447.  
  448. // Used to map network to local object numbers
  449.  
  450. extern short remote_to_local[MAX_NUM_NET_PLAYERS][MAX_OBJECTS];  // Network object num for each 
  451. extern short local_to_remote[MAX_OBJECTS];   // Local object num for each network objnum
  452. extern byte object_owner[MAX_OBJECTS]; // Who 'owns' each local object for network purposes
  453.  
  454. extern int multi_in_menu; // Flag to tell if we're executing GameLoop from within a newmenu.
  455. extern int multi_leave_menu;
  456. extern int multi_quit_game;
  457.  
  458. extern int multi_sending_message;
  459. extern int multi_defining_message;
  460. extern void multi_message_input_sub( int key );
  461. extern void multi_send_message_start();
  462.  
  463. extern int control_invul_time;
  464.  
  465. #define N_PLAYER_SHIP_TEXTURES 6
  466.  
  467. extern bitmap_index multi_player_textures[MAX_NUM_NET_PLAYERS][N_PLAYER_SHIP_TEXTURES];
  468.  
  469. #define NETGAME_FLAG_CLOSED     1
  470. #define NETGAME_FLAG_SHOW_ID    2
  471. #define NETGAME_FLAG_SHOW_MAP 4
  472.  
  473. #define NETGAME_NAME_LEN                15
  474.  
  475. typedef struct netplayer_info {
  476.     char        callsign[CALLSIGN_LEN+1];
  477.     ubyte        server[4];
  478.     ubyte        node[6];
  479.     ushort    socket;
  480.     byte         connected;
  481. } netplayer_info;
  482.  
  483. typedef struct netgame_info {
  484.     ubyte                    type;
  485.     char                    game_name[NETGAME_NAME_LEN+1];
  486.     char                    team_name[2][CALLSIGN_LEN+1];
  487.     ubyte                    gamemode;
  488.     ubyte                    difficulty;
  489.     ubyte                 game_status;
  490.     ubyte                    numplayers;
  491.     ubyte                    max_numplayers;
  492.     ubyte                    game_flags;
  493.     netplayer_info        players[MAX_PLAYERS];
  494.     int                    locations[MAX_PLAYERS];
  495.     short                    kills[MAX_PLAYERS][MAX_PLAYERS];
  496.     int                    levelnum;
  497.     ubyte                    protocol_version;
  498.     ubyte                    team_vector;
  499.     ushort                segments_checksum;
  500.     short                    team_kills[2];
  501.     short                    killed[MAX_PLAYERS];
  502.     short                    player_kills[MAX_PLAYERS];
  503. #ifndef SHAREWARE
  504.     fix                    level_time;
  505.     int                    control_invul_time;
  506.     int                     monitor_vector;
  507.     int                    player_score[MAX_PLAYERS];
  508.     ubyte                    player_flags[MAX_PLAYERS];
  509.     char                    mission_name[9];
  510.     char                    mission_title[MISSION_NAME_LEN+1];
  511. #endif
  512. } netgame_info;
  513.  
  514. extern struct netgame_info Netgame;
  515.  
  516. int network_i_am_master(void);
  517. void change_playernum_to(int new_pnum);
  518.  
  519. #endif
  520.  
  521. #endif
  522. 
  523.