diff --git a/source/build/include/build.h b/source/build/include/build.h index 9d513134d..02467aff6 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -795,10 +795,6 @@ EXTERN int16_t headspritesect[MAXSECTORS+1], headspritestat[MAXSTATUS+1]; EXTERN int16_t prevspritesect[MAXSPRITES], prevspritestat[MAXSPRITES]; EXTERN int16_t nextspritesect[MAXSPRITES], nextspritestat[MAXSPRITES]; -extern const vec2_16_t * const tilesiz; -extern const uint8_t * const picsiz; -EXTERN uint8_t walock[MAXTILES]; - extern const char pow2char_[]; static CONSTEXPR const int32_t pow2long[32] = { @@ -812,9 +808,6 @@ static CONSTEXPR const int32_t pow2long[32] = 268435456, 536870912, 1073741824, 2147483647 }; -EXTERN picanm_t picanm[MAXTILES]; -EXTERN rottile_t rottile[MAXTILES]; - EXTERN int32_t windowpos, windowx, windowy; //These variables are for auto-mapping with the draw2dscreen function. @@ -839,12 +832,6 @@ EXTERN char gotsector[(MAXSECTORS+7)>>3]; EXTERN char editorcolors[256]; -EXTERN char faketile[(MAXTILES+7)>>3]; -EXTERN char *faketiledata[MAXTILES]; - -EXTERN char spritecol2d[MAXTILES][2]; -EXTERN uint8_t tilecols[MAXTILES]; - EXTERN char editwall[(MAXWALLS+7)>>3]; extern uint8_t vgapal16[4*256]; diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index 68a3e2f0d..a501d2c49 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -8463,7 +8463,6 @@ int32_t renderDrawRoomsQ16(int32_t daposx, int32_t daposy, int32_t daposz, RotTile(tile.newtile).owner = w.picnum+animateoffs(w.picnum,16384); - auto &siz = tilesiz[w.picnum+animateoffs(w.picnum,16384)]; } } } diff --git a/source/build/src/engine_priv.h b/source/build/src/engine_priv.h index 90f3bbc0a..4383a5553 100644 --- a/source/build/src/engine_priv.h +++ b/source/build/src/engine_priv.h @@ -122,7 +122,6 @@ extern int16_t searchbottomwall, searchisbottom; extern char inpreparemirror; -extern const uint8_t * const picsiz; extern int16_t sectorborder[256]; extern int32_t qsetmode; extern int32_t hitallsprites; @@ -245,8 +244,8 @@ template static FORCE_INLINE void tileUpdatePicnum(T * const tilept if (picanm[tile].sf & PICANM_ANIMTYPE_MASK) tile += animateoffs(tile, obj); - if (((obj & 16384) == 16384) && (globalorientation & CSTAT_WALL_ROTATE_90) && rottile[tile].newtile != -1) - tile = rottile[tile].newtile; + if (((obj & 16384) == 16384) && (globalorientation & CSTAT_WALL_ROTATE_90) && RotTile(tile).newtile != -1) + tile = RotTile(tile).newtile; } #endif /* ENGINE_PRIV_H */ diff --git a/source/build/src/tiles.cpp b/source/build/src/tiles.cpp index 269cf9131..563808399 100644 --- a/source/build/src/tiles.cpp +++ b/source/build/src/tiles.cpp @@ -16,16 +16,8 @@ #include "vfs.h" -static int32_t tilefileoffs[MAXTILES]; - -vec2_16_t tilesizearray[MAXTILES]; -uint8_t picsizearray[MAXTILES]; -// These may only be manipulated through a function interface so that the backing texture objects can be adjusted or replaced. -const vec2_16_t* const tilesiz = tilesizearray; -const uint8_t* const picsiz = picsizearray; -static const uint8_t *tileptr[MAXTILES]; // points to tile data -. may be constant -static uint8_t* tiledata[MAXTILES]; // points to modifiable tile data - only set by tileCreate! +// // copytilepiece // void tileCopySection(int32_t tilenume1, int32_t sx1, int32_t sy1, int32_t xsiz, int32_t ysiz, diff --git a/source/common/textures/buildtiles.cpp b/source/common/textures/buildtiles.cpp index 617b6cd23..9d65d7bb2 100644 --- a/source/common/textures/buildtiles.cpp +++ b/source/common/textures/buildtiles.cpp @@ -333,26 +333,12 @@ FTexture* BuildFiles::ValidateCustomTile(int tilenum, int type) // global interface // //========================================================================== -extern vec2_16_t tilesizearray[MAXTILES]; -extern uint8_t picsizearray[MAXTILES]; int32_t BuildFiles::artLoadFiles(const char* filename) { TileFiles.LoadArtSet(filename); - memset(gotpic, 0, MAXTILES); + memset(gotpic, 0, sizeof(gotpic)); cacheInitBuffer(MAXCACHE1DSIZE); - - for (unsigned i = 0; i < MAXTILES; i++) - { - auto tex = TileFiles.tiles[i]; - assert(tex); - picanm[i] = tex->PicAnim; - tilesizearray[i] = tex->GetSize(); - picsizearray[i] = tex->PicSize; - rottile[i] = { -1, -1 }; - } - - return 0; } @@ -643,3 +629,7 @@ void tileSetAnim(int tile, const picanm_t& anm) { } + +TileSiz tilesiz; +PicAnm picanm; +PicSiz picsiz; diff --git a/source/common/textures/textures.h b/source/common/textures/textures.h index 9ff16d556..27e85ff18 100644 --- a/source/common/textures/textures.h +++ b/source/common/textures/textures.h @@ -348,13 +348,12 @@ public: //========================================================================== // -// A tile with its own pixel buffer +// A non-existent tile // //========================================================================== class FDummyTile : public FTileTexture { - uint8_t pixel = 0; public: FDummyTile(int width, int height) { @@ -364,7 +363,7 @@ public: const uint8_t* Get8BitPixels() override { - return &pixel; // do not return null. + return NULL; } }; @@ -558,8 +557,40 @@ inline uint8_t* tileData(int num) return tex->GetWritableBuffer(); } +// Some hacks to allow accessing the no lpnger existing arrays as if they still were arrays to avoid changing hundreds of lines of code. +struct TileSiz +{ + const vec2_16_t &operator[](size_t index) + { + assert(index < MAXTILES); + return TileFiles.tiles[index]->GetSize(); + } +}; +extern TileSiz tilesiz; + +struct PicAnm +{ + picanm_t& operator[](size_t index) + { + assert(index < MAXTILES); + return TileFiles.tiles[index]->GetAnim(); + } +}; +extern PicAnm picanm; + +struct PicSiz +{ + uint8_t operator[](size_t index) + { + assert(index < MAXTILES); + return TileFiles.tiles[index]->GetPicSize(); + } +}; +extern PicSiz picsiz; + inline rottile_t& RotTile(int tile) { + assert(tile < MAXTILES); return TileFiles.tiles[tile]->GetRotTile(); } #endif diff --git a/source/duke3d/src/gamevars.cpp b/source/duke3d/src/gamevars.cpp index e1da3930f..822aa8cb9 100644 --- a/source/duke3d/src/gamevars.cpp +++ b/source/duke3d/src/gamevars.cpp @@ -1491,8 +1491,8 @@ void Gv_RefreshPointers(void) # endif aGameArrays[Gv_GetArrayIndex("gotpic")].pValues = (intptr_t *)&gotpic[0]; - aGameArrays[Gv_GetArrayIndex("tilesizx")].pValues = (intptr_t *)&tilesiz[0].x; - aGameArrays[Gv_GetArrayIndex("tilesizy")].pValues = (intptr_t *)&tilesiz[0].y; + aGameArrays[Gv_GetArrayIndex("tilesizx")].pValues = (intptr_t *)tileWidth; + aGameArrays[Gv_GetArrayIndex("tilesizy")].pValues = (intptr_t *)tileHeight; } #endif