mirror of
https://github.com/p2r3/bareiron.git
synced 2025-10-01 23:25:09 +02:00
add a way to dump world data over the network
This commit is contained in:
14
src/main.c
14
src/main.c
@@ -568,6 +568,20 @@ int main () {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Received BEEF packet, dump world data and disconnect
|
||||||
|
if (recv_buffer[0] == 0xBE && recv_buffer[1] == 0xEF && getClientState(client_fd) == STATE_NONE) {
|
||||||
|
// Send block changes and player data back to back
|
||||||
|
// The client is expected to know (or calculate) the size of these buffers
|
||||||
|
send_all(client_fd, block_changes, sizeof(block_changes));
|
||||||
|
send_all(client_fd, player_data, sizeof(player_data));
|
||||||
|
// Flush the socket and receive everything left on the wire
|
||||||
|
shutdown(client_fd, SHUT_WR);
|
||||||
|
recv_all(client_fd, recv_buffer, sizeof(recv_buffer), false);
|
||||||
|
// Kick the client
|
||||||
|
disconnectClient(&clients[client_index], 6);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Read packet length
|
// Read packet length
|
||||||
int length = readVarInt(client_fd);
|
int length = readVarInt(client_fd);
|
||||||
if (length == VARNUM_ERROR) {
|
if (length == VARNUM_ERROR) {
|
||||||
|
Reference in New Issue
Block a user