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