diff --git a/source/common/textures/texturemanager.h b/source/common/textures/texturemanager.h index 41fe71b6f..84140c54d 100644 --- a/source/common/textures/texturemanager.h +++ b/source/common/textures/texturemanager.h @@ -192,11 +192,15 @@ private: int HashNext; uint64_t Flags; }; + enum : uint64_t { TEXFLAG_HASLOCALIZATION = 1, - TEXFLAG_FIRSTUSER = 65536, // this leaves 16 flags to the texture manager and 48 flags to the user }; +public: + constexpr static int TEXFLAG_FIRSTUSER = 65536; // this leaves 16 flags to the texture manager and 48 flags to the user +private: + enum { HASH_END = -1, HASH_SIZE = 1027 }; TArray Textures; TMap LocalizedTextures; diff --git a/source/core/textures/buildtiles.h b/source/core/textures/buildtiles.h index 991aec3e6..5a08afe6c 100644 --- a/source/core/textures/buildtiles.h +++ b/source/core/textures/buildtiles.h @@ -283,6 +283,7 @@ struct TileDesc rottile_t RotTile;// = { -1,-1 }; ReplacementType replacement; float alphaThreshold; + int tileflags; // Sprite offset hackery for hires replacements. This only gets used for sprites in the 3D view, nothing else. TileOffs hiofs; diff --git a/source/games/duke/src/constants.h b/source/games/duke/src/constants.h index 637dc522e..d3ca23b53 100644 --- a/source/games/duke/src/constants.h +++ b/source/games/duke/src/constants.h @@ -370,13 +370,14 @@ enum sflags2_t using EDukeFlags2 = TFlags; DEFINE_TFLAGS_OPERATORS(EDukeFlags2) +// these get stored as user flags inside the texture manager. enum { - TFLAG_WALLSWITCH = 1, - TFLAG_ADULT = 2, - TFLAG_ELECTRIC = 4, - TFLAG_CLEARINVENTORY = 8, // really dumb Duke stuff... - TFLAG_SLIME = 16, + TFLAG_WALLSWITCH = 1 << 0, + TFLAG_ADULT = 1 << 1, + TFLAG_ELECTRIC = 1 << 2, + TFLAG_CLEARINVENTORY = 1 << 3, // really dumb Duke stuff... + TFLAG_SLIME = 1 << 4, }; enum diff --git a/source/games/duke/src/inlines.h b/source/games/duke/src/inlines.h index 9f76afb04..f7d2eb4a7 100644 --- a/source/games/duke/src/inlines.h +++ b/source/games/duke/src/inlines.h @@ -100,17 +100,21 @@ inline bool inventory(DDukeActor* S) return actorflag(S, SFLAG_INVENTORY); } +inline int& tileflags(int tilenum) +{ + return TileFiles.tiledata[tilenum].tileflags; +} inline void settileflag(int flag, const std::initializer_list& types) { for (auto val : types) { - gs.tileinfo[val].flags |= flag; + tileflags(val) |= flag; } } inline bool wallswitchcheck(DDukeActor* s) { - return !!(gs.tileinfo[s->spr.picnum].flags & TFLAG_WALLSWITCH); + return !!(tileflags(s->spr.picnum) & TFLAG_WALLSWITCH); } inline int checkcursectnums(sectortype* se) diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index 02d03f4ca..70056ac0f 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -84,7 +84,7 @@ int setpal(player_struct* p) if (p->DrugMode) palette = DRUGPAL; else if (p->heat_on) palette = SLIMEPAL; else if (!p->insector()) palette = BASEPAL; // don't crash if out of range. - else if (gs.tileinfo[p->cursector->ceilingpicnum].flags & TFLAG_SLIME) palette = SLIMEPAL; + else if (tileflags(p->cursector->ceilingpicnum) & TFLAG_SLIME) palette = SLIMEPAL; else if (p->cursector->lotag == ST_2_UNDERWATER) palette = WATERPAL; else palette = BASEPAL; return palette; diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index fc03eecb5..14a8732ea 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -2929,7 +2929,7 @@ void processinput_d(int snum) if (p->on_ground && truefdist <= gs.playerheight + 16) { - int whichsound = (gs.tileinfo[j].flags & TFLAG_ELECTRIC) ? 0 : j == FLOORSLIME ? 1 : j == FLOORPLASMA ? 2 : -1; + int whichsound = (tileflags(j) & TFLAG_ELECTRIC) ? 0 : j == FLOORSLIME ? 1 : j == FLOORPLASMA ? 2 : -1; if (j >= 0) k = makepainsounds(snum, whichsound); } diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index f42c54c5d..203cbbf01 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -3565,7 +3565,7 @@ void processinput_r(int snum) if (p->on_ground && truefdist <= gs.playerheight + 16) { - int whichsound = (gs.tileinfo[j].flags & TFLAG_ELECTRIC) ? 0 : j == FLOORSLIME ? 1 : j == FLOORPLASMA ? 2 : + int whichsound = (tileflags(j) & TFLAG_ELECTRIC) ? 0 : j == FLOORSLIME ? 1 : j == FLOORPLASMA ? 2 : (isRRRA() && (j == RRTILE7768 || j == RRTILE7820) ? 3 : -1); if (j >= 0) k = makepainsounds(snum, whichsound); } diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index 9e30d550d..169ae72c3 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -1055,7 +1055,7 @@ void enterlevel(MapRecord *mi, int gamemode) { bool clearweapon = !!(currentLevel->flags & LEVEL_CLEARWEAPONS); int pn = ps[i].GetActor()->sector()->floorpicnum; - if (gs.tileinfo[pn].flags & TFLAG_CLEARINVENTORY) + if (tileflags(pn) & TFLAG_CLEARINVENTORY) { resetinventory(i); clearweapon = true; diff --git a/source/games/duke/src/types.h b/source/games/duke/src/types.h index 6bfc066b1..9fdd50c31 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -134,10 +134,9 @@ struct animwalltype int tag; }; -// for now just flags not related to actors, may get more info later. +// legacy CON baggage which needs to be refactored later. struct TileInfo { - int flags; int loadeventscriptptr; }; diff --git a/source/games/duke/src/vmexports.cpp b/source/games/duke/src/vmexports.cpp index a4d6fc157..89365be1b 100644 --- a/source/games/duke/src/vmexports.cpp +++ b/source/games/duke/src/vmexports.cpp @@ -1008,7 +1008,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(_DukeLevel, operateactivators, operateactivators) int duke_floorflags(sectortype* sector) { - return gs.tileinfo[sector->floorpicnum].flags; + return tileflags(sector->floorpicnum); } DEFINE_ACTION_FUNCTION_NATIVE(_DukeLevel, floorflags, duke_floorflags)