From 622710ede4b4ae2bce11ceec19f736527060c44f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 9 Dec 2022 08:28:55 +0100 Subject: [PATCH] - migrated all uses of floorpicnum. This necessitated a few more surface type definitions. --- source/core/maploader.cpp | 6 +- source/core/sectorgeometry.cpp | 2 +- source/core/sectorgeometry.h | 4 +- source/games/duke/src/constants.h | 4 ++ source/games/duke/src/namelist_r.h | 8 +-- source/games/duke/src/player_d.cpp | 13 ++--- source/games/duke/src/player_r.cpp | 56 ++++++++++--------- wadsrc/static/filter/dukeengine/constants.mi | 4 ++ .../static/filter/dukelike/rmapinfo.texflags | 1 + .../redneck.ridesagain/rmapinfo.texflags | 2 + .../static/filter/redneck/rmapinfo.texflags | 3 +- wadsrc/static/zscript/games/duke/dukegame.zs | 4 ++ 12 files changed, 62 insertions(+), 45 deletions(-) diff --git a/source/core/maploader.cpp b/source/core/maploader.cpp index dac52c12b..86cfc2e81 100644 --- a/source/core/maploader.cpp +++ b/source/core/maploader.cpp @@ -111,7 +111,7 @@ static void ReadSectorV7(FileReader& fr, sectortype& sect) sect.ceilingpal = fr.ReadUInt8(); sect.ceilingxpan_ = fr.ReadUInt8(); sect.ceilingypan_ = fr.ReadUInt8(); - sect.floorpicnum = fr.ReadUInt16(); + sect.setfloortexture(tileGetTextureID(fr.ReadUInt16())); sect.floorheinum = fr.ReadInt16(); sect.floorshade = fr.ReadInt8(); sect.floorpal = fr.ReadUInt8(); @@ -130,7 +130,7 @@ static void ReadSectorV6(FileReader& fr, sectortype& sect) int wallnum = fr.ReadInt16(); sect.walls.Set(&wall[wallptr], wallnum); sect.setceilingtexture(tileGetTextureID(fr.ReadUInt16())); - sect.floorpicnum = fr.ReadUInt16(); + sect.setfloortexture(tileGetTextureID(fr.ReadUInt16())); sect.ceilingheinum = clamp(fr.ReadInt16() << 5, -32768, 32767); sect.floorheinum = clamp(fr.ReadInt16() << 5, -32768, 32767); int c = fr.ReadInt32(); @@ -159,7 +159,7 @@ static void ReadSectorV5(FileReader& fr, sectortype& sect) int wallnum = fr.ReadInt16(); sect.walls.Set(&wall[wallptr], wallnum); sect.setceilingtexture(tileGetTextureID(fr.ReadUInt16())); - sect.floorpicnum = fr.ReadUInt16(); + sect.setfloortexture(tileGetTextureID(fr.ReadUInt16())); sect.ceilingheinum = clamp(fr.ReadInt16() << 5, -32768, 32767); sect.floorheinum = clamp(fr.ReadInt16() << 5, -32768, 32767); int c = fr.ReadInt32(); diff --git a/source/core/sectorgeometry.cpp b/source/core/sectorgeometry.cpp index a592e57e3..72561214c 100644 --- a/source/core/sectorgeometry.cpp +++ b/source/core/sectorgeometry.cpp @@ -366,7 +366,7 @@ bool SectionGeometry::ValidateSection(Section* section, int plane) if (plane == 0) { if (sec->floorheinum == compare->floorheinum && - sec->floorpicnum == compare->floorpicnum && + sec->floortexture() == compare->floortexture && ((sec->floorstat ^ compare->floorstat) & (CSTAT_SECTOR_ALIGN | CSTAT_SECTOR_YFLIP | CSTAT_SECTOR_XFLIP | CSTAT_SECTOR_TEXHALF | CSTAT_SECTOR_SWAPXY)) == 0 && sec->floorxpan_ == compare->floorxpan_ && sec->floorypan_ == compare->floorypan_ && diff --git a/source/core/sectorgeometry.h b/source/core/sectorgeometry.h index 661de1717..184d22aea 100644 --- a/source/core/sectorgeometry.h +++ b/source/core/sectorgeometry.h @@ -33,8 +33,8 @@ struct sectortypelight ESectorFlags ceilingstat; ESectorFlags floorstat; FTextureID ceilingtexture; + FTextureID floortexture; int16_t ceilingheinum; - int16_t floorpicnum; int16_t floorheinum; void copy(sectortype* sec) @@ -48,7 +48,7 @@ struct sectortypelight ceilingheinum = sec->ceilingheinum; floorheinum = sec->floorheinum; ceilingtexture = sec->ceilingtexture(); - floorpicnum = sec->floorpicnum; + floortexture = sec->floortexture(); } }; diff --git a/source/games/duke/src/constants.h b/source/games/duke/src/constants.h index c7347de6c..b8d84dd9e 100644 --- a/source/games/duke/src/constants.h +++ b/source/games/duke/src/constants.h @@ -436,6 +436,10 @@ enum TSURF_THUNDERSKY = 7, TSURF_PLASMA = 8, TSURF_MAGMA = 9, + TSURF_METALDUCTS = 10, + TSURF_OIL = 11, + TSURF_DEEPMUD = 12, // also affects motorcycle + TSURF_SPECIALWATER = 13, }; enum diff --git a/source/games/duke/src/namelist_r.h b/source/games/duke/src/namelist_r.h index 657e8d9bf..925e0f6fe 100644 --- a/source/games/duke/src/namelist_r.h +++ b/source/games/duke/src/namelist_r.h @@ -192,7 +192,7 @@ x(KEGHOLDER, 295) // that's what the text on the sprite says. It doesn't seem to x(RRTELEPORT, 296) x(RRTELEPORTDEST, 297) x(CDPLAYER, 370) -y(RRTILE380, 380) +y(WATERSURFACE, 380) x(BONUSPIC01, 403) x(BONUSPIC02, 404) x(BONUSPIC03, 405) @@ -1260,7 +1260,7 @@ y(RRTILE7705, 7705) y(HOTELSIGN, 7711) y(HOTELSIGNBROKE, 7712) y(RRTILE7716, 7716) -y(RRTILE7756, 7756) +y(OIL1, 7756) y(MAGMA1, 7768) y(RRTILE7806, 7806) y(MAGMA2, 7820) @@ -1280,8 +1280,8 @@ y(RADIATIONSIGNBROKE, 7884) y(RRTILE7885, 7885) y(RRTILE7886, 7886) y(RRTILE7887, 7887) -y(RRTILE7888, 7888) -y(RRTILE7889, 7889) +y(OIL2, 7888) +y(DEEPMUD, 7889) y(RRTILE7890, 7890) y(RRTILE7900, 7900) y(RRTILE7901, 7901) diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index 2434fb72b..13fdaa226 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -2916,26 +2916,23 @@ void processinput_d(int snum) { if (p->spritebridge == 0 && p->walking_snd_toggle == 0 && p->on_ground) { - int j; + FTextureID j; switch (psectlotag) { case 0: if (clz.type == kHitSprite) - j = clz.actor()->spr.picnum; + j = clz.actor()->spr.spritetexture(); else - j = psectp->floorpicnum; + j = psectp->floortexture(); - switch (j) + if (tilesurface(j) == TSURF_METALDUCTS) { - case DTILE_PANNEL1: - case DTILE_PANNEL2: S_PlayActorSound(DUKE_WALKINDUCTS, pact); p->walking_snd_toggle = 1; - break; } break; - case 1: + case ST_1_ABOVE_WATER: if ((krand() & 1) == 0) S_PlayActorSound(DUKE_ONWATER, pact); p->walking_snd_toggle = 1; diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index 78a105fec..4c1299622 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -2007,7 +2007,7 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, double floo p->footprintpal = 8; p->footprintshade = 0; } - else if (isRRRA() && (p->cursector->floorpicnum == RTILE_RRTILE7756 || p->cursector->floorpicnum == RTILE_RRTILE7888)) + else if (tilesurface(p->cursector->floortexture()) == TSURF_OIL) { p->footprintpal = 0; p->footprintshade = 40; @@ -3250,16 +3250,16 @@ void processinput_r(int snum) DukeSectIterator it(psectp); while (auto act2 = it.Next()) { - if (act2->spr.picnum == RTILE_RRTILE380) + if (act2->spr.picnum == RTILE_WATERSURFACE) if (act2->spr.pos.Z - 8 < p->GetActor()->getOffsetZ()) - psectlotag = 2; + psectlotag = ST_2_UNDERWATER; } } else if (psectlotag == 7777 && (currentLevel->gameflags & LEVEL_RR_HULKSPAWN)) lastlevel = 1; - if (psectlotag == 848 && psectp->floorpicnum == RTILE_WATERTILE2) - psectlotag = 1; + if (psectlotag == 848 && tilesurface(psectp->floortexture()) == TSURF_SPECIALWATER) + psectlotag = ST_1_ABOVE_WATER; if (psectlotag == 857) pact->clipdist = 0.25; @@ -3542,14 +3542,20 @@ void processinput_r(int snum) { if (p->spritebridge == 0 && p->walking_snd_toggle == 0 && p->on_ground) { - int j; + FTextureID j; switch (psectlotag) { case 0: - if (clz.type == kHitSprite) - j = clz.actor()->spr.picnum; - else j = psectp->floorpicnum; + j = clz.actor()->spr.spritetexture(); + else + j = psectp->floortexture(); + + if (tilesurface(j) == TSURF_METALDUCTS) + { + S_PlayActorSound(S_FindSound("PLAYER_WALKINDUCTS"), pact); // Duke's sound slot is not available here. + p->walking_snd_toggle = 1; + } break; case 1: if ((krand() & 1) == 0) @@ -3585,13 +3591,13 @@ void processinput_r(int snum) } } - if (isRRRA() && psectp->floorpicnum == RTILE_RRTILE7888) + if (tilesurface(psectp->floortexture()) == TSURF_OIL) { if (p->OnMotorcycle) if (p->on_ground) p->moto_on_oil = 1; } - else if (isRRRA() && psectp->floorpicnum == RTILE_RRTILE7889) + else if (tilesurface(psectp->floortexture()) == TSURF_DEEPMUD) { if (p->OnMotorcycle) { @@ -3605,25 +3611,23 @@ void processinput_r(int snum) p->vel.XY() *= gs.playerfriction; } } - else - - if (psectp->floorpicnum == RTILE_MUDDY || psectp->floorpicnum == RTILE_MUDDYPATH) + else if (tilesurface(psectp->floortexture()) == TSURF_MUDDY) + { + if (p->OnMotorcycle) { - if (p->OnMotorcycle) + if (p->on_ground) { - if (p->on_ground) - { - p->vel.XY() *= gs.playerfriction - FixedToFloat(0x1800); - } + p->vel.XY() *= gs.playerfriction - FixedToFloat(0x1800); } - else - if (p->boot_amount > 0) - p->boot_amount--; - else - { - p->vel.XY() *= gs.playerfriction - FixedToFloat(0x1800); - } } + else + if (p->boot_amount > 0) + p->boot_amount--; + else + { + p->vel.XY() *= gs.playerfriction - FixedToFloat(0x1800); + } + } if (abs(p->vel.X) < 1 / 128. && abs(p->vel.Y) < 1 / 128.) p->vel.X = p->vel.Y = 0; diff --git a/wadsrc/static/filter/dukeengine/constants.mi b/wadsrc/static/filter/dukeengine/constants.mi index c3bcb7354..77571b5d3 100644 --- a/wadsrc/static/filter/dukeengine/constants.mi +++ b/wadsrc/static/filter/dukeengine/constants.mi @@ -22,5 +22,9 @@ constants TSURF_THUNDERSKY = 7 TSURF_PLASMA = 8 TSURF_MAGMA = 9 + TSURF_METALDUCTS = 10 + TSURF_OIL = 11 + TSURF_DEEPMUD = 12 // also affects motorcycle + TSURF_SPECIALWATER = 13 } diff --git a/wadsrc/static/filter/dukelike/rmapinfo.texflags b/wadsrc/static/filter/dukelike/rmapinfo.texflags index e4f55ac09..84c00fdec 100644 --- a/wadsrc/static/filter/dukelike/rmapinfo.texflags +++ b/wadsrc/static/filter/dukelike/rmapinfo.texflags @@ -137,4 +137,5 @@ surfacetypes TSURF_PURPLELAVA = PURPLELAVA TSURF_PLASMA = FLOORPLASMA TSURF_SCROLLSKY = CLOUDYSKIES + TSURF_METALDUCTS = PANNEL1, PANNEL2 } \ No newline at end of file diff --git a/wadsrc/static/filter/redneck.ridesagain/rmapinfo.texflags b/wadsrc/static/filter/redneck.ridesagain/rmapinfo.texflags index 2e7b564e0..ee37fc54f 100644 --- a/wadsrc/static/filter/redneck.ridesagain/rmapinfo.texflags +++ b/wadsrc/static/filter/redneck.ridesagain/rmapinfo.texflags @@ -37,4 +37,6 @@ textureflags surfacetypes { TSURF_MAGMA = MAGMA1, MAGMA2 + TSURF_OIL = OIL1, OIL2 + TSURF_DEEPMUD = DEEPMUD } diff --git a/wadsrc/static/filter/redneck/rmapinfo.texflags b/wadsrc/static/filter/redneck/rmapinfo.texflags index f71ec747b..5e9ad353f 100644 --- a/wadsrc/static/filter/redneck/rmapinfo.texflags +++ b/wadsrc/static/filter/redneck/rmapinfo.texflags @@ -169,7 +169,8 @@ surfacetypes TSURF_SLIME = FLOORSLIME, FLOORSLIME1, FLOORSLIME2 TSURF_OUTERSPACE = MOONSKY1, BIGORBIT1 TSURF_PLASMA = FLOORPLASMA - TSURF_MUDDY = MUDDY + TSURF_MUDDY = MUDDY, MUDDYPATH TSURF_THUNDERSKY = RRTHUNDERSKY + TSURF_SPECIALWATER = WATERTILE2 } diff --git a/wadsrc/static/zscript/games/duke/dukegame.zs b/wadsrc/static/zscript/games/duke/dukegame.zs index 0b3706140..48131d809 100644 --- a/wadsrc/static/zscript/games/duke/dukegame.zs +++ b/wadsrc/static/zscript/games/duke/dukegame.zs @@ -91,6 +91,10 @@ struct Duke native TSURF_THUNDERSKY = 7, TSURF_PLASMA = 8, TSURF_MAGMA = 9, + TSURF_METALDUCTS = 10, + TSURF_OIL = 11, + TSURF_DEEPMUD = 12, // also affects motorcycle + TSURF_SPECIALWATER = 13, }; enum ESoundFlags