Make FOF fades use 0-255 alpha, not 1-256

This commit is contained in:
spherallic 2023-08-20 17:42:27 +02:00
parent 07ef7c4639
commit 259732cccb

View file

@ -3286,19 +3286,18 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
foundrover = true;
// If fading an invisible FOF whose render flags we did not yet set,
// initialize its alpha to 1
// for relative alpha calc
// initialize its alpha to 0 for relative alpha calculation
if (!(line->args[3] & TMST_DONTDOTRANSLUCENT) && // do translucent
(rover->spawnflags & FOF_NOSHADE) && // do not include light blocks, which don't set FOF_NOSHADE
!(rover->spawnflags & FOF_RENDERSIDES) &&
!(rover->spawnflags & FOF_RENDERPLANES) &&
!(rover->fofflags & FOF_RENDERALL))
rover->alpha = 1;
rover->alpha = 0;
P_RemoveFakeFloorFader(rover);
P_FadeFakeFloor(rover,
rover->alpha,
max(1, min(256, (line->args[3] & TMST_RELATIVE) ? rover->alpha + destvalue : destvalue)),
max(0, min(255, (line->args[3] & TMST_RELATIVE) ? rover->alpha + destvalue : destvalue)),
0, // set alpha immediately
false, NULL, // tic-based logic
false, // do not handle FOF_EXISTS
@ -3372,19 +3371,18 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
else
{
// If fading an invisible FOF whose render flags we did not yet set,
// initialize its alpha to 1
// for relative alpha calc
// initialize its alpha to 1 for relative alpha calculation
if (!(line->args[4] & TMFT_DONTDOTRANSLUCENT) && // do translucent
(rover->spawnflags & FOF_NOSHADE) && // do not include light blocks, which don't set FOF_NOSHADE
!(rover->spawnflags & FOF_RENDERSIDES) &&
!(rover->spawnflags & FOF_RENDERPLANES) &&
!(rover->fofflags & FOF_RENDERALL))
rover->alpha = 1;
rover->alpha = 0;
P_RemoveFakeFloorFader(rover);
P_FadeFakeFloor(rover,
rover->alpha,
max(1, min(256, (line->args[4] & TMFT_RELATIVE) ? rover->alpha + destvalue : destvalue)),
max(0, min(255, (line->args[4] & TMFT_RELATIVE) ? rover->alpha + destvalue : destvalue)),
0, // set alpha immediately
false, NULL, // tic-based logic
!(line->args[4] & TMFT_DONTDOEXISTS), // do not handle FOF_EXISTS
@ -7755,15 +7753,14 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 sourcevalue, INT16 destval
if (rover->master->special == 258) // Laser block
return false;
// If fading an invisible FOF whose render flags we did not yet set,
// initialize its alpha to 1
// If fading an invisible FOF whose render flags we did not yet set, initialize its alpha to 1
if (dotranslucent &&
(rover->spawnflags & FOF_NOSHADE) && // do not include light blocks, which don't set FOF_NOSHADE
!(rover->fofflags & FOF_FOG) && // do not include fog
!(rover->spawnflags & FOF_RENDERSIDES) &&
!(rover->spawnflags & FOF_RENDERPLANES) &&
!(rover->fofflags & FOF_RENDERALL))
rover->alpha = 1;
rover->alpha = 0;
if (fadingdata)
alpha = fadingdata->alpha;
@ -7849,7 +7846,7 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 sourcevalue, INT16 destval
{
if (doexists && !(rover->spawnflags & FOF_BUSTUP))
{
if (alpha <= 1)
if (alpha <= 0)
rover->fofflags &= ~FOF_EXISTS;
else
rover->fofflags |= FOF_EXISTS;
@ -7861,7 +7858,7 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 sourcevalue, INT16 destval
if (dotranslucent && !(rover->fofflags & FOF_FOG))
{
if (alpha >= 256)
if (alpha >= 255)
{
if (!(rover->fofflags & FOF_CUTSOLIDS) &&
(rover->spawnflags & FOF_CUTSOLIDS))
@ -7961,11 +7958,11 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 sourcevalue, INT16 destval
else // clamp fadingdata->alpha to software's alpha levels
{
if (alpha < 12)
rover->alpha = destvalue < 12 ? destvalue : 1; // Don't even draw it
rover->alpha = destvalue < 12 ? destvalue : 0; // Don't even draw it
else if (alpha < 38)
rover->alpha = destvalue >= 12 && destvalue < 38 ? destvalue : 25;
else if (alpha < 64)
rover->alpha = destvalue >=38 && destvalue < 64 ? destvalue : 51;
rover->alpha = destvalue >= 38 && destvalue < 64 ? destvalue : 51;
else if (alpha < 89)
rover->alpha = destvalue >= 64 && destvalue < 89 ? destvalue : 76;
else if (alpha < 115)
@ -7981,7 +7978,7 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 sourcevalue, INT16 destval
else if (alpha < 243)
rover->alpha = destvalue >= 217 && destvalue < 243 ? destvalue : 230;
else // Opaque
rover->alpha = destvalue >= 243 ? destvalue : 256;
rover->alpha = destvalue >= 243 ? destvalue : 255;
}
}
@ -8011,17 +8008,16 @@ static void P_AddFakeFloorFader(ffloor_t *rover, size_t sectornum, size_t ffloor
{
fade_t *d;
// If fading an invisible FOF whose render flags we did not yet set,
// initialize its alpha to 1
// If fading an invisible FOF whose render flags we did not yet set, initialize its alpha to 1
if (dotranslucent &&
(rover->spawnflags & FOF_NOSHADE) && // do not include light blocks, which don't set FOF_NOSHADE
!(rover->spawnflags & FOF_RENDERSIDES) &&
!(rover->spawnflags & FOF_RENDERPLANES) &&
!(rover->fofflags & FOF_RENDERALL))
rover->alpha = 1;
rover->alpha = 0;
// already equal, nothing to do
if (rover->alpha == max(1, min(256, relative ? rover->alpha + destvalue : destvalue)))
if (rover->alpha == max(0, min(255, relative ? rover->alpha + destvalue : destvalue)))
return;
d = Z_Malloc(sizeof *d, PU_LEVSPEC, NULL);
@ -8032,7 +8028,7 @@ static void P_AddFakeFloorFader(ffloor_t *rover, size_t sectornum, size_t ffloor
d->ffloornum = (UINT32)ffloornum;
d->alpha = d->sourcevalue = rover->alpha;
d->destvalue = max(1, min(256, relative ? rover->alpha + destvalue : destvalue)); // rover->alpha is 1-256
d->destvalue = max(0, min(255, relative ? rover->alpha + destvalue : destvalue)); // rover->alpha is 0-255
if (ticbased)
{