- Duke: change all checks for mirrors to texture IDs

This commit is contained in:
Christoph Oelckers 2022-12-08 23:09:46 +01:00
parent 5b8dd84361
commit 1a98f9b478
20 changed files with 55 additions and 44 deletions

View file

@ -1704,7 +1704,7 @@ void move_d(DDukeActor *actor, int playernum, int xvel)
actor->spr.shade += (actor->sector()->ceilingshade - actor->spr.shade) >> 1;
else actor->spr.shade += (actor->sector()->floorshade - actor->spr.shade) >> 1;
if (actor->sector()->floorpicnum == DTILE_MIRROR)
if (actor->sector()->floortexture() == mirrortex)
actor->Destroy();
}
}

View file

@ -1697,7 +1697,7 @@ void move_r(DDukeActor *actor, int pnum, int xvel)
}
else actor->spr.shade += (actor->sector()->floorshade - actor->spr.shade) >> 1;
if (actor->sector()->floorpicnum == RTILE_MIRROR)
if (actor->sector()->floortexture() == mirrortex)
actor->Destroy();
}
}

View file

@ -352,7 +352,7 @@ void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
}
h->dispicnum = t->picnum;
if (t->sectp->floorpicnum == DTILE_MIRROR)
if (t->sectp->floortexture() == mirrortex)
t->scale = DVector2(0, 0);
}
}

View file

@ -425,7 +425,7 @@ void animatesprites_r(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
}
h->dispicnum = t->picnum;
if (t->sectp->floorpicnum == RTILE_MIRROR)
if (t->sectp->floortexture() == mirrortex)
t->scale = DVector2(0, 0);
}
}

View file

@ -25,6 +25,8 @@ enum
RESPAWN = 9,
GPSPEED = 10,
FOF = 13,
MIRROR_DUKE = 560,
MIRROR_RR = 1089,
// hack alert! CYCLER is free for use here as all items of this type get destroyed right on map spawn and this value never gets checked anywhere else.
// This avoids overallocation of empty tile slots as a high value slightly below the tile limit would do.

View file

@ -188,7 +188,6 @@ int TILE_CLOUDYSKIES;
int TILE_ACCESSSWITCH;
int TILE_ACCESSSWITCH2;
int TILE_HEN;
int TILE_MIRROR;
int TILE_MIRRORBROKE;
int TILE_LOADSCREEN;
int TILE_CROSSHAIR;

View file

@ -127,6 +127,7 @@ void CallPlayFTASound(DDukeActor* actor);
void CallStandingOn(DDukeActor* actor, player_struct* p);
void CallRunState(DDukeActor* actor);
extern FTextureID mirrortex, foftex;
END_DUKE_NS

View file

@ -293,7 +293,6 @@ void initactorflags_d()
TILE_CLOUDYSKIES = DTILE_CLOUDYSKIES;
TILE_ACCESSSWITCH = DTILE_ACCESSSWITCH;
TILE_ACCESSSWITCH2 = DTILE_ACCESSSWITCH2;
TILE_MIRROR = DTILE_MIRROR;
TILE_MIRRORBROKE = DTILE_MIRRORBROKE;
TILE_LOADSCREEN = DTILE_LOADSCREEN;
TILE_CROSSHAIR = DTILE_CROSSHAIR;

View file

@ -293,7 +293,6 @@ void initactorflags_r()
TILE_CLOUDYSKIES = RTILE_CLOUDYSKIES;
TILE_ACCESSSWITCH = RTILE_ACCESSSWITCH;
TILE_ACCESSSWITCH2 = RTILE_ACCESSSWITCH2;
TILE_MIRROR = RTILE_MIRROR;
TILE_MIRRORBROKE = RTILE_MIRRORBROKE;
TILE_HEN = RTILE_HEN;
TILE_LOADSCREEN = RTILE_LOADSCREEN;

View file

@ -51,6 +51,8 @@ void SetDispatcher();
void InitCheats();
int registerosdcommands(void);
FTextureID mirrortex, foftex;
//---------------------------------------------------------------------------
//
// DObject stuff - everything GC related.
@ -309,12 +311,12 @@ void GameInterface::SetupSpecialTextures(TilesetBuildInfo& info)
FImageSource* viewscreen;
if (!isRR())
{
info.Delete(560); // the mirror tile.
info.Delete(MIRROR_DUKE); // the mirror tile.
viewscreen = info.tile[502].tileimage;
}
else
{
info.Delete(1089); // the mirror tile.
info.Delete(MIRROR_RR); // the mirror tile.
info.Delete(0); // RR uses this as an empty texture
info.MakeWritable(2025); // bowling lane pin displays
info.MakeWritable(2026);
@ -338,6 +340,18 @@ int GameInterface::GetCurrentSkill()
return ud.player_skill - 1;
}
//---------------------------------------------------------------------------
//
// IDs for non-textures that need direct checking
//
//---------------------------------------------------------------------------
void setTextureIDs()
{
mirrortex = tileGetTextureID(isRR() ? MIRROR_RR : MIRROR_DUKE);
foftex = tileGetTextureID(FOF);
}
//---------------------------------------------------------------------------
//
// set up the game module's state
@ -382,6 +396,7 @@ void GameInterface::app_init()
loadcons();
fi.initactorflags();
setTextureIDs(); // sets a few texture IDs needed for map checking.
duke_menufont->Callback(); // depends on the .CON files so it must be after loadcons
OnEvent(EVENT_INIT);

