Skip to content

Commit

Permalink
- moved Duke's tile flags into the tile manager.
Browse files Browse the repository at this point in the history
This is so that .def can access them. Later the other games also might make use of this.
  • Loading branch information
coelckers authored and mjr4077au committed Nov 26, 2022
1 parent 9d62627 commit 52f51a4
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 15 deletions.
6 changes: 5 additions & 1 deletion source/common/textures/texturemanager.h
Expand Up @@ -192,11 +192,15 @@ class FTextureManager
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;
Expand Down
1 change: 1 addition & 0 deletions source/core/textures/buildtiles.h
Expand Up @@ -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;
Expand Down
11 changes: 6 additions & 5 deletions source/games/duke/src/constants.h
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions source/games/duke/src/inlines.h
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion source/games/duke/src/player.cpp
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion source/games/duke/src/player_d.cpp
Expand Up @@ -2924,7 +2924,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);
}

Expand Down
2 changes: 1 addition & 1 deletion source/games/duke/src/player_r.cpp
Expand Up @@ -3566,7 +3566,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);
}
Expand Down
2 changes: 1 addition & 1 deletion source/games/duke/src/premap.cpp
Expand Up @@ -1054,7 +1054,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;
Expand Down
3 changes: 1 addition & 2 deletions source/games/duke/src/types.h
Expand Up @@ -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;
};

Expand Down
2 changes: 1 addition & 1 deletion source/games/duke/src/vmexports.cpp
Expand Up @@ -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)
Expand Down

0 comments on commit 52f51a4

Please sign in to comment.