diff --git a/source/build/include/build.h b/source/build/include/build.h index c8dea6e4f..d96163691 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -1034,7 +1034,6 @@ int32_t saveboard(const char *filename, const vec3_t *dapos, int16_t daang, in void tileSetupDummy(int32_t tile); void tileSetData(int32_t tile, int32_t tsiz, char const *buffer); -void tileDelete(int32_t tile); void tileSetSize(int32_t picnum, int16_t dasizx, int16_t dasizy); int32_t artReadHeader(buildvfs_kfd fil, char const *fn, artheader_t *local); int32_t artReadHeaderFromBuffer(uint8_t const *buf, artheader_t *local); diff --git a/source/build/src/defs.cpp b/source/build/src/defs.cpp index c70028ac6..f2ea81597 100644 --- a/source/build/src/defs.cpp +++ b/source/build/src/defs.cpp @@ -1027,18 +1027,7 @@ static int32_t defsparser(scriptfile *script) if (check_tile("dummytile", tile, script, cmdtokptr)) break; - if ((int16_t) xsiz == 0 || (int16_t) ysiz == 0) - { - tileDelete(tile); - break; - } - - if (xsiz > 0 && ysiz > 0) - { - tileSetSize(tile, xsiz, ysiz); - picanm[tile] = {}; - tileSetupDummy(tile); - } + tileSetDummy(tile, xsiz, ysiz); break; } @@ -1057,18 +1046,9 @@ static int32_t defsparser(scriptfile *script) if (xsiz < 0 || ysiz < 0) break; // TODO: message - if ((int16_t) xsiz == 0 || (int16_t) ysiz == 0) - { - for (i=tile1; i<=tile2; i++) - tileDelete(i); - break; - } - for (i=tile1; i<=tile2; i++) { - tileSetSize(i, xsiz, ysiz); - picanm[i] = {}; - tileSetupDummy(i); + tileSetDummy(i, xsiz, ysiz); } break; @@ -2281,9 +2261,7 @@ static int32_t defsparser(scriptfile *script) if (xsiz > 0 && ysiz > 0) { - tileSetSize(tile, xsiz, ysiz); - picanm[tile] = {}; - tileSetupDummy(tile); + tileSetDummy(tile, xsiz, ysiz); } #ifdef USE_OPENGL xscale = 1.0f / xscale; diff --git a/source/build/src/tiles.cpp b/source/build/src/tiles.cpp index 1d6e46fc6..e1f41d82d 100644 --- a/source/build/src/tiles.cpp +++ b/source/build/src/tiles.cpp @@ -264,22 +264,6 @@ static void tileSoftDelete(int32_t const tile) picanm[tile] = {}; } -void tileDelete(int32_t const tile) -{ - tileSoftDelete(tile); - - DO_FREE_AND_NULL(faketiledata[tile]); - - vox_undefine(tile); - -#ifdef USE_OPENGL - for (ssize_t i=MAXPALOOKUPS-1; i>=0; --i) - hicclearsubst(tile, i); - - md_undefinetile(tile); -#endif -} - void tileUpdatePicSiz(int32_t picnum) { int j = 15; diff --git a/source/common/textures/buildtiles.cpp b/source/common/textures/buildtiles.cpp index 2c2de9674..c1273c8fa 100644 --- a/source/common/textures/buildtiles.cpp +++ b/source/common/textures/buildtiles.cpp @@ -401,3 +401,38 @@ void BuildFiles::tileSetExternal(int tilenum, int width, int height, uint8_t* da if (buffer) memcpy(buffer, data, width * height); } +//========================================================================== +// +// +// +//========================================================================== + +void tileDelete(int tile) +{ + TileFiles.tiles[tile] = TileFiles.tilesbak[tile] = TileFiles.Placeholder; + vox_undefine(tile); + md_undefinetile(tile); + for (ssize_t i = MAXPALOOKUPS - 1; i >= 0; --i) + hicclearsubst(tile, i); + +} + +//========================================================================== +// +// +// +//========================================================================== + +void tileSetDummy(int tile, int width, int height) +{ + if (width == 0 || height == 0) + { + tileDelete(tile); + } + else if (width > 0 && height > 0) + { + auto dtile = new FDummyTile(width, height); + TileFiles.AddTile(tile, dtile); + } +} + diff --git a/source/common/textures/textures.h b/source/common/textures/textures.h index c6c3fa435..077f44160 100644 --- a/source/common/textures/textures.h +++ b/source/common/textures/textures.h @@ -517,6 +517,8 @@ struct BuildFiles }; +void tileSetDummy(int tile, int width, int height); +void tileDelete(int tile); extern BuildFiles TileFiles; inline bool tileCheck(int num) {