1 /* 2 * Copyright (C) Volition, Inc. 1999. All rights reserved. 3 * 4 * All source code herein is the property of Volition, Inc. You may not sell 5 * or otherwise commercially exploit the source or things you created based on the 6 * source. 7 * 8 */ 9 10 11 12 13 #ifndef MULTI_MSGS_H 14 #define MULTI_MSGS_H 15 16 #include "globalincs/pstypes.h" 17 18 #include <cstdint> 19 20 struct net_player; 21 struct net_addr; 22 class object; 23 class ship; 24 struct wing; 25 struct join_request; 26 struct button_info; 27 struct header; 28 struct beam_info; 29 class ship_subsys; 30 struct log_entry; 31 struct beam_fire_info; 32 33 // macros for building up packets -- to save on time and typing. Important to note that local variables 34 // must be named correctly 35 // there are two flavors of sending orientation matrices, 16 bit and 32 bit. Just #define ORIENT_16 to use 36 // 16 bits, otherwise 32 bits is the default 37 38 #define BUILD_HEADER(t) do { data[0]=t; packet_size = HEADER_LENGTH; } while(false) 39 #define ADD_DATA(d) do { Assert((static_cast<size_t>(packet_size) + sizeof(d)) < MAX_PACKET_SIZE); memcpy(data+packet_size, &d, sizeof(d) ); packet_size += sizeof(d); } while (false) 40 #define ADD_DATA_BLOCK(d, len) do { static_assert(std::is_integral<decltype(len)>::value, "ADD_DATA_BLOCK() len is invalid type!"); Assert(len > 0); Assert((packet_size + len) < MAX_PACKET_SIZE); memcpy(data+packet_size, d, static_cast<size_t>(len)); packet_size += len; } while (false) 41 #define ADD_SHORT(d) do { static_assert(sizeof(d) == sizeof(std::int16_t), "Size of short is not right!"); Assert((static_cast<size_t>(packet_size) + sizeof(d)) < MAX_PACKET_SIZE); short swap = INTEL_SHORT(d); memcpy(data+packet_size, &swap, sizeof(d) ); packet_size += sizeof(d); } while (false) 42 #define ADD_USHORT(d) do { static_assert(sizeof(d) == sizeof(std::uint16_t), "Size of unsigned short is not right!"); Assert((static_cast<size_t>(packet_size) + sizeof(d)) < MAX_PACKET_SIZE); ushort swap = INTEL_SHORT(d); memcpy(data+packet_size, &swap, sizeof(d) ); packet_size += sizeof(d); } while (false) 43 #define ADD_INT(d) do { static_assert(sizeof(d) == sizeof(std::int32_t), "Size of int is not right!"); Assert((static_cast<size_t>(packet_size) + sizeof(d)) < MAX_PACKET_SIZE); int swap = INTEL_INT(d); memcpy(data+packet_size, &swap, sizeof(d) ); packet_size += sizeof(d); } while (false) 44 #define ADD_UINT(d) do { static_assert(sizeof(d) == sizeof(std::uint32_t), "Size of unsigned int is not right!"); Assert((static_cast<size_t>(packet_size) + sizeof(d)) < MAX_PACKET_SIZE); uint swap = INTEL_INT(d); memcpy(data+packet_size, &swap, sizeof(d) ); packet_size += sizeof(d); } while (false) 45 #define ADD_ULONG(d) do { static_assert(sizeof(d) == sizeof(std::uint64_t), "Size of unsigned long is not right!"); Assert((static_cast<size_t>(packet_size) + sizeof(d)) < MAX_PACKET_SIZE); std::uint64_t swap = INTEL_LONG(d); memcpy(data+packet_size, &swap, sizeof(d) ); packet_size += sizeof(d); } while (false) 46 #define ADD_FLOAT(d) do { Assert((static_cast<size_t>(packet_size) + sizeof(d)) < MAX_PACKET_SIZE); float swap = INTEL_FLOAT(&d); memcpy(data+packet_size, &swap, sizeof(d) ); packet_size += sizeof(d); } while (false) 47 #define ADD_STRING(s) do { Assert((static_cast<size_t>(packet_size) + strlen(s) + sizeof(uint8_t)) < MAX_PACKET_SIZE); Assert(strlen(s) <= UINT8_MAX); uint8_t len = static_cast<uint8_t>(strlen(s)); ADD_DATA(len); memcpy(data+packet_size, s, len); packet_size += len; } while (false) 48 #define ADD_STRING_16(s) do { Assert((static_cast<size_t>(packet_size) + strlen(s) + sizeof(uint16_t)) < MAX_PACKET_SIZE); uint16_t len = static_cast<uint16_t>(strlen(s)); ADD_USHORT(len); memcpy(data+packet_size, s, static_cast<size_t>(len)); packet_size += len; } while (false) 49 #define ADD_STRING_32(s) do { Assert((static_cast<size_t>(packet_size) + strlen(s) + sizeof(int32_t)) < MAX_PACKET_SIZE); int32_t len = static_cast<int32_t>(strlen(s)); ADD_INT(len); memcpy(data+packet_size, s, static_cast<size_t>(len)); packet_size += len; } while (false) 50 #define ADD_ORIENT(d) { Assert((packet_size + 17) < MAX_PACKET_SIZE); ubyte dt[17]; multi_pack_orient_matrix(dt,&d); memcpy(data+packet_size,dt,17); packet_size += 17; } 51 #define ADD_VECTOR(d) do { vec3d tmpvec = ZERO_VECTOR; tmpvec.xyz.x = INTEL_FLOAT(&d.xyz.x); tmpvec.xyz.y = INTEL_FLOAT(&d.xyz.y); tmpvec.xyz.z = INTEL_FLOAT(&d.xyz.z); ADD_DATA(tmpvec); } while(false) 52 53 #define GET_DATA(d) do { memcpy(&d, data+offset, sizeof(d) ); offset += sizeof(d); } while(false) 54 #define GET_DATA_BLOCK(d, len) do { static_assert(std::is_array<decltype(d)>::value, "GET_DATA_BLOCK() must point to an array!"); static_assert(std::is_integral<decltype(len)>::value, "GET_DATA_BLOCK() len is invalid type!"); Assert(len > 0); const auto d_len = std::min(static_cast<size_t>(len), sizeof(d)); memcpy(d, data+offset, d_len); offset += len; } while (false) 55 #define GET_SHORT(d) do { std::int16_t swap; memcpy(&swap, data+offset, sizeof(d) ); d = INTEL_SHORT(swap); offset += sizeof(d); } while(false) 56 #define GET_USHORT(d) do { std::uint16_t swap; memcpy(&swap, data+offset, sizeof(d) ); d = INTEL_SHORT(swap); offset += sizeof(d); } while(false) 57 #define GET_INT(d) do { std::int32_t swap; memcpy(&swap, data+offset, sizeof(d) ); d = INTEL_INT(swap); offset += sizeof(d); } while(false) 58 #define GET_UINT(d) do { std::uint32_t swap; memcpy(&swap, data+offset, sizeof(d) ); d = INTEL_INT(swap); offset += sizeof(d); } while(false) 59 #define GET_ULONG(d) do { std::uint64_t swap; memcpy(&swap, data+offset, sizeof(d) ); d = INTEL_LONG(swap); offset += sizeof(d); } while(false) 60 #define GET_FLOAT(d) do { float swap; memcpy(&swap, data+offset, sizeof(d) ); d = INTEL_FLOAT(&swap); offset += sizeof(d); } while(false) 61 #define GET_STRING(s) do { static_assert(std::is_array<decltype(s)>::value, "GET_STRING() must point to an array!"); uint8_t len; memcpy(&len, data+offset, sizeof(len)); offset += sizeof(len); const auto s_len = std::min(static_cast<size_t>(len), sizeof(s)-1); memcpy(s, data+offset, s_len); offset += len; s[s_len] = '\0'; } while (false) 62 #define GET_STRING_16(s) do { static_assert(std::is_array<decltype(s)>::value, "GET_STRING_16() must point to an array!"); uint16_t len; GET_USHORT(len); const auto s_len = std::min(static_cast<size_t>(len), sizeof(s)-1); memcpy(s, data+offset, s_len); offset += len; s[s_len] = '\0'; } while (false) 63 #define GET_STRING_32(s) do { static_assert(std::is_array<decltype(s)>::value, "GET_STRING_32() must point to an array!"); int32_t len; GET_INT(len); const auto s_len = std::min(static_cast<size_t>(len), sizeof(s)-1); memcpy(s, data+offset, s_len); offset += len; s[s_len] = '\0'; } while (false) 64 #define GET_ORIENT(d) { ubyte dt[17]; memcpy(dt,data+offset,17); offset+=17; multi_unpack_orient_matrix(dt,&d); } 65 #define GET_VECTOR(d) do { vec3d tmpvec = ZERO_VECTOR; GET_DATA(tmpvec); d.xyz.x = INTEL_FLOAT(&tmpvec.xyz.x); d.xyz.y = INTEL_FLOAT(&tmpvec.xyz.y); d.xyz.z = INTEL_FLOAT(&tmpvec.xyz.z); } while(false) 66 67 #define PACKET_SET_SIZE() do { hinfo->bytes_processed = offset; } while(false) 68 69 // defines for weapon status changes. 70 #define MULTI_PRIMARY_CHANGED 1 71 #define MULTI_SECONDARY_CHANGED 2 72 73 // data sending wrappers 74 75 // send the specified data packet to all players 76 void multi_io_send(net_player *pl, ubyte *data, int length); 77 void multi_io_send_to_all(ubyte *data, int length, net_player *ignore = NULL); 78 void multi_io_send_force(net_player *pl); 79 80 // send the data packet to all players via their reliable sockets 81 void multi_io_send_reliable(net_player *pl, ubyte *data, int length); 82 void multi_io_send_to_all_reliable(ubyte* data, int length, net_player *ignore = NULL); 83 void multi_io_send_reliable_force(net_player *pl); 84 85 // send all buffered packets 86 void multi_io_send_buffered_packets(); 87 88 89 // packet handlers ------------------------------------------------------------------------------- 90 91 // process an incoming join request packet 92 void process_join_packet( ubyte* data, header* hinfo ); 93 94 // process an accept packet from the server 95 void process_accept_packet( ubyte* data, header* hinfo ); 96 97 // process a notification for a new player who has joined the game 98 void process_new_player_packet(ubyte* data, header* hinfo); 99 100 // process an incoming hud message packet 101 void process_hud_message(ubyte* data, header* hinfo); 102 103 // process a notification the a player has left the game 104 void process_leave_game_packet(ubyte* data, header* hinfo); 105 106 // process information about an active game 107 void process_game_active_packet(ubyte* data, header* hinfo); 108 109 // process a query from a client looking for active freespace games 110 void process_game_query(ubyte* data, header* hinfo); 111 112 // process a general game chat packet, if we're the standalone we should rebroadcast 113 void process_game_chat_packet( ubyte *data, header *hinfo ); 114 115 // process a game information update 116 void process_game_info_packet( ubyte *data, header *hinfo ); 117 118 // process a packet indicating a secondary weapon was fired 119 void process_secondary_fired_packet(ubyte* data, header* hinfo, int flag); 120 121 // process a packet indicating a countermeasure was fired 122 void process_countermeasure_fired_packet( ubyte *data, header *hinfo ); 123 124 // process information about the netgame sent from the server/host 125 void process_netgame_update_packet( ubyte *data, header *hinfo ); 126 127 // process an incoming netgame description packet 128 void process_netgame_descript_packet( ubyte *data, header *hinfo ); 129 130 // process an incoming netplayer state update. if we're the server, we should rebroadcast 131 void process_netplayer_update_packet( ubyte *data, header *hinfo ); 132 133 void process_ship_status_packet(ubyte *data, header *hinfo); 134 void process_player_order_packet(ubyte *data, header *hinfo); 135 136 // process an object update packet. See send_object_update for information on how 137 // this packet data should be interpreted. We send different information depending on 138 // on several variables (no change in orienation, etc). 139 void process_object_update_packet( ubyte *data, header *hinfo ); 140 141 // process a packet indicating that a ship has been killed 142 void process_ship_kill_packet( ubyte *data, header *hinfo ); 143 144 // process a packet saying that a wing should be created 145 void process_wing_create_packet( ubyte *data, header *hinfo ); 146 147 // process a packet indicating a ship should be created 148 void process_ship_create_packet( ubyte *data, header *hinfo ); 149 150 // process a packet indicating a ship is departing 151 void process_ship_depart_packet( ubyte *data, header *hinfo ); 152 153 // process a mission log item packet 154 void process_mission_log_packet( ubyte *data, header *hinfo ); 155 156 // process a mission message packet 157 void process_mission_message_packet( ubyte *data, header *hinfo ); 158 159 // just send them a pong back as fast as possible 160 void process_ping_packet(ubyte *data, header *hinfo); 161 162 // right now it just routes the pong through to the standalone gui, which is the only 163 // system which uses ping and pong right now. 164 void process_pong_packet(ubyte *data, header *hinfo); 165 166 // process a request for a list of missions 167 void process_mission_request_packet(ubyte *data, header *hinfo); 168 169 // process an individual mission file item 170 void process_mission_item_packet(ubyte *data, header *hinfo); 171 172 // process a pause update packet (pause, unpause, etc) 173 void process_multi_pause_packet(ubyte *data, header *hinfo); 174 175 // process an ingame nak packet 176 void process_ingame_nak(ubyte *data, header *hinfo); 177 178 void process_ingame_ships_packet(ubyte *data, header *hinfo); 179 void process_ingame_wings_packet(ubyte *data, header *hinfo); 180 181 // process a packet indicating we should end the current mission 182 void process_endgame_packet(ubyte *data, header *hinfo); 183 184 // process a packet indicating we should jump straight to the debrief screen 185 void process_force_end_mission_packet(ubyte *data, header *hinfo); 186 187 // process a position/orientation update from an observer 188 void process_observer_update_packet(ubyte *data, header *hinfo); 189 190 void process_netplayer_slot_packet(ubyte *data, header *hinfo); 191 void process_netplayer_class_packet(ubyte *data, header *hinfo); 192 193 void process_subsys_update_packet(ubyte *data, header *hinfo); 194 195 void process_ingame_ship_update_packet(ubyte *data, header *hinfo); 196 197 void process_file_sig_packet(ubyte *data, header *hinfo); 198 void process_file_sig_request(ubyte *data, header *hinfo); 199 200 void process_ingame_respawn_points_packet(ubyte *data, header *hinfo); 201 202 void process_subsystem_destroyed_packet( ubyte *data, header *hinfo ); 203 204 void process_netplayer_load_packet(ubyte *data, header *hinfo); 205 206 void process_jump_into_mission_packet(ubyte *data, header *hinfo); 207 208 void process_repair_info_packet(ubyte *data, header *hinfo); 209 210 void process_mission_sync_packet(ubyte *data, header *hinfo); 211 212 void process_store_stats_packet(ubyte *data, header *hinfo); 213 214 void process_debris_update_packet(ubyte *data, header *hinfo); 215 216 void process_ship_weapon_state_packet(ubyte *data, header *hinfo ); 217 void process_ship_weapon_change( ubyte *data, header *hinfo ); 218 219 void process_firing_info_packet( ubyte *data, header *hinfo ); 220 221 // process a cargo revealed packet 222 void process_cargo_revealed_packet( ubyte *data, header *hinfo ); 223 224 void process_subsystem_cargo_revealed_packet( ubyte *data, header *hinfo ); 225 226 void process_cargo_hidden_packet( ubyte *data, header *hinfo ); 227 228 void process_subsystem_cargo_hidden_packet( ubyte *data, header *hinfo ); 229 230 void process_mission_goal_info_packet( ubyte *data, header *hinfo ); 231 232 void process_player_kick_packet(ubyte *data, header *hinfo); 233 234 void process_player_settings_packet(ubyte *data, header *hinfo); 235 236 void process_deny_packet(ubyte *data, header *hinfo); 237 238 void process_post_sync_data_packet(ubyte *data, header *hinfo); 239 240 void process_wss_slots_data_packet(ubyte *data, header *hinfo); 241 242 void process_shield_explosion_packet( ubyte *data, header *hinfo ); 243 244 void process_player_stats_block_packet(ubyte *data, header *hinfo); 245 246 void process_host_restr_packet(ubyte *data, header *hinfo); 247 248 void process_netgame_end_error_packet(ubyte *data, header *hinfo); 249 250 void process_client_update_packet(ubyte *data, header *hinfo); 251 252 void process_countdown_packet(ubyte *data, header *hinfo); 253 254 // send a join packet request to the specified address (should be a server) 255 void send_join_packet(net_addr* addr,join_request *jr); 256 257 // send an accept packet to a client in response to a request to join the game 258 void send_accept_packet(int new_player_num, int code, int ingame_join_team = -1); 259 260 // send a general game chat packet (if msg_mode == MULTI_MSG_TARGET, need to pass in "to", if == MULTI_MSG_EXPR, need to pass in expr) 261 void send_game_chat_packet(net_player *from, const char *msg, int msg_mode, net_player *to = nullptr, const char *expr = nullptr, ubyte server_msg = 0); 262 263 // send a game information update 264 void send_game_info_packet( void ); 265 266 // send a notice that the player at net_addr is leaving (if target is NULL, the broadcast the packet) 267 void send_leave_game_packet(short player_id = -1,int kicked_reason = -1,net_player *target = NULL); 268 269 // send a packet indicating a secondary weapon was fired 270 void send_secondary_fired_packet( ship *shipp, ushort starting_sig, int starting_count, int num_fired, int allow_swarm ); 271 272 // send a packet indicating a countermeasure was fired 273 void send_countermeasure_fired_packet( object *objp, int cmeasure_count, int rand_val ); 274 275 276 277 // send_game_update_packet sends an updated Netgame structure to all players currently connected. The update 278 // is used to change the current mission, current state, etc. 279 void send_netgame_update_packet(net_player *pl = nullptr, const bool interval = false); 280 281 // sends information about netplayers in the game. if called on the server, broadcasts information about _all_ players 282 void send_netplayer_update_packet( net_player *pl = NULL ); 283 284 void send_ship_status_packet(net_player *pl, button_info *bi, int id); 285 void send_player_order_packet(int type, int index, int command); 286 287 // send a request or a reply for mission description, if code == 0, request, if code == 1, reply 288 void send_netgame_descript_packet(net_addr *addr, int code); 289 290 // send object update packet sends object updates for all objects in the game. This function will be smart 291 // about sending only certain objects to certain players based on the players distance from an object, whether 292 // the object is behind the player, etc. 293 void send_object_update_packet(int force_all = 0); 294 295 // send a packet indicating a ship has been killed 296 void send_ship_kill_packet( object *ship_obj, object *other_objp, float percent_killed, int self_destruct ); 297 298 // send a packet indicating that a missile died. 299 void send_missile_kill_packet(object* objp); 300 301 void process_weapon_kill_packet(ubyte* data, header* hinfo); 302 303 // send a packet indicating a wing of ships should be created 304 void send_wing_create_packet( wing *wingp, int num_to_create, int pre_create_count ); 305 306 // send a packet indicating a ship should be created 307 void send_ship_create_packet(object *objp, bool is_support = false ); 308 309 // packet indicating a ship is departing 310 void send_ship_depart_packet( object *objp, int method = -1 ); 311 312 // send a mission log item packet 313 void send_mission_log_packet( log_entry* entry ); 314 315 // send a mission message packet 316 void send_mission_message_packet(int id, const char *who_from, int priority, int timing, int source, int builtin_type, int multi_target, int multi_team_filter, int delay = 0, int event_num_to_cancel = -1); 317 318 // broadcast a query for active games. TCP will either request from the MT or from the specified list 319 void broadcast_game_query(); 320 321 // send an individual query to an address to see if there is an active game 322 void send_server_query(net_addr *addr); 323 324 // broadcast a hud message to all players 325 void send_hud_msg_to_all( char* msg ); 326 void send_heartbeat(); 327 328 // send a ping packet 329 void send_ping(net_addr *addr); 330 331 // send a pong packet 332 void send_pong(net_addr *addr); 333 334 // sent from host to master. give me the list of missions you have. 335 // this will be used only in a standalone mode 336 void send_mission_list_request( int what ); 337 338 // send an individual mission file item 339 void send_mission_item(net_player *pl,char *file_name,char *mission_name); 340 341 // send a request to the server to pause or unpause the game 342 void send_multi_pause_packet(int pause); 343 344 // send an ack packet 345 void send_ingame_ack(int state,net_player *p); 346 347 // send an ingame nak packet 348 void send_ingame_nak(int state,net_player *p); 349 350 void send_ingame_ships_packet(net_player *pl); 351 void send_ingame_wings_packet(net_player *pl); 352 353 // send a notification that a new player has joined the game (if target != NULL, broadcast the packet) 354 void send_new_player_packet(int new_player_num,net_player *target); 355 356 // send a packet telling players to end the mission 357 void send_endgame_packet(net_player *pl = NULL); 358 359 // send a skip to debrief item packet 360 void send_force_end_mission_packet(); 361 362 // send a position/orientation update for myself (if I'm an observer) 363 void send_observer_update_packet(); 364 365 void send_netplayer_slot_packet(); 366 367 void send_subsys_update_packet(net_player *p); 368 369 void send_ingame_ship_update_packet(net_player *p,ship *sp); 370 371 void send_ingame_final_packet(int net_sig); 372 373 void send_file_sig_packet(ushort sum_sig,int length_sig); 374 void send_file_sig_request(char *file_name); 375 376 void send_subsystem_destroyed_packet( ship *shipp, int index, vec3d worldpos ); 377 378 void send_netplayer_load_packet(net_player *pl); 379 380 void send_jump_into_mission_packet(net_player *pl = NULL); 381 382 void send_repair_info_packet(object *repaired_objp, object *repair_objp, int code ); 383 384 void send_mission_sync_packet(int mode,int start_campaign = 0); 385 386 void send_store_stats_packet(int accept); 387 388 void send_debris_create_packet(object *objp, ushort net_signature, int model_num, vec3d exp_center ); 389 void send_debris_update_packet(object *objp,int code); 390 391 void send_ship_weapon_change( ship *shipp, int what, int new_bank, int link_status ); 392 393 // ALAN BEGIN 394 395 // send a request from the client to the host of the game (which is not necessarily the server in the case of the standalone) 396 // mode == WSS_WEAPON_SELECT or WSS_SHIP_SELECT 397 void send_wss_request_packet(short player_id, int from_slot,int from_index, int to_slot, int to_index, int wl_ship_slot, int ship_class, int mode,net_player *p = NULL); 398 void process_wss_request_packet(ubyte *data, header *hinfo); 399 400 // send the update from the host to the clients 401 // wss_data is the pointer to a block of data returned by store_wss_stuff(...) 402 // 403 // I would reccomend : 404 // int store_wss_data(ubyte *block); // which returns bytes processed 405 // 406 // so you would say : 407 // 408 // ubyte block[MAX_PACKET_SIZE - 10 or so]; 409 // int processed = store_wss_data(block); 410 // send_wss_update_packet(block,processed); 411 // 412 // also : 413 // I would reccomend : 414 // int restore_wss_data(ubyte *block); // which returns bytes processed 415 // 416 // so I would say in the process_wss_update_packet() : 417 // 418 // int processed = restore_wss_data(block); 419 // do_other_lowlevel_packet_related_stuff_here(); 420 // 421 void send_wss_update_packet(int team_num,ubyte *wss_data,int size); 422 void process_wss_update_packet(ubyte *data, header *hinfo); 423 // ALAN END 424 425 void send_firing_info_packet(void); 426 427 void send_sh_transfer_complete_packet(int code); 428 429 // packet to tell clients cargo of a ship was revealed to all 430 void send_cargo_revealed_packet(ship *shipp); 431 432 void send_subsystem_cargo_revealed_packet(ship *shipp, int index); 433 434 void send_cargo_hidden_packet(ship *shipp); 435 436 void send_subsystem_cargo_hidden_packet(ship *shipp, int index); 437 438 void send_mission_goal_info_packet(int goal_num, int new_status, int valid); 439 440 void send_player_settings_packet(net_player *p = NULL); 441 442 void send_deny_packet(net_addr *addr, int code); 443 444 void send_post_sync_data_packet(net_player *p = NULL, int std_request = 1); 445 446 void send_wss_slots_data_packet(int team_num, int final, net_player *p = NULL, int std_request = 1); 447 448 void send_shield_explosion_packet(int objnum, int tri_num, vec3d hit_pos); 449 450 void send_player_stats_block_packet(net_player *pl, int stats_type, net_player *target = nullptr, const int offset = 0, const int count = 0); 451 452 void send_host_restr_packet(const char *callsign, int code, int mode); 453 454 void send_netgame_end_error_packet(int notify_code, int err_code); 455 456 void send_client_update_packet(net_player *pl); 457 458 // send information about this currently active game to the specified address 459 void send_game_active_packet(net_addr* addr); 460 461 void send_ai_info_update_packet(object *objp, char what, object * other_objp = NULL); 462 void process_ai_info_update_packet(ubyte *data, header *hinfo); 463 464 void send_asteroid_create(object *new_objp, object *parent_objp, int asteroid_type, vec3d *relvec); 465 void send_asteroid_throw(object *objp); 466 void send_asteroid_hit(object *objp, object *other_objp, vec3d *hitpos, float damage); 467 void process_asteroid_info(ubyte *data, header *hinfo); 468 469 void send_countermeasure_success_packet(int objnum); 470 void process_countermeasure_success_packet(ubyte *data, header *hinfo); 471 472 // host sends a -1 to the server to begin the countdown. server sends an int "seconds until start" 473 void send_countdown_packet(int time); 474 475 void send_debrief_info(int stage_count[], int *stage_active[]); 476 void process_debrief_info(ubyte *data, header *hinfo); 477 478 void send_accept_player_data(net_player *npp, int is_ingame); 479 void process_accept_player_data(ubyte *data, header *hinfo); 480 481 void send_homing_weapon_info(int num); 482 void process_homing_weapon_info(ubyte *data, header *hinfo); 483 484 // emp effect stuff 485 void send_emp_effect(ushort net_sig, float intensity, float time); 486 void process_emp_effect(ubyte *data, header *hinfo); 487 488 // for reinforcements 489 void send_reinforcement_avail( int rnum ); 490 void process_reinforcement_avail( ubyte *data, header *hinfo ); 491 492 // for basic server shots to clients 493 void send_NEW_primary_fired_packet(ship* shipp, int banks_fired); 494 void process_NEW_primary_fired_packet(ubyte* data, header* hinfo); 495 496 // new primary fired info 497 void send_non_homing_fired_packet(ship *shipp, int banks_fired, bool secondary = false); 498 void process_non_homing_fired_packet(ubyte *data, header *hinfo); 499 500 // new countermeasure fired info 501 void send_NEW_countermeasure_fired_packet(object *objp, int cmeasure_count, int rand_val); 502 void process_NEW_countermeasure_fired_packet(ubyte *data, header *hinfo); 503 504 // beam weapon packet 505 void send_beam_fired_packet(const beam_fire_info *fire_info, const beam_info *override); 506 507 void process_beam_fired_packet(ubyte *data, header *hinfo); 508 509 // sw std query packet 510 void send_sw_query_packet(ubyte code, char *txt); 511 void process_sw_query_packet(ubyte *data, header *hinfo); 512 513 // event update packet 514 void send_event_update_packet(int event); 515 void process_event_update_packet(ubyte *data, header *hinfo); 516 517 // variable update packet 518 void send_variable_update_packet(int variable_index, char *value); 519 void process_variable_update_packet( ubyte *data, header *hinfo); 520 521 // weapon detonate packet 522 void send_weapon_detonate_packet(object *objp); 523 void process_weapon_detonate_packet(ubyte *data, header *hinfo); 524 525 // turret fired packet 526 void send_turret_fired_packet( int objnum, int subsys_index, int weapon_objnum ); 527 void process_turret_fired_packet( ubyte *data, header *hinfo ); 528 529 // flak fired packet 530 void send_flak_fired_packet(int ship_objnum, int subsys_index, int weapon_objnum, float flak_range); 531 void process_flak_fired_packet(ubyte *data, header *hinfo); 532 533 // player pain packet 534 void send_player_pain_packet(net_player *pl, int weapon_info_index, float damage, vec3d *force, vec3d *hitpos, int quadrant_num); 535 void process_player_pain_packet(ubyte *data, header *hinfo); 536 537 // lightning packet 538 void send_lightning_packet(int bolt_type_internal, vec3d *start, vec3d *strike); 539 void process_lightning_packet(ubyte *data, header *hinfo); 540 541 // bytes sent 542 void send_bytes_recvd_packet(net_player *pl); 543 void process_bytes_recvd_packet(ubyte *data, header *hinfo); 544 545 // host transfer 546 void send_host_captain_change_packet(short player_id, bool captain_change); 547 void process_host_captain_change_packet(ubyte *data, header *hinfo); 548 549 // self destruct 550 void send_self_destruct_packet(); 551 void process_self_destruct_packet(ubyte *data, header *hinfo); 552 553 void send_sexp_packet(ubyte *sexp_packet, int num_ubytes); 554 void process_sexp_packet(ubyte *data, header *hinfo); 555 556 #endif 557