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