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