1 /* $Id: multi.h,v 1.7 2002-08-31 05:27:50 btb Exp $ */
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.
17 * FIXME: put description here
24 #define MAX_MESSAGE_LEN 35
30 // What version of the multiplayer protocol is this?
33 #define MULTI_PROTO_VERSION 3
35 #define MULTI_PROTO_VERSION 4
39 // 1 Descent Shareware
40 // 2 Descent Registered/Commercial
41 // 3 Descent II Shareware
42 // 4 Descent II Commercial
44 // Save multiplayer games?
48 // How many simultaneous network players do we support?
50 #define MAX_NUM_NET_PLAYERS 8
52 #define MULTI_POSITION 0
53 #define MULTI_REAPPEAR 1
56 #define MULTI_REMOVE_OBJECT 4
57 #define MULTI_PLAYER_EXPLODE 5
58 #define MULTI_MESSAGE 6
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
86 #define MULTI_SAVE_GAME 33
87 #define MULTI_RESTORE_GAME 34
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
119 #define MULTI_MAX_TYPE 63
121 #define MAX_NET_CREATE_OBJECTS 40
123 #define MAX_MULTI_MESSAGE_LEN 120
125 // Exported functions
127 int objnum_remote_to_local(int remote_obj, int owner);
128 int objnum_local_to_remote(int local_obj, byte *owner);
129 void map_objnum_local_to_remote(int local, int remote, int owner);
130 void map_objnum_local_to_local(int objnum);
132 void multi_init_objects(void);
133 void multi_show_player_list(void);
134 void multi_do_frame(void);
137 void multi_send_flags(char);
138 void multi_send_fire(void);
139 void multi_send_destroy_controlcen(int objnum, int player);
140 void multi_send_endlevel_start(int);
141 void multi_send_player_explode(char type);
142 void multi_send_message(void);
143 void multi_send_position(int objnum);
144 void multi_send_reappear();
145 void multi_send_kill(int objnum);
146 void multi_send_remobj(int objnum);
147 void multi_send_quit(int why);
148 void multi_send_door_open(int segnum, int side,ubyte flag);
149 void multi_send_create_explosion(int player_num);
150 void multi_send_controlcen_fire(vms_vector *to_target, int gun_num, int objnum);
151 void multi_send_cloak(void);
152 void multi_send_decloak(void);
153 void multi_send_create_powerup(int powerup_type, int segnum, int objnum, vms_vector *pos);
154 void multi_send_play_sound(int sound_num, fix volume);
155 void multi_send_audio_taunt(int taunt_num);
156 void multi_send_score(void);
157 void multi_send_trigger(int trigger);
158 void multi_send_hostage_door_status(int wallnum);
159 void multi_send_netplayer_stats_request(ubyte player_num);
160 void multi_send_drop_weapon (int objnum,int seed);
161 void multi_send_drop_marker (int player,vms_vector position,char messagenum,char text[]);
162 void multi_send_guided_info (object *miss,char);
165 void multi_endlevel_score(void);
166 void multi_prep_level(void);
167 int multi_endlevel(int *secret);
168 int multi_menu_poll(void);
169 void multi_leave_game(void);
170 void multi_process_data(char *dat, int len);
171 void multi_process_bigdata(char *buf, int len);
172 void multi_do_death(int objnum);
173 void multi_send_message_dialog(void);
174 int multi_delete_extra_objects(void);
175 void multi_make_ghost_player(int objnum);
176 void multi_make_player_ghost(int objnum);
177 void multi_define_macro(int key);
178 void multi_send_macro(int key);
179 int multi_get_kill_list(int *plist);
180 void multi_new_game(void);
181 void multi_sort_kill_list(void);
182 int multi_choose_mission(int *anarchy_only);
183 void multi_reset_stuff(void);
185 void multi_send_data(char *buf, int len, int repeat);
187 int get_team(int pnum);
189 // Exported variables
192 extern int Network_active;
193 extern int Network_laser_gun;
194 extern int Network_laser_fired;
195 extern int Network_laser_level;
196 extern int Network_laser_flags;
197 extern int Netlife_kills,Netlife_killed;
199 extern int message_length[MULTI_MAX_TYPE+1];
200 extern char multibuf[MAX_MULTI_MESSAGE_LEN+4];
201 extern short Network_laser_track;
203 extern int who_killed_controlcen;
205 extern int Net_create_objnums[MAX_NET_CREATE_OBJECTS];
206 extern int Net_create_loc;
208 extern short kill_matrix[MAX_NUM_NET_PLAYERS][MAX_NUM_NET_PLAYERS];
209 extern short team_kills[2];
211 extern int multi_goto_secret;
213 //do we draw the kill list on the HUD?
214 extern int Show_kill_list;
215 extern int Show_reticle_name;
216 extern fix Show_kill_list_timer;
218 // Used to send network messages
220 extern char Network_message[MAX_MESSAGE_LEN];
221 extern char Network_message_macro[4][MAX_MESSAGE_LEN];
222 extern int Network_message_reciever;
224 // Used to map network to local object numbers
226 extern short remote_to_local[MAX_NUM_NET_PLAYERS][MAX_OBJECTS]; // Network object num for each
227 extern short local_to_remote[MAX_OBJECTS]; // Local object num for each network objnum
228 extern byte object_owner[MAX_OBJECTS]; // Who 'owns' each local object for network purposes
230 extern int multi_in_menu; // Flag to tell if we're executing GameLoop from within a newmenu.
231 extern int multi_leave_menu;
232 extern int multi_quit_game;
234 extern int multi_sending_message;
235 extern int multi_defining_message;
236 extern void multi_message_input_sub( int key );
237 extern void multi_send_message_start();
239 extern int multi_powerup_is_4pack(int );
240 extern void multi_send_orb_bonus( char pnum );
241 extern void multi_send_got_orb( char pnum );
242 extern void multi_add_lifetime_kills(void);
244 extern int control_invul_time;
246 #define N_PLAYER_SHIP_TEXTURES 6
248 extern bitmap_index multi_player_textures[MAX_NUM_NET_PLAYERS][N_PLAYER_SHIP_TEXTURES];
250 #define NETGAME_FLAG_CLOSED 1
251 #define NETGAME_FLAG_SHOW_ID 2
252 #define NETGAME_FLAG_SHOW_MAP 4
253 #define NETGAME_FLAG_HOARD 8
254 #define NETGAME_FLAG_TEAM_HOARD 16
255 #define NETGAME_FLAG_REALLY_ENDLEVEL 32
256 #define NETGAME_FLAG_REALLY_FORMING 64
258 #define NETGAME_NAME_LEN 15
260 enum comp_type {DOS,WIN_32,WIN_95,MAC};
262 // sigh...the socket structure member was moved away from it's friends.
263 // I'll have to create a union for appletalk network info with just
264 // the server and node members since I cannot change the order ot these
267 typedef struct netplayer_info {
268 char callsign[CALLSIGN_LEN+1];
283 enum comp_type computer_type;
292 typedef struct AllNetPlayers_info
296 struct netplayer_info players[MAX_PLAYERS+4];
297 } AllNetPlayers_info;
299 typedef struct netgame_info {
302 char game_name[NETGAME_NAME_LEN+1];
303 char mission_title[MISSION_NAME_LEN+1];
304 char mission_name[9];
311 ubyte max_numplayers;
314 ubyte protocol_version;
319 // change the order of the bit fields for the mac compiler.
320 // doing so will mean I don't have to do screwy things to
321 // send this as network information
323 #ifndef WORDS_BIGENDIAN
329 short DoAfterburner:1;
330 short DoInvulnerability:1;
336 short DoSuperLaser:1;
342 short DoEarthShaker:1;
344 short Allow_marker_view:1;
345 short AlwaysLighting:1;
350 short DoLaserUpgrade:1;
351 short DoQuadLasers:1;
352 short ShowAllNames:1;
353 short BrightPlayers:1;
359 short DoSuperLaser:1;
365 short DoInvulnerability:1;
366 short DoAfterburner:1;
373 short bitfield_not_used2:1;
375 short BrightPlayers:1;
376 short ShowAllNames:1;
377 short DoQuadLasers:1;
378 short DoLaserUpgrade:1;
383 short AlwaysLighting:1;
384 short Allow_marker_view:1;
386 short DoEarthShaker:1;
391 char team_name[2][CALLSIGN_LEN+1];
392 int locations[MAX_PLAYERS];
393 short kills[MAX_PLAYERS][MAX_PLAYERS];
394 ushort segments_checksum;
396 short killed[MAX_PLAYERS];
397 short player_kills[MAX_PLAYERS];
401 int control_invul_time;
403 int player_score[MAX_PLAYERS];
404 ubyte player_flags[MAX_PLAYERS];
408 } __pack__ netgame_info;
410 extern struct netgame_info Netgame;
411 extern struct AllNetPlayers_info NetPlayers;
413 int network_i_am_master(void);
414 void change_playernum_to(int new_pnum);
416 //how to encode missiles & flares in weapon packets
417 #define MISSILE_ADJUST 100
418 #define FLARE_ADJUST 127