]> icculus.org git repositories - btb/d2x.git/blob - main/multi.h
fix bugfix of 2004-05-15
[btb/d2x.git] / main / multi.h
1 /* $Id: multi.h,v 1.14 2004-08-28 23:17:45 schaffner 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 /*
16  *
17  * Defines and exported variables for multi.c
18  *
19  */
20
21 #ifndef _MULTI_H
22 #define _MULTI_H
23
24 #define MAX_MESSAGE_LEN 35
25
26 // Defines
27 #include "gameseq.h"
28 #include "piggy.h"
29
30 // What version of the multiplayer protocol is this?
31
32 #ifdef SHAREWARE
33 #define MULTI_PROTO_VERSION 3
34 #else
35 #define MULTI_PROTO_VERSION 4
36 #endif
37
38 // Protocol versions:
39 //   1 Descent Shareware
40 //   2 Descent Registered/Commercial
41 //   3 Descent II Shareware
42 //   4 Descent II Commercial
43
44 // Save multiplayer games?
45
46 #define MULTI_SAVE
47
48 // How many simultaneous network players do we support?
49
50 #define MAX_NUM_NET_PLAYERS     8
51
52 #define MULTI_POSITION          0
53 #define MULTI_REAPPEAR          1
54 #define MULTI_FIRE              2
55 #define MULTI_KILL              3
56 #define MULTI_REMOVE_OBJECT     4
57 #define MULTI_PLAYER_EXPLODE    5
58 #define MULTI_MESSAGE           6
59 #define MULTI_QUIT              7
60 #define MULTI_PLAY_SOUND        8
61 #define MULTI_BEGIN_SYNC        9
62 #define MULTI_CONTROLCEN        10
63 #define MULTI_ROBOT_CLAIM       11
64 #define MULTI_END_SYNC          12
65 #define MULTI_CLOAK             13
66 #define MULTI_ENDLEVEL_START    14
67 #define MULTI_DOOR_OPEN         15
68 #define MULTI_CREATE_EXPLOSION  16
69 #define MULTI_CONTROLCEN_FIRE   17
70 #define MULTI_PLAYER_DROP       18
71 #define MULTI_CREATE_POWERUP    19
72 #define MULTI_CONSISTENCY       20
73 #define MULTI_DECLOAK           21
74 #define MULTI_MENU_CHOICE       22
75 #define MULTI_ROBOT_POSITION    23
76 #define MULTI_ROBOT_EXPLODE     24
77 #define MULTI_ROBOT_RELEASE     25
78 #define MULTI_ROBOT_FIRE        26
79 #define MULTI_SCORE             27
80 #define MULTI_CREATE_ROBOT      28
81 #define MULTI_TRIGGER           29
82 #define MULTI_BOSS_ACTIONS      30
83 #define MULTI_CREATE_ROBOT_POWERUPS 31
84 #define MULTI_HOSTAGE_DOOR      32
85
86 #define MULTI_SAVE_GAME         33
87 #define MULTI_RESTORE_GAME      34
88
89 #define MULTI_REQ_PLAYER        35  // Someone requests my player structure
90 #define MULTI_SEND_PLAYER       36  // Sending someone my player structure
91 #define MULTI_MARKER            37
92 #define MULTI_DROP_WEAPON       38
93 #define MULTI_GUIDED            39
94 #define MULTI_STOLEN_ITEMS      40
95 #define MULTI_WALL_STATUS       41  // send to new players
96 #define MULTI_HEARTBEAT         42
97 #define MULTI_KILLGOALS         43
98 #define MULTI_SEISMIC           44
99 #define MULTI_LIGHT             45
100 #define MULTI_START_TRIGGER     46
101 #define MULTI_FLAGS             47
102 #define MULTI_DROP_BLOB         48
103 #define MULTI_POWERUP_UPDATE    49
104 #define MULTI_ACTIVE_DOOR       50
105 #define MULTI_SOUND_FUNCTION    51
106 #define MULTI_CAPTURE_BONUS     52
107 #define MULTI_GOT_FLAG          53
108 #define MULTI_DROP_FLAG         54
109 #define MULTI_ROBOT_CONTROLS    55
110 #define MULTI_FINISH_GAME       56
111 #define MULTI_RANK              57
112 #define MULTI_MODEM_PING        58
113 #define MULTI_MODEM_PING_RETURN 59
114 #define MULTI_ORB_BONUS         60
115 #define MULTI_GOT_ORB           61
116 #define MULTI_DROP_ORB          62
117 #define MULTI_PLAY_BY_PLAY      63
118
119 #define MULTI_MAX_TYPE          63
120
121 #define MAX_NET_CREATE_OBJECTS  40
122
123 #define MAX_MULTI_MESSAGE_LEN   120
124
125 // Exported functions
126
127 int objnum_remote_to_local(int remote_obj, int owner);
128 int objnum_local_to_remote(int local_obj, sbyte *owner);
129 void map_objnum_local_to_remote(int local, int remote, int owner);
130 void map_objnum_local_to_local(int objnum);
131 void reset_network_objects();
132
133 void multi_init_objects(void);
134 void multi_show_player_list(void);
135 void multi_do_frame(void);
136
137
138 void multi_send_flags(char);
139 void multi_send_fire(void);
140 void multi_send_destroy_controlcen(int objnum, int player);
141 void multi_send_endlevel_start(int);
142 void multi_send_player_explode(char type);
143 void multi_send_message(void);
144 void multi_send_position(int objnum);
145 void multi_send_reappear();
146 void multi_send_kill(int objnum);
147 void multi_send_remobj(int objnum);
148 void multi_send_quit(int why);
149 void multi_send_door_open(int segnum, int side,ubyte flag);
150 void multi_send_create_explosion(int player_num);
151 void multi_send_controlcen_fire(vms_vector *to_target, int gun_num, int objnum);
152 void multi_send_cloak(void);
153 void multi_send_decloak(void);
154 void multi_send_create_powerup(int powerup_type, int segnum, int objnum, vms_vector *pos);
155 void multi_send_play_sound(int sound_num, fix volume);
156 void multi_send_audio_taunt(int taunt_num);
157 void multi_send_score(void);
158 void multi_send_trigger(int trigger);
159 void multi_send_hostage_door_status(int wallnum);
160 void multi_send_netplayer_stats_request(ubyte player_num);
161 void multi_send_drop_weapon (int objnum,int seed);
162 void multi_send_drop_marker (int player,vms_vector position,char messagenum,char text[]);
163 void multi_send_guided_info (object *miss,char);
164
165
166 void multi_endlevel_score(void);
167 void multi_prep_level(void);
168 int multi_endlevel(int *secret);
169 int multi_menu_poll(void);
170 void multi_leave_game(void);
171 void multi_process_data(char *dat, int len);
172 void multi_process_bigdata(char *buf, int len);
173 void multi_do_death(int objnum);
174 void multi_send_message_dialog(void);
175 int multi_delete_extra_objects(void);
176 void multi_make_ghost_player(int objnum);
177 void multi_make_player_ghost(int objnum);
178 void multi_define_macro(int key);
179 void multi_send_macro(int key);
180 int multi_get_kill_list(int *plist);
181 void multi_new_game(void);
182 void multi_sort_kill_list(void);
183 int multi_choose_mission(int *anarchy_only);
184 void multi_reset_stuff(void);
185
186 void multi_send_data(char *buf, int len, int repeat);
187
188 int get_team(int pnum);
189
190 // Exported variables
191
192
193 extern int Network_active;
194 extern int Network_laser_gun;
195 extern int Network_laser_fired;
196 extern int Network_laser_level;
197 extern int Network_laser_flags;
198 extern int Netlife_kills,Netlife_killed;
199
200 extern int message_length[MULTI_MAX_TYPE+1];
201 extern char multibuf[MAX_MULTI_MESSAGE_LEN+4];
202 extern short Network_laser_track;
203
204 extern int who_killed_controlcen;
205
206 extern int Net_create_objnums[MAX_NET_CREATE_OBJECTS];
207 extern int Net_create_loc;
208
209 extern short kill_matrix[MAX_NUM_NET_PLAYERS][MAX_NUM_NET_PLAYERS];
210 extern short team_kills[2];
211
212 extern int multi_goto_secret;
213
214 //do we draw the kill list on the HUD?
215 extern int Show_kill_list;
216 extern int Show_reticle_name;
217 extern fix Show_kill_list_timer;
218
219 // Used to send network messages
220
221 extern char Network_message[MAX_MESSAGE_LEN];
222 extern char Network_message_macro[4][MAX_MESSAGE_LEN];
223 extern int Network_message_reciever;
224
225 // Which player 'owns' each local object for network purposes
226 extern sbyte object_owner[MAX_OBJECTS];
227
228 extern int multi_in_menu; // Flag to tell if we're executing GameLoop from within a newmenu.
229 extern int multi_leave_menu;
230 extern int multi_quit_game;
231
232 extern int multi_sending_message;
233 extern int multi_defining_message;
234 extern void multi_message_input_sub( int key );
235 extern void multi_send_message_start();
236
237 extern int multi_powerup_is_4pack(int );
238 extern void multi_send_orb_bonus( char pnum );
239 extern void multi_send_got_orb( char pnum );
240 extern void multi_add_lifetime_kills(void);
241
242 extern int control_invul_time;
243
244 #define N_PLAYER_SHIP_TEXTURES 6
245
246 extern bitmap_index multi_player_textures[MAX_NUM_NET_PLAYERS][N_PLAYER_SHIP_TEXTURES];
247
248 #define NETGAME_FLAG_CLOSED             1
249 #define NETGAME_FLAG_SHOW_ID            2
250 #define NETGAME_FLAG_SHOW_MAP           4
251 #define NETGAME_FLAG_HOARD              8
252 #define NETGAME_FLAG_TEAM_HOARD         16
253 #define NETGAME_FLAG_REALLY_ENDLEVEL    32
254 #define NETGAME_FLAG_REALLY_FORMING     64
255
256 #define NETGAME_NAME_LEN                15
257 #define NETGAME_AUX_SIZE                20  // Amount of extra data for the network protocol to store in the netgame packet
258
259 enum comp_type {DOS,WIN_32,WIN_95,MAC} __pack__ ;
260
261 // sigh...the socket structure member was moved away from it's friends.
262 // I'll have to create a union for appletalk network info with just
263 // the server and node members since I cannot change the order ot these
264 // members.
265
266 typedef struct netplayer_info {
267         char    callsign[CALLSIGN_LEN+1];
268         union {
269                 struct {
270                         ubyte   server[4];
271                         ubyte   node[6];
272                 } ipx;
273                 struct {
274                         ushort  net;
275                         ubyte   node;
276                         ubyte   socket;
277                 } appletalk;
278         } network;
279
280         ubyte   version_major;
281         ubyte   version_minor;
282         enum comp_type computer_type;
283         sbyte    connected;
284
285         ushort  socket;
286
287         ubyte   rank;
288
289 } __pack__ netplayer_info;
290
291 typedef struct AllNetPlayers_info
292 {
293         char    type;
294         int     Security;
295         struct netplayer_info players[MAX_PLAYERS+4];
296 } __pack__ AllNetPlayers_info;
297
298 typedef struct netgame_info {
299         ubyte   type;
300         int     Security;
301         char    game_name[NETGAME_NAME_LEN+1];
302         char    mission_title[MISSION_NAME_LEN+1];
303         char    mission_name[9];
304         int     levelnum;
305         ubyte   gamemode;
306         ubyte   RefusePlayers;
307         ubyte   difficulty;
308         ubyte   game_status;
309         ubyte   numplayers;
310         ubyte   max_numplayers;
311         ubyte   numconnected;
312         ubyte   game_flags;
313         ubyte   protocol_version;
314         ubyte   version_major;
315         ubyte   version_minor;
316         ubyte   team_vector;
317
318 // change the order of the bit fields for the mac compiler.
319 // doing so will mean I don't have to do screwy things to
320 // send this as network information
321
322 #ifndef WORDS_BIGENDIAN
323         short DoMegas:1;
324         short DoSmarts:1;
325         short DoFusions:1;
326         short DoHelix:1;
327         short DoPhoenix:1;
328         short DoAfterburner:1;
329         short DoInvulnerability:1;
330         short DoCloak:1;
331         short DoGauss:1;
332         short DoVulcan:1;
333         short DoPlasma:1;
334         short DoOmega:1;
335         short DoSuperLaser:1;
336         short DoProximity:1;
337         short DoSpread:1;
338         short DoSmartMine:1;
339         short DoFlash:1;
340         short DoGuided:1;
341         short DoEarthShaker:1;
342         short DoMercury:1;
343         short Allow_marker_view:1;
344         short AlwaysLighting:1;
345         short DoAmmoRack:1;
346         short DoConverter:1;
347         short DoHeadlight:1;
348         short DoHoming:1;
349         short DoLaserUpgrade:1;
350         short DoQuadLasers:1;
351         short ShowAllNames:1;
352         short BrightPlayers:1;
353         short invul:1;
354         short bitfield_not_used2:1;
355 #else
356         short DoSmartMine:1;
357         short DoSpread:1;
358         short DoProximity:1;
359         short DoSuperLaser:1;
360         short DoOmega:1;
361         short DoPlasma:1;
362         short DoVulcan:1;
363         short DoGauss:1;
364         short DoCloak:1;
365         short DoInvulnerability:1;
366         short DoAfterburner:1;
367         short DoPhoenix:1;
368         short DoHelix:1;
369         short DoFusions:1;
370         short DoSmarts:1;
371         short DoMegas:1;
372
373         short bitfield_not_used2:1;
374         short invul:1;
375         short BrightPlayers:1;
376         short ShowAllNames:1;
377         short DoQuadLasers:1;
378         short DoLaserUpgrade:1;
379         short DoHoming:1;
380         short DoHeadlight:1;
381         short DoConverter:1;
382         short DoAmmoRack:1;
383         short AlwaysLighting:1;
384         short Allow_marker_view:1;
385         short DoMercury:1;
386         short DoEarthShaker:1;
387         short DoGuided:1;
388         short DoFlash:1;
389 #endif
390
391         char    team_name[2][CALLSIGN_LEN+1];
392         int     locations[MAX_PLAYERS];
393         short   kills[MAX_PLAYERS][MAX_PLAYERS];
394         ushort  segments_checksum;
395         short   team_kills[2];
396         short   killed[MAX_PLAYERS];
397         short   player_kills[MAX_PLAYERS];
398         int     KillGoal;
399         fix     PlayTimeAllowed;
400         fix     level_time;
401         int     control_invul_time;
402         int     monitor_vector;
403         int     player_score[MAX_PLAYERS];
404         ubyte   player_flags[MAX_PLAYERS];
405         short   PacketsPerSec;
406         ubyte   ShortPackets;
407         ubyte   AuxData[NETGAME_AUX_SIZE];  // Storage for protocol-specific data (e.g., multicast session and port)
408
409 } __pack__ netgame_info;
410
411 extern struct netgame_info Netgame;
412 extern struct AllNetPlayers_info NetPlayers;
413
414 int network_i_am_master(void);
415 void change_playernum_to(int new_pnum);
416
417 //how to encode missiles & flares in weapon packets
418 #define MISSILE_ADJUST  100
419 #define FLARE_ADJUST    127
420
421 #endif /* _MULTI_H */