MULTI.H 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  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. #ifndef _MULTI_H
  271. #define _MULTI_H
  272. #ifdef SHAREWARE
  273. #define MAX_MESSAGE_LEN 25
  274. #else
  275. #define MAX_MESSAGE_LEN 35
  276. #define SHAREWARE_MAX_MESSAGE_LEN 25
  277. #endif
  278. #ifdef NETWORK
  279. // Defines
  280. #include "gameseq.h"
  281. #include "piggy.h"
  282. // What version of the multiplayer protocol is this?
  283. #ifdef SHAREWARE
  284. #define MULTI_PROTO_VERSION 1
  285. #else
  286. #define MULTI_PROTO_VERSION 2
  287. #endif
  288. // How many simultaneous network players do we support?
  289. #define MAX_NUM_NET_PLAYERS 8
  290. #define MULTI_POSITION 0
  291. #define MULTI_REAPPEAR 1
  292. #define MULTI_FIRE 2
  293. #define MULTI_KILL 3
  294. #define MULTI_REMOVE_OBJECT 4
  295. #define MULTI_PLAYER_EXPLODE 5
  296. #define MULTI_MESSAGE 6
  297. #define MULTI_QUIT 7
  298. #define MULTI_PLAY_SOUND 8
  299. #define MULTI_BEGIN_SYNC 9
  300. #define MULTI_CONTROLCEN 10
  301. #define MULTI_ROBOT_CLAIM 11
  302. #define MULTI_END_SYNC 12
  303. #define MULTI_CLOAK 13
  304. #define MULTI_ENDLEVEL_START 14
  305. #define MULTI_DOOR_OPEN 15
  306. #define MULTI_CREATE_EXPLOSION 16
  307. #define MULTI_CONTROLCEN_FIRE 17
  308. #define MULTI_PLAYER_DROP 18
  309. #define MULTI_CREATE_POWERUP 19
  310. #define MULTI_CONSISTENCY 20
  311. #define MULTI_DECLOAK 21
  312. #define MULTI_MENU_CHOICE 22
  313. #ifndef SHAREWARE
  314. #define MULTI_ROBOT_POSITION 23
  315. #define MULTI_ROBOT_EXPLODE 24
  316. #define MULTI_ROBOT_RELEASE 25
  317. #define MULTI_ROBOT_FIRE 26
  318. #define MULTI_SCORE 27
  319. #define MULTI_CREATE_ROBOT 28
  320. #define MULTI_TRIGGER 29
  321. #define MULTI_BOSS_ACTIONS 30
  322. #define MULTI_CREATE_ROBOT_POWERUPS 31
  323. #define MULTI_HOSTAGE_DOOR 32
  324. #endif
  325. #define MULTI_SAVE_GAME 33
  326. #define MULTI_RESTORE_GAME 34
  327. #define MULTI_REQ_PLAYER 35 // Someone requests my player structure
  328. #define MULTI_SEND_PLAYER 36 // Sending someone my player structure
  329. #ifndef SHAREWARE
  330. #define MULTI_MAX_TYPE 36
  331. #else
  332. #define MULTI_MAX_TYPE 22
  333. #endif
  334. #ifdef SHAREWARE
  335. #define MAX_NET_CREATE_OBJECTS 19
  336. #else
  337. #define MAX_NET_CREATE_OBJECTS 20
  338. #endif
  339. #define MAX_MULTI_MESSAGE_LEN 90
  340. // Exported functions
  341. int objnum_remote_to_local(int remote_obj, int owner);
  342. int objnum_local_to_remote(int local_obj, byte *owner);
  343. void map_objnum_local_to_remote(int local, int remote, int owner);
  344. void map_objnum_local_to_local(int objnum);
  345. void multi_init_objects(void);
  346. void multi_show_player_list(void);
  347. void multi_do_frame(void);
  348. void multi_send_fire(void);
  349. void multi_send_destroy_controlcen(int objnum, int player);
  350. void multi_send_endlevel_start(int);
  351. void multi_send_player_explode(char type);
  352. void multi_send_message(void);
  353. void multi_send_position(int objnum);
  354. void multi_send_reappear();
  355. void multi_send_kill(int objnum);
  356. void multi_send_remobj(int objnum);
  357. void multi_send_quit(int why);
  358. void multi_send_door_open(int segnum, int side);
  359. void multi_send_create_explosion(int player_num);
  360. void multi_send_controlcen_fire(vms_vector *to_target, int gun_num, int objnum);
  361. void multi_send_cloak(void);
  362. void multi_send_decloak(void);
  363. void multi_send_create_powerup(int powerup_type, int segnum, int objnum, vms_vector *pos);
  364. void multi_send_play_sound(int sound_num, fix volume);
  365. void multi_send_audio_taunt(int taunt_num);
  366. void multi_send_score(void);
  367. void multi_send_trigger(int trigger);
  368. void multi_send_hostage_door_status(int wallnum);
  369. void multi_send_netplayer_stats_request(ubyte player_num);
  370. void multi_endlevel_score(void);
  371. void multi_prep_level(void);
  372. int multi_endlevel(int *secret);
  373. int multi_menu_poll(void);
  374. void multi_leave_game(void);
  375. void multi_process_data(char *dat, int len);
  376. void multi_process_bigdata(char *buf, int len);
  377. void multi_do_death(int objnum);
  378. void multi_send_message_dialog(void);
  379. int multi_delete_extra_objects(void);
  380. void multi_make_ghost_player(int objnum);
  381. void multi_make_player_ghost(int objnum);
  382. void multi_define_macro(int key);
  383. void multi_send_macro(int key);
  384. int multi_get_kill_list(int *plist);
  385. void multi_new_game(void);
  386. void multi_sort_kill_list(void);
  387. int multi_choose_mission(int *anarchy_only);
  388. void multi_reset_stuff(void);
  389. void multi_send_data(char *buf, int len, int repeat);
  390. int get_team(int pnum);
  391. // Exported variables
  392. extern int Network_active;
  393. extern int Network_laser_gun;
  394. extern int Network_laser_fired;
  395. extern int Network_laser_level;
  396. extern int Network_laser_flags;
  397. extern int message_length[MULTI_MAX_TYPE+1];
  398. extern char multibuf[MAX_MULTI_MESSAGE_LEN+4];
  399. extern short Network_laser_track;
  400. extern int who_killed_controlcen;
  401. extern int Net_create_objnums[MAX_NET_CREATE_OBJECTS];
  402. extern int Net_create_loc;
  403. extern short kill_matrix[MAX_NUM_NET_PLAYERS][MAX_NUM_NET_PLAYERS];
  404. extern short team_kills[2];
  405. extern int multi_goto_secret;
  406. //do we draw the kill list on the HUD?
  407. extern int Show_kill_list;
  408. extern int Show_reticle_name;
  409. extern fix Show_kill_list_timer;
  410. // Used to send network messages
  411. extern char Network_message[MAX_MESSAGE_LEN];
  412. extern char Network_message_macro[4][MAX_MESSAGE_LEN];
  413. extern int Network_message_reciever;
  414. // Used to map network to local object numbers
  415. extern short remote_to_local[MAX_NUM_NET_PLAYERS][MAX_OBJECTS]; // Network object num for each
  416. extern short local_to_remote[MAX_OBJECTS]; // Local object num for each network objnum
  417. extern byte object_owner[MAX_OBJECTS]; // Who 'owns' each local object for network purposes
  418. extern int multi_in_menu; // Flag to tell if we're executing GameLoop from within a newmenu.
  419. extern int multi_leave_menu;
  420. extern int multi_quit_game;
  421. extern int multi_sending_message;
  422. extern int multi_defining_message;
  423. extern void multi_message_input_sub( int key );
  424. extern void multi_send_message_start();
  425. extern int control_invul_time;
  426. #define N_PLAYER_SHIP_TEXTURES 6
  427. extern bitmap_index multi_player_textures[MAX_NUM_NET_PLAYERS][N_PLAYER_SHIP_TEXTURES];
  428. #define NETGAME_FLAG_CLOSED 1
  429. #define NETGAME_FLAG_SHOW_ID 2
  430. #define NETGAME_FLAG_SHOW_MAP 4
  431. #define NETGAME_NAME_LEN 15
  432. typedef struct netplayer_info {
  433. char callsign[CALLSIGN_LEN+1];
  434. ubyte server[4];
  435. ubyte node[6];
  436. ushort socket;
  437. byte connected;
  438. } netplayer_info;
  439. typedef struct netgame_info {
  440. ubyte type;
  441. char game_name[NETGAME_NAME_LEN+1];
  442. char team_name[2][CALLSIGN_LEN+1];
  443. ubyte gamemode;
  444. ubyte difficulty;
  445. ubyte game_status;
  446. ubyte numplayers;
  447. ubyte max_numplayers;
  448. ubyte game_flags;
  449. netplayer_info players[MAX_PLAYERS];
  450. int locations[MAX_PLAYERS];
  451. short kills[MAX_PLAYERS][MAX_PLAYERS];
  452. int levelnum;
  453. ubyte protocol_version;
  454. ubyte team_vector;
  455. ushort segments_checksum;
  456. short team_kills[2];
  457. short killed[MAX_PLAYERS];
  458. short player_kills[MAX_PLAYERS];
  459. #ifndef SHAREWARE
  460. fix level_time;
  461. int control_invul_time;
  462. int monitor_vector;
  463. int player_score[MAX_PLAYERS];
  464. ubyte player_flags[MAX_PLAYERS];
  465. char mission_name[9];
  466. char mission_title[MISSION_NAME_LEN+1];
  467. #endif
  468. } netgame_info;
  469. extern struct netgame_info Netgame;
  470. int network_i_am_master(void);
  471. void change_playernum_to(int new_pnum);
  472. #endif
  473. #endif
  474.