// send a squadmsg packet to a player void multi_msg_send_squadmsg_packet(net_player *target,net_player *source,int command,ushort net_sig,int subsys_type) { ubyte data[100]; char s_val; int packet_size; Assert(source != NULL); Assert(target != NULL); if((source == NULL) || (target == NULL)){ return; } // build the header BUILD_HEADER(SQUADMSG_PLAYER); // add the command and targeting data ADD_INT(command); // add the id of the guy sending the order ADD_SHORT(source->player_id); // net signature ADD_USHORT(net_sig); // targeted subsytem (or -1 if none) s_val = (char)subsys_type; ADD_DATA(s_val); // send to the player multi_io_send_reliable(target, data, packet_size); }
// send a broadcast pack indicating a player has respawned void multi_respawn_broadcast(net_player *np) { ubyte data[50],val; int packet_size = 0; ushort signature; vector pos; // broadcast the packet to all players Assert(Net_player->flags & NETINFO_FLAG_AM_MASTER); signature = Objects[np->player->objnum].net_signature; pos = Objects[np->player->objnum].pos; // build the header and add the opcode BUILD_HEADER(RESPAWN_NOTICE); val = RESPAWN_BROADCAST; ADD_DATA(val); // add the data for the respawn ADD_USHORT(signature); add_vector_data( data, &packet_size, pos ); ADD_SHORT(np->player_id); ADD_DATA(np->s_info.cur_primary_bank); ADD_DATA(np->s_info.cur_secondary_bank); ADD_DATA(np->s_info.cur_link_status); ADD_USHORT(np->s_info.ship_ets); ADD_STRING(np->p_info.p_objp->name); Assert( np->s_info.ship_ets != 0 ); // find dave or allender multi_io_send_to_all_reliable(data, packet_size); }
// send a player kick packet void send_player_kick_packet(int player_index, int ban, int reason) { ubyte data[MAX_PACKET_SIZE]; int packet_size = 0; BUILD_HEADER(KICK_PLAYER); // add the address of the player to be kicked ADD_SHORT(Net_players[player_index].player_id); // indicate if he should be banned ADD_INT(ban); ADD_INT(reason); // send the request to the server multi_io_send_reliable(Net_player, data, packet_size); }