View file

@ -21,7 +21,6 @@ extern int TILE_CLOUDYSKIES;
extern int TILE_ACCESSSWITCH;
extern int TILE_ACCESSSWITCH2;
extern int TILE_HEN;
extern int TILE_MIRROR;
extern int TILE_MIRRORBROKE;
extern int TILE_LOADSCREEN;
extern int TILE_CROSSHAIR;

View file

@ -2844,7 +2844,7 @@ void processinput_d(int snum)
pact->vel.X = clamp((p->GetActor()->spr.pos.XY() - p->bobpos).Length(), 0., 32.);
if (p->on_ground) p->bobcounter += int(p->GetActor()->vel.X * 8);
p->backuppos(ud.clipping == 0 && ((p->insector() && p->cursector->floorpicnum == DTILE_MIRROR) || !p->insector()));
p->backuppos(ud.clipping == 0 && ((p->insector() && p->cursector->floortexture() == mirrortex) || !p->insector()));
// Shrinking code

View file

@ -3441,7 +3441,7 @@ void processinput_r(int snum)
pact->vel.X = clamp((p->GetActor()->spr.pos.XY() - p->bobpos).Length(), 0., 32.);
if (p->on_ground) p->bobcounter += int(p->GetActor()->vel.X * 8);
p->backuppos(ud.clipping == 0 && ((p->insector() && p->cursector->floorpicnum == RTILE_MIRROR) || !p->insector()));
p->backuppos(ud.clipping == 0 && ((p->insector() && p->cursector->floortexture() == mirrortex) || !p->insector()));
// Shrinking code

View file

