From 92d54ca0fc3e6d5ab870130106dae931b59359b1 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Sun, 21 Apr 2013 02:22:37 +0000 Subject: [PATCH] - Instead of setting the default skybox in every sector without an explicit skybox set, set it once in the level struct and then use that for sectors with a NULL skybox. This fixes zpack's E2M3 so that when it removes its sector stacks, you will get the default skybox in their place, since stacked sectors and skyboxes use the same pointers in a sector. SVN r4224 (trunk) --- src/dobjgc.cpp | 1 + src/g_level.cpp | 7 +++++++ src/g_level.h | 2 ++ src/g_shared/a_skies.cpp | 20 ++++++-------------- src/r_bsp.cpp | 11 +++++++---- 5 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/dobjgc.cpp b/src/dobjgc.cpp index ebf61a698..d52962f11 100644 --- a/src/dobjgc.cpp +++ b/src/dobjgc.cpp @@ -307,6 +307,7 @@ static void MarkRoot() DThinker::MarkRoots(); FCanvasTextureInfo::Mark(); Mark(DACSThinker::ActiveThinker); + Mark(level.DefaultSkybox); // Mark dead bodies. for (i = 0; i < BODYQUESIZE; ++i) { diff --git a/src/g_level.cpp b/src/g_level.cpp index e01152924..3b0c8fe12 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -77,6 +77,7 @@ #include "d_netinf.h" #include "v_palette.h" #include "menu/menu.h" +#include "a_sharedglobal.h" #include "a_strifeglobal.h" #include "r_data/colormaps.h" #include "farchive.h" @@ -1272,6 +1273,7 @@ void G_InitLevelLocals () NormalLight.ChangeFade (level.fadeto); level.DefaultEnvironment = info->DefaultEnvironment; + level.DefaultSkybox = NULL; } //========================================================================== @@ -1435,6 +1437,11 @@ void G_SerializeLevel (FArchive &arc, bool hubLoad) P_SerializeSubsectors(arc); StatusBar->Serialize (arc); + if (SaveVersion >= 4222) + { // This must be done *after* thinkers are serialized. + arc << level.DefaultSkybox; + } + arc << level.total_monsters << level.total_items << level.total_secrets; // Does this level have custom translations? diff --git a/src/g_level.h b/src/g_level.h index cd8f6c1f7..e7d1cbbd2 100644 --- a/src/g_level.h +++ b/src/g_level.h @@ -426,6 +426,8 @@ struct FLevelLocals int airsupply; int DefaultEnvironment; // Default sound environment. + TObjPtr DefaultSkybox; + FSectorScrollValues *Scrolls; // NULL if no DScrollers in this level SBYTE WallVertLight; // Light diffs for vert/horiz walls diff --git a/src/g_shared/a_skies.cpp b/src/g_shared/a_skies.cpp index 5e894002d..616b87c9e 100644 --- a/src/g_shared/a_skies.cpp +++ b/src/g_shared/a_skies.cpp @@ -49,21 +49,9 @@ void ASkyViewpoint::BeginPlay () { Super::BeginPlay (); - if (tid == 0) + if (tid == 0 && level.DefaultSkybox == NULL) { - int i; - - for (i = 0; i ColorMap; } + skybox = frontsector->CeilingSkyBox != NULL ? frontsector->CeilingSkyBox : level.DefaultSkybox; ceilingplane = frontsector->ceilingplane.PointOnSide(viewx, viewy, viewz) > 0 || frontsector->GetTexture(sector_t::ceiling) == skyflatnum || - (frontsector->CeilingSkyBox != NULL && frontsector->CeilingSkyBox->bAlways) || + (skybox != NULL && skybox->bAlways) || (frontsector->heightsec && !(frontsector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC) && frontsector->heightsec->GetTexture(sector_t::floor) == skyflatnum) ? @@ -1099,7 +1101,7 @@ void R_Subsector (subsector_t *sub) frontsector->GetYScale(sector_t::ceiling), frontsector->GetAngle(sector_t::ceiling), frontsector->sky, - frontsector->CeilingSkyBox + skybox ) : NULL; if (fixedlightlev < 0 && frontsector->e && frontsector->e->XFloor.lightlist.Size()) @@ -1121,9 +1123,10 @@ void R_Subsector (subsector_t *sub) // killough 3/7/98: Add (x,y) offsets to flats, add deep water check // killough 3/16/98: add floorlightlevel // killough 10/98: add support for skies transferred from sidedefs + skybox = frontsector->FloorSkyBox != NULL ? frontsector->FloorSkyBox : level.DefaultSkybox; floorplane = frontsector->floorplane.PointOnSide(viewx, viewy, viewz) > 0 || // killough 3/7/98 frontsector->GetTexture(sector_t::floor) == skyflatnum || - (frontsector->FloorSkyBox != NULL && frontsector->FloorSkyBox->bAlways) || + (skybox != NULL && skybox->bAlways) || (frontsector->heightsec && !(frontsector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC) && frontsector->heightsec->GetTexture(sector_t::ceiling) == skyflatnum) ? @@ -1138,7 +1141,7 @@ void R_Subsector (subsector_t *sub) frontsector->GetYScale(sector_t::floor), frontsector->GetAngle(sector_t::floor), frontsector->sky, - frontsector->FloorSkyBox + skybox ) : NULL; // kg3D - fake planes rendering