Commit Diff


commit - 433a2ca3503d70d10eb07372e9ff76865d18a6f9
commit + 7d390ed8992106bf3574f65f7fe6ca195c208d07
blob - 1bb6107b13620e0c1d026dc3736b2ffe3efc0e06
blob + b4e9accd02c29f4a684a0a82f6f087ee5cc71dad
--- src/main.c
+++ src/main.c
@@ -568,6 +568,20 @@ int main () {
       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
     int length = readVarInt(client_fd);
     if (length == VARNUM_ERROR) {