added missing cave buffer offsets to robot wheel position
[rocksndiamonds.git] / src / network.c
index 6c1f4c6de4d1bd5d91674188fed45a725eb845cb..25108000ba44d12a0dd2d04925282b47a35d4cae 100644 (file)
@@ -221,7 +221,7 @@ boolean ConnectToServer(char *hostname, int port)
       Error(ERR_EXIT, "SDLNet_AllocSocketSet() failed: %s"), SDLNet_GetError();
 
     udp = SDLNet_UDP_Open(0);
-    if(!udp)
+    if (!udp)
       Error(ERR_EXIT, "SDLNet_UDP_Open() failed: %s", SDLNet_GetError());
 
     if (SDLNet_UDP_AddSocket(udp_socket_set, udp) == -1)
@@ -870,7 +870,11 @@ static void Handle_OP_LEVEL_FILE(void)
   if (hasPathSeparator(file_info->basename))
     Error(ERR_EXIT, "protocol error: invalid filename from network client");
 
-  getNetworkBufferFile(read_buffer, file_info->filename);
+  int num_bytes = getNetworkBufferFile(read_buffer, file_info->filename);
+
+  // if received level file is empty, remove it (as being non-existent)
+  if (num_bytes == 0)
+    remove(file_info->filename);
 
   use_custom_template = getNetworkBuffer8BitInteger(read_buffer);
   if (use_custom_template)
@@ -884,6 +888,10 @@ static void Handle_OP_LEVEL_FILE(void)
       Error(ERR_EXIT, "protocol error: invalid filename from network client");
 
     getNetworkBufferFile(read_buffer, tmpl_info->filename);
+
+    // if received level file is empty, use level template file instead
+    if (num_bytes == 0)
+      setString(&file_info->filename,  tmpl_info->filename);
   }
 
   network_level.leveldir_identifier = leveldir_identifier;