static void NET_SV_SendWaitingData(net_client_t *client) { net_waitdata_t wait_data; net_packet_t *packet; net_client_t *controller; int i; NET_SV_AssignPlayers(); controller = NET_SV_Controller(); wait_data.num_players = NET_SV_NumPlayers(); wait_data.num_drones = NET_SV_NumDrones(); wait_data.ready_players = NET_SV_NumReadyPlayers(); wait_data.max_players = NET_SV_MaxPlayers(); wait_data.is_controller = (client == controller); wait_data.consoleplayer = client->player_number; // Send the WAD and dehacked checksums of the controlling client. // If no controller found (?), send the details that the client // is expecting anyway. if (controller == NULL) { controller = client; } memcpy(&wait_data.wad_sha1sum, &controller->wad_sha1sum, sizeof(sha1_digest_t)); memcpy(&wait_data.deh_sha1sum, &controller->deh_sha1sum, sizeof(sha1_digest_t)); wait_data.is_freedoom = controller->is_freedoom; // set name and address of each player: for (i = 0; i < wait_data.num_players; ++i) { M_StringCopy(wait_data.player_names[i], sv_players[i]->name, MAXPLAYERNAME); M_StringCopy(wait_data.player_addrs[i], NET_AddrToString(sv_players[i]->addr), MAXPLAYERNAME); } // Construct packet: packet = NET_NewPacket(10); NET_WriteInt16(packet, NET_PACKET_TYPE_WAITING_DATA); NET_WriteWaitData(packet, &wait_data); // Send packet to client and free NET_Conn_SendPacket(&client->connection, packet); NET_FreePacket(packet); }
static void NET_SV_SendWaitingData(net_client_t *client) { net_packet_t *packet; net_client_t *controller; int num_players; int i; NET_SV_AssignPlayers(); controller = NET_SV_Controller(); num_players = NET_SV_NumPlayers(); // time to send the client another status packet packet = NET_NewPacket(10); NET_WriteInt16(packet, NET_PACKET_TYPE_WAITING_DATA); // include the number of players waiting NET_WriteInt8(packet, num_players); // send the number of drone clients NET_WriteInt8(packet, NET_SV_NumDrones()); // indicate whether the client is the controller NET_WriteInt8(packet, client == controller); // send the player number of this client NET_WriteInt8(packet, client->player_number); // send the addresses of all players for (i=0; i<num_players; ++i) { char *addr; // name NET_WriteString(packet, sv_players[i]->name); // address addr = NET_AddrToString(sv_players[i]->addr); NET_WriteString(packet, addr); } // Send the WAD and dehacked checksums of the controlling client. if (controller != NULL) { NET_WriteMD5Sum(packet, controller->wad_md5sum); NET_WriteMD5Sum(packet, controller->deh_md5sum); NET_WriteInt8(packet, controller->is_freedoom); } else { NET_WriteMD5Sum(packet, client->wad_md5sum); NET_WriteMD5Sum(packet, client->deh_md5sum); NET_WriteInt8(packet, client->is_freedoom); } // send packet to client and free NET_Conn_SendPacket(&client->connection, packet); NET_FreePacket(packet); }