diff --git a/docs/rh-log.txt b/docs/rh-log.txt index dea52db43..fbfb4d264 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,11 @@ +May 23, 2008 (Changes by Graf Zahl) +- Fixed: side_t::GetLightLevel relied on the global 'linedef' variable for + automatic fake contrast. +- Changed: Fake contrast now uses the WALLF_AUTOCONTRAST globally instead + of manipulating the sides' light values individually. This allows changing + the fake contrast at run time and also allows adding individual relative + lighting on top of it which is a planned UDMF feature. + May 22, 2008 - Fixed: ActorStencilColor() did not set the palette part of the actor's fill color, so it would always produce black for STYLE_Shaded. diff --git a/src/g_level.cpp b/src/g_level.cpp index db1b63d45..f1a95647c 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -2373,8 +2373,8 @@ void G_InitLevelLocals () } level.airsupply = info->airsupply*TICRATE; level.outsidefog = info->outsidefog; - level.WallVertLight = info->WallVertLight; - level.WallHorizLight = info->WallHorizLight; + level.WallVertLight = info->WallVertLight*2; + level.WallHorizLight = info->WallHorizLight*2; if (info->gravity != 0.f) { level.gravity = info->gravity * 35/TICRATE; diff --git a/src/p_setup.cpp b/src/p_setup.cpp index fba52444e..c4b5e0d41 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -1601,7 +1601,6 @@ void P_FinishLoadingLineDef(line_t *ld, int alpha) ld->backsector = ld->sidenum[1]!=NO_SIDE ? sides[ld->sidenum[1]].sector : 0; float dx = FIXED2FLOAT(ld->v2->x - ld->v1->x); float dy = FIXED2FLOAT(ld->v2->y - ld->v1->y); - SBYTE light; int linenum = ld-lines; if (ld->frontsector == NULL) @@ -1611,20 +1610,16 @@ void P_FinishLoadingLineDef(line_t *ld, int alpha) // [RH] Set some new sidedef properties int len = (int)(sqrtf (dx*dx + dy*dy) + 0.5f); - light = dy == 0 ? level.WallHorizLight : - dx == 0 ? level.WallVertLight : 0; if (ld->sidenum[0] != NO_SIDE) { sides[ld->sidenum[0]].linenum = linenum; sides[ld->sidenum[0]].TexelLength = len; - sides[ld->sidenum[0]].Light = light; } if (ld->sidenum[1] != NO_SIDE) { sides[ld->sidenum[1]].linenum = linenum; sides[ld->sidenum[1]].TexelLength = len; - sides[ld->sidenum[1]].Light = light; } switch (ld->special) @@ -2171,6 +2166,7 @@ void P_LoadSideDefs2 (MapData * map) sd->SetTextureXOffset(LittleShort(msd->textureoffset)<SetTextureYOffset(LittleShort(msd->rowoffset)<linenum = NO_INDEX; + sd->Flags = WALLF_AUTOCONTRAST; // killough 4/4/98: allow sidedef texture names to be overloaded // killough 4/11/98: refined to allow colormaps to work as wall diff --git a/src/p_spec.cpp b/src/p_spec.cpp index 2f414c4f3..d724d4f31 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -791,12 +791,12 @@ void DWallLightTransfer::DoTransfer (BYTE lightlevel, int target, BYTE flags) if (flags & WLF_SIDE1 && line->sidenum[0]!=NO_SIDE) { - sides[line->sidenum[0]].Light = (BYTE)lightlevel; + sides[line->sidenum[0]].Light = lightlevel; } if (flags & WLF_SIDE2 && line->sidenum[1]!=NO_SIDE) { - sides[line->sidenum[1]].Light = (BYTE)lightlevel; + sides[line->sidenum[1]].Light = lightlevel; } } } diff --git a/src/r_defs.h b/src/r_defs.h index 01df40b65..d58c39632 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -489,7 +489,7 @@ struct side_t WORD linenum; DWORD LeftSide, RightSide; // [RH] Group walls into loops WORD TexelLength; - SBYTE Light; + SWORD Light; BYTE Flags; int GetLightLevel (bool foggy, int baselight) const; diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 894efc9ea..b9a7d0060 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -1423,31 +1423,25 @@ void R_NewWall (bool needlights) int side_t::GetLightLevel (bool foggy, int baselight) const { - // [RH] Get wall light level - if (this->Flags & WALLF_ABSLIGHTING && (!(this->Flags & WALLF_AUTOCONTRAST) || foggy)) + if (Flags & WALLF_ABSLIGHTING) { - return (BYTE)this->Light; + baselight = (BYTE)Light; } - else + + + if (!foggy) // Don't do relative lighting in foggy sectors { - if (!foggy) // Don't do relative lighting in foggy sectors + if (Flags & WALLF_AUTOCONTRAST) { - int rellight; - - if (this->Flags & WALLF_AUTOCONTRAST) - { - baselight = (BYTE)this->Light; - rellight = linedef->dx==0? level.WallVertLight : linedef->dy==0 ? level.WallHorizLight : 0; - } - else - { - rellight = this->Light; - } - - baselight += rellight * 2; + baselight += lines[linenum].dx==0? level.WallVertLight : + lines[linenum].dy==0? level.WallHorizLight : 0; + } + if (!(Flags & WALLF_ABSLIGHTING)) + { + baselight += this->Light; } - return baselight; } + return clamp(baselight, 0, 255); } FArchive &operator<< (FArchive &arc, side_t::part &p)