diff --git a/src/g_game.c b/src/g_game.c index c05d7f78..9b761763 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -950,8 +950,6 @@ static void G_DoLoadLevel(void) break; }//jff 3/27/98 end sky setting fix - R_InitSkyMap(); // [FG] stretch short skies - levelstarttic = gametic; // for time calculation playback_levelstarttic = playback_tic; @@ -993,6 +991,8 @@ static void G_DoLoadLevel(void) MN_UpdateFreeLook(!mouselook && !padlook); HU_UpdateTurnFormat(); + R_InitSkyMap(); // SKYDEFS flatmapping + // [Woof!] Do not reset chosen player view across levels in multiplayer // demo playback. However, it must be reset when starting a new game. if (usergame) diff --git a/src/p_setup.c b/src/p_setup.c index 9e0e516a..9a905126 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -345,7 +345,7 @@ void P_LoadSectors (int lump) ss->bottommap = ss->midmap = ss->topmap = 0; // killough 10/98: sky textures coming from sidedefs: - ss->sky = 0; + ss->floorsky = ss->ceilingsky = 0; // [AM] Sector interpolation. Even if we're // not running uncapped, the renderer still diff --git a/src/p_spec.c b/src/p_spec.c index 3c21978e..34be90c2 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2630,7 +2630,7 @@ void P_SpawnSpecials (void) // Pre-calculate sky color R_GetSkyColor(texturetranslation[sides[*lines[i].sidenum].toptexture]); for (s = -1; (s = P_FindSectorFromLineTag(lines+i,s)) >= 0;) - sectors[s].sky = i | PL_SKYFLAT; + sectors[s].floorsky = sectors[s].ceilingsky = i | PL_SKYFLAT; break; } } diff --git a/src/r_bsp.c b/src/r_bsp.c index 99c5be83..645e28e4 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -616,7 +616,7 @@ static void R_Subsector(int num) sectors[frontsector->heightsec].ceilingpic == skyflatnum) ? R_FindPlane(frontsector->interpfloorheight, frontsector->floorpic == skyflatnum && // kilough 10/98 - frontsector->sky & PL_SKYFLAT ? frontsector->sky : + frontsector->floorsky & PL_SKYFLAT ? frontsector->floorsky : frontsector->floorpic, floorlightlevel, // killough 3/16/98 frontsector->floor_xoffs, // killough 3/7/98 @@ -629,7 +629,7 @@ static void R_Subsector(int num) sectors[frontsector->heightsec].floorpic == skyflatnum) ? R_FindPlane(frontsector->interpceilingheight, // killough 3/8/98 frontsector->ceilingpic == skyflatnum && // kilough 10/98 - frontsector->sky & PL_SKYFLAT ? frontsector->sky : + frontsector->ceilingsky & PL_SKYFLAT ? frontsector->ceilingsky : frontsector->ceilingpic, ceilinglightlevel, // killough 4/11/98 frontsector->ceiling_xoffs, // killough 3/7/98 diff --git a/src/r_defs.h b/src/r_defs.h index 605c0a5f..612d18c6 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -125,7 +125,7 @@ typedef struct sector_s // or ceilingpic, because the rest of Doom needs to know which is sky // and which isn't, etc. - int sky; + int floorsky, ceilingsky; // list of mobjs that are at least partially in the sector // thinglist is a subset of touching_thinglist diff --git a/src/r_plane.c b/src/r_plane.c index 77136220..04d1c10d 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -488,7 +488,13 @@ static void do_draw_mbf_sky(visplane_t *pl) an = viewangle; - if (pl->picnum & PL_SKYFLAT) + if ((pl->picnum & PL_FLATMAPPING) == PL_FLATMAPPING) + { + dc_texturemid = skytexturemid; + texture = pl->picnum & ~PL_FLATMAPPING; + flip = 0; + } + else if (pl->picnum & PL_SKYFLAT) { // Sky Linedef const line_t *l = &lines[pl->picnum & ~PL_SKYFLAT]; @@ -601,10 +607,19 @@ static void do_draw_plane(visplane_t *pl) // sky flat - if (pl->picnum == skyflatnum && sky) + if (sky) { - DrawSkyDef(pl); - return; + if ((pl->picnum & PL_FLATMAPPING) == PL_FLATMAPPING) + { + do_draw_mbf_sky(pl); + return; + } + + if (pl->picnum == skyflatnum) + { + DrawSkyDef(pl); + return; + } } if (pl->picnum == skyflatnum || pl->picnum & PL_SKYFLAT) diff --git a/src/r_sky.c b/src/r_sky.c index 908bbc04..ae0297cc 100644 --- a/src/r_sky.c +++ b/src/r_sky.c @@ -137,6 +137,29 @@ static void InitSky(void) return; } + flatmap_t *flatmap = NULL; + array_foreach(flatmap, skydefs->flatmapping) + { + int flatnum = R_FlatNumForName(flatmap->flat); + int skytex = R_TextureNumForName(flatmap->sky); + + for (int i = 0; i < numsectors; i++) + { + if (sectors[i].floorpic == flatnum) + { + sectors[i].floorpic = skyflatnum; + sectors[i].floorsky = skytex | PL_FLATMAPPING; + R_GetSkyColor(skytex); + } + if (sectors[i].ceilingpic == flatnum) + { + sectors[i].ceilingpic = skyflatnum; + sectors[i].ceilingsky = skytex | PL_FLATMAPPING; + R_GetSkyColor(skytex); + } + } + } + array_foreach(sky, skydefs->skies) { if (skytexture == R_CheckTextureNumForName(sky->skytex.name)) diff --git a/src/r_sky.h b/src/r_sky.h index a4491af9..138e7638 100644 --- a/src/r_sky.h +++ b/src/r_sky.h @@ -39,6 +39,8 @@ extern boolean linearsky; extern int skytexture; extern int skytexturemid; +#define PL_FLATMAPPING (0xC0000000) // (PL_SKYFLAT | 0x40000000) + extern sky_t *sky; // Called whenever the view size changes.