From 0f2f46ec35ead6f80c1d01f6a823dd8981195fca Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 18 Nov 2021 00:08:52 +0100 Subject: [PATCH] - made one_parallax_sectnum a pointer --- source/games/duke/src/actors.cpp | 6 +++--- source/games/duke/src/gameexec.cpp | 5 ----- source/games/duke/src/premap.cpp | 12 +++++------- source/games/duke/src/types.h | 8 ++------ wadsrc/static/zscript/games/duke/dukegame.zs | 2 +- 5 files changed, 11 insertions(+), 22 deletions(-) diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index 626b8ea2a..72354d543 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -3815,10 +3815,10 @@ void handle_se13(DDukeActor* actor) sc->floorshade = s->shade; - if (ps[0].one_parallax_sectnum >= 0) + if (ps[0].one_parallax_sectnum != nullptr) { - sc->ceilingpicnum = ps[0].one_parallax_sector()->ceilingpicnum; - sc->ceilingshade = ps[0].one_parallax_sector()->ceilingshade; + sc->ceilingpicnum = ps[0].one_parallax_sectnum->ceilingpicnum; + sc->ceilingshade = ps[0].one_parallax_sectnum->ceilingshade; } } } diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index 6b6d491ad..fbcfbd5b6 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -601,11 +601,6 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, else SetGameVarID(lVar2, ps[iPlayer].i, sActor, sPlayer); break; - case PLAYER_ONE_PARALLAX_SECTNUM: - if (bSet) ps[iPlayer].one_parallax_sectnum = lValue; - else SetGameVarID(lVar2, ps[iPlayer].one_parallax_sectnum, sActor, sPlayer); - break; - case PLAYER_OVER_SHOULDER_ON: if (bSet) ps[iPlayer].over_shoulder_on = lValue; else SetGameVarID(lVar2, ps[iPlayer].over_shoulder_on, sActor, sPlayer); diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index fb43f32a0..4727641b0 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -408,7 +408,7 @@ void resetprestat(int snum,int g) p->holster_weapon = 0; p->last_pissed_time = 0; - p->one_parallax_sectnum = -1; + p->one_parallax_sectnum = nullptr; p->visibility = ud.const_visibility; screenpeek = myconnectindex; @@ -652,8 +652,6 @@ void lava_cleararrays(); void prelevel_common(int g) { - int i; - auto p = &ps[screenpeek]; p->sea_sick_stat = 0; ufospawnsminion = 0; @@ -691,9 +689,9 @@ void prelevel_common(int g) memset(ambienthitag, -1, sizeof(ambienthitag)); memset(ambientlotag, -1, sizeof(ambientlotag)); - for (i = 0; i < numsectors; i++) + for(auto&sec : sectors()) { - auto sectp = §or[i]; + auto sectp = &sec; sectp->extra = 256; switch (sectp->lotag) @@ -712,8 +710,8 @@ void prelevel_common(int g) if (sectp->ceilingpicnum == TILE_CLOUDYSKIES && numclouds < 127) clouds[numclouds++] = sectp; - if (ps[0].one_parallax_sectnum == -1) - ps[0].one_parallax_sectnum = i; + if (ps[0].one_parallax_sectnum == nullptr) + ps[0].one_parallax_sectnum = sectp; } if (sectp->lotag == 32767) //Found a secret room diff --git a/source/games/duke/src/types.h b/source/games/duke/src/types.h index 8627f66be..c43d4104c 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -211,7 +211,8 @@ struct player_struct int aim_mode, ftt; - int cursectnum, one_parallax_sectnum; // wall + sector references. Make them pointers later? + int cursectnum; + sectortype* one_parallax_sectnum; // wall + sector references. Make them pointers later? walltype* access_wall; short last_extra, subweapon; @@ -311,11 +312,6 @@ struct player_struct { return &::sector[cursectnum]; } - sectortype* one_parallax_sector() const - { - return &::sector[one_parallax_sectnum]; - } - }; diff --git a/wadsrc/static/zscript/games/duke/dukegame.zs b/wadsrc/static/zscript/games/duke/dukegame.zs index 2adb9c811..a28297d11 100644 --- a/wadsrc/static/zscript/games/duke/dukegame.zs +++ b/wadsrc/static/zscript/games/duke/dukegame.zs @@ -159,7 +159,7 @@ struct DukePlayer native int randomflamex, crack_time; native int aim_mode, ftt; - native int cursectnum, one_parallax_sectnum; + //native int cursectnum;// , one_parallax_sectnum //native walltype access_wall; // can't do yet. native int16 last_extra, subweapon;