From: Holger Schemel Date: Sat, 5 Jan 2019 12:29:54 +0000 (+0100) Subject: fixed network games playing empty level files that use level template X-Git-Tag: 4.1.2.0~64 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=0d6a00e7cdcb2f6e9a4eef1fad477e5d4d7282b2;p=rocksndiamonds.git fixed network games playing empty level files that use level template --- diff --git a/src/network.c b/src/network.c index 6c1f4c6d..ded92acf 100644 --- a/src/network.c +++ b/src/network.c @@ -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;