diff --git a/source/core/gamestruct.h b/source/core/gamestruct.h index 270301311..a682a21db 100644 --- a/source/core/gamestruct.h +++ b/source/core/gamestruct.h @@ -50,9 +50,9 @@ extern cycle_t drawtime, actortime, thinktime, gameupdatetime; struct GeoEffect { - int* geosectorwarp; - int* geosectorwarp2; - int* geosector; + sectortype** geosectorwarp; + sectortype** geosectorwarp2; + sectortype** geosector; int* geox; int* geoy; int* geox2; diff --git a/source/core/rendering/scene/hw_drawinfo.cpp b/source/core/rendering/scene/hw_drawinfo.cpp index bb6804160..4c3121613 100644 --- a/source/core/rendering/scene/hw_drawinfo.cpp +++ b/source/core/rendering/scene/hw_drawinfo.cpp @@ -399,17 +399,18 @@ void HWDrawInfo::CreateScene(bool portal) GeoEffect eff; int effsect = vp.SectNums ? vp.SectNums[0] : vp.SectCount; - int drawsect = effsect; + auto drawsectp = §or[effsect]; + auto orgdrawsectp = drawsectp; // RR geometry hack. Ugh... // This just adds to the existing render list, so we must offset the effect areas to the same xy-space as the main one as we cannot change the view matrix. - if (gi->GetGeoEffect(&eff, §or[effsect])) + if (gi->GetGeoEffect(&eff, drawsectp)) { ingeo = true; geoofs = { (float)eff.geox[0], (float)eff.geoy[0] }; // process the first layer. for (int i = 0; i < eff.geocnt; i++) { - auto sect = §or[eff.geosectorwarp[i]]; + auto sect = eff.geosectorwarp[i]; for (auto w = 0; w < sect->wallnum; w++) { auto wal = &wall[sect->wallptr + w]; @@ -417,17 +418,18 @@ void HWDrawInfo::CreateScene(bool portal) wal->y += eff.geoy[i]; } sect->dirty = 255; - if (eff.geosector[i] == effsect) drawsect = eff.geosectorwarp[i]; + if (eff.geosector[i] == drawsectp) drawsectp = eff.geosectorwarp[i]; } if (a1 != 0xffffffff) mDrawer.Init(this, mClipper, view, bamang(vp.RotAngle - a1), bamang(vp.RotAngle + a1)); else mDrawer.Init(this, mClipper, view, bamang(0), bamang(0)); + int drawsect = sectnum(drawsectp); mDrawer.RenderScene(&drawsect, 1, false); for (int i = 0; i < eff.geocnt; i++) { - auto sect = §or[eff.geosectorwarp[i]]; + auto sect = eff.geosectorwarp[i]; for (auto w = 0; w < sect->wallnum; w++) { auto wal = &wall[sect->wallptr + w]; @@ -440,7 +442,7 @@ void HWDrawInfo::CreateScene(bool portal) geoofs = { (float)eff.geox2[0], (float)eff.geoy2[0] }; for (int i = 0; i < eff.geocnt; i++) { - auto sect = §or[eff.geosectorwarp2[i]]; + auto sect = eff.geosectorwarp2[i]; for (auto w = 0; w < sect->wallnum; w++) { auto wal = &wall[sect->wallptr + w]; @@ -448,16 +450,17 @@ void HWDrawInfo::CreateScene(bool portal) wal->y += eff.geoy2[i]; } sect->dirty = 255; - if (eff.geosector[i] == effsect) drawsect = eff.geosectorwarp2[i]; + if (eff.geosector[i] == orgdrawsectp) drawsectp = eff.geosectorwarp2[i]; } if (a1 != 0xffffffff) mDrawer.Init(this, mClipper, view, bamang(vp.RotAngle - a1), bamang(vp.RotAngle + a1)); else mDrawer.Init(this, mClipper, view, bamang(0), bamang(0)); + drawsect = sectnum(drawsectp); mDrawer.RenderScene(&drawsect, 1, false); for (int i = 0; i < eff.geocnt; i++) { - auto sect = §or[eff.geosectorwarp2[i]]; + auto sect = eff.geosectorwarp2[i]; for (auto w = 0; w < sect->wallnum; w++) { auto wal = &wall[sect->wallptr + w]; diff --git a/source/games/duke/src/_polymost.cpp b/source/games/duke/src/_polymost.cpp index 3582b7804..a2e9bd55b 100644 --- a/source/games/duke/src/_polymost.cpp +++ b/source/games/duke/src/_polymost.cpp @@ -203,7 +203,9 @@ void renderMirror(int cposx, int cposy, int cposz, binangle cang, fixedhoriz cho static void geometryEffect(int cposx, int cposy, int cposz, binangle cang, fixedhoriz choriz, int sect, int smoothratio) { - int gs, tgsect, geosect, geoid = 0; + auto sectp = §or[sect]; + int gs, geoid = 0; + sectortype* tgsect, *geosect; renderDrawRoomsQ16(cposx, cposy, cposz, cang.asq16(), choriz.asq16(), sect, false); fi.animatesprites(pm_tsprite, pm_spritesortcnt, cposx, cposy, cang.asbuild(), smoothratio); renderDrawMasks(); @@ -217,7 +219,7 @@ static void geometryEffect(int cposx, int cposy, int cposz, binangle cang, fixed changeactorsect(act, geosectorwarp[gs]); setsprite(act, act->s->x -= geox[gs], act->s->y -= geoy[gs], act->s->z); } - if (geosector[gs] == sect) + if (geosector[gs] == sectp) { geosect = geosectorwarp[gs]; geoid = gs; @@ -249,7 +251,7 @@ static void geometryEffect(int cposx, int cposy, int cposz, binangle cang, fixed changeactorsect(act, geosectorwarp2[gs]); setsprite(act, act->s->x -= geox2[gs], act->s->y -= geoy2[gs], act->s->z); } - if (geosector[gs] == sect) + if (geosector[gs] == sectp) { geosect = geosectorwarp2[gs]; geoid = gs; diff --git a/source/games/duke/src/global.cpp b/source/games/duke/src/global.cpp index 28db7c69d..a4dba7617 100644 --- a/source/games/duke/src/global.cpp +++ b/source/games/duke/src/global.cpp @@ -123,9 +123,9 @@ uint32_t everyothertime; // Global animation ticker helper. // Redneck Rampage int thunder_brightness; int wupass; // used to play the level entry sound only once. -int geosectorwarp[MAXGEOSECTORS]; // geometry render hack (overlay a secondary scene) -int geosectorwarp2[MAXGEOSECTORS]; -int geosector[MAXGEOSECTORS]; +sectortype* geosectorwarp[MAXGEOSECTORS]; // geometry render hack (overlay a secondary scene) +sectortype* geosectorwarp2[MAXGEOSECTORS]; +sectortype* geosector[MAXGEOSECTORS]; int geox[MAXGEOSECTORS]; int geoy[MAXGEOSECTORS]; int geox2[MAXGEOSECTORS]; diff --git a/source/games/duke/src/global.h b/source/games/duke/src/global.h index 36d85933c..1d78eb3ed 100644 --- a/source/games/duke/src/global.h +++ b/source/games/duke/src/global.h @@ -104,9 +104,9 @@ extern int ufocnt; extern int hulkspawn; extern int lastlevel; -extern int geosectorwarp[MAXGEOSECTORS]; -extern int geosectorwarp2[MAXGEOSECTORS]; -extern int geosector[MAXGEOSECTORS]; +extern sectortype* geosectorwarp[MAXGEOSECTORS]; +extern sectortype* geosectorwarp2[MAXGEOSECTORS]; +extern sectortype* geosector[MAXGEOSECTORS]; extern int geox[MAXGEOSECTORS]; extern int geoy[MAXGEOSECTORS]; extern int geox2[MAXGEOSECTORS]; diff --git a/source/games/duke/src/premap_r.cpp b/source/games/duke/src/premap_r.cpp index fdb5be34b..2d27a11ce 100644 --- a/source/games/duke/src/premap_r.cpp +++ b/source/games/duke/src/premap_r.cpp @@ -610,7 +610,7 @@ void prelevel_r(int g) I_Error("Too many geometry effects"); if (spr->hitag == 0) { - geosector[geocnt] = spr->sectnum; + geosector[geocnt] = spr->sector(); for (j = 0; j < MAXSPRITES; j++) { auto spj = &sprite[j]; @@ -618,14 +618,14 @@ void prelevel_r(int g) { if (spj->hitag == 1) { - geosectorwarp[geocnt] = spj->sectnum; + geosectorwarp[geocnt] = spj->sector(); geox[geocnt] = spr->x - spj->x; geoy[geocnt] = spr->y - spj->y; //geoz[geocnt] = spr->z - spj->z; } if (spj->hitag == 2) { - geosectorwarp2[geocnt] = spj->sectnum; + geosectorwarp2[geocnt] = spj->sector(); geox2[geocnt] = spr->x - spj->x; geoy2[geocnt] = spr->y - spj->y; //geoz2[geocnt] = spr->z - spj->z;