]> icculus.org git repositories - btb/d2x.git/blob - main/network.h
formatting, patch for better d1 texture conversion from Martin Schaffner <maschaffner...
[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 /*
15  * $Source: /cvs/cvsroot/d2x/main/network.h,v $
16  * $Revision: 1.7 $
17  * $Author: bradleyb $
18  * $Date: 2002-07-16 08:14:35 $
19  *
20  * FIXME: put description here
21  *
22  * $Log: not supported by cvs2svn $
23  * Revision 1.6  2002/02/14 09:24:19  bradleyb
24  * d1x->d2x
25  *
26  * Revision 1.5  2002/02/13 10:39:22  bradleyb
27  * Lotsa networking stuff from d1x
28  *
29  * Revision 1.4  2001/10/25 02:15:57  bradleyb
30  * conditionalize including multi.h and network.h, fix backslashes
31  *
32  *
33  */
34
35 #ifndef _NETWORK_H
36 #define _NETWORK_H
37
38 #include "gameseq.h"
39 #include "multi.h"
40 #include "newmenu.h"
41
42 #define NETSTAT_MENU                                    0
43 #define NETSTAT_PLAYING                         1
44 #define NETSTAT_BROWSING                        2
45 #define NETSTAT_WAITING                         3
46 #define NETSTAT_STARTING                        4
47 #define NETSTAT_ENDLEVEL                        5
48
49 #define CONNECT_DISCONNECTED            0
50 #define CONNECT_PLAYING                         1
51 #define CONNECT_WAITING                         2
52 #define CONNECT_DIED_IN_MINE            3
53 #define CONNECT_FOUND_SECRET            4
54 #define CONNECT_ESCAPE_TUNNEL           5
55 #define CONNECT_END_MENU                        6
56
57 #define NETGAMEIPX                              1
58 #define NETGAMETCP                              2
59
60 // defines and other things for appletalk/ipx games on mac
61
62 #define IPX_GAME                1
63 #define APPLETALK_GAME  2
64 #ifdef MACINTOSH
65 extern int Network_game_type;
66 #else
67 #define Network_game_type IPX_GAME
68 #endif
69
70 typedef struct sequence_packet {
71         ubyte                                   type;
72         int                                     Security;
73    ubyte pad1[3];
74         netplayer_info          player;
75 } __pack__ sequence_packet;
76
77 #define NET_XDATA_SIZE 454
78
79
80 // frame info is aligned -- 01/18/96 -- MWA
81 // if you change this structure -- be sure to keep
82 // alignment:
83 //              bytes on byte boundries
84 //              shorts on even byte boundries
85 //              ints on even byte boundries
86
87 typedef struct frame_info {
88         ubyte                           type;                                           // What type of packet
89         ubyte                           pad[3];                                 // Pad out length of frame_info packet
90         int                             numpackets;                     
91         vms_vector              obj_pos;
92         vms_matrix              obj_orient;
93         vms_vector              phys_velocity;
94         vms_vector              phys_rotvel;
95         short                           obj_segnum;
96         ushort                  data_size;              // Size of data appended to the net packet
97         ubyte                           playernum;
98         ubyte                           obj_render_type;
99         ubyte                           level_num;
100         ubyte                           data[NET_XDATA_SIZE];           // extra data to be tacked on the end
101 } __pack__ frame_info;
102
103 // short_frame_info is not aligned -- 01/18/96 -- MWA
104 // won't align because of shortpos.  Shortpos needs
105 // to stay in current form.
106
107 typedef struct short_frame_info {
108         ubyte                           type;                                           // What type of packet
109         ubyte                           pad[3];                                 // Pad out length of frame_info packet
110         int                             numpackets;                     
111         shortpos                        thepos;
112         ushort                  data_size;              // Size of data appended to the net packet
113         ubyte                           playernum;
114         ubyte                           obj_render_type;
115         ubyte                           level_num;
116         ubyte                           data[NET_XDATA_SIZE];           // extra data to be tacked on the end
117 } __pack__ short_frame_info;
118
119 void network_start_game();
120 void network_join_game();
121 void network_rejoin_game();
122 void network_leave_game();
123 int network_endlevel(int *secret);
124 void network_endlevel_poll2( int nitems, struct newmenu_item * menus, int * key, int citem );
125
126 int network_level_sync();
127 void network_send_endlevel_packet();
128
129 int network_delete_extra_objects();
130 int network_find_max_net_players();
131 int network_objnum_is_past(int objnum);
132 char * network_get_player_name( int objnum );
133 void network_send_endlevel_sub(int player_num);
134
135 void network_disconnect_player(int playernum);
136
137 extern int NetGameType;
138 extern int Network_send_objects;
139 extern int Network_send_objnum;
140 extern int PacketUrgent;
141 extern int Network_rejoined;
142
143 extern int Network_new_game;
144 extern int Network_status;
145
146 extern fix LastPacketTime[MAX_PLAYERS];
147
148 extern ushort my_segments_checksum;
149
150 extern int Network_initial_pps;
151 extern int Network_initial_shortpackets;
152
153 // By putting an up-to-20-char-message into Network_message and 
154 // setting Network_message_reciever to the player num you want to
155 // send it to (100 for broadcast) the next frame the player will
156 // get your message.
157
158 // Call once at the beginning of a frame
159 void network_do_frame(int force, int listen);
160
161 // Tacks data of length 'len' onto the end of the next
162 // packet that we're transmitting.
163 void network_send_data( ubyte * ptr, int len, int urgent );
164
165 void network_send_objects(void);
166 void network_dump_player(ubyte * server, ubyte *node, int why);
167 void network_send_game_info(sequence_packet *their);
168
169 int GetMyNetRanking();
170 int HoardEquipped();
171
172 #define PID_LITE_INFO                           43
173 #define PID_SEND_ALL_GAMEINFO                   44
174 #define PID_PLAYERSINFO                         45
175 #define PID_REQUEST                             46
176 #define PID_SYNC                                47
177 #define PID_PDATA                               48
178 #define PID_ADDPLAYER                           49
179 #define PID_DUMP                                51
180 #define PID_ENDLEVEL                            52
181 #define PID_QUIT_JOINING                        54
182 #define PID_OBJECT_DATA                         55
183 #define PID_GAME_LIST                           56
184 #define PID_GAME_INFO                           57
185 #define PID_PING_SEND                           58
186 #define PID_PING_RETURN                         59
187 #define PID_GAME_UPDATE                         60
188 #define PID_ENDLEVEL_SHORT                      61
189 #define PID_NAKED_PDATA                         62
190 #define PID_GAME_PLAYERS                        63
191 #define PID_NAMES_RETURN                        64
192
193 #define PID_SHORTPDATA                          42
194 #define PID_D2X_GAME_INFO_REQ                   65
195 #define PID_D2X_GAME_LITE                       68
196 #define PID_PDATA_SHORT2                        70
197
198 #define NETGAME_ANARCHY                         0
199 #define NETGAME_TEAM_ANARCHY                    1
200 #define NETGAME_ROBOT_ANARCHY                   2
201 #define NETGAME_COOPERATIVE                     3
202 #define NETGAME_CAPTURE_FLAG                    4
203 #define NETGAME_HOARD                           5
204 #define NETGAME_TEAM_HOARD                      6
205
206 typedef struct endlevel_info {
207         ubyte                                   type;
208         ubyte                                   player_num;
209         byte                                    connected;
210         ubyte                                   seconds_left;
211         short                                   kill_matrix[MAX_PLAYERS][MAX_PLAYERS];
212         short                                   kills;
213         short                                   killed;
214 } __pack__ endlevel_info;
215
216 #endif