@ -805,7 +805,7 @@ static void SpawnPortals()
{
for (auto& wal : wall)
{
if (wal.overpicnum == TILE_MIRROR && (wal.cstat & CSTAT_WALL_1WAY)) wal.portalflags |= PORTAL_WALL_MIRROR;
if (wal.overtexture() == mirrortex && (wal.cstat & CSTAT_WALL_1WAY)) wal.portalflags |= PORTAL_WALL_MIRROR;
}
portalClear();
@ -887,7 +887,7 @@ static void SpawnPortals()
}
}
}
else if (sectp->ceilingpicnum == FOF && sectp->portalflags != PORTAL_SECTOR_CEILING)
else if (sectp->ceilingtexture() == foftex && sectp->portalflags != PORTAL_SECTOR_CEILING)
{
for (auto& pt : allPortals)
{

View file

@ -325,16 +325,16 @@ void prelevel_d(int g, TArray<DDukeActor*>& actors)
for (auto& wal : wall)
{
if (wal.overpicnum == DTILE_MIRROR && (wal.cstat & CSTAT_WALL_1WAY) != 0)
if (wal.overtexture() == mirrortex && (wal.cstat & CSTAT_WALL_1WAY) != 0)
{
auto sectp = wal.nextSector();
if (mirrorcnt > 63)
I_Error("Too many mirrors (64 max.)");
if (sectp && sectp->ceilingpicnum != DTILE_MIRROR)
if (sectp && sectp->ceilingtexture() != mirrortex)
{
sectp->ceilingpicnum = DTILE_MIRROR;
sectp->floorpicnum = DTILE_MIRROR;
sectp->setceilingtexture(mirrortex);
sectp->setfloortexture(mirrortex);
mirrorwall[mirrorcnt] = &wal;
mirrorsector[mirrorcnt] = sectp;
mirrorcnt++;
@ -443,8 +443,8 @@ void prelevel_d(int g, TArray<DDukeActor*>& actors)
{
for (auto& wal : mirrorsector[i]->walls)
{
wal.wallpicnum = DTILE_MIRROR;
wal.overpicnum = DTILE_MIRROR;
wal.setwalltexture(mirrortex);
wal.setovertexture(mirrortex);
}
}
}

View file

@ -634,22 +634,19 @@ void prelevel_r(int g, TArray<DDukeActor*>& actors)
mirrorcnt = 0;
for (auto& wl : wall)
for (auto& wal : wall)
{
walltype* wal = &wl;
if (wal->overpicnum == RTILE_MIRROR && (wal->cstat & CSTAT_WALL_1WAY) != 0)
if (wal.overtexture() == mirrortex && (wal.cstat & CSTAT_WALL_1WAY) != 0)
{
auto sectp = wal->nextSector();
auto sectp = wal.nextSector();
if (mirrorcnt > 63)
I_Error("Too many mirrors (64 max.)");
if (sectp && sectp->ceilingpicnum != RTILE_MIRROR)
if (sectp && sectp->ceilingtexture() != mirrortex)
{
sectp->ceilingpicnum = RTILE_MIRROR;
sectp->floorpicnum = RTILE_MIRROR;
mirrorwall[mirrorcnt] = wal;
sectp->setceilingtexture(mirrortex);
sectp->setfloortexture(mirrortex);
mirrorwall[mirrorcnt] = &wal;
mirrorsector[mirrorcnt] = sectp;
mirrorcnt++;
continue;
@ -662,29 +659,29 @@ void prelevel_r(int g, TArray<DDukeActor*>& actors)
animwall[numanimwalls].tag = 0;
animwall[numanimwalls].wall = nullptr;
switch (wal->overpicnum)
switch (wal.overpicnum)
{
case RTILE_FANSPRITE:
//wal.cstat |= CSTAT_WALL_BLOCK | CSTAT_WALL_BLOCK_HITSCAN; Original code assigned this to 'wall', i.e. wall[0]
animwall[numanimwalls].wall = wal;
animwall[numanimwalls].wall = &wal;
numanimwalls++;
break;
case RTILE_BIGFORCE:
animwall[numanimwalls].wall = wal;
animwall[numanimwalls].wall = &wal;
numanimwalls++;
continue;
}
wal->extra = -1;
wal.extra = -1;
switch (wal->wallpicnum)
switch (wal.wallpicnum)
{
case RTILE_SCREENBREAK6:
case RTILE_SCREENBREAK7:
case RTILE_SCREENBREAK8:
for (j = RTILE_SCREENBREAK6; j <= RTILE_SCREENBREAK8; j++)
tloadtile(j);
animwall[numanimwalls].wall = wal;
animwall[numanimwalls].wall = &wal;
animwall[numanimwalls].tag = -1;
numanimwalls++;
break;
@ -694,10 +691,10 @@ void prelevel_r(int g, TArray<DDukeActor*>& actors)
//Invalidate textures in sector behind mirror
for (i = 0; i < mirrorcnt; i++)
{
for (auto& mwal : mirrorsector[i]->walls)
for (auto& wal : mirrorsector[i]->walls)
{
mwal.wallpicnum = RTILE_MIRROR;
mwal.overpicnum = RTILE_MIRROR;
wal.setwalltexture(mirrortex);
wal.setovertexture(mirrortex);
}
}
thunder_brightness = 0;

View file

@ -1273,7 +1273,7 @@ void operateforcefields_common(DDukeActor *effector, int low, const std::initial
void checkhitwall(DDukeActor* spr, walltype* wal, const DVector3& pos)
{
if (wal->overpicnum == TILE_MIRROR && actorflag(spr, SFLAG2_BREAKMIRRORS))
if (wal->overtexture() == mirrortex && actorflag(spr, SFLAG2_BREAKMIRRORS))
{
lotsofglass(spr, wal, 70);
wal->cstat &= ~CSTAT_WALL_MASKED;

View file

@ -832,7 +832,7 @@ void checksectors_d(int snum)
if (hitscanwall != nullptr)
{
if (dist < 80 && hitscanwall->overpicnum == DTILE_MIRROR)
if (dist < 80 && hitscanwall->overtexture() == mirrortex)
if (hitscanwall->lotag > 0 && S_CheckSoundPlaying(hitscanwall->lotag) == 0 && snum == screenpeek)
{
S_PlayActorSound(hitscanwall->lotag, pact);

View file

@ -901,7 +901,7 @@ void checksectors_r(int snum)
{
if (isRRRA())
{
if (hitscanwall->overpicnum == RTILE_MIRROR && snum == screenpeek)
if (hitscanwall->overtexture() == mirrortex && snum == screenpeek)
if (numplayers == 1)
{
if (S_CheckActorSoundPlaying(pact, 27) == 0 && S_CheckActorSoundPlaying(pact, 28) == 0 && S_CheckActorSoundPlaying(pact, 29) == 0
@ -924,7 +924,7 @@ void checksectors_r(int snum)
}
else
{
if (hitscanwall->overpicnum == RTILE_MIRROR)
if (hitscanwall->overtexture() == mirrortex)
if (hitscanwall->lotag > 0 && S_CheckActorSoundPlaying(pact, hitscanwall->lotag) == 0 && snum == screenpeek)
{
S_PlayActorSound(hitscanwall->lotag, pact);

View file

@ -1323,7 +1323,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(_DukeLevel, wallflags, duke_wallflags)
int duke_ismirror(walltype* wal)
{
return wal->wallpicnum == TILE_MIRROR || wal->overpicnum == TILE_MIRROR;
return wal->walltexture() == mirrortex || wal->overtexture() == mirrortex;
}
DEFINE_ACTION_FUNCTION_NATIVE(_DukeLevel, ismirror, duke_ismirror)