From: fgsfds Date: Tue, 6 Apr 2021 15:56:33 +0000 (+0300) Subject: don't write empty blocks (by deaddoomer) X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=f177fb5c59af3153886d2ce1e8ffad33201d5d25;p=d2df-sdl.git don't write empty blocks (by deaddoomer) --- diff --git a/src/tools/png2map/png2map.c b/src/tools/png2map/png2map.c index ee17a60..c0188e2 100644 --- a/src/tools/png2map/png2map.c +++ b/src/tools/png2map/png2map.c @@ -218,17 +218,21 @@ int map_save(const char *fname) { fwrite(&blk, sizeof(blk), 1, fout); fwrite(&hdr, sizeof(hdr), 1, fout); - blk.type = MBLK_TEXTURES; - blk.size = sizeof(map_texture_t) * map_numtex; - fwrite(&blk, sizeof(blk), 1, fout); - for (int i = 0; i < map_numtex; ++i) - fwrite(map_tex + i, sizeof(map_texture_t), 1, fout); + if (map_numtex > 0) { + blk.type = MBLK_TEXTURES; + blk.size = sizeof(map_texture_t) * map_numtex; + fwrite(&blk, sizeof(blk), 1, fout); + for (int i = 0; i < map_numtex; ++i) + fwrite(map_tex + i, sizeof(map_texture_t), 1, fout); + } - blk.type = MBLK_PANELS; - blk.size = sizeof(map_panel_t) * map_numpan; - fwrite(&blk, sizeof(blk), 1, fout); - for (int i = 0; i < map_numpan; ++i) - fwrite(map_pan + i, sizeof(map_panel_t), 1, fout); + if (map_numpan > 0) { + blk.type = MBLK_PANELS; + blk.size = sizeof(map_panel_t) * map_numpan; + fwrite(&blk, sizeof(blk), 1, fout); + for (int i = 0; i < map_numpan; ++i) + fwrite(map_pan + i, sizeof(map_panel_t), 1, fout); + } blk.type = MBLK_NONE; blk.size = 0;