NETWORK.H 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  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/network.h $
  15. * $Revision: 2.2 $
  16. * $Author: john $
  17. * $Date: 1995/03/21 14:58:09 $
  18. *
  19. * Prototypes for network management functions.
  20. *
  21. * $Log: network.h $
  22. * Revision 2.2 1995/03/21 14:58:09 john
  23. * *** empty log message ***
  24. *
  25. * Revision 2.1 1995/03/21 14:39:43 john
  26. * Ifdef'd out the NETWORK code.
  27. *
  28. * Revision 2.0 1995/02/27 11:29:48 john
  29. * New version 2.0, which has no anonymous unions, builds with
  30. * Watcom 10.0, and doesn't require parsing BITMAPS.TBL.
  31. *
  32. * Revision 1.72 1995/02/11 14:24:39 rob
  33. * Added suppor for invul. cntrlcen.
  34. *
  35. * Revision 1.71 1995/02/08 19:18:43 rob
  36. * Added extern for segments checksum.
  37. *
  38. * Revision 1.70 1995/02/08 11:01:16 rob
  39. * Fixed a bug.
  40. *
  41. * Revision 1.69 1995/02/07 21:16:49 rob
  42. * Added flag for automap.
  43. *
  44. * Revision 1.68 1995/02/06 18:18:33 rob
  45. * Extern'ed Packet Urgent.
  46. *
  47. * Revision 1.67 1995/02/05 14:36:29 rob
  48. * Moved defines to network.h.
  49. *
  50. * Revision 1.66 1995/02/01 16:34:09 john
  51. * Linted.
  52. *
  53. * Revision 1.65 1995/01/30 21:14:35 rob
  54. * Fixed a bug in join menu.
  55. * Simplified mission load support.
  56. *
  57. * Revision 1.64 1995/01/30 18:19:40 rob
  58. * Added mission title to gameinfo packet.
  59. *
  60. * Revision 1.63 1995/01/28 17:02:39 rob
  61. * Fixed monitor syncing bug (minor 19).
  62. *
  63. * Revision 1.62 1995/01/27 11:15:25 rob
  64. * removed extern of variable no longer in network.c
  65. *
  66. * Revision 1.61 1995/01/26 12:17:34 rob
  67. * Added new param to network_do_frame.
  68. *
  69. * Revision 1.60 1995/01/22 17:32:11 rob
  70. * Added mission support for network games.
  71. *
  72. * Revision 1.59 1995/01/17 17:10:33 rob
  73. * Added some flags to netgame struct.
  74. *
  75. * Revision 1.58 1995/01/12 18:57:15 rob
  76. * Added score resync stuff.
  77. *
  78. * Revision 1.57 1995/01/12 16:42:18 rob
  79. * Added new prototypes.
  80. *
  81. * Revision 1.56 1995/01/05 12:12:10 rob
  82. * Fixed a problem with packet size.
  83. *
  84. * Revision 1.55 1995/01/05 11:12:36 rob
  85. * Reduced packet size by 1 byte just to be safe.
  86. *
  87. * Revision 1.54 1995/01/04 21:39:32 rob
  88. * New framedata packet for registered.
  89. *
  90. * Revision 1.53 1995/01/04 08:47:04 rob
  91. * JOHN CHECKED IN FOR ROB !!!
  92. *
  93. * Revision 1.52 1994/12/30 20:09:07 rob
  94. * ADded a toggle for showing player names on HUD.
  95. *
  96. * Revision 1.51 1994/12/29 15:59:52 rob
  97. * Centralized network disconnects.
  98. *
  99. * Revision 1.50 1994/12/09 21:21:57 rob
  100. * rolled back changes.
  101. *
  102. * Revision 1.48 1994/12/05 22:59:27 rob
  103. * added prototype for send_endlevel_packet.
  104. *
  105. * Revision 1.47 1994/12/05 21:47:34 rob
  106. * Added a new field to netgame struct.
  107. *
  108. * Revision 1.46 1994/12/05 14:39:16 rob
  109. * Added new variable to indicate new net game starting.
  110. *
  111. * Revision 1.45 1994/12/04 15:37:18 rob
  112. * Fixed a typo.
  113. *
  114. * Revision 1.44 1994/12/04 15:30:42 rob
  115. * Added new fields to netgame struct.
  116. *
  117. * Revision 1.43 1994/12/03 18:03:19 rob
  118. * ADded team kill syncing.
  119. *
  120. * Revision 1.42 1994/12/01 21:21:27 rob
  121. * Added new system for object sync on rejoin.
  122. *
  123. * Revision 1.41 1994/11/29 13:07:33 rob
  124. * Changed structure defs to .h files.
  125. *
  126. * Revision 1.40 1994/11/22 17:10:48 rob
  127. * Fix for secret levels in network play mode.
  128. *
  129. * Revision 1.39 1994/11/18 16:36:31 rob
  130. * Added variable network_rejoined to enable random placement
  131. * of rejoining palyers.
  132. *
  133. * Revision 1.38 1994/11/12 19:51:13 rob
  134. * Changed prototype for network_send_data to pass
  135. * urgent flag.
  136. *
  137. * Revision 1.37 1994/11/10 21:48:26 rob
  138. * Changed net_endlevel to return an int.
  139. *
  140. * Revision 1.36 1994/11/10 20:32:49 rob
  141. * Added extern for LastPacketTime.
  142. *
  143. * Revision 1.35 1994/11/09 11:36:34 rob
  144. * ADded return value to network_level_sync for success/fail.
  145. *
  146. * Revision 1.34 1994/11/08 21:22:31 rob
  147. * Added proto for network_endlevel_snyc
  148. *
  149. * Revision 1.33 1994/11/08 15:20:00 rob
  150. * added proto for change_playernum_to
  151. *
  152. * Revision 1.32 1994/11/07 17:45:40 rob
  153. * Added prototype for network_endlevel (called from multi.c)
  154. *
  155. * Revision 1.31 1994/11/04 19:52:37 rob
  156. * Removed a function from network.h (network_show_player_list)
  157. *
  158. * Revision 1.30 1994/11/01 19:39:26 rob
  159. * Removed a couple of variables that should be externed from multi.c
  160. * (remnants of the changover)
  161. *
  162. * Revision 1.29 1994/10/31 19:18:24 rob
  163. * Changed prototype for network_do_frame to add a parameter if you wish
  164. * to force the frame to be sent. Important if this is a leave_game frame.
  165. *
  166. * Revision 1.28 1994/10/08 19:59:20 rob
  167. * Removed network message variables.
  168. *
  169. * Revision 1.27 1994/10/08 11:08:38 john
  170. * Moved network_delete_unused objects into multi.c,
  171. * took out network callsign stuff and used Matt's net
  172. * players[.].callsign stuff.
  173. *
  174. * Revision 1.26 1994/10/07 11:26:20 rob
  175. * Changed network_start_frame to network_do_frame,.
  176. *
  177. *
  178. * Revision 1.25 1994/10/05 13:58:10 rob
  179. * Added a new function net_endlevel that is called after each level is
  180. * completed. Currently it only does anything if SERIAL game is in effect.
  181. *
  182. * Revision 1.24 1994/10/04 19:34:57 rob
  183. * export network_find_max_net_players.
  184. *
  185. * Revision 1.23 1994/10/04 17:31:10 rob
  186. * Exported MaxNumNetPlayers.
  187. *
  188. * Revision 1.22 1994/10/03 22:57:30 matt
  189. * Took out redundant definition of callsign_len
  190. *
  191. * Revision 1.21 1994/10/03 15:12:48 rob
  192. * Boosted MAX_CREATE_OBJECTS to 15.
  193. *
  194. * Revision 1.20 1994/09/30 18:19:51 rob
  195. * Added two new variables for tracking object creation.
  196. *
  197. * Revision 1.19 1994/09/27 15:03:18 rob
  198. * Added prototype for network_delete_extra_objects used by modem.c
  199. *
  200. * Revision 1.18 1994/09/27 14:36:45 rob
  201. * Added two new varaibles for network/serial weapon firing.
  202. *
  203. * Revision 1.17 1994/09/07 17:10:57 john
  204. * Started adding code to sync powerups.
  205. *
  206. * Revision 1.16 1994/09/06 19:29:05 john
  207. * Added trial version of rejoin function.
  208. *
  209. * Revision 1.15 1994/08/26 13:01:54 john
  210. * Put high score system in.
  211. *
  212. * Revision 1.14 1994/08/25 18:12:04 matt
  213. * Made player's weapons and flares fire from the positions on the 3d model.
  214. * Also added support for quad lasers.
  215. *
  216. * Revision 1.13 1994/08/17 16:50:00 john
  217. * Added damaging fireballs, missiles.
  218. *
  219. * Revision 1.12 1994/08/16 12:25:22 john
  220. * Added hooks for sending messages.
  221. *
  222. * Revision 1.11 1994/08/13 12:20:18 john
  223. * Made the networking uise the Players array.
  224. *
  225. * Revision 1.10 1994/08/12 22:41:27 john
  226. * Took away Player_stats; add Players array.
  227. *
  228. * Revision 1.9 1994/08/12 03:10:22 john
  229. * Made network be default off; Moved network options into
  230. * main menu. Made starting net game check that mines are the
  231. * same.
  232. *
  233. * Revision 1.8 1994/08/11 21:57:08 john
  234. * Moved network options to main menu.
  235. *
  236. * Revision 1.7 1994/08/10 11:29:20 john
  237. * *** empty log message ***
  238. *
  239. * Revision 1.6 1994/08/10 10:44:12 john
  240. * Made net players fire..
  241. *
  242. * Revision 1.5 1994/08/09 19:31:46 john
  243. * Networking changes.
  244. *
  245. * Revision 1.4 1994/08/05 16:30:26 john
  246. * Added capability to turn off network.
  247. *
  248. * Revision 1.3 1994/08/05 16:11:43 john
  249. * Psuedo working version of networking.
  250. *
  251. * Revision 1.2 1994/07/25 12:33:34 john
  252. * Network "pinging" in.
  253. *
  254. * Revision 1.1 1994/07/20 16:09:05 john
  255. * Initial revision
  256. *
  257. *
  258. */
  259. #ifdef NETWORK
  260. #ifndef _NETWORK_H
  261. #define _NETWORK_H
  262. #include "gameseq.h"
  263. #include "multi.h"
  264. #define NETSTAT_MENU 0
  265. #define NETSTAT_PLAYING 1
  266. #define NETSTAT_BROWSING 2
  267. #define NETSTAT_WAITING 3
  268. #define NETSTAT_STARTING 4
  269. #define NETSTAT_ENDLEVEL 5
  270. #define CONNECT_DISCONNECTED 0
  271. #define CONNECT_PLAYING 1
  272. #define CONNECT_WAITING 2
  273. #define CONNECT_DIED_IN_MINE 3
  274. #define CONNECT_FOUND_SECRET 4
  275. #define CONNECT_ESCAPE_TUNNEL 5
  276. #define CONNECT_END_MENU 6
  277. typedef struct sequence_packet {
  278. ubyte type;
  279. netplayer_info player;
  280. } sequence_packet;
  281. #ifdef SHAREWARE
  282. #define NET_XDATA_SIZE 256
  283. #else
  284. #define NET_XDATA_SIZE 454
  285. #endif
  286. #ifdef SHAREWARE
  287. typedef struct frame_info {
  288. ubyte type; // What type of p
  289. int numpackets;
  290. short objnum;
  291. ubyte playernum;
  292. short obj_segnum;
  293. vms_vector obj_pos;
  294. vms_matrix obj_orient;
  295. physics_info obj_phys_info;
  296. ubyte obj_render_type;
  297. ubyte level_num;
  298. ushort data_size; // Size of data appended to the net packet
  299. ubyte data[NET_XDATA_SIZE]; // extra data to be tacked on the end
  300. } frame_info;
  301. #else
  302. typedef struct frame_info {
  303. ubyte type; // What type of packet
  304. ubyte pad[3]; // Pad out length of frame_info packet
  305. int numpackets;
  306. vms_vector obj_pos;
  307. vms_matrix obj_orient;
  308. vms_vector phys_velocity;
  309. vms_vector phys_rotvel;
  310. short obj_segnum;
  311. ushort data_size; // Size of data appended to the net packet
  312. ubyte playernum;
  313. ubyte obj_render_type;
  314. ubyte level_num;
  315. ubyte data[NET_XDATA_SIZE]; // extra data to be tacked on the end
  316. } frame_info;
  317. #endif
  318. void network_start_game();
  319. void network_join_game();
  320. void network_rejoin_game();
  321. void network_leave_game();
  322. int network_endlevel(int *secret);
  323. int network_endlevel_poll2( int nitems, struct newmenu_item * menus, int * key, int citem );
  324. int network_level_sync();
  325. void network_send_endlevel_packet();
  326. int network_delete_extra_objects();
  327. int network_find_max_net_players();
  328. int network_objnum_is_past(int objnum);
  329. char * network_get_player_name( int objnum );
  330. void network_disconnect_player(int playernum);
  331. extern int Network_send_objects;
  332. extern int Network_send_objnum;
  333. extern int PacketUrgent;
  334. extern int Network_rejoined;
  335. extern int Network_new_game;
  336. extern int Network_status;
  337. extern fix LastPacketTime[MAX_PLAYERS];
  338. extern ushort my_segments_checksum;
  339. // By putting an up-to-20-char-message into Network_message and
  340. // setting Network_message_reciever to the player num you want to
  341. // send it to (100 for broadcast) the next frame the player will
  342. // get your message.
  343. // Call once at the beginning of a frame
  344. void network_do_frame(int force, int listen);
  345. // Tacks data of length 'len' onto the end of the next
  346. // packet that we're transmitting.
  347. void network_send_data( ubyte * ptr, int len, int urgent );
  348. #endif
  349. #endif
  350.