- moved Duke's tile flags into the tile manager.

This is so that .def can access them. Later the other games also might make use of this.
This commit is contained in:
Christoph Oelckers 2022-11-25 13:45:18 +01:00
parent bb1113c251
commit 5a2819239c
10 changed files with 24 additions and 15 deletions

View file

@ -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<TextureDescriptor> Textures;
TMap<uint64_t, int> LocalizedTextures;

View file

@ -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;

View file

@ -370,13 +370,14 @@ enum sflags2_t
using EDukeFlags2 = TFlags<sflags2_t, uint32_t>;
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

View file

@ -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<short>& 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)

View file

@ -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;

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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;

View file

@ -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;
};

View file

@ -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)