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; foundrover = true;
// If fading an invisible FOF whose render flags we did not yet set, // If fading an invisible FOF whose render flags we did not yet set,
// initialize its alpha to 1 // initialize its alpha to 0 for relative alpha calculation
// for relative alpha calc
if (!(line->args[3] & TMST_DONTDOTRANSLUCENT) && // do translucent 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_NOSHADE) && // do not include light blocks, which don't set FOF_NOSHADE
!(rover->spawnflags & FOF_RENDERSIDES) && !(rover->spawnflags & FOF_RENDERSIDES) &&
!(rover->spawnflags & FOF_RENDERPLANES) && !(rover->spawnflags & FOF_RENDERPLANES) &&
!(rover->fofflags & FOF_RENDERALL)) !(rover->fofflags & FOF_RENDERALL))
rover->alpha = 1; rover->alpha = 0;
P_RemoveFakeFloorFader(rover); P_RemoveFakeFloorFader(rover);
P_FadeFakeFloor(rover, P_FadeFakeFloor(rover,
rover->alpha, 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 0, // set alpha immediately
false, NULL, // tic-based logic false, NULL, // tic-based logic
false, // do not handle FOF_EXISTS false, // do not handle FOF_EXISTS
@ -3372,19 +3371,18 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
else else
{ {
// If fading an invisible FOF whose render flags we did not yet set, // If fading an invisible FOF whose render flags we did not yet set,
// initialize its alpha to 1 // initialize its alpha to 1 for relative alpha calculation
// for relative alpha calc
if (!(line->args[4] & TMFT_DONTDOTRANSLUCENT) && // do translucent 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_NOSHADE) && // do not include light blocks, which don't set FOF_NOSHADE
!(rover->spawnflags & FOF_RENDERSIDES) && !(rover->spawnflags & FOF_RENDERSIDES) &&
!(rover->spawnflags & FOF_RENDERPLANES) && !(rover->spawnflags & FOF_RENDERPLANES) &&
!(rover->fofflags & FOF_RENDERALL)) !(rover->fofflags & FOF_RENDERALL))
rover->alpha = 1; rover->alpha = 0;
P_RemoveFakeFloorFader(rover); P_RemoveFakeFloorFader(rover);
P_FadeFakeFloor(rover, P_FadeFakeFloor(rover,
rover->alpha, 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 0, // set alpha immediately
false, NULL, // tic-based logic false, NULL, // tic-based logic
!(line->args[4] & TMFT_DONTDOEXISTS), // do not handle FOF_EXISTS !(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 if (rover->master->special == 258) // Laser block
return false; return false;
// If fading an invisible FOF whose render flags we did not yet set, // If fading an invisible FOF whose render flags we did not yet set, initialize its alpha to 1
// initialize its alpha to 1
if (dotranslucent && if (dotranslucent &&
(rover->spawnflags & FOF_NOSHADE) && // do not include light blocks, which don't set FOF_NOSHADE (rover->spawnflags & FOF_NOSHADE) && // do not include light blocks, which don't set FOF_NOSHADE
!(rover->fofflags & FOF_FOG) && // do not include fog !(rover->fofflags & FOF_FOG) && // do not include fog
!(rover->spawnflags & FOF_RENDERSIDES) && !(rover->spawnflags & FOF_RENDERSIDES) &&
!(rover->spawnflags & FOF_RENDERPLANES) && !(rover->spawnflags & FOF_RENDERPLANES) &&
!(rover->fofflags & FOF_RENDERALL)) !(rover->fofflags & FOF_RENDERALL))
rover->alpha = 1; rover->alpha = 0;
if (fadingdata) if (fadingdata)
alpha = fadingdata->alpha; 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 (doexists && !(rover->spawnflags & FOF_BUSTUP))
{ {
if (alpha <= 1) if (alpha <= 0)
rover->fofflags &= ~FOF_EXISTS; rover->fofflags &= ~FOF_EXISTS;
else else
rover->fofflags |= FOF_EXISTS; 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 (dotranslucent && !(rover->fofflags & FOF_FOG))
{ {
if (alpha >= 256) if (alpha >= 255)
{ {
if (!(rover->fofflags & FOF_CUTSOLIDS) && if (!(rover->fofflags & FOF_CUTSOLIDS) &&
(rover->spawnflags & FOF_CUTSOLIDS)) (rover->spawnflags & FOF_CUTSOLIDS))
@ -7961,7 +7958,7 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 sourcevalue, INT16 destval
else // clamp fadingdata->alpha to software's alpha levels else // clamp fadingdata->alpha to software's alpha levels
{ {
if (alpha < 12) 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) else if (alpha < 38)
rover->alpha = destvalue >= 12 && destvalue < 38 ? destvalue : 25; rover->alpha = destvalue >= 12 && destvalue < 38 ? destvalue : 25;
else if (alpha < 64) else if (alpha < 64)
@ -7981,7 +7978,7 @@ static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 sourcevalue, INT16 destval
else if (alpha < 243) else if (alpha < 243)
rover->alpha = destvalue >= 217 && destvalue < 243 ? destvalue : 230; rover->alpha = destvalue >= 217 && destvalue < 243 ? destvalue : 230;
else // Opaque 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; fade_t *d;
// If fading an invisible FOF whose render flags we did not yet set, // If fading an invisible FOF whose render flags we did not yet set, initialize its alpha to 1
// initialize its alpha to 1
if (dotranslucent && if (dotranslucent &&
(rover->spawnflags & FOF_NOSHADE) && // do not include light blocks, which don't set FOF_NOSHADE (rover->spawnflags & FOF_NOSHADE) && // do not include light blocks, which don't set FOF_NOSHADE
!(rover->spawnflags & FOF_RENDERSIDES) && !(rover->spawnflags & FOF_RENDERSIDES) &&
!(rover->spawnflags & FOF_RENDERPLANES) && !(rover->spawnflags & FOF_RENDERPLANES) &&
!(rover->fofflags & FOF_RENDERALL)) !(rover->fofflags & FOF_RENDERALL))
rover->alpha = 1; rover->alpha = 0;
// already equal, nothing to do // 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; return;
d = Z_Malloc(sizeof *d, PU_LEVSPEC, NULL); 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->ffloornum = (UINT32)ffloornum;
d->alpha = d->sourcevalue = rover->alpha; 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) if (ticbased)
{ {