1 /* $Id: network.h,v 1.11 2003/02/28 03:54:55 btb Exp $ */ 2 /* 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. 13 */ 14 15 #ifndef _NETWORK_H 16 #define _NETWORK_H 17 18 #include "gameseq.h" 19 #include "multi.h" 20 #include "newmenu.h" 21 22 #define NETSTAT_MENU 0 23 #define NETSTAT_PLAYING 1 24 #define NETSTAT_BROWSING 2 25 #define NETSTAT_WAITING 3 26 #define NETSTAT_STARTING 4 27 #define NETSTAT_ENDLEVEL 5 28 29 #define CONNECT_DISCONNECTED 0 30 #define CONNECT_PLAYING 1 31 #define CONNECT_WAITING 2 32 #define CONNECT_DIED_IN_MINE 3 33 #define CONNECT_FOUND_SECRET 4 34 #define CONNECT_ESCAPE_TUNNEL 5 35 #define CONNECT_END_MENU 6 36 37 #define NETGAMEIPX 1 38 #define NETGAMETCP 2 39 40 // defines and other things for appletalk/ipx games on mac 41 42 #define IPX_GAME 1 43 #define APPLETALK_GAME 2 44 #ifdef MACINTOSH 45 extern int Network_game_type; 46 #else 47 #define Network_game_type IPX_GAME 48 #endif 49 50 typedef struct sequence_packet { 51 ubyte type; 52 int Security; 53 ubyte pad1[3]; 54 netplayer_info player; 55 } __pack__ sequence_packet; 56 57 #define NET_XDATA_SIZE 454 58 59 60 // frame info is aligned -- 01/18/96 -- MWA 61 // if you change this structure -- be sure to keep 62 // alignment: 63 // bytes on byte boundries 64 // shorts on even byte boundries 65 // ints on even byte boundries 66 67 typedef struct frame_info { 68 ubyte type; // What type of packet 69 ubyte pad[3]; // Pad out length of frame_info packet 70 int numpackets; 71 vms_vector obj_pos; 72 vms_matrix obj_orient; 73 vms_vector phys_velocity; 74 vms_vector phys_rotvel; 75 short obj_segnum; 76 ushort data_size; // Size of data appended to the net packet 77 ubyte playernum; 78 ubyte obj_render_type; 79 ubyte level_num; 80 ubyte data[NET_XDATA_SIZE]; // extra data to be tacked on the end 81 } __pack__ frame_info; 82 83 // short_frame_info is not aligned -- 01/18/96 -- MWA 84 // won't align because of shortpos. Shortpos needs 85 // to stay in current form. 86 87 typedef struct short_frame_info { 88 ubyte type; // What type of packet 89 ubyte pad[3]; // Pad out length of frame_info packet 90 int numpackets; 91 shortpos thepos; 92 ushort data_size; // Size of data appended to the net packet 93 ubyte playernum; 94 ubyte obj_render_type; 95 ubyte level_num; 96 ubyte data[NET_XDATA_SIZE]; // extra data to be tacked on the end 97 } __pack__ short_frame_info; 98 99 void network_start_game(); 100 void network_join_game(); 101 void network_rejoin_game(); 102 void network_leave_game(); 103 int network_endlevel(int *secret); 104 void network_endlevel_poll2( int nitems, struct newmenu_item * menus, int * key, int citem ); 105 106 107 int network_level_sync(); 108 void network_send_endlevel_packet(); 109 110 int network_delete_extra_objects(); 111 int network_find_max_net_players(); 112 int network_objnum_is_past(int objnum); 113 char * network_get_player_name( int objnum ); 114 void network_send_endlevel_sub(int player_num); 115 void network_disconnect_player(int playernum); 116 117 extern void network_dump_player(ubyte * server, ubyte *node, int why); 118 extern void network_send_netgame_update(); 119 120 extern int GetMyNetRanking(); 121 122 extern int NetGameType; 123 extern int Network_send_objects; 124 extern int Network_send_objnum; 125 extern int PacketUrgent; 126 extern int Network_rejoined; 127 128 extern int Network_new_game; 129 extern int Network_status; 130 131 extern fix LastPacketTime[MAX_PLAYERS]; 132 133 extern ushort my_segments_checksum; 134 // By putting an up-to-20-char-message into Network_message and 135 // setting Network_message_reciever to the player num you want to 136 // send it to (100 for broadcast) the next frame the player will 137 // get your message. 138 139 // Call once at the beginning of a frame 140 void network_do_frame(int force, int listen); 141 142 // Tacks data of length 'len' onto the end of the next 143 // packet that we're transmitting. 144 void network_send_data( ubyte * ptr, int len, int urgent ); 145 146 // returns 1 if hoard.ham available 147 extern int HoardEquipped(); 148 149 #endif 150