From 0b365d0d08df2922d92512267f85462b08e97475 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 7 Sep 2018 15:27:18 -0400 Subject: [PATCH 001/132] Initial polyobj fade skeleton --- src/p_polyobj.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++ src/p_polyobj.h | 17 +++++++++++++ src/p_saveg.c | 24 ++++++++++++++++++ src/p_spec.c | 32 ++++++++++++++++++++++++ 4 files changed, 138 insertions(+) diff --git a/src/p_polyobj.c b/src/p_polyobj.c index fd3237c9d..d943a0bfe 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -2853,6 +2853,71 @@ INT32 EV_DoPolyObjFlag(line_t *pfdata) return 1; } +void T_PolyObjFade(polyfade_t *th) +{ + polyobj_t *po = Polyobj_GetForNum(th->polyObjNum); + size_t i; + + if (!po) +#ifdef RANGECHECK + I_Error("T_PolyObjFade: thinker has invalid id %d\n", th->polyObjNum); +#else + { + CONS_Debug(DBG_POLYOBJ, "T_PolyObjFade: thinker with invalid id %d removed.\n", th->polyObjNum); + P_RemoveThinkerDelayed(&th->thinker); + return; + } +#endif + + // check for displacement due to override and reattach when possible + if (po->thinker == NULL) + po->thinker = &th->thinker; + + // \todo logic +} + +INT32 EV_DoPolyObjFade(polyfadedata_t *pfdata) +{ + polyobj_t *po; + polyobj_t *oldpo; + polyfade_t *th; + INT32 start; + + if (!(po = Polyobj_GetForNum(prdata->polyObjNum))) + { + CONS_Debug(DBG_POLYOBJ, "EV_DoPolyObjRotate: bad polyobj %d\n", prdata->polyObjNum); + return 0; + } + + // don't allow line actions to affect bad polyobjects + if (po->isBad) + return 0; + + // create a new thinker + th = Z_Malloc(sizeof(polyfade_t), PU_LEVSPEC, NULL); + th->thinker.function.acp1 = (actionf_p1)T_PolyObjFade; + PolyObj_AddThinker(&th->thinker); + po->thinker = &th->thinker; + + // set fields + th->polyObjNum = pfdata->tag; + + // \todo polyfade fields + + oldpo = po; + + // apply action to mirroring polyobjects as well + start = 0; + while ((po = Polyobj_GetChild(oldpo, &start))) + { + pfdata->tag = po->id; + EV_DoPolyObjFade(pfdata); + } + + // action was successful + return 1; +} + #endif // ifdef POLYOBJECTS // EOF diff --git a/src/p_polyobj.h b/src/p_polyobj.h index c9838a922..0bd94a636 100644 --- a/src/p_polyobj.h +++ b/src/p_polyobj.h @@ -207,6 +207,15 @@ typedef struct polydisplace_s fixed_t oldHeights; } polydisplace_t; +typedef struct polyfade_s +{ + thinker_t thinker; // must be first + + INT32 polyObjNum; + + // \todo polyfade fields +} polyfade_t; + // // Line Activation Data Structures // @@ -266,6 +275,12 @@ typedef struct polydisplacedata_s fixed_t dy; } polydisplacedata_t; +typedef struct polyfadedata_s +{ + INT32 polyObjNum; + // \todo polyfadedata fields +} polyfadedata_t; + // // Functions // @@ -287,6 +302,7 @@ void T_PolyDoorSlide(polyslidedoor_t *); void T_PolyDoorSwing(polyswingdoor_t *); void T_PolyObjDisplace (polydisplace_t *); void T_PolyObjFlag (polymove_t *); +void T_PolyObjFade (polyfade_t *); INT32 EV_DoPolyDoor(polydoordata_t *); INT32 EV_DoPolyObjMove(polymovedata_t *); @@ -294,6 +310,7 @@ INT32 EV_DoPolyObjWaypoint(polywaypointdata_t *); INT32 EV_DoPolyObjRotate(polyrotdata_t *); INT32 EV_DoPolyObjDisplace(polydisplacedata_t *); INT32 EV_DoPolyObjFlag(struct line_s *); +INT32 EV_DoPolyObjFade(polyfadedata_t *); // diff --git a/src/p_saveg.c b/src/p_saveg.c index 22d43f358..3cc061ebb 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1019,6 +1019,7 @@ typedef enum tc_polyswingdoor, tc_polyflag, tc_polydisplace, + tc_polyfade, #endif tc_end } specials_e; @@ -1918,6 +1919,11 @@ static void P_NetArchiveThinkers(void) SavePolydisplaceThinker(th, tc_polydisplace); continue; } + else if (th->function.acp1 == (actionf_p1)T_PolyObjFade) + { + SavePolyfadeThinker(th, tc_polyfade); + continue; + } #endif #ifdef PARANOIA else if (th->function.acv != P_RemoveThinkerDelayed) // wait garbage collection @@ -2689,6 +2695,20 @@ static inline void LoadPolydisplaceThinker(actionf_p1 thinker) ht->oldHeights = READFIXED(save_p); P_AddThinker(&ht->thinker); } + +// +// LoadPolyfadeThinker +// +// Loads a polyfadet_t thinker +// +static void LoadPolyfadeThinker(actionf_p1 thinker) +{ + polyfade_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); + ht->thinker.function.acp1 = thinker; + ht->polyObjNum = READINT32(save_p); + // \todo polyfade thinker fields + P_AddThinker(&ht->thinker); +} #endif /* @@ -2886,6 +2906,10 @@ static void P_NetUnArchiveThinkers(void) case tc_polydisplace: LoadPolydisplaceThinker((actionf_p1)T_PolyObjDisplace); break; + + case tc_polyfade: + LoadPolyfadeThinker((actionf_p1)T_PolyObjFade); + break; #endif case tc_scroll: LoadScrollThinker((actionf_p1)T_Scroll); diff --git a/src/p_spec.c b/src/p_spec.c index 6c359c9cc..fd2c312fb 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1245,6 +1245,35 @@ static void PolyTranslucency(line_t *line) po->translucency = (line->frontsector->floorheight >> FRACBITS) / 100; } +// +// PolyFade +// +// Makes a polyobject translucency fade and applies tangibility +// +static void PolyFade(line_t *line) +{ + INT32 polyObjNum = line->tag; + polyobj_t *po; + + if (!(po = Polyobj_GetForNum(polyObjNum))) + { + CONS_Debug(DBG_POLYOBJ, "EV_DoPolyObjWaypoint: bad polyobj %d\n", polyObjNum); + return; + } + + // don't allow line actions to affect bad polyobjects + if (po->isBad) + return; + + polyfadedata_t pfd; + + pfd.polyObjNum = line->tag; + + // \todo polyfadedata fields + + return EV_DoPolyObjFade(&pfd); +} + // // PolyWaypoint // @@ -3337,6 +3366,9 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) case 491: PolyTranslucency(line); break; + case 492: + PolyFade(line); + break; #endif default: From f52f72256bd7abbd36876f42a213ca2e02121634 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 7 Sep 2018 18:14:52 -0400 Subject: [PATCH 002/132] Thwomp fix: Don't trigger (look for players) when ~FF_EXISTS --- src/p_floor.c | 44 ++++++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/src/p_floor.c b/src/p_floor.c index 0e28b831f..bb6bf8d16 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -1839,6 +1839,7 @@ void T_ThwompSector(levelspecthink_t *thwomp) #define ceilingwasheight vars[5] fixed_t thwompx, thwompy; sector_t *actionsector; + ffloor_t *rover = NULL; INT32 secnum; // If you just crashed down, wait a second before coming back up. @@ -1853,7 +1854,16 @@ void T_ThwompSector(levelspecthink_t *thwomp) secnum = P_FindSectorFromTag((INT16)thwomp->vars[0], -1); if (secnum > 0) + { actionsector = §ors[secnum]; + + // Look for thwomp FFloor + for (rover = actionsector->ffloors; rover; rover = rover->next) + { + if (rover->master == thwomp->sourceline) + break; + } + } else return; // Bad bad bad! @@ -1942,10 +1952,13 @@ void T_ThwompSector(levelspecthink_t *thwomp) { mobj_t *mp = (void *)&actionsector->soundorg; - if (thwomp->sourceline->flags & ML_EFFECT4) - S_StartSound(mp, sides[thwomp->sourceline->sidenum[0]].textureoffset>>FRACBITS); - else - S_StartSound(mp, sfx_thwomp); + if (!rover || (rover->flags & FF_EXISTS)) + { + if (thwomp->sourceline->flags & ML_EFFECT4) + S_StartSound(mp, sides[thwomp->sourceline->sidenum[0]].textureoffset>>FRACBITS); + else + S_StartSound(mp, sfx_thwomp); + } thwomp->direction = 1; // start heading back up thwomp->distance = TICRATE; // but only after a small delay @@ -1959,18 +1972,21 @@ void T_ThwompSector(levelspecthink_t *thwomp) thinker_t *th; mobj_t *mo; - // scan the thinkers to find players! - for (th = thinkercap.next; th != &thinkercap; th = th->next) + if (!rover || (rover->flags & FF_EXISTS)) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) - continue; - - mo = (mobj_t *)th; - if (mo->type == MT_PLAYER && mo->health && mo->z <= thwomp->sector->ceilingheight - && P_AproxDistance(thwompx - mo->x, thwompy - mo->y) <= 96*FRACUNIT) + // scan the thinkers to find players! + for (th = thinkercap.next; th != &thinkercap; th = th->next) { - thwomp->direction = -1; - break; + if (th->function.acp1 != (actionf_p1)P_MobjThinker) + continue; + + mo = (mobj_t *)th; + if (mo->type == MT_PLAYER && mo->health && mo->z <= thwomp->sector->ceilingheight + && P_AproxDistance(thwompx - mo->x, thwompy - mo->y) <= 96*FRACUNIT) + { + thwomp->direction = -1; + break; + } } } From 76d7a54b2b5e1c4a125f3bfbfb5b4336cf50688c Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 8 Sep 2018 00:34:56 -0400 Subject: [PATCH 003/132] Fix player Z snap to floor on moving platform ~FF_EXISTS * Track player's old floorz by mo->floor_sectornum and floor_ffloornum * Track tmfloorz by tmfloorrover, tmfloor_sectornum, tmfloor_rovernum * Ceiling variants of the above --- src/p_map.c | 100 +++++++++++++++++++++++++++++++++++++++++++++----- src/p_mobj.h | 4 ++ src/p_saveg.c | 13 +++++++ 3 files changed, 108 insertions(+), 9 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index f951621e2..8d0a7aeb1 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -52,6 +52,8 @@ fixed_t tmfloorz, tmceilingz; static fixed_t tmdropoffz, tmdrpoffceilz; // drop-off floor/ceiling heights mobj_t *tmfloorthing; // the thing corresponding to tmfloorz or NULL if tmfloorz is from a sector mobj_t *tmhitthing; // the solid thing you bumped into (for collisions) +ffloor_t *tmfloorrover, *tmceilingrover; +size_t tmfloor_sectornum, tmfloor_rovernum, tmceiling_sectornum, tmceiling_rovernum; #ifdef ESLOPE pslope_t *tmfloorslope, *tmceilingslope; #endif @@ -1417,6 +1419,8 @@ static boolean PIT_CheckThing(mobj_t *thing) if (thing->z + thing->height > tmfloorz) { tmfloorz = thing->z + thing->height; + tmfloorrover = NULL; + tmfloor_sectornum = tmfloor_rovernum = 0; #ifdef ESLOPE tmfloorslope = NULL; #endif @@ -1437,6 +1441,8 @@ static boolean PIT_CheckThing(mobj_t *thing) return false; tmfloorz = tmceilingz = topz; // block while in air + tmceilingrover = NULL; + tmceiling_sectornum = tmceiling_rovernum = 0; #ifdef ESLOPE tmceilingslope = NULL; #endif @@ -1445,6 +1451,8 @@ static boolean PIT_CheckThing(mobj_t *thing) else if (topz < tmceilingz && tmthing->z <= thing->z+thing->height) { tmceilingz = topz; + tmceilingrover = NULL; + tmceiling_sectornum = tmceiling_rovernum = 0; #ifdef ESLOPE tmceilingslope = NULL; #endif @@ -1461,6 +1469,8 @@ static boolean PIT_CheckThing(mobj_t *thing) if (thing->z < tmceilingz) { tmceilingz = thing->z; + tmceilingrover = NULL; + tmceiling_sectornum = tmceiling_rovernum = 0; #ifdef ESLOPE tmceilingslope = NULL; #endif @@ -1481,6 +1491,8 @@ static boolean PIT_CheckThing(mobj_t *thing) return false; tmfloorz = tmceilingz = topz; // block while in air + tmfloorrover = NULL; + tmfloor_sectornum = tmfloor_rovernum = 0; #ifdef ESLOPE tmfloorslope = NULL; #endif @@ -1489,6 +1501,8 @@ static boolean PIT_CheckThing(mobj_t *thing) else if (topz > tmfloorz && tmthing->z+tmthing->height >= thing->z) { tmfloorz = topz; + tmfloorrover = NULL; + tmfloor_sectornum = tmfloor_rovernum = 0; #ifdef ESLOPE tmfloorslope = NULL; #endif @@ -1640,6 +1654,8 @@ static boolean PIT_CheckLine(line_t *ld) { tmceilingz = opentop; ceilingline = ld; + tmceilingrover = NULL; + tmceiling_sectornum = tmceiling_rovernum = 0; #ifdef ESLOPE tmceilingslope = opentopslope; #endif @@ -1648,6 +1664,8 @@ static boolean PIT_CheckLine(line_t *ld) if (openbottom > tmfloorz) { tmfloorz = openbottom; + tmfloorrover = NULL; + tmfloor_sectornum = tmfloor_rovernum = 0; #ifdef ESLOPE tmfloorslope = openbottomslope; #endif @@ -1729,6 +1747,10 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) // will adjust them. tmfloorz = tmdropoffz = P_GetFloorZ(thing, newsubsec->sector, x, y, NULL); //newsubsec->sector->floorheight; tmceilingz = P_GetCeilingZ(thing, newsubsec->sector, x, y, NULL); //newsubsec->sector->ceilingheight; + tmfloorrover = NULL; + tmfloor_sectornum = tmfloor_rovernum = 0; + tmceilingrover = NULL; + tmceiling_sectornum = tmceiling_rovernum = 0; #ifdef ESLOPE tmfloorslope = newsubsec->sector->f_slope; tmceilingslope = newsubsec->sector->c_slope; @@ -1738,6 +1760,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) if (newsubsec->sector->ffloors) { ffloor_t *rover; + size_t rovernum = 0; fixed_t delta1, delta2; INT32 thingtop = thing->z + thing->height; @@ -1746,7 +1769,10 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) fixed_t topheight, bottomheight; if (!(rover->flags & FF_EXISTS)) + { + rovernum++; continue; + } topheight = P_GetFOFTopZ(thing, newsubsec->sector, rover, x, y, NULL); bottomheight = P_GetFOFBottomZ(thing, newsubsec->sector, rover, x, y, NULL); @@ -1772,6 +1798,9 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) { if (tmfloorz < topheight - sinklevel) { tmfloorz = topheight - sinklevel; + tmfloorrover = rover; + tmfloor_sectornum = newsubsec->sector - sectors; + tmfloor_rovernum = rovernum; #ifdef ESLOPE tmfloorslope = *rover->t_slope; #endif @@ -1781,12 +1810,16 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) { if (tmceilingz > bottomheight + sinklevel) { tmceilingz = bottomheight + sinklevel; + tmceilingrover = rover; + tmceiling_sectornum = newsubsec->sector - sectors; + tmceiling_rovernum = rovernum; #ifdef ESLOPE tmceilingslope = *rover->b_slope; #endif } } } + rovernum++; continue; } @@ -1797,7 +1830,10 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) else if (!((rover->flags & FF_BLOCKPLAYER && thing->player) || (rover->flags & FF_BLOCKOTHERS && !thing->player) || rover->flags & FF_QUICKSAND)) + { + rovernum++; continue; + } if (rover->flags & FF_QUICKSAND) { @@ -1805,12 +1841,16 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) { if (tmfloorz < thing->z) { tmfloorz = thing->z; + tmfloorrover = rover; + tmfloor_sectornum = newsubsec->sector - sectors; + tmfloor_rovernum = rovernum; #ifdef ESLOPE tmfloorslope = NULL; #endif } } // Quicksand blocks never change heights otherwise. + rovernum++; continue; } @@ -1823,6 +1863,9 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) && !(rover->flags & FF_REVERSEPLATFORM)) { tmfloorz = tmdropoffz = topheight; + tmfloorrover = rover; + tmfloor_sectornum = newsubsec->sector - sectors; + tmfloor_rovernum = rovernum; #ifdef ESLOPE tmfloorslope = *rover->t_slope; #endif @@ -1832,10 +1875,14 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) && !(thing->type == MT_SKIM && (rover->flags & FF_SWIMMABLE))) { tmceilingz = tmdrpoffceilz = bottomheight; + tmceilingrover = rover; + tmceiling_sectornum = newsubsec->sector - sectors; + tmceiling_rovernum = rovernum; #ifdef ESLOPE tmceilingslope = *rover->b_slope; #endif } + rovernum++; } } @@ -2328,6 +2375,12 @@ boolean PIT_PushableMoved(mobj_t *thing) mobj_t *oldthing = tmthing; line_t *oldceilline = ceilingline; line_t *oldblockline = blockingline; + ffloor_t *oldflrrover = tmfloorrover; + ffloor_t *oldceilrover = tmceilingrover; + size_t oldflrrover_sectornum = tmfloor_sectornum; + size_t oldflrrover_ffloornum = tmfloor_rovernum; + size_t oldceilrover_sectornum = tmceiling_sectornum; + size_t oldceilrover_ffloornum = tmceiling_rovernum; #ifdef ESLOPE pslope_t *oldfslope = tmfloorslope; pslope_t *oldcslope = tmceilingslope; @@ -2344,6 +2397,12 @@ boolean PIT_PushableMoved(mobj_t *thing) P_SetTarget(&tmthing, oldthing); ceilingline = oldceilline; blockingline = oldblockline; + tmfloorrover = oldflrrover; + tmceilingrover = oldceilrover; + tmfloor_sectornum = oldflrrover_sectornum; + tmfloor_rovernum = oldflrrover_ffloornum; + tmceiling_sectornum = oldceilrover_sectornum; + tmceiling_rovernum = oldceilrover_ffloornum; #ifdef ESLOPE tmfloorslope = oldfslope; tmceilingslope = oldcslope; @@ -2663,7 +2722,9 @@ static boolean P_ThingHeightClip(mobj_t *thing) { boolean floormoved; fixed_t oldfloorz = thing->floorz; + size_t oldfloor_sectornum = thing->floor_sectornum, oldfloor_rovernum = thing->floor_rovernum; boolean onfloor = P_IsObjectOnGround(thing);//(thing->z <= thing->floorz); + ffloor_t *rover = NULL; if (thing->flags & MF_NOCLIPHEIGHT) return true; @@ -2678,6 +2739,10 @@ static boolean P_ThingHeightClip(mobj_t *thing) thing->floorz = tmfloorz; thing->ceilingz = tmceilingz; + thing->floor_sectornum = tmfloor_sectornum; + thing->floor_rovernum = tmfloor_rovernum; + thing->ceiling_sectornum = tmceiling_sectornum; + thing->ceiling_rovernum = tmceiling_rovernum; // Ugly hack?!?! As long as just ceilingz is the lowest, // you'll still get crushed, right? @@ -2686,16 +2751,33 @@ static boolean P_ThingHeightClip(mobj_t *thing) if (onfloor && !(thing->flags & MF_NOGRAVITY) && floormoved) { - if (thing->eflags & MFE_VERTICALFLIP) - thing->pmomz = thing->ceilingz - (thing->z + thing->height); - else - thing->pmomz = thing->floorz - thing->z; - thing->eflags |= MFE_APPLYPMOMZ; + // Find FOF referenced by floorz + if (oldfloor_sectornum) + { + size_t rovernum = 0; + for (rover = sectors[oldfloor_sectornum].ffloors; rover; rover = rover->next) + { + if (rovernum == oldfloor_rovernum) + break; + rovernum++; + } + } - if (thing->eflags & MFE_VERTICALFLIP) - thing->z = thing->ceilingz - thing->height; - else - thing->z = thing->floorz; + // Match the Thing's old floorz to an FOF and check for FF_EXISTS + // If ~FF_EXISTS, don't set mobj Z. + if (!rover || (rover->flags & FF_EXISTS)) + { + if (thing->eflags & MFE_VERTICALFLIP) + thing->pmomz = thing->ceilingz - (thing->z + thing->height); + else + thing->pmomz = thing->floorz - thing->z; + thing->eflags |= MFE_APPLYPMOMZ; + + if (thing->eflags & MFE_VERTICALFLIP) + thing->z = thing->ceilingz - thing->height; + else + thing->z = thing->floorz; + } } else if (!tmfloorthing) { diff --git a/src/p_mobj.h b/src/p_mobj.h index afab6fda6..3a83a0f58 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -282,6 +282,10 @@ typedef struct mobj_s // The closest interval over all contacted sectors (or things). fixed_t floorz; // Nearest floor below. fixed_t ceilingz; // Nearest ceiling above. + size_t floor_sectornum; // FOF referred by floorz + size_t floor_rovernum; // FOF referred by floorz + size_t ceiling_sectornum; // FOF referred by ceilingz + size_t ceiling_rovernum; // FOF referred by ceilingz // For movement checking. fixed_t radius; diff --git a/src/p_saveg.c b/src/p_saveg.c index 22d43f358..33dfd1424 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1192,6 +1192,10 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) WRITEFIXED(save_p, mobj->z); // Force this so 3dfloor problems don't arise. WRITEFIXED(save_p, mobj->floorz); WRITEFIXED(save_p, mobj->ceilingz); + WRITEUINT32(save_p, (UINT32)mobj->floor_sectornum); + WRITEUINT32(save_p, (UINT32)mobj->floor_rovernum); + WRITEUINT32(save_p, (UINT32)mobj->ceiling_sectornum); + WRITEUINT32(save_p, (UINT32)mobj->ceiling_rovernum); if (diff & MD_SPAWNPOINT) { @@ -1989,6 +1993,7 @@ static void LoadMobjThinker(actionf_p1 thinker) UINT16 diff2; INT32 i; fixed_t z, floorz, ceilingz; + size_t floor_sectornum, floor_rovernum, ceiling_sectornum, ceiling_rovernum; diff = READUINT32(save_p); if (diff & MD_MORE) @@ -2001,6 +2006,10 @@ static void LoadMobjThinker(actionf_p1 thinker) z = READFIXED(save_p); // Force this so 3dfloor problems don't arise. floorz = READFIXED(save_p); ceilingz = READFIXED(save_p); + floor_sectornum = (size_t)READUINT32(save_p); + floor_rovernum = (size_t)READUINT32(save_p); + ceiling_sectornum = (size_t)READUINT32(save_p); + ceiling_rovernum = (size_t)READUINT32(save_p); if (diff & MD_SPAWNPOINT) { @@ -2026,6 +2035,10 @@ static void LoadMobjThinker(actionf_p1 thinker) mobj->z = z; mobj->floorz = floorz; mobj->ceilingz = ceilingz; + mobj->floor_sectornum = floor_sectornum; + mobj->floor_rovernum = floor_rovernum; + mobj->ceiling_sectornum = ceiling_sectornum; + mobj->ceiling_rovernum = ceiling_rovernum; if (diff & MD_TYPE) mobj->type = READUINT32(save_p); From 7e3d5cd3734c5b2194dca7fb8875c9cfeca97dc4 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 8 Sep 2018 00:36:43 -0400 Subject: [PATCH 004/132] Comment out tmfloorrover and tmceilingrover because unused --- src/p_map.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index 8d0a7aeb1..62f64922c 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -52,7 +52,7 @@ fixed_t tmfloorz, tmceilingz; static fixed_t tmdropoffz, tmdrpoffceilz; // drop-off floor/ceiling heights mobj_t *tmfloorthing; // the thing corresponding to tmfloorz or NULL if tmfloorz is from a sector mobj_t *tmhitthing; // the solid thing you bumped into (for collisions) -ffloor_t *tmfloorrover, *tmceilingrover; +//ffloor_t *tmfloorrover, *tmceilingrover; // unused for now size_t tmfloor_sectornum, tmfloor_rovernum, tmceiling_sectornum, tmceiling_rovernum; #ifdef ESLOPE pslope_t *tmfloorslope, *tmceilingslope; @@ -1419,7 +1419,7 @@ static boolean PIT_CheckThing(mobj_t *thing) if (thing->z + thing->height > tmfloorz) { tmfloorz = thing->z + thing->height; - tmfloorrover = NULL; + // tmfloorrover = NULL; tmfloor_sectornum = tmfloor_rovernum = 0; #ifdef ESLOPE tmfloorslope = NULL; @@ -1441,7 +1441,7 @@ static boolean PIT_CheckThing(mobj_t *thing) return false; tmfloorz = tmceilingz = topz; // block while in air - tmceilingrover = NULL; + // tmceilingrover = NULL; tmceiling_sectornum = tmceiling_rovernum = 0; #ifdef ESLOPE tmceilingslope = NULL; @@ -1451,7 +1451,7 @@ static boolean PIT_CheckThing(mobj_t *thing) else if (topz < tmceilingz && tmthing->z <= thing->z+thing->height) { tmceilingz = topz; - tmceilingrover = NULL; + // tmceilingrover = NULL; tmceiling_sectornum = tmceiling_rovernum = 0; #ifdef ESLOPE tmceilingslope = NULL; @@ -1469,7 +1469,7 @@ static boolean PIT_CheckThing(mobj_t *thing) if (thing->z < tmceilingz) { tmceilingz = thing->z; - tmceilingrover = NULL; + // tmceilingrover = NULL; tmceiling_sectornum = tmceiling_rovernum = 0; #ifdef ESLOPE tmceilingslope = NULL; @@ -1491,7 +1491,7 @@ static boolean PIT_CheckThing(mobj_t *thing) return false; tmfloorz = tmceilingz = topz; // block while in air - tmfloorrover = NULL; + // tmfloorrover = NULL; tmfloor_sectornum = tmfloor_rovernum = 0; #ifdef ESLOPE tmfloorslope = NULL; @@ -1501,7 +1501,7 @@ static boolean PIT_CheckThing(mobj_t *thing) else if (topz > tmfloorz && tmthing->z+tmthing->height >= thing->z) { tmfloorz = topz; - tmfloorrover = NULL; + // tmfloorrover = NULL; tmfloor_sectornum = tmfloor_rovernum = 0; #ifdef ESLOPE tmfloorslope = NULL; @@ -1654,7 +1654,7 @@ static boolean PIT_CheckLine(line_t *ld) { tmceilingz = opentop; ceilingline = ld; - tmceilingrover = NULL; + // tmceilingrover = NULL; tmceiling_sectornum = tmceiling_rovernum = 0; #ifdef ESLOPE tmceilingslope = opentopslope; @@ -1664,7 +1664,7 @@ static boolean PIT_CheckLine(line_t *ld) if (openbottom > tmfloorz) { tmfloorz = openbottom; - tmfloorrover = NULL; + // tmfloorrover = NULL; tmfloor_sectornum = tmfloor_rovernum = 0; #ifdef ESLOPE tmfloorslope = openbottomslope; @@ -1747,9 +1747,9 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) // will adjust them. tmfloorz = tmdropoffz = P_GetFloorZ(thing, newsubsec->sector, x, y, NULL); //newsubsec->sector->floorheight; tmceilingz = P_GetCeilingZ(thing, newsubsec->sector, x, y, NULL); //newsubsec->sector->ceilingheight; - tmfloorrover = NULL; + // tmfloorrover = NULL; tmfloor_sectornum = tmfloor_rovernum = 0; - tmceilingrover = NULL; + // tmceilingrover = NULL; tmceiling_sectornum = tmceiling_rovernum = 0; #ifdef ESLOPE tmfloorslope = newsubsec->sector->f_slope; @@ -1798,7 +1798,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) { if (tmfloorz < topheight - sinklevel) { tmfloorz = topheight - sinklevel; - tmfloorrover = rover; + // tmfloorrover = rover; tmfloor_sectornum = newsubsec->sector - sectors; tmfloor_rovernum = rovernum; #ifdef ESLOPE @@ -1810,7 +1810,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) { if (tmceilingz > bottomheight + sinklevel) { tmceilingz = bottomheight + sinklevel; - tmceilingrover = rover; + // tmceilingrover = rover; tmceiling_sectornum = newsubsec->sector - sectors; tmceiling_rovernum = rovernum; #ifdef ESLOPE @@ -1841,7 +1841,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) { if (tmfloorz < thing->z) { tmfloorz = thing->z; - tmfloorrover = rover; + // tmfloorrover = rover; tmfloor_sectornum = newsubsec->sector - sectors; tmfloor_rovernum = rovernum; #ifdef ESLOPE @@ -1863,7 +1863,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) && !(rover->flags & FF_REVERSEPLATFORM)) { tmfloorz = tmdropoffz = topheight; - tmfloorrover = rover; + // tmfloorrover = rover; tmfloor_sectornum = newsubsec->sector - sectors; tmfloor_rovernum = rovernum; #ifdef ESLOPE @@ -1875,7 +1875,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) && !(thing->type == MT_SKIM && (rover->flags & FF_SWIMMABLE))) { tmceilingz = tmdrpoffceilz = bottomheight; - tmceilingrover = rover; + // tmceilingrover = rover; tmceiling_sectornum = newsubsec->sector - sectors; tmceiling_rovernum = rovernum; #ifdef ESLOPE @@ -2375,8 +2375,8 @@ boolean PIT_PushableMoved(mobj_t *thing) mobj_t *oldthing = tmthing; line_t *oldceilline = ceilingline; line_t *oldblockline = blockingline; - ffloor_t *oldflrrover = tmfloorrover; - ffloor_t *oldceilrover = tmceilingrover; + // ffloor_t *oldflrrover = tmfloorrover; + // ffloor_t *oldceilrover = tmceilingrover; size_t oldflrrover_sectornum = tmfloor_sectornum; size_t oldflrrover_ffloornum = tmfloor_rovernum; size_t oldceilrover_sectornum = tmceiling_sectornum; @@ -2397,8 +2397,8 @@ boolean PIT_PushableMoved(mobj_t *thing) P_SetTarget(&tmthing, oldthing); ceilingline = oldceilline; blockingline = oldblockline; - tmfloorrover = oldflrrover; - tmceilingrover = oldceilrover; + // tmfloorrover = oldflrrover; + // tmceilingrover = oldceilrover; tmfloor_sectornum = oldflrrover_sectornum; tmfloor_rovernum = oldflrrover_ffloornum; tmceiling_sectornum = oldceilrover_sectornum; From b629104197ada81d27c84c023430749965ed5dc6 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 8 Sep 2018 01:02:17 -0400 Subject: [PATCH 005/132] Also check for FF_SOLID --- src/p_map.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_map.c b/src/p_map.c index 62f64922c..c275ba0be 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2765,7 +2765,7 @@ static boolean P_ThingHeightClip(mobj_t *thing) // Match the Thing's old floorz to an FOF and check for FF_EXISTS // If ~FF_EXISTS, don't set mobj Z. - if (!rover || (rover->flags & FF_EXISTS)) + if (!rover || ((rover->flags & FF_EXISTS) && (rover->flags & FF_SOLID))) { if (thing->eflags & MFE_VERTICALFLIP) thing->pmomz = thing->ceilingz - (thing->z + thing->height); From 1e1b01c1572f8dcb941e06ba0e914ef881ed1643 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 8 Sep 2018 22:10:51 -0400 Subject: [PATCH 006/132] Implemented tic-based light fading * ML_BLOCKMONSTERS specifies destvalue and speed by texture offsets * ML_NOCLIMB toggles tic-based logic * Added props `duration`, `interval`, and `firsttic` to `lightlevel_t` --- src/lua_baselib.c | 3 ++- src/p_lights.c | 47 ++++++++++++++++++++++++++++++++++++++++++----- src/p_saveg.c | 6 ++++++ src/p_spec.c | 5 ++++- src/p_spec.h | 7 ++++++- 5 files changed, 60 insertions(+), 8 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index c1fd87af3..840863eb0 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1809,9 +1809,10 @@ static int lib_pFadeLight(lua_State *L) INT16 tag = (INT16)luaL_checkinteger(L, 1); INT32 destvalue = (INT32)luaL_checkinteger(L, 2); INT32 speed = (INT32)luaL_checkinteger(L, 3); + boolean ticbased = lua_optboolean(L, 4); NOHUD INLEVEL - P_FadeLight(tag, destvalue, speed); + P_FadeLight(tag, destvalue, speed, ticbased); return 0; } diff --git a/src/p_lights.c b/src/p_lights.c index 8aa2eedca..e37eda5fb 100644 --- a/src/p_lights.c +++ b/src/p_lights.c @@ -13,6 +13,7 @@ /// Fire flicker, light flash, strobe flash, lightning flash, glow, and fade. #include "doomdef.h" +#include "doomstat.h" // gametic #include "p_local.h" #include "r_state.h" #include "z_zone.h" @@ -329,12 +330,10 @@ glow_t *P_SpawnAdjustableGlowingLight(sector_t *minsector, sector_t *maxsector, * \param destvalue The final light value in these sectors. * \param speed Speed of the fade; the change to the ligh * level in each sector per tic. - * \todo Calculate speed better so that it is possible to specify - * the time for completion of the fade, and all lights fade - * in this time regardless of initial values. + * \param ticbased Use a specific duration for the fade, defined by speed * \sa T_LightFade */ -void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed) +void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased) { INT32 i; lightlevel_t *ll; @@ -346,6 +345,13 @@ void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed) sector = §ors[i]; P_RemoveLighting(sector); // remove the old lighting effect first + + if ((ticbased && !speed) || sector->lightlevel == destvalue) // set immediately + { + sector->lightlevel = destvalue; + continue; + } + ll = Z_Calloc(sizeof (*ll), PU_LEVSPEC, NULL); ll->thinker.function.acp1 = (actionf_p1)T_LightFade; sector->lightingdata = ll; // set it to the lightlevel_t @@ -354,7 +360,21 @@ void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed) ll->sector = sector; ll->destlevel = destvalue; - ll->speed = speed; + + if (ticbased) + { + ll->duration = abs(speed); + ll->speed = FixedFloor(FixedDiv(destvalue - sector->lightlevel, ll->duration))/FRACUNIT; + if (!ll->speed) + ll->speed = (destvalue < sector->lightlevel) ? -1 : 1; + ll->interval = max(FixedFloor(FixedDiv(ll->duration, abs(destvalue - sector->lightlevel)))/FRACUNIT, 1); + ll->firsttic = gametic; + } + else + { + ll->duration = -1; + ll->speed = abs(speed); + } } } @@ -365,6 +385,23 @@ void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed) */ void T_LightFade(lightlevel_t *ll) { + if (ll->duration >= 0) // tic-based + { + if (gametic - ll->firsttic >= ll->duration) + { + ll->sector->lightlevel = (INT16)ll->destlevel; // set to dest lightlevel + P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker + } + else if (!((gametic - ll->firsttic) % ll->interval)) + { + if (ll->speed < 0) + ll->sector->lightlevel = max(ll->sector->lightlevel + (INT16)ll->speed, (INT16)ll->destlevel); + else + ll->sector->lightlevel = min(ll->sector->lightlevel + (INT16)ll->speed, (INT16)ll->destlevel); + } + return; + } + if (ll->sector->lightlevel < ll->destlevel) { // increase the lightlevel diff --git a/src/p_saveg.c b/src/p_saveg.c index 22d43f358..8ec5b5ea8 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1539,6 +1539,9 @@ static void SaveLightlevelThinker(const thinker_t *th, const UINT8 type) WRITEUINT32(save_p, SaveSector(ht->sector)); WRITEINT32(save_p, ht->destlevel); WRITEINT32(save_p, ht->speed); + WRITEINT32(save_p, ht->duration); + WRITEUINT32(save_p, ht->interval); + WRITEUINT32(save_p, (UINT32)ht->firsttic); } // @@ -2512,6 +2515,9 @@ static inline void LoadLightlevelThinker(actionf_p1 thinker) ht->sector = LoadSector(READUINT32(save_p)); ht->destlevel = READINT32(save_p); ht->speed = READINT32(save_p); + ht->duration = READINT32(save_p); + ht->interval = READUINT32(save_p); + ht->firsttic = (tic_t)READUINT32(save_p); if (ht->sector) ht->sector->lightingdata = ht; P_AddThinker(&ht->thinker); diff --git a/src/p_spec.c b/src/p_spec.c index 6c359c9cc..a894dcbfb 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2778,7 +2778,10 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 420: // Fade light levels in tagged sectors to new value - P_FadeLight(line->tag, line->frontsector->lightlevel, P_AproxDistance(line->dx, line->dy)>>FRACBITS); + P_FadeLight(line->tag, + (line->flags & ML_BLOCKMONSTERS) ? max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, 255), 0) : line->frontsector->lightlevel, + (line->flags & ML_BLOCKMONSTERS) ? max(sides[line->sidenum[0]].rowoffset>>FRACBITS, 0) : P_AproxDistance(line->dx, line->dy)>>FRACBITS, + (line->flags & ML_NOCLIMB)); break; case 421: // Stop lighting effect in tagged sectors diff --git a/src/p_spec.h b/src/p_spec.h index e0bcc18eb..8e296891b 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -138,6 +138,11 @@ typedef struct sector_t *sector; ///< Sector where action is taking place. INT32 destlevel; ///< Light level we're fading to. INT32 speed; ///< Speed at which to change light level. + + // Tic-based behavior + INT32 duration; ///< If <0, do not use tic-based behavior. If 0, set instantly. If >0, fade lasts this duration. + UINT32 interval; ///< Interval to deduct light level + tic_t firsttic; ///< First gametic to count from } lightlevel_t; #define GLOWSPEED 8 @@ -156,7 +161,7 @@ strobe_t * P_SpawnAdjustableStrobeFlash(sector_t *minsector, sector_t *maxsector void T_Glow(glow_t *g); glow_t *P_SpawnAdjustableGlowingLight(sector_t *minsector, sector_t *maxsector, INT32 length); -void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed); +void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased); void T_LightFade(lightlevel_t *ll); typedef enum From 68e67917f1b345633151e3315ffd061d4fde5837 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 8 Sep 2018 22:14:49 -0400 Subject: [PATCH 007/132] Split P_FadeLight into P_FadeLightBySector --- src/p_lights.c | 80 +++++++++++++++++++++++++------------------------- src/p_spec.h | 1 + 2 files changed, 41 insertions(+), 40 deletions(-) diff --git a/src/p_lights.c b/src/p_lights.c index e37eda5fb..8be3d793c 100644 --- a/src/p_lights.c +++ b/src/p_lights.c @@ -323,59 +323,59 @@ glow_t *P_SpawnAdjustableGlowingLight(sector_t *minsector, sector_t *maxsector, return g; } -/** Fades all the lights in sectors with a particular tag to a new +/** Fades all the lights in specified sector to a new * value. * - * \param tag Tag to look for sectors by. + * \param sector Target sector * \param destvalue The final light value in these sectors. * \param speed Speed of the fade; the change to the ligh * level in each sector per tic. * \param ticbased Use a specific duration for the fade, defined by speed * \sa T_LightFade */ +void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean ticbased) +{ + lightlevel_t *ll; + + P_RemoveLighting(sector); // remove the old lighting effect first + + if ((ticbased && !speed) || sector->lightlevel == destvalue) // set immediately + { + sector->lightlevel = destvalue; + return; + } + + ll = Z_Calloc(sizeof (*ll), PU_LEVSPEC, NULL); + ll->thinker.function.acp1 = (actionf_p1)T_LightFade; + sector->lightingdata = ll; // set it to the lightlevel_t + + P_AddThinker(&ll->thinker); // add thinker + + ll->sector = sector; + ll->destlevel = destvalue; + + if (ticbased) + { + ll->duration = abs(speed); + ll->speed = FixedFloor(FixedDiv(destvalue - sector->lightlevel, ll->duration))/FRACUNIT; + if (!ll->speed) + ll->speed = (destvalue < sector->lightlevel) ? -1 : 1; + ll->interval = max(FixedFloor(FixedDiv(ll->duration, abs(destvalue - sector->lightlevel)))/FRACUNIT, 1); + ll->firsttic = gametic; + } + else + { + ll->duration = -1; + ll->speed = abs(speed); + } +} + void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased) { INT32 i; - lightlevel_t *ll; - sector_t *sector; - // search all sectors for ones with tag for (i = -1; (i = P_FindSectorFromTag(tag, i)) >= 0 ;) - { - sector = §ors[i]; - - P_RemoveLighting(sector); // remove the old lighting effect first - - if ((ticbased && !speed) || sector->lightlevel == destvalue) // set immediately - { - sector->lightlevel = destvalue; - continue; - } - - ll = Z_Calloc(sizeof (*ll), PU_LEVSPEC, NULL); - ll->thinker.function.acp1 = (actionf_p1)T_LightFade; - sector->lightingdata = ll; // set it to the lightlevel_t - - P_AddThinker(&ll->thinker); // add thinker - - ll->sector = sector; - ll->destlevel = destvalue; - - if (ticbased) - { - ll->duration = abs(speed); - ll->speed = FixedFloor(FixedDiv(destvalue - sector->lightlevel, ll->duration))/FRACUNIT; - if (!ll->speed) - ll->speed = (destvalue < sector->lightlevel) ? -1 : 1; - ll->interval = max(FixedFloor(FixedDiv(ll->duration, abs(destvalue - sector->lightlevel)))/FRACUNIT, 1); - ll->firsttic = gametic; - } - else - { - ll->duration = -1; - ll->speed = abs(speed); - } - } + P_FadeLightBySector(§ors[i], destvalue, speed, ticbased); } /** Fades the light level in a sector to a new value. diff --git a/src/p_spec.h b/src/p_spec.h index 8e296891b..c2c4c8976 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -161,6 +161,7 @@ strobe_t * P_SpawnAdjustableStrobeFlash(sector_t *minsector, sector_t *maxsector void T_Glow(glow_t *g); glow_t *P_SpawnAdjustableGlowingLight(sector_t *minsector, sector_t *maxsector, INT32 length); +void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean ticbased); void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased); void T_LightFade(lightlevel_t *ll); From cc26d03c93c91d6209b2b51acc63758c837b2cf4 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 8 Sep 2018 23:01:35 -0400 Subject: [PATCH 008/132] Snap light level to software values (32 levels) * New properties `exactlightlevel` and `lightlevel` in `lightlevel_t` --- src/lua_baselib.c | 3 +- src/p_lights.c | 75 +++++++++++++++++++++++++++++++---------------- src/p_saveg.c | 4 +++ src/p_spec.c | 3 +- src/p_spec.h | 8 +++-- 5 files changed, 63 insertions(+), 30 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 840863eb0..74b842e2a 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1810,9 +1810,10 @@ static int lib_pFadeLight(lua_State *L) INT32 destvalue = (INT32)luaL_checkinteger(L, 2); INT32 speed = (INT32)luaL_checkinteger(L, 3); boolean ticbased = lua_optboolean(L, 4); + boolean exactlightlevel = lua_optboolean(L, 5); NOHUD INLEVEL - P_FadeLight(tag, destvalue, speed, ticbased); + P_FadeLight(tag, destvalue, speed, ticbased, exactlightlevel); return 0; } diff --git a/src/p_lights.c b/src/p_lights.c index 8be3d793c..b2934b792 100644 --- a/src/p_lights.c +++ b/src/p_lights.c @@ -15,6 +15,7 @@ #include "doomdef.h" #include "doomstat.h" // gametic #include "p_local.h" +#include "r_main.h" // LIGHTSEGSHIFT #include "r_state.h" #include "z_zone.h" #include "m_random.h" @@ -331,9 +332,10 @@ glow_t *P_SpawnAdjustableGlowingLight(sector_t *minsector, sector_t *maxsector, * \param speed Speed of the fade; the change to the ligh * level in each sector per tic. * \param ticbased Use a specific duration for the fade, defined by speed + * \param exactlightlevel Do not snap to software values (for OpenGL) * \sa T_LightFade */ -void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean ticbased) +void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean ticbased, boolean exactlightlevel) { lightlevel_t *ll; @@ -353,6 +355,8 @@ void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean ll->sector = sector; ll->destlevel = destvalue; + ll->exactlightlevel = exactlightlevel; + ll->lightlevel = sector->lightlevel; if (ticbased) { @@ -370,12 +374,12 @@ void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean } } -void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased) +void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased, boolean exactlightlevel) { INT32 i; // search all sectors for ones with tag for (i = -1; (i = P_FindSectorFromTag(tag, i)) >= 0 ;) - P_FadeLightBySector(§ors[i], destvalue, speed, ticbased); + P_FadeLightBySector(§ors[i], destvalue, speed, ticbased, exactlightlevel); } /** Fades the light level in a sector to a new value. @@ -385,47 +389,66 @@ void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased) */ void T_LightFade(lightlevel_t *ll) { + boolean stillfading = false; + INT16 lightlevel = ll->lightlevel; + if (ll->duration >= 0) // tic-based { + stillfading = !(gametic - ll->firsttic >= ll->duration); if (gametic - ll->firsttic >= ll->duration) { - ll->sector->lightlevel = (INT16)ll->destlevel; // set to dest lightlevel + lightlevel = (INT16)ll->destlevel; // set to dest lightlevel P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker } else if (!((gametic - ll->firsttic) % ll->interval)) { if (ll->speed < 0) - ll->sector->lightlevel = max(ll->sector->lightlevel + (INT16)ll->speed, (INT16)ll->destlevel); + lightlevel = max(lightlevel + (INT16)ll->speed, (INT16)ll->destlevel); else - ll->sector->lightlevel = min(ll->sector->lightlevel + (INT16)ll->speed, (INT16)ll->destlevel); + lightlevel = min(lightlevel + (INT16)ll->speed, (INT16)ll->destlevel); } - return; } - - if (ll->sector->lightlevel < ll->destlevel) + else // x/tic speed-based { - // increase the lightlevel - if (ll->sector->lightlevel + ll->speed >= ll->destlevel) + if (lightlevel < ll->destlevel) { - // stop changing light level - ll->sector->lightlevel = (INT16)ll->destlevel; // set to dest lightlevel + // increase the lightlevel + if (lightlevel + ll->speed >= ll->destlevel) + { + // stop changing light level + lightlevel = (INT16)ll->destlevel; // set to dest lightlevel - P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker + P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker + } + else + { + stillfading = true; + lightlevel = (INT16)(lightlevel + (INT16)ll->speed); // move lightlevel + } } else - ll->sector->lightlevel = (INT16)(ll->sector->lightlevel + (INT16)ll->speed); // move lightlevel + { + // decrease lightlevel + if (lightlevel - ll->speed <= ll->destlevel) + { + // stop changing light level + lightlevel = (INT16)ll->destlevel; // set to dest lightlevel + + P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker + } + else + { + stillfading = true; + lightlevel = (INT16)(lightlevel - (INT16)ll->speed); // move lightlevel + } + } } + + // Snap light level to software values + if (!stillfading || ll->exactlightlevel) + ll->sector->lightlevel = lightlevel; else - { - // decrease lightlevel - if (ll->sector->lightlevel - ll->speed <= ll->destlevel) - { - // stop changing light level - ll->sector->lightlevel = (INT16)ll->destlevel; // set to dest lightlevel + ll->sector->lightlevel = (lightlevel >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT; - P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker - } - else - ll->sector->lightlevel = (INT16)(ll->sector->lightlevel - (INT16)ll->speed); // move lightlevel - } + ll->lightlevel = lightlevel; } diff --git a/src/p_saveg.c b/src/p_saveg.c index 8ec5b5ea8..95d073fc9 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1542,6 +1542,8 @@ static void SaveLightlevelThinker(const thinker_t *th, const UINT8 type) WRITEINT32(save_p, ht->duration); WRITEUINT32(save_p, ht->interval); WRITEUINT32(save_p, (UINT32)ht->firsttic); + WRITEUINT8(save_p, (UINT8)ht->exactlightlevel); + WRITEINT16(save_p, ht->lightlevel); } // @@ -2518,6 +2520,8 @@ static inline void LoadLightlevelThinker(actionf_p1 thinker) ht->duration = READINT32(save_p); ht->interval = READUINT32(save_p); ht->firsttic = (tic_t)READUINT32(save_p); + ht->exactlightlevel = (boolean)READUINT8(save_p); + ht->lightlevel = READINT16(save_p); if (ht->sector) ht->sector->lightingdata = ht; P_AddThinker(&ht->thinker); diff --git a/src/p_spec.c b/src/p_spec.c index a894dcbfb..707e19f08 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2781,7 +2781,8 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) P_FadeLight(line->tag, (line->flags & ML_BLOCKMONSTERS) ? max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, 255), 0) : line->frontsector->lightlevel, (line->flags & ML_BLOCKMONSTERS) ? max(sides[line->sidenum[0]].rowoffset>>FRACBITS, 0) : P_AproxDistance(line->dx, line->dy)>>FRACBITS, - (line->flags & ML_NOCLIMB)); + (line->flags & ML_NOCLIMB), + (line->flags & ML_TFERLINE)); break; case 421: // Stop lighting effect in tagged sectors diff --git a/src/p_spec.h b/src/p_spec.h index c2c4c8976..b354e6772 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -143,6 +143,10 @@ typedef struct INT32 duration; ///< If <0, do not use tic-based behavior. If 0, set instantly. If >0, fade lasts this duration. UINT32 interval; ///< Interval to deduct light level tic_t firsttic; ///< First gametic to count from + + // Snap to software values + boolean exactlightlevel; ///< Use exact values for OpenGL + INT16 lightlevel; ///< Internal counter for fading } lightlevel_t; #define GLOWSPEED 8 @@ -161,8 +165,8 @@ strobe_t * P_SpawnAdjustableStrobeFlash(sector_t *minsector, sector_t *maxsector void T_Glow(glow_t *g); glow_t *P_SpawnAdjustableGlowingLight(sector_t *minsector, sector_t *maxsector, INT32 length); -void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean ticbased); -void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased); +void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean ticbased, boolean exactlightlevel); +void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased, boolean exactlightlevel); void T_LightFade(lightlevel_t *ll); typedef enum From 3f4656e57ee2f97b6dc86e9e817eabc449cfb515 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 9 Sep 2018 01:08:02 -0400 Subject: [PATCH 009/132] Polyobject Fade logic --- src/p_polyobj.c | 85 ++++++++++++++++++++++++++++++++++++++++++++----- src/p_polyobj.h | 17 ++++++++-- src/p_saveg.c | 22 ++++++++++++- src/p_spec.c | 22 ++++++++++--- 4 files changed, 129 insertions(+), 17 deletions(-) diff --git a/src/p_polyobj.c b/src/p_polyobj.c index d943a0bfe..9e5cdf90e 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -2855,8 +2855,8 @@ INT32 EV_DoPolyObjFlag(line_t *pfdata) void T_PolyObjFade(polyfade_t *th) { + boolean stillfading = false; polyobj_t *po = Polyobj_GetForNum(th->polyObjNum); - size_t i; if (!po) #ifdef RANGECHECK @@ -2873,7 +2873,67 @@ void T_PolyObjFade(polyfade_t *th) if (po->thinker == NULL) po->thinker = &th->thinker; - // \todo logic + stillfading = !(gametic - th->firsttic >= th->duration); + + if (gametic - th->firsttic >= th->duration) + { + po->translucency = th->destvalue; // set to dest translucency + + // remove thinker + if (po->thinker == &th->thinker) + po->thinker = NULL; + P_RemoveThinker(&th->thinker); + } + else if (!((gametic - th->firsttic) % th->interval)) + { + if (th->speed <= 0) + po->translucency = max(po->translucency + th->speed, th->destvalue); + else + po->translucency = min(po->translucency + th->speed, th->destvalue); + } + + if (!stillfading) + { + // set render flags + if (po->translucency >= NUMTRANSMAPS) // invisible + po->flags &= ~POF_RENDERALL; + else + po->flags |= POF_RENDERALL; + + // set collision + if (th->docollision && th->speed) + { + if (th->speed > 0) // faded out + { + po->flags &= ~POF_SOLID; + po->flags |= POF_NOSPECIALS; + } + else + { + po->flags |= POF_SOLID; + po->flags &= ~POF_NOSPECIALS; + } + } + } + else + { + po->flags |= POF_RENDERALL; + + // set collision + if (th->docollision && th->speed) + { + if (th->doghostfade) + { + po->flags &= ~POF_SOLID; + po->flags |= POF_NOSPECIALS; + } + else + { + po->flags |= POF_SOLID; + po->flags &= ~POF_NOSPECIALS; + } + } + } } INT32 EV_DoPolyObjFade(polyfadedata_t *pfdata) @@ -2883,9 +2943,9 @@ INT32 EV_DoPolyObjFade(polyfadedata_t *pfdata) polyfade_t *th; INT32 start; - if (!(po = Polyobj_GetForNum(prdata->polyObjNum))) + if (!(po = Polyobj_GetForNum(pfdata->polyObjNum))) { - CONS_Debug(DBG_POLYOBJ, "EV_DoPolyObjRotate: bad polyobj %d\n", prdata->polyObjNum); + CONS_Debug(DBG_POLYOBJ, "EV_DoPolyObjFade: bad polyobj %d\n", pfdata->polyObjNum); return 0; } @@ -2893,6 +2953,10 @@ INT32 EV_DoPolyObjFade(polyfadedata_t *pfdata) if (po->isBad) return 0; + // already equal, nothing to do + if (po->translucency == pfdata->destvalue) + return 1; + // create a new thinker th = Z_Malloc(sizeof(polyfade_t), PU_LEVSPEC, NULL); th->thinker.function.acp1 = (actionf_p1)T_PolyObjFade; @@ -2900,9 +2964,14 @@ INT32 EV_DoPolyObjFade(polyfadedata_t *pfdata) po->thinker = &th->thinker; // set fields - th->polyObjNum = pfdata->tag; - - // \todo polyfade fields + th->polyObjNum = pfdata->polyObjNum; + th->destvalue = pfdata->destvalue; + th->docollision = pfdata->docollision; + th->doghostfade = pfdata->doghostfade; + th->duration = pfdata->duration; + th->speed = pfdata->speed; + th->interval = pfdata->interval; + th->firsttic = pfdata->firsttic; oldpo = po; @@ -2910,7 +2979,7 @@ INT32 EV_DoPolyObjFade(polyfadedata_t *pfdata) start = 0; while ((po = Polyobj_GetChild(oldpo, &start))) { - pfdata->tag = po->id; + pfdata->polyObjNum = po->id; EV_DoPolyObjFade(pfdata); } diff --git a/src/p_polyobj.h b/src/p_polyobj.h index 0bd94a636..cf00d64ba 100644 --- a/src/p_polyobj.h +++ b/src/p_polyobj.h @@ -212,8 +212,13 @@ typedef struct polyfade_s thinker_t thinker; // must be first INT32 polyObjNum; - - // \todo polyfade fields + INT32 destvalue; + boolean docollision; + boolean doghostfade; + UINT32 duration; + INT32 speed; + UINT32 interval; + tic_t firsttic; } polyfade_t; // @@ -278,7 +283,13 @@ typedef struct polydisplacedata_s typedef struct polyfadedata_s { INT32 polyObjNum; - // \todo polyfadedata fields + INT32 destvalue; + boolean docollision; + boolean doghostfade; + UINT32 duration; + INT32 speed; + UINT32 interval; + tic_t firsttic; } polyfadedata_t; // diff --git a/src/p_saveg.c b/src/p_saveg.c index 3cc061ebb..fc9382233 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1700,6 +1700,20 @@ static void SavePolydisplaceThinker(const thinker_t *th, const UINT8 type) WRITEFIXED(save_p, ht->oldHeights); } +static void SavePolyfadeThinker(const thinker_t *th, const UINT8 type) +{ + const polyfade_t *ht = (const void *)th; + WRITEUINT8(save_p, type); + WRITEINT32(save_p, ht->polyObjNum); + WRITEINT32(save_p, ht->destvalue); + WRITEUINT8(save_p, (UINT8)ht->docollision); + WRITEUINT8(save_p, (UINT8)ht->doghostfade); + WRITEUINT32(save_p, ht->duration); + WRITEINT32(save_p, ht->speed); + WRITEUINT32(save_p, ht->interval); + WRITEUINT32(save_p, (UINT32)ht->firsttic); +} + #endif /* // @@ -2706,7 +2720,13 @@ static void LoadPolyfadeThinker(actionf_p1 thinker) polyfade_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); ht->thinker.function.acp1 = thinker; ht->polyObjNum = READINT32(save_p); - // \todo polyfade thinker fields + ht->destvalue = READINT32(save_p); + ht->docollision = (boolean)READUINT8(save_p); + ht->doghostfade = (boolean)READUINT8(save_p); + ht->duration = READUINT32(save_p); + ht->speed = READINT32(save_p); + ht->interval = READUINT32(save_p); + ht->firsttic = (tic_t)READUINT32(save_p); P_AddThinker(&ht->thinker); } #endif diff --git a/src/p_spec.c b/src/p_spec.c index fd2c312fb..6d746f670 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1250,7 +1250,7 @@ static void PolyTranslucency(line_t *line) // // Makes a polyobject translucency fade and applies tangibility // -static void PolyFade(line_t *line) +static boolean PolyFade(line_t *line) { INT32 polyObjNum = line->tag; polyobj_t *po; @@ -1258,18 +1258,30 @@ static void PolyFade(line_t *line) if (!(po = Polyobj_GetForNum(polyObjNum))) { CONS_Debug(DBG_POLYOBJ, "EV_DoPolyObjWaypoint: bad polyobj %d\n", polyObjNum); - return; + return 0; } // don't allow line actions to affect bad polyobjects if (po->isBad) - return; + return 0; + + // already equal, nothing to do + if (po->translucency == max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), 0)) + return 1; polyfadedata_t pfd; - pfd.polyObjNum = line->tag; + pfd.polyObjNum = polyObjNum; + pfd.destvalue = max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), 0); + pfd.docollision = !(line->flags & ML_BOUNCY), // do not handle collision flags + pfd.doghostfade = (line->flags & ML_EFFECT1), // do ghost fade (no collision flags during fade) - // \todo polyfadedata fields + pfd.duration = abs(sides[line->sidenum[0]].rowoffset>>FRACBITS); + pfd.speed = FixedFloor(FixedDiv(pfd.destvalue - po->translucency, pfd.duration))/FRACUNIT; + if (!pfd.speed) + pfd.speed = (pfd.destvalue < po->translucency) ? -1 : 1; + pfd.interval = max(FixedFloor(FixedDiv(pfd.duration, abs(pfd.destvalue - po->translucency)))/FRACUNIT, 1); + pfd.firsttic = gametic; return EV_DoPolyObjFade(&pfd); } From 675f69afea115c284383dde25d54fac17b9c81c8 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 9 Sep 2018 09:29:18 -0400 Subject: [PATCH 010/132] Flag re-organization * Change alternate param flag from BLOCKMONSTERS to DONTPEGBOTTOM * Change tic-based flag from NOCLIMB to EFFECT5 --- src/p_spec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 707e19f08..87f5676bb 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2779,9 +2779,9 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) case 420: // Fade light levels in tagged sectors to new value P_FadeLight(line->tag, - (line->flags & ML_BLOCKMONSTERS) ? max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, 255), 0) : line->frontsector->lightlevel, - (line->flags & ML_BLOCKMONSTERS) ? max(sides[line->sidenum[0]].rowoffset>>FRACBITS, 0) : P_AproxDistance(line->dx, line->dy)>>FRACBITS, - (line->flags & ML_NOCLIMB), + (line->flags & ML_DONTPEGBOTTOM) ? max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, 255), 0) : line->frontsector->lightlevel, + (line->flags & ML_DONTPEGBOTTOM) ? max(sides[line->sidenum[0]].rowoffset>>FRACBITS, 0) : P_AproxDistance(line->dx, line->dy)>>FRACBITS, + (line->flags & ML_EFFECT5), (line->flags & ML_TFERLINE)); break; From aeb45132c5d86e64a641f3311fff7f70e163af36 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 9 Sep 2018 13:43:00 -0400 Subject: [PATCH 011/132] Revert "Snap light level to software values (32 levels)" This reverts commit cc26d03c93c91d6209b2b51acc63758c837b2cf4. --- src/lua_baselib.c | 3 +- src/p_lights.c | 79 +++++++++++++++++------------------------------ src/p_saveg.c | 4 --- src/p_spec.c | 3 +- src/p_spec.h | 8 ++--- 5 files changed, 32 insertions(+), 65 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 74b842e2a..840863eb0 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1810,10 +1810,9 @@ static int lib_pFadeLight(lua_State *L) INT32 destvalue = (INT32)luaL_checkinteger(L, 2); INT32 speed = (INT32)luaL_checkinteger(L, 3); boolean ticbased = lua_optboolean(L, 4); - boolean exactlightlevel = lua_optboolean(L, 5); NOHUD INLEVEL - P_FadeLight(tag, destvalue, speed, ticbased, exactlightlevel); + P_FadeLight(tag, destvalue, speed, ticbased); return 0; } diff --git a/src/p_lights.c b/src/p_lights.c index b2934b792..8be3d793c 100644 --- a/src/p_lights.c +++ b/src/p_lights.c @@ -15,7 +15,6 @@ #include "doomdef.h" #include "doomstat.h" // gametic #include "p_local.h" -#include "r_main.h" // LIGHTSEGSHIFT #include "r_state.h" #include "z_zone.h" #include "m_random.h" @@ -332,10 +331,9 @@ glow_t *P_SpawnAdjustableGlowingLight(sector_t *minsector, sector_t *maxsector, * \param speed Speed of the fade; the change to the ligh * level in each sector per tic. * \param ticbased Use a specific duration for the fade, defined by speed - * \param exactlightlevel Do not snap to software values (for OpenGL) * \sa T_LightFade */ -void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean ticbased, boolean exactlightlevel) +void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean ticbased) { lightlevel_t *ll; @@ -355,8 +353,6 @@ void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean ll->sector = sector; ll->destlevel = destvalue; - ll->exactlightlevel = exactlightlevel; - ll->lightlevel = sector->lightlevel; if (ticbased) { @@ -374,12 +370,12 @@ void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean } } -void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased, boolean exactlightlevel) +void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased) { INT32 i; // search all sectors for ones with tag for (i = -1; (i = P_FindSectorFromTag(tag, i)) >= 0 ;) - P_FadeLightBySector(§ors[i], destvalue, speed, ticbased, exactlightlevel); + P_FadeLightBySector(§ors[i], destvalue, speed, ticbased); } /** Fades the light level in a sector to a new value. @@ -389,66 +385,47 @@ void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased, bool */ void T_LightFade(lightlevel_t *ll) { - boolean stillfading = false; - INT16 lightlevel = ll->lightlevel; - if (ll->duration >= 0) // tic-based { - stillfading = !(gametic - ll->firsttic >= ll->duration); if (gametic - ll->firsttic >= ll->duration) { - lightlevel = (INT16)ll->destlevel; // set to dest lightlevel + ll->sector->lightlevel = (INT16)ll->destlevel; // set to dest lightlevel P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker } else if (!((gametic - ll->firsttic) % ll->interval)) { if (ll->speed < 0) - lightlevel = max(lightlevel + (INT16)ll->speed, (INT16)ll->destlevel); + ll->sector->lightlevel = max(ll->sector->lightlevel + (INT16)ll->speed, (INT16)ll->destlevel); else - lightlevel = min(lightlevel + (INT16)ll->speed, (INT16)ll->destlevel); + ll->sector->lightlevel = min(ll->sector->lightlevel + (INT16)ll->speed, (INT16)ll->destlevel); } + return; } - else // x/tic speed-based - { - if (lightlevel < ll->destlevel) - { - // increase the lightlevel - if (lightlevel + ll->speed >= ll->destlevel) - { - // stop changing light level - lightlevel = (INT16)ll->destlevel; // set to dest lightlevel - P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker - } - else - { - stillfading = true; - lightlevel = (INT16)(lightlevel + (INT16)ll->speed); // move lightlevel - } + if (ll->sector->lightlevel < ll->destlevel) + { + // increase the lightlevel + if (ll->sector->lightlevel + ll->speed >= ll->destlevel) + { + // stop changing light level + ll->sector->lightlevel = (INT16)ll->destlevel; // set to dest lightlevel + + P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker } else - { - // decrease lightlevel - if (lightlevel - ll->speed <= ll->destlevel) - { - // stop changing light level - lightlevel = (INT16)ll->destlevel; // set to dest lightlevel - - P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker - } - else - { - stillfading = true; - lightlevel = (INT16)(lightlevel - (INT16)ll->speed); // move lightlevel - } - } + ll->sector->lightlevel = (INT16)(ll->sector->lightlevel + (INT16)ll->speed); // move lightlevel } - - // Snap light level to software values - if (!stillfading || ll->exactlightlevel) - ll->sector->lightlevel = lightlevel; else - ll->sector->lightlevel = (lightlevel >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT; + { + // decrease lightlevel + if (ll->sector->lightlevel - ll->speed <= ll->destlevel) + { + // stop changing light level + ll->sector->lightlevel = (INT16)ll->destlevel; // set to dest lightlevel - ll->lightlevel = lightlevel; + P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker + } + else + ll->sector->lightlevel = (INT16)(ll->sector->lightlevel - (INT16)ll->speed); // move lightlevel + } } diff --git a/src/p_saveg.c b/src/p_saveg.c index 95d073fc9..8ec5b5ea8 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1542,8 +1542,6 @@ static void SaveLightlevelThinker(const thinker_t *th, const UINT8 type) WRITEINT32(save_p, ht->duration); WRITEUINT32(save_p, ht->interval); WRITEUINT32(save_p, (UINT32)ht->firsttic); - WRITEUINT8(save_p, (UINT8)ht->exactlightlevel); - WRITEINT16(save_p, ht->lightlevel); } // @@ -2520,8 +2518,6 @@ static inline void LoadLightlevelThinker(actionf_p1 thinker) ht->duration = READINT32(save_p); ht->interval = READUINT32(save_p); ht->firsttic = (tic_t)READUINT32(save_p); - ht->exactlightlevel = (boolean)READUINT8(save_p); - ht->lightlevel = READINT16(save_p); if (ht->sector) ht->sector->lightingdata = ht; P_AddThinker(&ht->thinker); diff --git a/src/p_spec.c b/src/p_spec.c index 87f5676bb..917ad68d4 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2781,8 +2781,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) P_FadeLight(line->tag, (line->flags & ML_DONTPEGBOTTOM) ? max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, 255), 0) : line->frontsector->lightlevel, (line->flags & ML_DONTPEGBOTTOM) ? max(sides[line->sidenum[0]].rowoffset>>FRACBITS, 0) : P_AproxDistance(line->dx, line->dy)>>FRACBITS, - (line->flags & ML_EFFECT5), - (line->flags & ML_TFERLINE)); + (line->flags & ML_EFFECT5)); break; case 421: // Stop lighting effect in tagged sectors diff --git a/src/p_spec.h b/src/p_spec.h index b354e6772..c2c4c8976 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -143,10 +143,6 @@ typedef struct INT32 duration; ///< If <0, do not use tic-based behavior. If 0, set instantly. If >0, fade lasts this duration. UINT32 interval; ///< Interval to deduct light level tic_t firsttic; ///< First gametic to count from - - // Snap to software values - boolean exactlightlevel; ///< Use exact values for OpenGL - INT16 lightlevel; ///< Internal counter for fading } lightlevel_t; #define GLOWSPEED 8 @@ -165,8 +161,8 @@ strobe_t * P_SpawnAdjustableStrobeFlash(sector_t *minsector, sector_t *maxsector void T_Glow(glow_t *g); glow_t *P_SpawnAdjustableGlowingLight(sector_t *minsector, sector_t *maxsector, INT32 length); -void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean ticbased, boolean exactlightlevel); -void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased, boolean exactlightlevel); +void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean ticbased); +void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased); void T_LightFade(lightlevel_t *ll); typedef enum From 3d5f225702bbb9cae9a52ec00ff1a32304d8eb71 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 9 Sep 2018 20:18:43 -0400 Subject: [PATCH 012/132] Replace firsttic with decrement timer --- src/p_lights.c | 16 ++++++++-------- src/p_saveg.c | 8 ++++---- src/p_spec.h | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/p_lights.c b/src/p_lights.c index 8be3d793c..77d05dad3 100644 --- a/src/p_lights.c +++ b/src/p_lights.c @@ -356,16 +356,16 @@ void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean if (ticbased) { - ll->duration = abs(speed); - ll->speed = FixedFloor(FixedDiv(destvalue - sector->lightlevel, ll->duration))/FRACUNIT; + ll->ticbased = ticbased; + ll->timer = abs(speed); + ll->speed = FixedFloor(FixedDiv(destvalue - sector->lightlevel, ll->timer))/FRACUNIT; if (!ll->speed) ll->speed = (destvalue < sector->lightlevel) ? -1 : 1; - ll->interval = max(FixedFloor(FixedDiv(ll->duration, abs(destvalue - sector->lightlevel)))/FRACUNIT, 1); - ll->firsttic = gametic; + ll->interval = max(FixedFloor(FixedDiv(ll->timer, abs(destvalue - sector->lightlevel)))/FRACUNIT, 1); } else { - ll->duration = -1; + ll->timer = -1; ll->speed = abs(speed); } } @@ -385,14 +385,14 @@ void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased) */ void T_LightFade(lightlevel_t *ll) { - if (ll->duration >= 0) // tic-based + if (ll->ticbased) { - if (gametic - ll->firsttic >= ll->duration) + if (--ll->timer <= 0) { ll->sector->lightlevel = (INT16)ll->destlevel; // set to dest lightlevel P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker } - else if (!((gametic - ll->firsttic) % ll->interval)) + else if (!(ll->timer % ll->interval)) { if (ll->speed < 0) ll->sector->lightlevel = max(ll->sector->lightlevel + (INT16)ll->speed, (INT16)ll->destlevel); diff --git a/src/p_saveg.c b/src/p_saveg.c index 8ec5b5ea8..eefee072d 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1539,9 +1539,9 @@ static void SaveLightlevelThinker(const thinker_t *th, const UINT8 type) WRITEUINT32(save_p, SaveSector(ht->sector)); WRITEINT32(save_p, ht->destlevel); WRITEINT32(save_p, ht->speed); - WRITEINT32(save_p, ht->duration); + WRITEUINT8(save_p, (UINT8)ht->ticbased); + WRITEINT32(save_p, ht->timer); WRITEUINT32(save_p, ht->interval); - WRITEUINT32(save_p, (UINT32)ht->firsttic); } // @@ -2515,9 +2515,9 @@ static inline void LoadLightlevelThinker(actionf_p1 thinker) ht->sector = LoadSector(READUINT32(save_p)); ht->destlevel = READINT32(save_p); ht->speed = READINT32(save_p); - ht->duration = READINT32(save_p); + ht->ticbased = (boolean)READUINT8(save_p); + ht->timer = READINT32(save_p); ht->interval = READUINT32(save_p); - ht->firsttic = (tic_t)READUINT32(save_p); if (ht->sector) ht->sector->lightingdata = ht; P_AddThinker(&ht->thinker); diff --git a/src/p_spec.h b/src/p_spec.h index c2c4c8976..1e327c5f2 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -140,9 +140,9 @@ typedef struct INT32 speed; ///< Speed at which to change light level. // Tic-based behavior - INT32 duration; ///< If <0, do not use tic-based behavior. If 0, set instantly. If >0, fade lasts this duration. + boolean ticbased; ///< Tic-based logic + INT32 timer; ///< Tic-based timer UINT32 interval; ///< Interval to deduct light level - tic_t firsttic; ///< First gametic to count from } lightlevel_t; #define GLOWSPEED 8 From 573e1d00173d373bf0a6e72b7800c9925c209441 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 9 Sep 2018 21:01:00 -0400 Subject: [PATCH 013/132] Replace firsttic with timer increment --- src/p_polyobj.c | 9 ++++----- src/p_polyobj.h | 6 ++---- src/p_saveg.c | 6 ++---- src/p_spec.c | 7 +++---- 4 files changed, 11 insertions(+), 17 deletions(-) diff --git a/src/p_polyobj.c b/src/p_polyobj.c index 9e5cdf90e..a8616dba1 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -2873,9 +2873,9 @@ void T_PolyObjFade(polyfade_t *th) if (po->thinker == NULL) po->thinker = &th->thinker; - stillfading = !(gametic - th->firsttic >= th->duration); + stillfading = !(--(th->timer) <= 0); - if (gametic - th->firsttic >= th->duration) + if (th->timer <= 0) { po->translucency = th->destvalue; // set to dest translucency @@ -2884,7 +2884,7 @@ void T_PolyObjFade(polyfade_t *th) po->thinker = NULL; P_RemoveThinker(&th->thinker); } - else if (!((gametic - th->firsttic) % th->interval)) + else if (!(th->timer % th->interval)) { if (th->speed <= 0) po->translucency = max(po->translucency + th->speed, th->destvalue); @@ -2968,10 +2968,9 @@ INT32 EV_DoPolyObjFade(polyfadedata_t *pfdata) th->destvalue = pfdata->destvalue; th->docollision = pfdata->docollision; th->doghostfade = pfdata->doghostfade; - th->duration = pfdata->duration; + th->timer = pfdata->timer; th->speed = pfdata->speed; th->interval = pfdata->interval; - th->firsttic = pfdata->firsttic; oldpo = po; diff --git a/src/p_polyobj.h b/src/p_polyobj.h index cf00d64ba..d5c07cb5b 100644 --- a/src/p_polyobj.h +++ b/src/p_polyobj.h @@ -215,10 +215,9 @@ typedef struct polyfade_s INT32 destvalue; boolean docollision; boolean doghostfade; - UINT32 duration; + INT32 timer; INT32 speed; UINT32 interval; - tic_t firsttic; } polyfade_t; // @@ -286,10 +285,9 @@ typedef struct polyfadedata_s INT32 destvalue; boolean docollision; boolean doghostfade; - UINT32 duration; + INT32 timer; INT32 speed; UINT32 interval; - tic_t firsttic; } polyfadedata_t; // diff --git a/src/p_saveg.c b/src/p_saveg.c index fc9382233..403f05b00 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1708,10 +1708,9 @@ static void SavePolyfadeThinker(const thinker_t *th, const UINT8 type) WRITEINT32(save_p, ht->destvalue); WRITEUINT8(save_p, (UINT8)ht->docollision); WRITEUINT8(save_p, (UINT8)ht->doghostfade); - WRITEUINT32(save_p, ht->duration); + WRITEINT32(save_p, ht->timer); WRITEINT32(save_p, ht->speed); WRITEUINT32(save_p, ht->interval); - WRITEUINT32(save_p, (UINT32)ht->firsttic); } #endif @@ -2723,10 +2722,9 @@ static void LoadPolyfadeThinker(actionf_p1 thinker) ht->destvalue = READINT32(save_p); ht->docollision = (boolean)READUINT8(save_p); ht->doghostfade = (boolean)READUINT8(save_p); - ht->duration = READUINT32(save_p); + ht->timer = READINT32(save_p); ht->speed = READINT32(save_p); ht->interval = READUINT32(save_p); - ht->firsttic = (tic_t)READUINT32(save_p); P_AddThinker(&ht->thinker); } #endif diff --git a/src/p_spec.c b/src/p_spec.c index 6d746f670..a20a339ed 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1276,12 +1276,11 @@ static boolean PolyFade(line_t *line) pfd.docollision = !(line->flags & ML_BOUNCY), // do not handle collision flags pfd.doghostfade = (line->flags & ML_EFFECT1), // do ghost fade (no collision flags during fade) - pfd.duration = abs(sides[line->sidenum[0]].rowoffset>>FRACBITS); - pfd.speed = FixedFloor(FixedDiv(pfd.destvalue - po->translucency, pfd.duration))/FRACUNIT; + pfd.timer = abs(sides[line->sidenum[0]].rowoffset>>FRACBITS); + pfd.speed = FixedFloor(FixedDiv(pfd.destvalue - po->translucency, pfd.timer))/FRACUNIT; if (!pfd.speed) pfd.speed = (pfd.destvalue < po->translucency) ? -1 : 1; - pfd.interval = max(FixedFloor(FixedDiv(pfd.duration, abs(pfd.destvalue - po->translucency)))/FRACUNIT, 1); - pfd.firsttic = gametic; + pfd.interval = max(FixedFloor(FixedDiv(pfd.timer, abs(pfd.destvalue - po->translucency)))/FRACUNIT, 1); return EV_DoPolyObjFade(&pfd); } From 231f19aaabb28bfc40b0a5e25546da8df186372d Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 9 Sep 2018 21:02:43 -0400 Subject: [PATCH 014/132] Revert "Merge branch 'random-fof-fixes' into fof-fixes-movingplatexists" This reverts commit cc114590548cb1b7f099d12499d556af2da2c993, reversing changes made to 7e3d5cd3734c5b2194dca7fb8875c9cfeca97dc4. --- src/p_floor.c | 44 ++++++++++++++------------------------------ 1 file changed, 14 insertions(+), 30 deletions(-) diff --git a/src/p_floor.c b/src/p_floor.c index bb6bf8d16..0e28b831f 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -1839,7 +1839,6 @@ void T_ThwompSector(levelspecthink_t *thwomp) #define ceilingwasheight vars[5] fixed_t thwompx, thwompy; sector_t *actionsector; - ffloor_t *rover = NULL; INT32 secnum; // If you just crashed down, wait a second before coming back up. @@ -1854,16 +1853,7 @@ void T_ThwompSector(levelspecthink_t *thwomp) secnum = P_FindSectorFromTag((INT16)thwomp->vars[0], -1); if (secnum > 0) - { actionsector = §ors[secnum]; - - // Look for thwomp FFloor - for (rover = actionsector->ffloors; rover; rover = rover->next) - { - if (rover->master == thwomp->sourceline) - break; - } - } else return; // Bad bad bad! @@ -1952,13 +1942,10 @@ void T_ThwompSector(levelspecthink_t *thwomp) { mobj_t *mp = (void *)&actionsector->soundorg; - if (!rover || (rover->flags & FF_EXISTS)) - { - if (thwomp->sourceline->flags & ML_EFFECT4) - S_StartSound(mp, sides[thwomp->sourceline->sidenum[0]].textureoffset>>FRACBITS); - else - S_StartSound(mp, sfx_thwomp); - } + if (thwomp->sourceline->flags & ML_EFFECT4) + S_StartSound(mp, sides[thwomp->sourceline->sidenum[0]].textureoffset>>FRACBITS); + else + S_StartSound(mp, sfx_thwomp); thwomp->direction = 1; // start heading back up thwomp->distance = TICRATE; // but only after a small delay @@ -1972,21 +1959,18 @@ void T_ThwompSector(levelspecthink_t *thwomp) thinker_t *th; mobj_t *mo; - if (!rover || (rover->flags & FF_EXISTS)) + // scan the thinkers to find players! + for (th = thinkercap.next; th != &thinkercap; th = th->next) { - // scan the thinkers to find players! - for (th = thinkercap.next; th != &thinkercap; th = th->next) - { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) - continue; + if (th->function.acp1 != (actionf_p1)P_MobjThinker) + continue; - mo = (mobj_t *)th; - if (mo->type == MT_PLAYER && mo->health && mo->z <= thwomp->sector->ceilingheight - && P_AproxDistance(thwompx - mo->x, thwompy - mo->y) <= 96*FRACUNIT) - { - thwomp->direction = -1; - break; - } + mo = (mobj_t *)th; + if (mo->type == MT_PLAYER && mo->health && mo->z <= thwomp->sector->ceilingheight + && P_AproxDistance(thwompx - mo->x, thwompy - mo->y) <= 96*FRACUNIT) + { + thwomp->direction = -1; + break; } } From d01193df80d3164d437ceb02e9e75cbe304248e9 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 9 Sep 2018 21:59:41 -0400 Subject: [PATCH 015/132] Apply ~FF_EXISTS moving plat fix for VERTICALFLIP --- src/p_map.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index c275ba0be..ab6c03da0 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2723,6 +2723,7 @@ static boolean P_ThingHeightClip(mobj_t *thing) boolean floormoved; fixed_t oldfloorz = thing->floorz; size_t oldfloor_sectornum = thing->floor_sectornum, oldfloor_rovernum = thing->floor_rovernum; + size_t oldceil_sectornum = thing->ceiling_sectornum, oldceil_rovernum = thing->ceiling_rovernum; boolean onfloor = P_IsObjectOnGround(thing);//(thing->z <= thing->floorz); ffloor_t *rover = NULL; @@ -2751,13 +2752,15 @@ static boolean P_ThingHeightClip(mobj_t *thing) if (onfloor && !(thing->flags & MF_NOGRAVITY) && floormoved) { + size_t old_sectornum = (thing->eflags & MFE_VERTICALFLIP) ? oldceil_sectornum : oldfloor_sectornum; + size_t old_rovernum = (thing->eflags & MFE_VERTICALFLIP) ? oldceil_rovernum : oldfloor_rovernum; // Find FOF referenced by floorz - if (oldfloor_sectornum) + if (old_sectornum) { size_t rovernum = 0; - for (rover = sectors[oldfloor_sectornum].ffloors; rover; rover = rover->next) + for (rover = sectors[old_sectornum].ffloors; rover; rover = rover->next) { - if (rovernum == oldfloor_rovernum) + if (rovernum == old_rovernum) break; rovernum++; } From f33f9dd284f67a1a0cf4c1b8a3b671ce3bd30249 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 9 Sep 2018 23:12:37 -0400 Subject: [PATCH 016/132] Replace sectornum/rovernum index vars with ffloor pointers --- src/p_map.c | 93 ++++++++++++++------------------------------------- src/p_mobj.h | 6 ++-- src/p_saveg.c | 48 +++++++++++++++++++------- 3 files changed, 62 insertions(+), 85 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index ab6c03da0..4bf06fa4b 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -52,8 +52,7 @@ fixed_t tmfloorz, tmceilingz; static fixed_t tmdropoffz, tmdrpoffceilz; // drop-off floor/ceiling heights mobj_t *tmfloorthing; // the thing corresponding to tmfloorz or NULL if tmfloorz is from a sector mobj_t *tmhitthing; // the solid thing you bumped into (for collisions) -//ffloor_t *tmfloorrover, *tmceilingrover; // unused for now -size_t tmfloor_sectornum, tmfloor_rovernum, tmceiling_sectornum, tmceiling_rovernum; +ffloor_t *tmfloorrover, *tmceilingrover; #ifdef ESLOPE pslope_t *tmfloorslope, *tmceilingslope; #endif @@ -1419,8 +1418,7 @@ static boolean PIT_CheckThing(mobj_t *thing) if (thing->z + thing->height > tmfloorz) { tmfloorz = thing->z + thing->height; - // tmfloorrover = NULL; - tmfloor_sectornum = tmfloor_rovernum = 0; + tmfloorrover = NULL; #ifdef ESLOPE tmfloorslope = NULL; #endif @@ -1441,8 +1439,7 @@ static boolean PIT_CheckThing(mobj_t *thing) return false; tmfloorz = tmceilingz = topz; // block while in air - // tmceilingrover = NULL; - tmceiling_sectornum = tmceiling_rovernum = 0; + tmceilingrover = NULL; #ifdef ESLOPE tmceilingslope = NULL; #endif @@ -1451,8 +1448,7 @@ static boolean PIT_CheckThing(mobj_t *thing) else if (topz < tmceilingz && tmthing->z <= thing->z+thing->height) { tmceilingz = topz; - // tmceilingrover = NULL; - tmceiling_sectornum = tmceiling_rovernum = 0; + tmceilingrover = NULL; #ifdef ESLOPE tmceilingslope = NULL; #endif @@ -1469,8 +1465,7 @@ static boolean PIT_CheckThing(mobj_t *thing) if (thing->z < tmceilingz) { tmceilingz = thing->z; - // tmceilingrover = NULL; - tmceiling_sectornum = tmceiling_rovernum = 0; + tmceilingrover = NULL; #ifdef ESLOPE tmceilingslope = NULL; #endif @@ -1491,8 +1486,7 @@ static boolean PIT_CheckThing(mobj_t *thing) return false; tmfloorz = tmceilingz = topz; // block while in air - // tmfloorrover = NULL; - tmfloor_sectornum = tmfloor_rovernum = 0; + tmfloorrover = NULL; #ifdef ESLOPE tmfloorslope = NULL; #endif @@ -1501,8 +1495,7 @@ static boolean PIT_CheckThing(mobj_t *thing) else if (topz > tmfloorz && tmthing->z+tmthing->height >= thing->z) { tmfloorz = topz; - // tmfloorrover = NULL; - tmfloor_sectornum = tmfloor_rovernum = 0; + tmfloorrover = NULL; #ifdef ESLOPE tmfloorslope = NULL; #endif @@ -1654,8 +1647,7 @@ static boolean PIT_CheckLine(line_t *ld) { tmceilingz = opentop; ceilingline = ld; - // tmceilingrover = NULL; - tmceiling_sectornum = tmceiling_rovernum = 0; + tmceilingrover = NULL; #ifdef ESLOPE tmceilingslope = opentopslope; #endif @@ -1664,8 +1656,7 @@ static boolean PIT_CheckLine(line_t *ld) if (openbottom > tmfloorz) { tmfloorz = openbottom; - // tmfloorrover = NULL; - tmfloor_sectornum = tmfloor_rovernum = 0; + tmfloorrover = NULL; #ifdef ESLOPE tmfloorslope = openbottomslope; #endif @@ -1747,10 +1738,8 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) // will adjust them. tmfloorz = tmdropoffz = P_GetFloorZ(thing, newsubsec->sector, x, y, NULL); //newsubsec->sector->floorheight; tmceilingz = P_GetCeilingZ(thing, newsubsec->sector, x, y, NULL); //newsubsec->sector->ceilingheight; - // tmfloorrover = NULL; - tmfloor_sectornum = tmfloor_rovernum = 0; - // tmceilingrover = NULL; - tmceiling_sectornum = tmceiling_rovernum = 0; + tmfloorrover = NULL; + tmceilingrover = NULL; #ifdef ESLOPE tmfloorslope = newsubsec->sector->f_slope; tmceilingslope = newsubsec->sector->c_slope; @@ -1798,9 +1787,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) { if (tmfloorz < topheight - sinklevel) { tmfloorz = topheight - sinklevel; - // tmfloorrover = rover; - tmfloor_sectornum = newsubsec->sector - sectors; - tmfloor_rovernum = rovernum; + tmfloorrover = rover; #ifdef ESLOPE tmfloorslope = *rover->t_slope; #endif @@ -1810,9 +1797,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) { if (tmceilingz > bottomheight + sinklevel) { tmceilingz = bottomheight + sinklevel; - // tmceilingrover = rover; - tmceiling_sectornum = newsubsec->sector - sectors; - tmceiling_rovernum = rovernum; + tmceilingrover = rover; #ifdef ESLOPE tmceilingslope = *rover->b_slope; #endif @@ -1841,9 +1826,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) { if (tmfloorz < thing->z) { tmfloorz = thing->z; - // tmfloorrover = rover; - tmfloor_sectornum = newsubsec->sector - sectors; - tmfloor_rovernum = rovernum; + tmfloorrover = rover; #ifdef ESLOPE tmfloorslope = NULL; #endif @@ -1863,9 +1846,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) && !(rover->flags & FF_REVERSEPLATFORM)) { tmfloorz = tmdropoffz = topheight; - // tmfloorrover = rover; - tmfloor_sectornum = newsubsec->sector - sectors; - tmfloor_rovernum = rovernum; + tmfloorrover = rover; #ifdef ESLOPE tmfloorslope = *rover->t_slope; #endif @@ -1875,9 +1856,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) && !(thing->type == MT_SKIM && (rover->flags & FF_SWIMMABLE))) { tmceilingz = tmdrpoffceilz = bottomheight; - // tmceilingrover = rover; - tmceiling_sectornum = newsubsec->sector - sectors; - tmceiling_rovernum = rovernum; + tmceilingrover = rover; #ifdef ESLOPE tmceilingslope = *rover->b_slope; #endif @@ -2375,12 +2354,8 @@ boolean PIT_PushableMoved(mobj_t *thing) mobj_t *oldthing = tmthing; line_t *oldceilline = ceilingline; line_t *oldblockline = blockingline; - // ffloor_t *oldflrrover = tmfloorrover; - // ffloor_t *oldceilrover = tmceilingrover; - size_t oldflrrover_sectornum = tmfloor_sectornum; - size_t oldflrrover_ffloornum = tmfloor_rovernum; - size_t oldceilrover_sectornum = tmceiling_sectornum; - size_t oldceilrover_ffloornum = tmceiling_rovernum; + ffloor_t *oldflrrover = tmfloorrover; + ffloor_t *oldceilrover = tmceilingrover; #ifdef ESLOPE pslope_t *oldfslope = tmfloorslope; pslope_t *oldcslope = tmceilingslope; @@ -2397,12 +2372,8 @@ boolean PIT_PushableMoved(mobj_t *thing) P_SetTarget(&tmthing, oldthing); ceilingline = oldceilline; blockingline = oldblockline; - // tmfloorrover = oldflrrover; - // tmceilingrover = oldceilrover; - tmfloor_sectornum = oldflrrover_sectornum; - tmfloor_rovernum = oldflrrover_ffloornum; - tmceiling_sectornum = oldceilrover_sectornum; - tmceiling_rovernum = oldceilrover_ffloornum; + tmfloorrover = oldflrrover; + tmceilingrover = oldceilrover; #ifdef ESLOPE tmfloorslope = oldfslope; tmceilingslope = oldcslope; @@ -2722,8 +2693,8 @@ static boolean P_ThingHeightClip(mobj_t *thing) { boolean floormoved; fixed_t oldfloorz = thing->floorz; - size_t oldfloor_sectornum = thing->floor_sectornum, oldfloor_rovernum = thing->floor_rovernum; - size_t oldceil_sectornum = thing->ceiling_sectornum, oldceil_rovernum = thing->ceiling_rovernum; + ffloor_t *oldfloorrover = thing->floorrover; + ffloor_t *oldceilingrover = thing->ceilingrover; boolean onfloor = P_IsObjectOnGround(thing);//(thing->z <= thing->floorz); ffloor_t *rover = NULL; @@ -2740,10 +2711,8 @@ static boolean P_ThingHeightClip(mobj_t *thing) thing->floorz = tmfloorz; thing->ceilingz = tmceilingz; - thing->floor_sectornum = tmfloor_sectornum; - thing->floor_rovernum = tmfloor_rovernum; - thing->ceiling_sectornum = tmceiling_sectornum; - thing->ceiling_rovernum = tmceiling_rovernum; + thing->floorrover = tmfloorrover; + thing->ceilingrover = tmceilingrover; // Ugly hack?!?! As long as just ceilingz is the lowest, // you'll still get crushed, right? @@ -2752,19 +2721,7 @@ static boolean P_ThingHeightClip(mobj_t *thing) if (onfloor && !(thing->flags & MF_NOGRAVITY) && floormoved) { - size_t old_sectornum = (thing->eflags & MFE_VERTICALFLIP) ? oldceil_sectornum : oldfloor_sectornum; - size_t old_rovernum = (thing->eflags & MFE_VERTICALFLIP) ? oldceil_rovernum : oldfloor_rovernum; - // Find FOF referenced by floorz - if (old_sectornum) - { - size_t rovernum = 0; - for (rover = sectors[old_sectornum].ffloors; rover; rover = rover->next) - { - if (rovernum == old_rovernum) - break; - rovernum++; - } - } + rover = (thing->eflags & MFE_VERTICALFLIP) ? oldceilingrover : oldfloorrover; // Match the Thing's old floorz to an FOF and check for FF_EXISTS // If ~FF_EXISTS, don't set mobj Z. diff --git a/src/p_mobj.h b/src/p_mobj.h index 3a83a0f58..90394c70d 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -282,10 +282,8 @@ typedef struct mobj_s // The closest interval over all contacted sectors (or things). fixed_t floorz; // Nearest floor below. fixed_t ceilingz; // Nearest ceiling above. - size_t floor_sectornum; // FOF referred by floorz - size_t floor_rovernum; // FOF referred by floorz - size_t ceiling_sectornum; // FOF referred by ceilingz - size_t ceiling_rovernum; // FOF referred by ceilingz + struct ffloor_s *floorrover; // FOF referred by floorz + struct ffloor_s *ceilingrover; // FOF referred by ceilingz // For movement checking. fixed_t radius; diff --git a/src/p_saveg.c b/src/p_saveg.c index 33dfd1424..d0ca0a873 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1192,10 +1192,13 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) WRITEFIXED(save_p, mobj->z); // Force this so 3dfloor problems don't arise. WRITEFIXED(save_p, mobj->floorz); WRITEFIXED(save_p, mobj->ceilingz); - WRITEUINT32(save_p, (UINT32)mobj->floor_sectornum); - WRITEUINT32(save_p, (UINT32)mobj->floor_rovernum); - WRITEUINT32(save_p, (UINT32)mobj->ceiling_sectornum); - WRITEUINT32(save_p, (UINT32)mobj->ceiling_rovernum); + + // \todo netsync for floorrover + + // WRITEUINT32(save_p, (UINT32)mobj->floor_sectornum); + // WRITEUINT32(save_p, (UINT32)mobj->floor_rovernum); + // WRITEUINT32(save_p, (UINT32)mobj->ceiling_sectornum); + // WRITEUINT32(save_p, (UINT32)mobj->ceiling_rovernum); if (diff & MD_SPAWNPOINT) { @@ -1993,7 +1996,7 @@ static void LoadMobjThinker(actionf_p1 thinker) UINT16 diff2; INT32 i; fixed_t z, floorz, ceilingz; - size_t floor_sectornum, floor_rovernum, ceiling_sectornum, ceiling_rovernum; + //size_t floor_sectornum, floor_rovernum, ceiling_sectornum, ceiling_rovernum; diff = READUINT32(save_p); if (diff & MD_MORE) @@ -2006,10 +2009,26 @@ static void LoadMobjThinker(actionf_p1 thinker) z = READFIXED(save_p); // Force this so 3dfloor problems don't arise. floorz = READFIXED(save_p); ceilingz = READFIXED(save_p); - floor_sectornum = (size_t)READUINT32(save_p); - floor_rovernum = (size_t)READUINT32(save_p); - ceiling_sectornum = (size_t)READUINT32(save_p); - ceiling_rovernum = (size_t)READUINT32(save_p); + + // \todo netsync for floorrover +#if 0 + // Find FOF referenced by floorz + if (old_sectornum) + { + size_t rovernum = 0; + for (rover = sectors[old_sectornum].ffloors; rover; rover = rover->next) + { + if (rovernum == old_rovernum) + break; + rovernum++; + } + } +#endif + + // floor_sectornum = (size_t)READUINT32(save_p); + // floor_rovernum = (size_t)READUINT32(save_p); + // ceiling_sectornum = (size_t)READUINT32(save_p); + // ceiling_rovernum = (size_t)READUINT32(save_p); if (diff & MD_SPAWNPOINT) { @@ -2035,10 +2054,13 @@ static void LoadMobjThinker(actionf_p1 thinker) mobj->z = z; mobj->floorz = floorz; mobj->ceilingz = ceilingz; - mobj->floor_sectornum = floor_sectornum; - mobj->floor_rovernum = floor_rovernum; - mobj->ceiling_sectornum = ceiling_sectornum; - mobj->ceiling_rovernum = ceiling_rovernum; + + // \todo netsync for floorrover + + // mobj->floor_sectornum = floor_sectornum; + // mobj->floor_rovernum = floor_rovernum; + // mobj->ceiling_sectornum = ceiling_sectornum; + // mobj->ceiling_rovernum = ceiling_rovernum; if (diff & MD_TYPE) mobj->type = READUINT32(save_p); From dd35871699cef6f77d05435c1aecdb2ae594f92f Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 9 Sep 2018 23:48:14 -0400 Subject: [PATCH 017/132] Savegame netsync for mobj->floorrover and ceilingrrover --- src/p_saveg.c | 100 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 73 insertions(+), 27 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index d0ca0a873..4c9e17b4f 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -972,11 +972,13 @@ typedef enum MD2_EXTVAL1 = 1<<5, MD2_EXTVAL2 = 1<<6, MD2_HNEXT = 1<<7, -#ifdef ESLOPE MD2_HPREV = 1<<8, - MD2_SLOPE = 1<<9 + MD2_FLOORROVER = 1<<9, +#ifdef ESLOPE + MD2_CEILINGROVER = 1<<10, + MD2_SLOPE = 1<<11 #else - MD2_HPREV = 1<<8 + MD2_CEILINGROVER = 1<<10 #endif } mobj_diff2_t; @@ -1170,6 +1172,10 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) diff2 |= MD2_HNEXT; if (mobj->hprev) diff2 |= MD2_HPREV; + if (mobj->floorrover) + diff2 |= MD2_FLOORROVER; + if (mobj->ceilingrover) + diff2 |= MD2_CEILINGROVER; #ifdef ESLOPE if (mobj->standingslope) diff2 |= MD2_SLOPE; @@ -1193,12 +1199,45 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) WRITEFIXED(save_p, mobj->floorz); WRITEFIXED(save_p, mobj->ceilingz); - // \todo netsync for floorrover + if (diff & MD2_FLOORROVER) + { + ffloor_t *rover; + size_t i = 0; + INT32 roverindex = -1; - // WRITEUINT32(save_p, (UINT32)mobj->floor_sectornum); - // WRITEUINT32(save_p, (UINT32)mobj->floor_rovernum); - // WRITEUINT32(save_p, (UINT32)mobj->ceiling_sectornum); - // WRITEUINT32(save_p, (UINT32)mobj->ceiling_rovernum); + for (rover = mobj->floorrover->target->ffloors; rover; rover = rover->next) + { + if (rover == mobj->floorrover) + { + roverindex = i; + break; + } + i++; + } + + WRITEUINT32(save_p, (UINT32)(mobj->floorrover->target - sectors)); + WRITEUINT32(save_p, (UINT32)roverindex); + } + + if (diff & MD2_CEILINGROVER) + { + ffloor_t *rover; + size_t i = 0; + INT32 roverindex = -1; + + for (rover = mobj->ceilingrover->target->ffloors; rover; rover = rover->next) + { + if (rover == mobj->ceilingrover) + { + roverindex = i; + break; + } + i++; + } + + WRITEUINT32(save_p, mobj->ceilingrover->target - sectors); + WRITEUINT32(save_p, roverindex); + } if (diff & MD_SPAWNPOINT) { @@ -1996,7 +2035,7 @@ static void LoadMobjThinker(actionf_p1 thinker) UINT16 diff2; INT32 i; fixed_t z, floorz, ceilingz; - //size_t floor_sectornum, floor_rovernum, ceiling_sectornum, ceiling_rovernum; + ffloor_t *floorrover = NULL, *ceilingrover = NULL; diff = READUINT32(save_p); if (diff & MD_MORE) @@ -2010,25 +2049,37 @@ static void LoadMobjThinker(actionf_p1 thinker) floorz = READFIXED(save_p); ceilingz = READFIXED(save_p); - // \todo netsync for floorrover -#if 0 - // Find FOF referenced by floorz - if (old_sectornum) + if (diff2 & MD2_FLOORROVER) { + size_t floor_sectornum = (size_t)READUINT32(save_p); + size_t floor_rovernum = (size_t)READUINT32(save_p); + ffloor_t *rover = NULL; size_t rovernum = 0; - for (rover = sectors[old_sectornum].ffloors; rover; rover = rover->next) + + for (rover = sectors[floor_sectornum].ffloors; rover; rover = rover->next) { - if (rovernum == old_rovernum) + if (rovernum == floor_rovernum) break; rovernum++; } + floorrover = rover; } -#endif - // floor_sectornum = (size_t)READUINT32(save_p); - // floor_rovernum = (size_t)READUINT32(save_p); - // ceiling_sectornum = (size_t)READUINT32(save_p); - // ceiling_rovernum = (size_t)READUINT32(save_p); + if (diff2 & MD2_CEILINGROVER) + { + size_t ceiling_sectornum = (size_t)READUINT32(save_p); + size_t ceiling_rovernum = (size_t)READUINT32(save_p); + ffloor_t *rover = NULL; + size_t rovernum = 0; + + for (rover = sectors[ceiling_sectornum].ffloors; rover; rover = rover->next) + { + if (rovernum == ceiling_rovernum) + break; + rovernum++; + } + ceilingrover = rover; + } if (diff & MD_SPAWNPOINT) { @@ -2054,13 +2105,8 @@ static void LoadMobjThinker(actionf_p1 thinker) mobj->z = z; mobj->floorz = floorz; mobj->ceilingz = ceilingz; - - // \todo netsync for floorrover - - // mobj->floor_sectornum = floor_sectornum; - // mobj->floor_rovernum = floor_rovernum; - // mobj->ceiling_sectornum = ceiling_sectornum; - // mobj->ceiling_rovernum = ceiling_rovernum; + mobj->floorrover = floorrover; + mobj->ceilingrover = ceilingrover; if (diff & MD_TYPE) mobj->type = READUINT32(save_p); From 03d1baf422434b87f7e1c842f89f9fa3ab7236fa Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 00:07:22 -0400 Subject: [PATCH 018/132] Savegame floorrover fixes --- src/p_saveg.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 4c9e17b4f..c73df0cc9 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1199,11 +1199,11 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) WRITEFIXED(save_p, mobj->floorz); WRITEFIXED(save_p, mobj->ceilingz); - if (diff & MD2_FLOORROVER) + if (diff2 & MD2_FLOORROVER) { ffloor_t *rover; size_t i = 0; - INT32 roverindex = -1; + UINT32 roverindex = 0; for (rover = mobj->floorrover->target->ffloors; rover; rover = rover->next) { @@ -1216,14 +1216,14 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) } WRITEUINT32(save_p, (UINT32)(mobj->floorrover->target - sectors)); - WRITEUINT32(save_p, (UINT32)roverindex); + WRITEUINT32(save_p, rover ? roverindex : i); // store max index to denote invalid ffloor ref } - if (diff & MD2_CEILINGROVER) + if (diff2 & MD2_CEILINGROVER) { ffloor_t *rover; size_t i = 0; - INT32 roverindex = -1; + UINT32 roverindex = 0; for (rover = mobj->ceilingrover->target->ffloors; rover; rover = rover->next) { @@ -1235,8 +1235,8 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) i++; } - WRITEUINT32(save_p, mobj->ceilingrover->target - sectors); - WRITEUINT32(save_p, roverindex); + WRITEUINT32(save_p, (UINT32)(mobj->ceilingrover->target - sectors)); + WRITEUINT32(save_p, rover ? roverindex : i); // store max index to denote invalid ffloor ref } if (diff & MD_SPAWNPOINT) From 832f891cbbacb5f8c1dbb96436753c7472cdce86 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 00:13:32 -0400 Subject: [PATCH 019/132] Remove rovernum increment from P_CheckPosition because unused --- src/p_map.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index 4bf06fa4b..0726084d5 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -1749,7 +1749,6 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) if (newsubsec->sector->ffloors) { ffloor_t *rover; - size_t rovernum = 0; fixed_t delta1, delta2; INT32 thingtop = thing->z + thing->height; @@ -1758,10 +1757,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) fixed_t topheight, bottomheight; if (!(rover->flags & FF_EXISTS)) - { - rovernum++; continue; - } topheight = P_GetFOFTopZ(thing, newsubsec->sector, rover, x, y, NULL); bottomheight = P_GetFOFBottomZ(thing, newsubsec->sector, rover, x, y, NULL); @@ -1804,7 +1800,6 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) } } } - rovernum++; continue; } @@ -1815,10 +1810,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) else if (!((rover->flags & FF_BLOCKPLAYER && thing->player) || (rover->flags & FF_BLOCKOTHERS && !thing->player) || rover->flags & FF_QUICKSAND)) - { - rovernum++; continue; - } if (rover->flags & FF_QUICKSAND) { @@ -1833,7 +1825,6 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) } } // Quicksand blocks never change heights otherwise. - rovernum++; continue; } @@ -1861,7 +1852,6 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) tmceilingslope = *rover->b_slope; #endif } - rovernum++; } } From 943dc9412d3e3f39ceb906f379786ac285c533da Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 00:20:51 -0400 Subject: [PATCH 020/132] Initialize floorrover and ceilingrover on SpawnMobj --- src/p_mobj.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/p_mobj.c b/src/p_mobj.c index 7b588645b..d433561ae 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -8627,6 +8627,9 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) #endif mobj->subsector->sector->ceilingheight; + mobj->floorrover = NULL; + mobj->ceilingrover = NULL; + // Tells MobjCheckWater that the water height was not set. mobj->watertop = INT32_MAX; @@ -8890,6 +8893,9 @@ static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype #endif mobj->subsector->sector->ceilingheight; + mobj->floorrover = NULL; + mobj->ceilingrover = NULL; + mobj->z = z; mobj->momz = mobjinfo[type].speed; From 0d88f31bbd22b8893503f7d6719bc72923947970 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 00:23:23 -0400 Subject: [PATCH 021/132] Add floorrover and ceilingrover to precipmobj_t --- src/p_mobj.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/p_mobj.h b/src/p_mobj.h index 90394c70d..630600b54 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -400,6 +400,8 @@ typedef struct precipmobj_s // The closest interval over all contacted sectors (or things). fixed_t floorz; // Nearest floor below. fixed_t ceilingz; // Nearest ceiling above. + struct ffloor_s *floorrover; // FOF referred by floorz + struct ffloor_s *ceilingrover; // FOF referred by ceilingz // For movement checking. fixed_t radius; // Fixed at 2*FRACUNIT From a6f959ba21c9f599b4823d0adce9bc9d7c355b65 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 00:35:40 -0400 Subject: [PATCH 022/132] Set mobj->floorrover and ceilingrover in appropriate places --- src/lua_mobjlib.c | 6 ++++++ src/p_local.h | 1 + src/p_map.c | 10 ++++++++++ src/p_mobj.c | 4 ++++ src/p_polyobj.c | 2 ++ 5 files changed, 23 insertions(+) diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 1583bd3c4..6efbeff8e 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -396,6 +396,8 @@ static int mobj_set(lua_State *L) P_CheckPosition(mo, mo->x, mo->y); mo->floorz = tmfloorz; mo->ceilingz = tmceilingz; + mo->floorrover = tmfloorrover; + mo->ceilingrover = tmceilingrover; P_SetTarget(&tmthing, ptmthing); break; } @@ -439,6 +441,8 @@ static int mobj_set(lua_State *L) P_CheckPosition(mo, mo->x, mo->y); mo->floorz = tmfloorz; mo->ceilingz = tmceilingz; + mo->floorrover = tmfloorrover; + mo->ceilingrover = tmceilingrover; P_SetTarget(&tmthing, ptmthing); break; } @@ -451,6 +455,8 @@ static int mobj_set(lua_State *L) P_CheckPosition(mo, mo->x, mo->y); mo->floorz = tmfloorz; mo->ceilingz = tmceilingz; + mo->floorrover = tmfloorrover; + mo->ceilingrover = tmceilingrover; P_SetTarget(&tmthing, ptmthing); break; } diff --git a/src/p_local.h b/src/p_local.h index 2676fb030..b98eeae1c 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -326,6 +326,7 @@ void P_InternalFlickyHop(mobj_t *actor, fixed_t momz, fixed_t momh, angle_t angl extern boolean floatok; extern fixed_t tmfloorz; extern fixed_t tmceilingz; +extern ffloor_t *tmfloorrover, *tmceilingrover; extern mobj_t *tmfloorthing, *tmhitthing, *tmthing; extern camera_t *mapcampointer; extern fixed_t tmx; diff --git a/src/p_map.c b/src/p_map.c index 0726084d5..648bb2bcc 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -102,6 +102,8 @@ boolean P_TeleportMove(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z) thing->floorz = tmfloorz; thing->ceilingz = tmceilingz; + thing->floorrover = tmfloorrover; + thing->ceilingrover = tmceilingrover; return true; } @@ -2485,6 +2487,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) if (thingtop == thing->ceilingz && tmceilingz > thingtop && tmceilingz - thingtop <= maxstep) { thing->z = (thing->ceilingz = thingtop = tmceilingz) - thing->height; + thing->ceilingrover = tmceilingrover; thing->eflags |= MFE_JUSTSTEPPEDDOWN; } #ifdef ESLOPE @@ -2492,6 +2495,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) else if (tmceilingslope && tmceilingz < thingtop && thingtop - tmceilingz <= maxstep) { thing->z = (thing->ceilingz = thingtop = tmceilingz) - thing->height; + thing->ceilingrover = tmceilingrover; thing->eflags |= MFE_JUSTSTEPPEDDOWN; } #endif @@ -2499,6 +2503,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) else if (thing->z == thing->floorz && tmfloorz < thing->z && thing->z - tmfloorz <= maxstep) { thing->z = thing->floorz = tmfloorz; + thing->floorrover = tmfloorrover; thing->eflags |= MFE_JUSTSTEPPEDDOWN; } #ifdef ESLOPE @@ -2506,6 +2511,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) else if (tmfloorslope && tmfloorz > thing->z && tmfloorz - thing->z <= maxstep) { thing->z = thing->floorz = tmfloorz; + thing->floorrover = tmfloorrover; thing->eflags |= MFE_JUSTSTEPPEDDOWN; } #endif @@ -2577,6 +2583,8 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) thing->floorz = tmfloorz; thing->ceilingz = tmceilingz; + thing->floorrover = tmfloorrover; + thing->ceilingrover = tmceilingrover; #ifdef ESLOPE if (!(thing->flags & MF_NOCLIPHEIGHT)) @@ -2657,6 +2665,8 @@ boolean P_SceneryTryMove(mobj_t *thing, fixed_t x, fixed_t y) thing->floorz = tmfloorz; thing->ceilingz = tmceilingz; + thing->floorrover = tmfloorrover; + thing->ceilingrover = tmceilingrover; thing->x = x; thing->y = y; diff --git a/src/p_mobj.c b/src/p_mobj.c index d433561ae..7c9baf0f1 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -8027,6 +8027,8 @@ void P_MobjThinker(mobj_t *mobj) return; mobj->floorz = tmfloorz; mobj->ceilingz = tmceilingz; + mobj->floorrover = tmfloorrover; + mobj->ceilingrover = tmceilingrover; if ((mobj->eflags & MFE_UNDERWATER) && mobj->health > 0) { @@ -8545,6 +8547,8 @@ void P_SceneryThinker(mobj_t *mobj) return; mobj->floorz = tmfloorz; mobj->ceilingz = tmceilingz; + mobj->floorrover = tmfloorrover; + mobj->ceilingrover = tmceilingrover; } else { diff --git a/src/p_polyobj.c b/src/p_polyobj.c index fd3237c9d..23e799d06 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -985,6 +985,8 @@ static void Polyobj_pushThing(polyobj_t *po, line_t *line, mobj_t *mo) P_CheckPosition(mo, mo->x + momx, mo->y + momy); mo->floorz = tmfloorz; mo->ceilingz = tmceilingz; + mo->floorrover = tmfloorrover; + mo->ceilingrover = tmceilingrover; } } From 88d9da79e6433164336663f3df6f66b64662d9ba Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 12:00:44 -0400 Subject: [PATCH 023/132] Move tic-based to EFFECT4 --- src/p_spec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index 917ad68d4..aa3a81f23 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2781,7 +2781,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) P_FadeLight(line->tag, (line->flags & ML_DONTPEGBOTTOM) ? max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, 255), 0) : line->frontsector->lightlevel, (line->flags & ML_DONTPEGBOTTOM) ? max(sides[line->sidenum[0]].rowoffset>>FRACBITS, 0) : P_AproxDistance(line->dx, line->dy)>>FRACBITS, - (line->flags & ML_EFFECT5)); + (line->flags & ML_EFFECT4)); break; case 421: // Stop lighting effect in tagged sectors From e33ed45b7b774a819812d4f7887bd93c107206cc Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 15:59:31 -0400 Subject: [PATCH 024/132] Colormap overhaul in r_data.c * Split R_CreateColormap to R_CreateLightTable * Replace extra_colormaps array with next/prev pointer chain * Remove foundcolormaps; instead store lumpnum in extracolormap_t * Add properties to extracolormap_t for portability --- src/r_data.c | 333 ++++++++++++++++++++++++++++++++------------------ src/r_data.h | 3 +- src/r_defs.h | 12 +- src/r_state.h | 3 +- 4 files changed, 226 insertions(+), 125 deletions(-) diff --git a/src/r_data.c b/src/r_data.c index 18c93787c..1c964993f 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1311,8 +1311,6 @@ void R_ReInitColormaps(UINT16 num) R_ClearColormaps(); } -static lumpnum_t foundcolormaps[MAXCOLORMAPS]; - // // R_ClearColormaps // @@ -1320,48 +1318,73 @@ static lumpnum_t foundcolormaps[MAXCOLORMAPS]; // void R_ClearColormaps(void) { - size_t i; + extracolormap_t *exc, *exc_next; - num_extra_colormaps = 0; + for (exc = extra_colormaps; exc; exc = exc_next) + { + exc_next = exc->next; + memset(exc, 0, sizeof(exc)); + } - for (i = 0; i < MAXCOLORMAPS; i++) - foundcolormaps[i] = LUMPERROR; + extra_colormaps = NULL; +} - memset(extra_colormaps, 0, sizeof (extra_colormaps)); +// +// R_AddColormapToList +// +// Sets prev/next chain for extra_colormaps var +// Copypasta from P_AddFFloorToList +// +void R_AddColormapToList(extracolormap_t *extra_colormap) +{ + extracolormap_t *exc; + + if (!extra_colormaps) + { + extra_colormaps = extra_colormap; + extra_colormap->next = 0; + extra_colormap->prev = 0; + return; + } + + for (exc = extra_colormaps; exc->next; exc = exc->next); + + exc->next = extra_colormap; + extra_colormap->prev = exc; + extra_colormap->next = 0; } INT32 R_ColormapNumForName(char *name) { - lumpnum_t lump, i; - - if (num_extra_colormaps == MAXCOLORMAPS) - I_Error("R_ColormapNumForName: Too many colormaps! the limit is %d\n", MAXCOLORMAPS); + lumpnum_t lump; + extracolormap_t *exc; lump = R_CheckNumForNameList(name, colormaplumps, numcolormaplumps); if (lump == LUMPERROR) I_Error("R_ColormapNumForName: Cannot find colormap lump %.8s\n", name); - for (i = 0; i < num_extra_colormaps; i++) - if (lump == foundcolormaps[i]) - return i; + for (exc = extra_colormaps; exc; exc = exc->next) + if (lump == exc->lump) + return exc; - foundcolormaps[num_extra_colormaps] = lump; + exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL); + + exc->lump = lump; // aligned on 8 bit for asm code - extra_colormaps[num_extra_colormaps].colormap = Z_MallocAlign(W_LumpLength(lump), PU_LEVEL, NULL, 16); - W_ReadLump(lump, extra_colormaps[num_extra_colormaps].colormap); + exc->colormap = Z_MallocAlign(W_LumpLength(lump), PU_LEVEL, NULL, 16); + W_ReadLump(lump, exc->colormap); // We set all params of the colormap to normal because there // is no real way to tell how GL should handle a colormap lump anyway.. - extra_colormaps[num_extra_colormaps].maskcolor = 0xffff; - extra_colormaps[num_extra_colormaps].fadecolor = 0x0; - extra_colormaps[num_extra_colormaps].maskamt = 0x0; - extra_colormaps[num_extra_colormaps].fadestart = 0; - extra_colormaps[num_extra_colormaps].fadeend = 31; - extra_colormaps[num_extra_colormaps].fog = 0; + exc->maskcolor = 0xffff; + exc->fadecolor = 0x0; + exc->maskamt = 0x0; + exc->fadestart = 0; + exc->fadeend = 31; + exc->fog = 0; - num_extra_colormaps++; - return (INT32)num_extra_colormaps - 1; + return exc; } // @@ -1377,105 +1400,30 @@ static double deltas[256][3], map[256][3]; static UINT8 NearestColor(UINT8 r, UINT8 g, UINT8 b); static int RoundUp(double number); -INT32 R_CreateColormap(char *p1, char *p2, char *p3) +lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap) { - double cmaskr, cmaskg, cmaskb, cdestr, cdestg, cdestb; - double maskamt = 0, othermask = 0; - int mask, fog = 0; - size_t mapnum = num_extra_colormaps; - size_t i; - UINT32 cr, cg, cb, maskcolor, fadecolor; - UINT32 fadestart = 0, fadeend = 31, fadedist = 31; + // "Unpackage" our variables for ease of reading below + UINT32 maskcolor = (UINT32)extra_colormap->maskcolor, + fadecolor = (UINT32)extra_colormap->fadecolor, + fadestart = (UINT16)extra_colormap->fadestart, + fadeend = (UINT16)extra_colormap->fadeend, + fadedist = extra_colormap->fadedist; -#define HEX2INT(x) (UINT32)(x >= '0' && x <= '9' ? x - '0' : x >= 'a' && x <= 'f' ? x - 'a' + 10 : x >= 'A' && x <= 'F' ? x - 'A' + 10 : 0) - if (p1[0] == '#') - { - cr = ((HEX2INT(p1[1]) * 16) + HEX2INT(p1[2])); - cmaskr = cr; - cg = ((HEX2INT(p1[3]) * 16) + HEX2INT(p1[4])); - cmaskg = cg; - cb = ((HEX2INT(p1[5]) * 16) + HEX2INT(p1[6])); - cmaskb = cb; - // Create a rough approximation of the color (a 16 bit color) - maskcolor = ((cb) >> 3) + (((cg) >> 2) << 5) + (((cr) >> 3) << 11); - if (p1[7] >= 'a' && p1[7] <= 'z') - mask = (p1[7] - 'a'); - else if (p1[7] >= 'A' && p1[7] <= 'Z') - mask = (p1[7] - 'A'); - else - mask = 24; + double maskamt = extra_colormap->maskamt, + othermask = extra_colormap->othermask, + cmaskr = extra_colormap->cmaskr, + cmaskg = extra_colormap->cmaskg, + cmaskb = extra_colormap->cmaskb, + cdestr = extra_colormap->cdestr, + cdestg = extra_colormap->cdestg, + cdestb = extra_colormap->cdestb; - maskamt = (double)(mask/24.0l); + int fog = extra_colormap->fog; - othermask = 1 - maskamt; - maskamt /= 0xff; - cmaskr *= maskamt; - cmaskg *= maskamt; - cmaskb *= maskamt; - } - else - { - cmaskr = cmaskg = cmaskb = 0xff; - maskamt = 0; - maskcolor = ((0xff) >> 3) + (((0xff) >> 2) << 5) + (((0xff) >> 3) << 11); - } + INT32 rgba = extra_colormap->rgba, + fadergba = extra_colormap->fadergba; -#define NUMFROMCHAR(c) (c >= '0' && c <= '9' ? c - '0' : 0) - if (p2[0] == '#') - { - // Get parameters like fadestart, fadeend, and the fogflag - fadestart = NUMFROMCHAR(p2[3]) + (NUMFROMCHAR(p2[2]) * 10); - fadeend = NUMFROMCHAR(p2[5]) + (NUMFROMCHAR(p2[4]) * 10); - if (fadestart > 30) - fadestart = 0; - if (fadeend > 31 || fadeend < 1) - fadeend = 31; - fadedist = fadeend - fadestart; - fog = NUMFROMCHAR(p2[1]); - } -#undef NUMFROMCHAR - - if (p3[0] == '#') - { - cdestr = cr = ((HEX2INT(p3[1]) * 16) + HEX2INT(p3[2])); - cdestg = cg = ((HEX2INT(p3[3]) * 16) + HEX2INT(p3[4])); - cdestb = cb = ((HEX2INT(p3[5]) * 16) + HEX2INT(p3[6])); - fadecolor = (((cb) >> 3) + (((cg) >> 2) << 5) + (((cr) >> 3) << 11)); - } - else - cdestr = cdestg = cdestb = fadecolor = 0; -#undef HEX2INT - - for (i = 0; i < num_extra_colormaps; i++) - { - if (foundcolormaps[i] != LUMPERROR) - continue; - if (maskcolor == extra_colormaps[i].maskcolor - && fadecolor == extra_colormaps[i].fadecolor - && (float)maskamt == (float)extra_colormaps[i].maskamt - && fadestart == extra_colormaps[i].fadestart - && fadeend == extra_colormaps[i].fadeend - && fog == extra_colormaps[i].fog) - { - return (INT32)i; - } - } - - if (num_extra_colormaps == MAXCOLORMAPS) - I_Error("R_CreateColormap: Too many colormaps! the limit is %d\n", MAXCOLORMAPS); - - num_extra_colormaps++; - - foundcolormaps[mapnum] = LUMPERROR; - - // aligned on 8 bit for asm code - extra_colormaps[mapnum].colormap = NULL; - extra_colormaps[mapnum].maskcolor = (UINT16)maskcolor; - extra_colormaps[mapnum].fadecolor = (UINT16)fadecolor; - extra_colormaps[mapnum].maskamt = maskamt; - extra_colormaps[mapnum].fadestart = (UINT16)fadestart; - extra_colormaps[mapnum].fadeend = (UINT16)fadeend; - extra_colormaps[mapnum].fog = fog; + lighttable_t *lighttable; // This code creates the colormap array used by software renderer if (rendermode == render_soft) @@ -1513,8 +1461,9 @@ INT32 R_CreateColormap(char *p1, char *p2, char *p3) } // Now allocate memory for the actual colormap array itself! + // aligned on 8 bit for asm code colormap_p = Z_MallocAlign((256 * 34) + 10, PU_LEVEL, NULL, 8); - extra_colormaps[mapnum].colormap = (UINT8 *)colormap_p; + lighttable = (UINT8 *)colormap_p; // Calculate the palette index for each palette index, for each light level // (as well as the two unused colormap lines we inherited from Doom) @@ -1549,7 +1498,149 @@ INT32 R_CreateColormap(char *p1, char *p2, char *p3) } } - return (INT32)mapnum; + return lighttable; +} + +extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) +{ + double cmaskr, cmaskg, cmaskb, cdestr, cdestg, cdestb; + double maskamt = 0, othermask = 0; + int mask, fog = 0; + extracolormap_t *extra_colormap, *exc; + + UINT32 cr, cg, cb, maskcolor, fadecolor; + UINT32 fadestart = 0, fadeend = 31, fadedist = 31; + + INT32 rgba, fadergba; + +#define HEX2INT(x) (UINT32)(x >= '0' && x <= '9' ? x - '0' : x >= 'a' && x <= 'f' ? x - 'a' + 10 : x >= 'A' && x <= 'F' ? x - 'A' + 10 : 0) + if (p1[0] == '#') + { + cr = ((HEX2INT(p1[1]) * 16) + HEX2INT(p1[2])); + cmaskr = cr; + cg = ((HEX2INT(p1[3]) * 16) + HEX2INT(p1[4])); + cmaskg = cg; + cb = ((HEX2INT(p1[5]) * 16) + HEX2INT(p1[6])); + cmaskb = cb; + // Create a rough approximation of the color (a 16 bit color) + maskcolor = ((cb) >> 3) + (((cg) >> 2) << 5) + (((cr) >> 3) << 11); + if (p1[7] >= 'a' && p1[7] <= 'z') + mask = (p1[7] - 'a'); + else if (p1[7] >= 'A' && p1[7] <= 'Z') + mask = (p1[7] - 'A'); + else + mask = 24; + + maskamt = (double)(mask/24.0l); + + othermask = 1 - maskamt; + maskamt /= 0xff; + cmaskr *= maskamt; + cmaskg *= maskamt; + cmaskb *= maskamt; + + // package up cmask vars for passing around + maskrgba = + + // for opengl; generate on software too for netsync + rgba = (HEX2INT(p1[1]) << 4) + (HEX2INT(p1[2]) << 0) + + (HEX2INT(p1[3]) << 12) + (HEX2INT(p1[4]) << 8) + + (HEX2INT(p1[5]) << 20) + (HEX2INT(p1[6]) << 16); + + if (p1[7] >= 'a' && p1[7] <= 'z' || p1[7] >= 'A' && p1[7] <= 'Z') + rgba += (ALPHA2INT(p1[7]) << 24); + else + rgba += (25 << 24); + } + else + { + cmaskr = cmaskg = cmaskb = 0xff; + maskamt = 0; + maskcolor = ((0xff) >> 3) + (((0xff) >> 2) << 5) + (((0xff) >> 3) << 11); + rgba = 0; + } + +#define NUMFROMCHAR(c) (c >= '0' && c <= '9' ? c - '0' : 0) + if (p2[0] == '#') + { + // Get parameters like fadestart, fadeend, and the fogflag + fadestart = NUMFROMCHAR(p2[3]) + (NUMFROMCHAR(p2[2]) * 10); + fadeend = NUMFROMCHAR(p2[5]) + (NUMFROMCHAR(p2[4]) * 10); + if (fadestart > 30) + fadestart = 0; + if (fadeend > 31 || fadeend < 1) + fadeend = 31; + fadedist = fadeend - fadestart; + fog = NUMFROMCHAR(p2[1]); + } +#undef NUMFROMCHAR + + if (p3[0] == '#') + { + cdestr = cr = ((HEX2INT(p3[1]) * 16) + HEX2INT(p3[2])); + cdestg = cg = ((HEX2INT(p3[3]) * 16) + HEX2INT(p3[4])); + cdestb = cb = ((HEX2INT(p3[5]) * 16) + HEX2INT(p3[6])); + fadecolor = (((cb) >> 3) + (((cg) >> 2) << 5) + (((cr) >> 3) << 11)); + + // for opengl; generate on software too for netsync + fadergba = (HEX2INT(p3[1]) << 4) + (HEX2INT(p3[2]) << 0) + + (HEX2INT(p3[3]) << 12) + (HEX2INT(p3[4]) << 8) + + (HEX2INT(p3[5]) << 20) + (HEX2INT(p3[6]) << 16); + + if (p3[7] >= 'a' && p3[7] <= 'z' || p3[7] >= 'A' && p3[7] <= 'Z') + fadergba += (ALPHA2INT(p3[7]) << 24); + else + fadergba += (25 << 24); + } + else + { + cdestr = cdestg = cdestb = fadecolor = 0; + fadergba = 0x19000000; // default alpha for fade, (25 << 24) + } +#undef HEX2INT + + for (exc = extra_colormaps; exc; exc = exc->next) + { + if (exc->lump) + continue; + if (maskcolor == exc->maskcolor + && fadecolor == exc->fadecolor + && (float)maskamt == (float)exc->maskamt + && fadestart == exc->fadestart + && fadeend == exc->fadeend + && fog == exc->fog) + return exc; + } + + extra_colormap = Z_Calloc(sizeof (*extra_colormap), PU_LEVEL, NULL); + + extra_colormap->maskcolor = (UINT16)maskcolor; + extra_colormap->fadecolor = (UINT16)fadecolor; + extra_colormap->maskamt = maskamt; + extra_colormap->othermask = othermask; + extra_colormap->fadestart = (UINT16)fadestart; + extra_colormap->fadeend = (UINT16)fadeend; + extra_colormap->fadedist = fadedist; + extra_colormap->fog = fog; + + extra_colormap->cmaskr = cmaskr; + extra_colormap->cmaskg = cmaskg; + extra_colormap->cmaskb = cmaskb; + extra_colormap->cdestr = cdestr; + extra_colormap->cdestg = cdestg; + extra_colormap->cdestb = cdestb; + + extra_colormap->rgba = rgba; + extra_colormap->fadergba = fadergba; + + extra_colormap->lump = LUMPERROR; + extra_colormap->next = extra_colormap->prev = NULL; + + extra_colormap->colormap = R_CreateLightTable(extra_colormap); + + R_AddColormapToList(extra_colormap); + + return extra_colormap; } // Thanks to quake2 source! diff --git a/src/r_data.h b/src/r_data.h index 250f4d7c2..612c184e4 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -99,7 +99,8 @@ INT32 R_CheckTextureNumForName(const char *name); void R_ReInitColormaps(UINT16 num); void R_ClearColormaps(void); INT32 R_ColormapNumForName(char *name); -INT32 R_CreateColormap(char *p1, char *p2, char *p3); +lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap); +extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3); const char *R_ColormapNameForNum(INT32 num); extern INT32 numtextures; diff --git a/src/r_defs.h b/src/r_defs.h index 7c8f2a73f..15312114a 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -53,15 +53,25 @@ typedef UINT8 lighttable_t; typedef struct { UINT16 maskcolor, fadecolor; - double maskamt; + double maskamt, othermask; UINT16 fadestart, fadeend; + UINT32 fadedist; INT32 fog; + // mask rgb for colormap table generation + double cmaskr, cmaskg, cmaskb; + double cdestr, cdestg, cdestb; + // rgba is used in hw mode for colored sector lighting INT32 rgba; // similar to maskcolor in sw mode INT32 fadergba; // The colour the colourmaps fade to lighttable_t *colormap; + + lumpnum_t lump; // for colormap lump matching, init to LUMPERROR + + extracolormap_t *next; + extracolormap_t *prev; } extracolormap_t; // diff --git a/src/r_state.h b/src/r_state.h index ac3e1fa42..effa4e36c 100644 --- a/src/r_state.h +++ b/src/r_state.h @@ -43,8 +43,7 @@ extern lighttable_t *colormaps; // Had to put a limit on colormaps :( #define MAXCOLORMAPS 60 -extern size_t num_extra_colormaps; -extern extracolormap_t extra_colormaps[MAXCOLORMAPS]; +extern extracolormap_t *extra_colormaps; // for global animation extern INT32 *texturetranslation; From 574a591d434bc1574e54479a443b15b315e422b2 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 16:08:43 -0400 Subject: [PATCH 025/132] P_LoadRawSideDefs2 colormap cleanup (merge ogl and software to one block) --- src/p_setup.c | 82 +++++---------------------------------------------- 1 file changed, 7 insertions(+), 75 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 5cc7279c5..a29a6080a 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1474,82 +1474,17 @@ static void P_LoadRawSideDefs2(void *data) // Perhaps we should just call it instead of doing the calculations here. if (rendermode == render_soft || rendermode == render_none) { - if (msd->toptexture[0] == '#' || msd->bottomtexture[0] == '#') - { - sec->midmap = R_CreateColormap(msd->toptexture, msd->midtexture, - msd->bottomtexture); - sd->toptexture = sd->bottomtexture = 0; - } - else - { - if ((num = R_CheckTextureNumForName(msd->toptexture)) == -1) - sd->toptexture = 0; - else - sd->toptexture = num; - if ((num = R_CheckTextureNumForName(msd->midtexture)) == -1) - sd->midtexture = 0; - else - sd->midtexture = num; - if ((num = R_CheckTextureNumForName(msd->bottomtexture)) == -1) - sd->bottomtexture = 0; - else - sd->bottomtexture = num; - } - break; - } + if ( + ((rendermode == render_soft || rendermode == render_none) && (msd->toptexture[0] == '#' || msd->bottomtexture[0] == '#')) #ifdef HWRENDER - else - { - // for now, full support of toptexture only - if ((msd->toptexture[0] == '#' && msd->toptexture[1] && msd->toptexture[2] && msd->toptexture[3] && msd->toptexture[4] && msd->toptexture[5] && msd->toptexture[6]) - || (msd->bottomtexture[0] == '#' && msd->bottomtexture[1] && msd->bottomtexture[2] && msd->bottomtexture[3] && msd->bottomtexture[4] && msd->bottomtexture[5] && msd->bottomtexture[6])) + || (msd->toptexture[0] == '#' && msd->toptexture[1] && msd->toptexture[2] && msd->toptexture[3] && msd->toptexture[4] && msd->toptexture[5] && msd->toptexture[6]) + || (msd->bottomtexture[0] == '#' && msd->bottomtexture[1] && msd->bottomtexture[2] && msd->bottomtexture[3] && msd->bottomtexture[4] && msd->bottomtexture[5] && msd->bottomtexture[6]) +#endif + ) { - char *col; - - sec->midmap = R_CreateColormap(msd->toptexture, msd->midtexture, + sec->extra_colormap = R_CreateColormap(msd->toptexture, msd->midtexture, msd->bottomtexture); sd->toptexture = sd->bottomtexture = 0; -#define HEX2INT(x) (x >= '0' && x <= '9' ? x - '0' : x >= 'a' && x <= 'f' ? x - 'a' + 10 : x >= 'A' && x <= 'F' ? x - 'A' + 10 : 0) -#define ALPHA2INT(x) (x >= 'a' && x <= 'z' ? x - 'a' : x >= 'A' && x <= 'Z' ? x - 'A' : x >= '0' && x <= '9' ? 25 : 0) - sec->extra_colormap = &extra_colormaps[sec->midmap]; - - if (msd->toptexture[0] == '#' && msd->toptexture[1] && msd->toptexture[2] && msd->toptexture[3] && msd->toptexture[4] && msd->toptexture[5] && msd->toptexture[6]) - { - col = msd->toptexture; - - sec->extra_colormap->rgba = - (HEX2INT(col[1]) << 4) + (HEX2INT(col[2]) << 0) + - (HEX2INT(col[3]) << 12) + (HEX2INT(col[4]) << 8) + - (HEX2INT(col[5]) << 20) + (HEX2INT(col[6]) << 16); - - // alpha - if (msd->toptexture[7]) - sec->extra_colormap->rgba += (ALPHA2INT(col[7]) << 24); - else - sec->extra_colormap->rgba += (25 << 24); - } - else - sec->extra_colormap->rgba = 0; - - if (msd->bottomtexture[0] == '#' && msd->bottomtexture[1] && msd->bottomtexture[2] && msd->bottomtexture[3] && msd->bottomtexture[4] && msd->bottomtexture[5] && msd->bottomtexture[6]) - { - col = msd->bottomtexture; - - sec->extra_colormap->fadergba = - (HEX2INT(col[1]) << 4) + (HEX2INT(col[2]) << 0) + - (HEX2INT(col[3]) << 12) + (HEX2INT(col[4]) << 8) + - (HEX2INT(col[5]) << 20) + (HEX2INT(col[6]) << 16); - - // alpha - if (msd->bottomtexture[7]) - sec->extra_colormap->fadergba += (ALPHA2INT(col[7]) << 24); - else - sec->extra_colormap->fadergba += (25 << 24); - } - else - sec->extra_colormap->fadergba = 0x19000000; // default alpha, (25 << 24) -#undef ALPHA2INT -#undef HEX2INT } else { @@ -1557,12 +1492,10 @@ static void P_LoadRawSideDefs2(void *data) sd->toptexture = 0; else sd->toptexture = num; - if ((num = R_CheckTextureNumForName(msd->midtexture)) == -1) sd->midtexture = 0; else sd->midtexture = num; - if ((num = R_CheckTextureNumForName(msd->bottomtexture)) == -1) sd->bottomtexture = 0; else @@ -1570,7 +1503,6 @@ static void P_LoadRawSideDefs2(void *data) } break; } -#endif case 413: // Change music { From e0d8a6eec0807afe4dc93fcb65e80e82d2131a73 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 16:16:04 -0400 Subject: [PATCH 026/132] Get rid of bottommap, midmap, topmap --- src/p_setup.c | 1 - src/p_spec.c | 2 +- src/r_bsp.c | 25 ++++--------------------- src/r_defs.h | 2 -- 4 files changed, 5 insertions(+), 25 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index a29a6080a..eb8489726 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -718,7 +718,6 @@ static void P_LoadRawSectors(UINT8 *data, size_t i) ss->spawn_flr_xoffs = ss->spawn_ceil_xoffs = ss->spawn_flr_yoffs = ss->spawn_ceil_yoffs = 0; ss->floorpic_angle = ss->ceilingpic_angle = 0; ss->spawn_flrpic_angle = ss->spawn_ceilpic_angle = 0; - ss->bottommap = ss->midmap = ss->topmap = -1; ss->gravity = NULL; ss->cullheight = NULL; ss->verticalflip = false; diff --git a/src/p_spec.c b/src/p_spec.c index 6c359c9cc..698c8f4b1 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -6760,7 +6760,7 @@ void P_SpawnSpecials(INT32 fromnetsave) case 606: // HACK! Copy colormaps. Just plain colormaps. for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) - sectors[s].midmap = lines[i].frontsector->midmap; + sectors[s].extra_colormap = lines[i].frontsector->extra_colormap; break; #ifdef ESLOPE // Slope copy specials. Handled here for sanity. diff --git a/src/r_bsp.c b/src/r_bsp.c index 183def25a..512aab696 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -234,8 +234,6 @@ static INT32 R_DoorClosed(void) sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel, INT32 *ceilinglightlevel, boolean back) { - INT32 mapnum = -1; - if (floorlightlevel) *floorlightlevel = sec->floorlightsec == -1 ? sec->lightlevel : sectors[sec->floorlightsec].lightlevel; @@ -244,10 +242,10 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel, *ceilinglightlevel = sec->ceilinglightsec == -1 ? sec->lightlevel : sectors[sec->ceilinglightsec].lightlevel; - // If the sector has a midmap, it's probably from 280 type - if (sec->midmap != -1) - mapnum = sec->midmap; - else if (sec->heightsec != -1) + // if (sec->midmap != -1) + // mapnum = sec->midmap; + // In original colormap code, this block did not run if sec->midmap was set + if (!sec->extra_colormap && sec->heightsec != -1) { const sector_t *s = §ors[sec->heightsec]; mobj_t *viewmobj = viewplayer->mo; @@ -271,8 +269,6 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel, tempsec->floorheight = s->floorheight; tempsec->ceilingheight = s->ceilingheight; - mapnum = s->midmap; - if ((underwater && (tempsec-> floorheight = sec->floorheight, tempsec->ceilingheight = s->floorheight - 1, !back)) || viewz <= s->floorheight) { // head-below-floor hack @@ -298,7 +294,6 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel, tempsec->ceiling_yoffs = s->ceiling_yoffs; tempsec->ceilingpic_angle = s->ceilingpic_angle; } - mapnum = s->bottommap; } tempsec->lightlevel = s->lightlevel; @@ -322,8 +317,6 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel, tempsec->floor_yoffs = tempsec->ceiling_yoffs = s->ceiling_yoffs; tempsec->floorpic_angle = tempsec->ceilingpic_angle = s->ceilingpic_angle; - mapnum = s->topmap; - if (s->floorpic == skyflatnum) // SKYFIX? { tempsec->ceilingheight = tempsec->floorheight-1; @@ -354,11 +347,6 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel, sec = tempsec; } - if (mapnum >= 0 && (size_t)mapnum < num_extra_colormaps) - sec->extra_colormap = &extra_colormaps[mapnum]; - else - sec->extra_colormap = NULL; - return sec; } @@ -1342,11 +1330,6 @@ void R_Prep3DFloors(sector_t *sector) sector->lightlist[i].slope = bestslope; #endif sec = §ors[best->secnum]; - mapnum = sec->midmap; - if (mapnum >= 0 && (size_t)mapnum < num_extra_colormaps) - sec->extra_colormap = &extra_colormaps[mapnum]; - else - sec->extra_colormap = NULL; if (best->flags & FF_NOSHADE) { diff --git a/src/r_defs.h b/src/r_defs.h index 15312114a..257e36147 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -333,8 +333,6 @@ typedef struct sector_s INT32 floorlightsec, ceilinglightsec; INT32 crumblestate; // used for crumbling and bobbing - INT32 bottommap, midmap, topmap; // dynamic colormaps - // list of mobjs that are at least partially in the sector // thinglist is a subset of touching_thinglist struct msecnode_s *touching_thinglist; From 2701976ba39124f1687da05018c30644c821f30e Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 16:28:39 -0400 Subject: [PATCH 027/132] Compiler fixes --- src/r_bsp.c | 2 +- src/r_data.c | 43 +++++++++++++++---------------------------- src/r_data.h | 2 +- src/r_defs.h | 6 +++--- src/r_main.c | 3 +-- 5 files changed, 21 insertions(+), 35 deletions(-) diff --git a/src/r_bsp.c b/src/r_bsp.c index 512aab696..01676572e 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -1225,7 +1225,7 @@ void R_Prep3DFloors(sector_t *sector) ffloor_t *rover; ffloor_t *best; fixed_t bestheight, maxheight; - INT32 count, i, mapnum; + INT32 count, i; sector_t *sec; #ifdef ESLOPE pslope_t *bestslope = NULL; diff --git a/src/r_data.c b/src/r_data.c index 1c964993f..eb5e27b0b 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1323,7 +1323,7 @@ void R_ClearColormaps(void) for (exc = extra_colormaps; exc; exc = exc_next) { exc_next = exc->next; - memset(exc, 0, sizeof(exc)); + memset(exc, 0, sizeof(*exc)); } extra_colormaps = NULL; @@ -1354,14 +1354,14 @@ void R_AddColormapToList(extracolormap_t *extra_colormap) extra_colormap->next = 0; } -INT32 R_ColormapNumForName(char *name) +extracolormap_t *R_ColormapForName(char *name) { lumpnum_t lump; extracolormap_t *exc; lump = R_CheckNumForNameList(name, colormaplumps, numcolormaplumps); if (lump == LUMPERROR) - I_Error("R_ColormapNumForName: Cannot find colormap lump %.8s\n", name); + I_Error("R_ColormapForName: Cannot find colormap lump %.8s\n", name); for (exc = extra_colormaps; exc; exc = exc->next) if (lump == exc->lump) @@ -1402,15 +1402,10 @@ static int RoundUp(double number); lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap) { - // "Unpackage" our variables for ease of reading below - UINT32 maskcolor = (UINT32)extra_colormap->maskcolor, - fadecolor = (UINT32)extra_colormap->fadecolor, - fadestart = (UINT16)extra_colormap->fadestart, - fadeend = (UINT16)extra_colormap->fadeend, + UINT32 fadestart = (UINT16)extra_colormap->fadestart, fadedist = extra_colormap->fadedist; - double maskamt = extra_colormap->maskamt, - othermask = extra_colormap->othermask, + double othermask = extra_colormap->othermask, cmaskr = extra_colormap->cmaskr, cmaskg = extra_colormap->cmaskg, cmaskb = extra_colormap->cmaskb, @@ -1418,12 +1413,8 @@ lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap) cdestg = extra_colormap->cdestg, cdestb = extra_colormap->cdestb; - int fog = extra_colormap->fog; - - INT32 rgba = extra_colormap->rgba, - fadergba = extra_colormap->fadergba; - - lighttable_t *lighttable; + lighttable_t *lighttable = NULL; + size_t i; // This code creates the colormap array used by software renderer if (rendermode == render_soft) @@ -1514,6 +1505,7 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) INT32 rgba, fadergba; #define HEX2INT(x) (UINT32)(x >= '0' && x <= '9' ? x - '0' : x >= 'a' && x <= 'f' ? x - 'a' + 10 : x >= 'A' && x <= 'F' ? x - 'A' + 10 : 0) +#define ALPHA2INT(x) (x >= 'a' && x <= 'z' ? x - 'a' : x >= 'A' && x <= 'Z' ? x - 'A' : x >= '0' && x <= '9' ? 25 : 0) if (p1[0] == '#') { cr = ((HEX2INT(p1[1]) * 16) + HEX2INT(p1[2])); @@ -1539,15 +1531,12 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) cmaskg *= maskamt; cmaskb *= maskamt; - // package up cmask vars for passing around - maskrgba = - // for opengl; generate on software too for netsync rgba = (HEX2INT(p1[1]) << 4) + (HEX2INT(p1[2]) << 0) + (HEX2INT(p1[3]) << 12) + (HEX2INT(p1[4]) << 8) + (HEX2INT(p1[5]) << 20) + (HEX2INT(p1[6]) << 16); - if (p1[7] >= 'a' && p1[7] <= 'z' || p1[7] >= 'A' && p1[7] <= 'Z') + if ((p1[7] >= 'a' && p1[7] <= 'z') || (p1[7] >= 'A' && p1[7] <= 'Z')) rgba += (ALPHA2INT(p1[7]) << 24); else rgba += (25 << 24); @@ -1587,7 +1576,7 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) (HEX2INT(p3[3]) << 12) + (HEX2INT(p3[4]) << 8) + (HEX2INT(p3[5]) << 20) + (HEX2INT(p3[6]) << 16); - if (p3[7] >= 'a' && p3[7] <= 'z' || p3[7] >= 'A' && p3[7] <= 'Z') + if ((p3[7] >= 'a' && p3[7] <= 'z') || (p3[7] >= 'A' && p3[7] <= 'Z')) fadergba += (ALPHA2INT(p3[7]) << 24); else fadergba += (25 << 24); @@ -1597,6 +1586,7 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) cdestr = cdestg = cdestb = fadecolor = 0; fadergba = 0x19000000; // default alpha for fade, (25 << 24) } +#undef ALPHA2INT #undef HEX2INT for (exc = extra_colormaps; exc; exc = exc->next) @@ -1683,18 +1673,15 @@ static int RoundUp(double number) return (int)number; } -const char *R_ColormapNameForNum(INT32 num) +const char *R_ColormapNameForColormap(extracolormap_t *extra_colormap) { - if (num == -1) + if (!extra_colormap) return "NONE"; - if (num < 0 || num > MAXCOLORMAPS) - I_Error("R_ColormapNameForNum: num %d is invalid!\n", num); - - if (foundcolormaps[num] == LUMPERROR) + if (extra_colormap->lump == LUMPERROR) return "INLEVEL"; - return W_CheckNameForNum(foundcolormaps[num]); + return W_CheckNameForNum(extra_colormap->lump); } diff --git a/src/r_data.h b/src/r_data.h index 612c184e4..db2749834 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -98,7 +98,7 @@ INT32 R_CheckTextureNumForName(const char *name); void R_ReInitColormaps(UINT16 num); void R_ClearColormaps(void); -INT32 R_ColormapNumForName(char *name); +extracolormap_t *R_ColormapForName(char *name); lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap); extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3); const char *R_ColormapNameForNum(INT32 num); diff --git a/src/r_defs.h b/src/r_defs.h index 257e36147..d8915cab8 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -50,7 +50,7 @@ typedef struct typedef UINT8 lighttable_t; // ExtraColormap type. Use for extra_colormaps from now on. -typedef struct +typedef struct extracolormap_s { UINT16 maskcolor, fadecolor; double maskamt, othermask; @@ -70,8 +70,8 @@ typedef struct lumpnum_t lump; // for colormap lump matching, init to LUMPERROR - extracolormap_t *next; - extracolormap_t *prev; + struct extracolormap_s *next; + struct extracolormap_s *prev; } extracolormap_t; // diff --git a/src/r_main.c b/src/r_main.c index 8e58906d4..281058362 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -118,8 +118,7 @@ lighttable_t *scalelightfixed[MAXLIGHTSCALE]; lighttable_t *zlight[LIGHTLEVELS][MAXLIGHTZ]; // Hack to support extra boom colormaps. -size_t num_extra_colormaps; -extracolormap_t extra_colormaps[MAXCOLORMAPS]; +extracolormap_t *extra_colormaps; static CV_PossibleValue_t drawdist_cons_t[] = { {256, "256"}, {512, "512"}, {768, "768"}, From 53733ddf76440a70cf414c67b8ff5c58e93fe1f3 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 16:32:54 -0400 Subject: [PATCH 028/132] Type 606 renderer check allow OGL again --- src/p_setup.c | 53 ++++++++++++++++++++++++--------------------------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index eb8489726..09ba553bf 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1471,37 +1471,34 @@ static void P_LoadRawSideDefs2(void *data) case 606: //SoM: 4/4/2000: Just colormap transfer // SoM: R_CreateColormap will only create a colormap in software mode... // Perhaps we should just call it instead of doing the calculations here. - if (rendermode == render_soft || rendermode == render_none) - { - if ( - ((rendermode == render_soft || rendermode == render_none) && (msd->toptexture[0] == '#' || msd->bottomtexture[0] == '#')) + if ( + ((rendermode == render_soft || rendermode == render_none) && (msd->toptexture[0] == '#' || msd->bottomtexture[0] == '#')) #ifdef HWRENDER - || (msd->toptexture[0] == '#' && msd->toptexture[1] && msd->toptexture[2] && msd->toptexture[3] && msd->toptexture[4] && msd->toptexture[5] && msd->toptexture[6]) - || (msd->bottomtexture[0] == '#' && msd->bottomtexture[1] && msd->bottomtexture[2] && msd->bottomtexture[3] && msd->bottomtexture[4] && msd->bottomtexture[5] && msd->bottomtexture[6]) + || (msd->toptexture[0] == '#' && msd->toptexture[1] && msd->toptexture[2] && msd->toptexture[3] && msd->toptexture[4] && msd->toptexture[5] && msd->toptexture[6]) + || (msd->bottomtexture[0] == '#' && msd->bottomtexture[1] && msd->bottomtexture[2] && msd->bottomtexture[3] && msd->bottomtexture[4] && msd->bottomtexture[5] && msd->bottomtexture[6]) #endif - ) - { - sec->extra_colormap = R_CreateColormap(msd->toptexture, msd->midtexture, - msd->bottomtexture); - sd->toptexture = sd->bottomtexture = 0; - } - else - { - if ((num = R_CheckTextureNumForName(msd->toptexture)) == -1) - sd->toptexture = 0; - else - sd->toptexture = num; - if ((num = R_CheckTextureNumForName(msd->midtexture)) == -1) - sd->midtexture = 0; - else - sd->midtexture = num; - if ((num = R_CheckTextureNumForName(msd->bottomtexture)) == -1) - sd->bottomtexture = 0; - else - sd->bottomtexture = num; - } - break; + ) + { + sec->extra_colormap = R_CreateColormap(msd->toptexture, msd->midtexture, + msd->bottomtexture); + sd->toptexture = sd->bottomtexture = 0; } + else + { + if ((num = R_CheckTextureNumForName(msd->toptexture)) == -1) + sd->toptexture = 0; + else + sd->toptexture = num; + if ((num = R_CheckTextureNumForName(msd->midtexture)) == -1) + sd->midtexture = 0; + else + sd->midtexture = num; + if ((num = R_CheckTextureNumForName(msd->bottomtexture)) == -1) + sd->bottomtexture = 0; + else + sd->bottomtexture = num; + } + break; case 413: // Change music { From 7608583c6fbe134d6f9ef6677cd2d1b3c26c6cd5 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 16:42:07 -0400 Subject: [PATCH 029/132] Fix shared colormap matching --- src/r_data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_data.c b/src/r_data.c index eb5e27b0b..eef6434b0 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1591,7 +1591,7 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) for (exc = extra_colormaps; exc; exc = exc->next) { - if (exc->lump) + if (exc->lump != LUMPERROR) continue; if (maskcolor == exc->maskcolor && fadecolor == exc->fadecolor From 7e9297d06e0fbfe104b8749c44d7aa54fa11ce86 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 9 Sep 2018 12:01:50 -0400 Subject: [PATCH 030/132] Savegame netsync for sector colormaps; add spawn_midmap and co for comparison --- src/p_saveg.c | 74 ++++++++++++++++++++++++++++++++++++++------------- src/p_setup.c | 3 ++- src/p_spec.c | 2 +- src/r_defs.h | 3 +++ 4 files changed, 61 insertions(+), 21 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 22d43f358..1c9589e8f 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -487,10 +487,16 @@ static void P_NetUnArchivePlayers(void) #define SD_FYOFFS 0x02 #define SD_CXOFFS 0x04 #define SD_CYOFFS 0x08 -#define SD_TAG 0x10 -#define SD_FLOORANG 0x20 -#define SD_CEILANG 0x40 -#define SD_TAGLIST 0x80 +#define SD_FLOORANG 0x10 +#define SD_CEILANG 0x20 +#define SD_TAG 0x40 +#define SD_DIFF3 0x80 + +// diff3 flags +#define SD_TAGLIST 0x01 +#define SD_BOTTOMMAP 0x02 +#define SD_MIDMAP 0x04 +#define SD_TOPMAP 0x08 #define LD_FLAG 0x01 #define LD_SPECIAL 0x02 @@ -523,7 +529,7 @@ static void P_NetArchiveWorld(void) mapsidedef_t *msd; maplinedef_t *mld; const sector_t *ss = sectors; - UINT8 diff, diff2; + UINT8 diff, diff2, diff3; WRITEUINT32(save_p, ARCHIVEBLOCK_WORLD); put = save_p; @@ -550,7 +556,7 @@ static void P_NetArchiveWorld(void) for (i = 0; i < numsectors; i++, ss++, ms++) { - diff = diff2 = 0; + diff = diff2 = diff3 = 0; if (ss->floorheight != SHORT(ms->floorheight)<ceilingheight != SHORT(ms->ceilingheight)<tag != SHORT(ms->tag)) diff2 |= SD_TAG; if (ss->nexttag != ss->spawn_nexttag || ss->firsttag != ss->spawn_firsttag) - diff2 |= SD_TAGLIST; + diff3 |= SD_TAGLIST; + if (ss->bottommap != ss->spawn_bottommap) + diff3 |= SD_BOTTOMMAP; + if (ss->midmap != ss->spawn_midmap) + diff3 |= SD_MIDMAP; + if (ss->topmap != ss->spawn_topmap) + diff3 |= SD_TOPMAP; // Check if any of the sector's FOFs differ from how they spawned if (ss->ffloors) @@ -601,6 +613,9 @@ static void P_NetArchiveWorld(void) } } + if (diff3) + diff2 |= SD_DIFF3; + if (diff2) diff |= SD_DIFF2; @@ -612,6 +627,8 @@ static void P_NetArchiveWorld(void) WRITEUINT8(put, diff); if (diff & SD_DIFF2) WRITEUINT8(put, diff2); + if (diff2 & SD_DIFF3) + WRITEUINT8(put, diff3); if (diff & SD_FLOORHT) WRITEFIXED(put, ss->floorheight); if (diff & SD_CEILHT) @@ -632,17 +649,23 @@ static void P_NetArchiveWorld(void) WRITEFIXED(put, ss->ceiling_xoffs); if (diff2 & SD_CYOFFS) WRITEFIXED(put, ss->ceiling_yoffs); - if (diff2 & SD_TAG) // save only the tag - WRITEINT16(put, ss->tag); if (diff2 & SD_FLOORANG) WRITEANGLE(put, ss->floorpic_angle); if (diff2 & SD_CEILANG) WRITEANGLE(put, ss->ceilingpic_angle); - if (diff2 & SD_TAGLIST) // save both firsttag and nexttag + if (diff2 & SD_TAG) // save only the tag + WRITEINT16(put, ss->tag); + if (diff3 & SD_TAGLIST) // save both firsttag and nexttag { // either of these could be changed even if tag isn't WRITEINT32(put, ss->firsttag); WRITEINT32(put, ss->nexttag); } + if (diff3 & SD_BOTTOMMAP) + WRITEINT32(put, ss->bottommap); + if (diff3 & SD_MIDMAP) + WRITEINT32(put, ss->midmap); + if (diff3 & SD_TOPMAP) + WRITEINT32(put, ss->topmap); // Special case: save the stats of all modified ffloors along with their ffloor "number"s // we don't bother with ffloors that haven't changed, that would just add to savegame even more than is really needed @@ -680,7 +703,7 @@ static void P_NetArchiveWorld(void) // do lines for (i = 0; i < numlines; i++, mld++, li++) { - diff = diff2 = 0; + diff = diff2 = diff3 = 0; if (li->special != SHORT(mld->special)) diff |= LD_SPECIAL; @@ -772,7 +795,7 @@ static void P_NetUnArchiveWorld(void) line_t *li; side_t *si; UINT8 *get; - UINT8 diff, diff2; + UINT8 diff, diff2, diff3; if (READUINT32(save_p) != ARCHIVEBLOCK_WORLD) I_Error("Bad $$$.sav at archive block World"); @@ -794,6 +817,10 @@ static void P_NetUnArchiveWorld(void) diff2 = READUINT8(get); else diff2 = 0; + if (diff2 & SD_DIFF3) + diff3 = READUINT8(get); + else + diff3 = 0; if (diff & SD_FLOORHT) sectors[i].floorheight = READFIXED(get); @@ -822,17 +849,23 @@ static void P_NetUnArchiveWorld(void) sectors[i].ceiling_xoffs = READFIXED(get); if (diff2 & SD_CYOFFS) sectors[i].ceiling_yoffs = READFIXED(get); - if (diff2 & SD_TAG) - sectors[i].tag = READINT16(get); // DON'T use P_ChangeSectorTag - if (diff2 & SD_TAGLIST) - { - sectors[i].firsttag = READINT32(get); - sectors[i].nexttag = READINT32(get); - } if (diff2 & SD_FLOORANG) sectors[i].floorpic_angle = READANGLE(get); if (diff2 & SD_CEILANG) sectors[i].ceilingpic_angle = READANGLE(get); + if (diff2 & SD_TAG) + sectors[i].tag = READINT16(get); // DON'T use P_ChangeSectorTag + if (diff3 & SD_TAGLIST) + { + sectors[i].firsttag = READINT32(get); + sectors[i].nexttag = READINT32(get); + } + if (diff3 & SD_BOTTOMMAP) + sectors[i].bottommap = READINT32(get); + if (diff3 & SD_MIDMAP) + sectors[i].midmap = READINT32(get); + if (diff3 & SD_TOPMAP) + sectors[i].topmap = READINT32(get); if (diff & SD_FFLOORS) { @@ -891,6 +924,9 @@ static void P_NetUnArchiveWorld(void) diff2 = READUINT8(get); else diff2 = 0; + + diff3 = 0; + if (diff & LD_FLAG) li->flags = READINT16(get); if (diff & LD_SPECIAL) diff --git a/src/p_setup.c b/src/p_setup.c index 09ba553bf..b503b6a58 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -713,6 +713,7 @@ static void P_LoadRawSectors(UINT8 *data, size_t i) ss->moved = true; ss->extra_colormap = NULL; + ss->spawn_extra_colormap = NULL; ss->floor_xoffs = ss->ceiling_xoffs = ss->floor_yoffs = ss->ceiling_yoffs = 0; ss->spawn_flr_xoffs = ss->spawn_ceil_xoffs = ss->spawn_flr_yoffs = ss->spawn_ceil_yoffs = 0; @@ -1479,7 +1480,7 @@ static void P_LoadRawSideDefs2(void *data) #endif ) { - sec->extra_colormap = R_CreateColormap(msd->toptexture, msd->midtexture, + sec->extra_colormap = sec->spawn_extra_colormap = R_CreateColormap(msd->toptexture, msd->midtexture, msd->bottomtexture); sd->toptexture = sd->bottomtexture = 0; } diff --git a/src/p_spec.c b/src/p_spec.c index 698c8f4b1..5135676ab 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -6760,7 +6760,7 @@ void P_SpawnSpecials(INT32 fromnetsave) case 606: // HACK! Copy colormaps. Just plain colormaps. for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) - sectors[s].extra_colormap = lines[i].frontsector->extra_colormap; + sectors[s].extra_colormap = sectors[s].spawn_extra_colormap = lines[i].frontsector->extra_colormap; break; #ifdef ESLOPE // Slope copy specials. Handled here for sanity. diff --git a/src/r_defs.h b/src/r_defs.h index d8915cab8..e81631eb9 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -401,6 +401,9 @@ typedef struct sector_s // flag angles sector spawned with (via linedef type 7) angle_t spawn_flrpic_angle; angle_t spawn_ceilpic_angle; + + // colormap structure + extracolormap_t *spawn_extra_colormap; } sector_t; // From c92226890e002cee36d5b5700b59724a851ae445 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 09:03:58 -0400 Subject: [PATCH 031/132] Remove bottommap and topmap from savegame because unused --- src/p_saveg.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 1c9589e8f..42757faf2 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -494,9 +494,7 @@ static void P_NetUnArchivePlayers(void) // diff3 flags #define SD_TAGLIST 0x01 -#define SD_BOTTOMMAP 0x02 -#define SD_MIDMAP 0x04 -#define SD_TOPMAP 0x08 +#define SD_MIDMAP 0x02 #define LD_FLAG 0x01 #define LD_SPECIAL 0x02 @@ -591,12 +589,8 @@ static void P_NetArchiveWorld(void) diff2 |= SD_TAG; if (ss->nexttag != ss->spawn_nexttag || ss->firsttag != ss->spawn_firsttag) diff3 |= SD_TAGLIST; - if (ss->bottommap != ss->spawn_bottommap) - diff3 |= SD_BOTTOMMAP; if (ss->midmap != ss->spawn_midmap) diff3 |= SD_MIDMAP; - if (ss->topmap != ss->spawn_topmap) - diff3 |= SD_TOPMAP; // Check if any of the sector's FOFs differ from how they spawned if (ss->ffloors) @@ -660,12 +654,8 @@ static void P_NetArchiveWorld(void) WRITEINT32(put, ss->firsttag); WRITEINT32(put, ss->nexttag); } - if (diff3 & SD_BOTTOMMAP) - WRITEINT32(put, ss->bottommap); if (diff3 & SD_MIDMAP) WRITEINT32(put, ss->midmap); - if (diff3 & SD_TOPMAP) - WRITEINT32(put, ss->topmap); // Special case: save the stats of all modified ffloors along with their ffloor "number"s // we don't bother with ffloors that haven't changed, that would just add to savegame even more than is really needed @@ -860,12 +850,8 @@ static void P_NetUnArchiveWorld(void) sectors[i].firsttag = READINT32(get); sectors[i].nexttag = READINT32(get); } - if (diff3 & SD_BOTTOMMAP) - sectors[i].bottommap = READINT32(get); if (diff3 & SD_MIDMAP) sectors[i].midmap = READINT32(get); - if (diff3 & SD_TOPMAP) - sectors[i].topmap = READINT32(get); if (diff & SD_FFLOORS) { From 8d78c2219474f91b8741854e1ecb67e486dd63c4 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 20:36:34 -0400 Subject: [PATCH 032/132] extracolormap_t refinement and netsyncing * Store raw values per rgba in extracolormap_t (no maskcolor or fadecolor) * Crunched some UINT16/32 into UINT8 * Calculate mask values in R_CreateLightTable * ifdef out EXTRACOLORMAPLUMPS --- src/p_saveg.c | 116 +++++++++++++++++++++++++++++++++--- src/r_data.c | 160 ++++++++++++++++++++++++++++++++------------------ src/r_data.h | 11 +++- src/r_defs.h | 16 ++--- 4 files changed, 228 insertions(+), 75 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 42757faf2..68d00a42c 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -21,6 +21,7 @@ #include "p_local.h" #include "p_setup.h" #include "p_saveg.h" +#include "r_data.h" #include "r_things.h" #include "r_state.h" #include "w_wad.h" @@ -494,7 +495,7 @@ static void P_NetUnArchivePlayers(void) // diff3 flags #define SD_TAGLIST 0x01 -#define SD_MIDMAP 0x02 +#define SD_COLORMAP 0x02 #define LD_FLAG 0x01 #define LD_SPECIAL 0x02 @@ -589,8 +590,8 @@ static void P_NetArchiveWorld(void) diff2 |= SD_TAG; if (ss->nexttag != ss->spawn_nexttag || ss->firsttag != ss->spawn_firsttag) diff3 |= SD_TAGLIST; - if (ss->midmap != ss->spawn_midmap) - diff3 |= SD_MIDMAP; + if (ss->extra_colormap != ss->spawn_extra_colormap) + diff3 |= SD_COLORMAP; // Check if any of the sector's FOFs differ from how they spawned if (ss->ffloors) @@ -654,8 +655,30 @@ static void P_NetArchiveWorld(void) WRITEINT32(put, ss->firsttag); WRITEINT32(put, ss->nexttag); } - if (diff3 & SD_MIDMAP) - WRITEINT32(put, ss->midmap); + + if (diff3 & SD_COLORMAP) + { + WRITEUINT8(put, ss->extra_colormap->fadestart); + WRITEUINT8(put, ss->extra_colormap->fadeend); + WRITEUINT8(put, ss->extra_colormap->fadedist); + WRITEUINT8(put, (UINT8)ss->extra_colormap->fog); + + WRITEUINT8(put, ss->extra_colormap->cr); + WRITEUINT8(put, ss->extra_colormap->cg); + WRITEUINT8(put, ss->extra_colormap->cb); + WRITEUINT8(put, ss->extra_colormap->ca); + WRITEUINT8(put, ss->extra_colormap->cfr); + WRITEUINT8(put, ss->extra_colormap->cfg); + WRITEUINT8(put, ss->extra_colormap->cfb); + WRITEUINT8(put, ss->extra_colormap->cfa); + + WRITEINT32(put, ss->extra_colormap->rgba); + WRITEINT32(put, ss->extra_colormap->fadergba); + +#ifdef EXTRACOLORMAPLUMPS + WRITESTRINGN(put, ss->extra_colormap->lumpname, 9); +#endif + } // Special case: save the stats of all modified ffloors along with their ffloor "number"s // we don't bother with ffloors that haven't changed, that would just add to savegame even more than is really needed @@ -850,8 +873,87 @@ static void P_NetUnArchiveWorld(void) sectors[i].firsttag = READINT32(get); sectors[i].nexttag = READINT32(get); } - if (diff3 & SD_MIDMAP) - sectors[i].midmap = READINT32(get); + + if (diff3 & SD_COLORMAP) + { + extracolormap_t *exc; + + UINT8 fadestart = READUINT8(get), + fadeend = READUINT8(get), + fadedist = READUINT8(get); + + boolean fog = (boolean)READUINT8(get); + + UINT8 cr = READUINT8(get), + cg = READUINT8(get), + cb = READUINT8(get), + ca = READUINT8(get), + cfr = READUINT8(get), + cfg = READUINT8(get), + cfb = READUINT8(get), + cfa = READUINT8(get); + + INT32 rgba = READINT32(get), + fadergba = READINT32(get); + +#ifdef EXTRACOLORMAPLUMPS + char lumpname[9]; + READSTRINGN(get, lumpname, 9); + + if (lumpname[0]) + sectors[i].extra_colormap = R_ColormapForName(lumpname); + else + { +#endif + + for (exc = extra_colormaps; exc; exc = exc->next) + { +#ifdef EXTRACOLORMAPLUMPS + if (exc->lump != LUMPERROR) + continue; +#endif + if (cr == exc->cr && cg == exc->cg && cb == exc->cb && ca == exc->ca + && cfr == exc->cfr && cfg == exc->cfg && cfb == exc->cfb && cfa == exc->cfa + && fadestart == exc->fadestart + && fadeend == exc->fadeend + && fog == exc->fog) + break; + } + + if (!exc) + { + exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL); + + exc->fadestart = fadestart; + exc->fadeend = fadeend; + exc->fadedist = fadedist; + exc->fog = fog; + + exc->cr = cr; + exc->cg = cg; + exc->cb = cb; + exc->ca = ca; + exc->cfr = cfr; + exc->cfg = cfg; + exc->cfb = cfb; + exc->cfa = cfa; + + exc->rgba = rgba; + exc->fadergba = fadergba; + + exc->colormap = R_CreateLightTable(exc); + + R_AddColormapToList(exc); + + sectors[i].extra_colormap = exc; + +#ifdef EXTRACOLORMAPLUMPS + exc->lump = LUMPERROR; + exc->lumpname[0] = 0; + } // if (!exc) // if (!lumpname[0] || !R_ColormapForName(lumpname)) +#endif + } + } if (diff & SD_FFLOORS) { diff --git a/src/r_data.c b/src/r_data.c index eef6434b0..32cf17fa9 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1160,6 +1160,7 @@ static inline lumpnum_t R_CheckNumForNameList(const char *name, lumplist_t *list return LUMPERROR; } +#ifdef EXTRACOLORMAPLUMPS static lumplist_t *colormaplumps = NULL; ///\todo free leak static size_t numcolormaplumps = 0; @@ -1195,6 +1196,7 @@ static void R_InitExtraColormaps(void) } CONS_Printf(M_GetText("Number of Extra Colormaps: %s\n"), sizeu1(numcolormaplumps)); } +#endif // Search for flat name through all lumpnum_t R_GetFlatNumForName(const char *name) @@ -1291,7 +1293,9 @@ static void R_InitColormaps(void) // Init Boom colormaps. R_ClearColormaps(); +#ifdef EXTRACOLORMAPLUMPS R_InitExtraColormaps(); +#endif } void R_ReInitColormaps(UINT16 num) @@ -1354,6 +1358,7 @@ void R_AddColormapToList(extracolormap_t *extra_colormap) extra_colormap->next = 0; } +#ifdef EXTRACOLORMAPLUMPS extracolormap_t *R_ColormapForName(char *name) { lumpnum_t lump; @@ -1370,6 +1375,8 @@ extracolormap_t *R_ColormapForName(char *name) exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL); exc->lump = lump; + strncpy(exc->lumpname, name, 9); + exc->lumpname[8] = 0; // aligned on 8 bit for asm code exc->colormap = Z_MallocAlign(W_LumpLength(lump), PU_LEVEL, NULL, 16); @@ -1377,15 +1384,21 @@ extracolormap_t *R_ColormapForName(char *name) // We set all params of the colormap to normal because there // is no real way to tell how GL should handle a colormap lump anyway.. - exc->maskcolor = 0xffff; - exc->fadecolor = 0x0; - exc->maskamt = 0x0; + exc->cr = exc->cg = exc->cb = 0xff; + exc->ca = 0; + exc->cfr = exc->cfg = exc->cfb = 0; + exc->cfa = 18; exc->fadestart = 0; exc->fadeend = 31; exc->fog = 0; + exc->rgba = 0; + exc->fadergba = 0x19000000; + + R_AddColormapToList(exc); return exc; } +#endif // // R_CreateColormap @@ -1402,21 +1415,58 @@ static int RoundUp(double number); lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap) { + double cmaskr, cmaskg, cmaskb, cdestr, cdestg, cdestb; + double maskamt = 0, othermask = 0; + + UINT8 cr = extra_colormap->cr, + cg = extra_colormap->cg, + cb = extra_colormap->cb, + ca = extra_colormap->ca, + cfr = extra_colormap->cfr, + cfg = extra_colormap->cfg, + cfb = extra_colormap->cfb; +// cfa = extra_colormap->cfa; // unused in software + UINT32 fadestart = (UINT16)extra_colormap->fadestart, fadedist = extra_colormap->fadedist; - double othermask = extra_colormap->othermask, - cmaskr = extra_colormap->cmaskr, - cmaskg = extra_colormap->cmaskg, - cmaskb = extra_colormap->cmaskb, - cdestr = extra_colormap->cdestr, - cdestg = extra_colormap->cdestg, - cdestb = extra_colormap->cdestb; - lighttable_t *lighttable = NULL; size_t i; + ///////////////////// + // Calc the RGBA mask + ///////////////////// + cmaskr = cr; + cmaskg = cg; + cmaskb = cb; + + maskamt = (double)(ca/24.0l); + othermask = 1 - maskamt; + maskamt /= 0xff; + + cmaskr *= maskamt; + cmaskg *= maskamt; + cmaskb *= maskamt; + + ///////////////////// + // Calc the RGBA fade mask + ///////////////////// + cdestr = cfr; + cdestg = cfg; + cdestb = cfb; + + // fade alpha unused in software + // maskamt = (double)(cfa/24.0l); + // othermask = 1 - maskamt; + // maskamt /= 0xff; + + // cdestr *= maskamt; + // cdestg *= maskamt; + // cdestb *= maskamt; + + ///////////////////// // This code creates the colormap array used by software renderer + ///////////////////// if (rendermode == render_soft) { double r, g, b, cbrightness; @@ -1494,12 +1544,10 @@ lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap) extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) { - double cmaskr, cmaskg, cmaskb, cdestr, cdestg, cdestb; - double maskamt = 0, othermask = 0; - int mask, fog = 0; + boolean fog = false; extracolormap_t *extra_colormap, *exc; - UINT32 cr, cg, cb, maskcolor, fadecolor; + UINT8 cr, cg, cb, ca, cfr, cfg, cfb, cfa; UINT32 fadestart = 0, fadeend = 31, fadedist = 31; INT32 rgba, fadergba; @@ -1509,27 +1557,15 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) if (p1[0] == '#') { cr = ((HEX2INT(p1[1]) * 16) + HEX2INT(p1[2])); - cmaskr = cr; cg = ((HEX2INT(p1[3]) * 16) + HEX2INT(p1[4])); - cmaskg = cg; cb = ((HEX2INT(p1[5]) * 16) + HEX2INT(p1[6])); - cmaskb = cb; - // Create a rough approximation of the color (a 16 bit color) - maskcolor = ((cb) >> 3) + (((cg) >> 2) << 5) + (((cr) >> 3) << 11); + if (p1[7] >= 'a' && p1[7] <= 'z') - mask = (p1[7] - 'a'); + ca = (p1[7] - 'a'); else if (p1[7] >= 'A' && p1[7] <= 'Z') - mask = (p1[7] - 'A'); + ca = (p1[7] - 'A'); else - mask = 24; - - maskamt = (double)(mask/24.0l); - - othermask = 1 - maskamt; - maskamt /= 0xff; - cmaskr *= maskamt; - cmaskg *= maskamt; - cmaskb *= maskamt; + ca = 24; // for opengl; generate on software too for netsync rgba = (HEX2INT(p1[1]) << 4) + (HEX2INT(p1[2]) << 0) + @@ -1543,9 +1579,8 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) } else { - cmaskr = cmaskg = cmaskb = 0xff; - maskamt = 0; - maskcolor = ((0xff) >> 3) + (((0xff) >> 2) << 5) + (((0xff) >> 3) << 11); + cr = cg = cb = 0xff; + ca = 0; rgba = 0; } @@ -1560,16 +1595,22 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) if (fadeend > 31 || fadeend < 1) fadeend = 31; fadedist = fadeend - fadestart; - fog = NUMFROMCHAR(p2[1]); + fog = (boolean)NUMFROMCHAR(p2[1]); } #undef NUMFROMCHAR if (p3[0] == '#') { - cdestr = cr = ((HEX2INT(p3[1]) * 16) + HEX2INT(p3[2])); - cdestg = cg = ((HEX2INT(p3[3]) * 16) + HEX2INT(p3[4])); - cdestb = cb = ((HEX2INT(p3[5]) * 16) + HEX2INT(p3[6])); - fadecolor = (((cb) >> 3) + (((cg) >> 2) << 5) + (((cr) >> 3) << 11)); + cfr = ((HEX2INT(p3[1]) * 16) + HEX2INT(p3[2])); + cfg = ((HEX2INT(p3[3]) * 16) + HEX2INT(p3[4])); + cfb = ((HEX2INT(p3[5]) * 16) + HEX2INT(p3[6])); + + if (p1[7] >= 'a' && p1[7] <= 'z') + cfa = (p1[7] - 'a'); + else if (p1[7] >= 'A' && p1[7] <= 'Z') + cfa = (p1[7] - 'A'); + else + cfa = 18; // for opengl; generate on software too for netsync fadergba = (HEX2INT(p3[1]) << 4) + (HEX2INT(p3[2]) << 0) + @@ -1583,7 +1624,8 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) } else { - cdestr = cdestg = cdestb = fadecolor = 0; + cfr = cfg = cfb = 0; + cfa = 18; fadergba = 0x19000000; // default alpha for fade, (25 << 24) } #undef ALPHA2INT @@ -1591,40 +1633,41 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) for (exc = extra_colormaps; exc; exc = exc->next) { +#ifdef EXTRACOLORMAPLUMPS if (exc->lump != LUMPERROR) continue; - if (maskcolor == exc->maskcolor - && fadecolor == exc->fadecolor - && (float)maskamt == (float)exc->maskamt +#endif + if (cr == exc->cr && cg == exc->cg && cb == exc->cb && ca == exc->ca + && cfr == exc->cfr && cfg == exc->cfg && cfb == exc->cfb && cfa == exc->cfa && fadestart == exc->fadestart && fadeend == exc->fadeend && fog == exc->fog) - return exc; + break; } extra_colormap = Z_Calloc(sizeof (*extra_colormap), PU_LEVEL, NULL); - extra_colormap->maskcolor = (UINT16)maskcolor; - extra_colormap->fadecolor = (UINT16)fadecolor; - extra_colormap->maskamt = maskamt; - extra_colormap->othermask = othermask; extra_colormap->fadestart = (UINT16)fadestart; extra_colormap->fadeend = (UINT16)fadeend; extra_colormap->fadedist = fadedist; extra_colormap->fog = fog; - extra_colormap->cmaskr = cmaskr; - extra_colormap->cmaskg = cmaskg; - extra_colormap->cmaskb = cmaskb; - extra_colormap->cdestr = cdestr; - extra_colormap->cdestg = cdestg; - extra_colormap->cdestb = cdestb; + extra_colormap->cr = cr; + extra_colormap->cg = cg; + extra_colormap->cb = cb; + extra_colormap->ca = ca; + extra_colormap->cfr = cfr; + extra_colormap->cfg = cfg; + extra_colormap->cfb = cfb; + extra_colormap->cfa = cfa; extra_colormap->rgba = rgba; extra_colormap->fadergba = fadergba; +#ifdef EXTRACOLORMAPLUMPS extra_colormap->lump = LUMPERROR; - extra_colormap->next = extra_colormap->prev = NULL; + extra_colormap->lumpname[0] = 0; +#endif extra_colormap->colormap = R_CreateLightTable(extra_colormap); @@ -1673,7 +1716,8 @@ static int RoundUp(double number) return (int)number; } -const char *R_ColormapNameForColormap(extracolormap_t *extra_colormap) +#ifdef EXTRACOLORMAPLUMPS +const char *R_NameForColormap(extracolormap_t *extra_colormap) { if (!extra_colormap) return "NONE"; @@ -1681,9 +1725,9 @@ const char *R_ColormapNameForColormap(extracolormap_t *extra_colormap) if (extra_colormap->lump == LUMPERROR) return "INLEVEL"; - return W_CheckNameForNum(extra_colormap->lump); + return extra_colormap->lumpname; } - +#endif // // build a table for quick conversion from 8bpp to 15bpp diff --git a/src/r_data.h b/src/r_data.h index db2749834..5600d36dc 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -96,12 +96,19 @@ void R_ClearTextureNumCache(boolean btell); INT32 R_TextureNumForName(const char *name); INT32 R_CheckTextureNumForName(const char *name); +// Extra Colormap lumps (C_START/C_END) are not used anywhere +// Uncomment to enable +//#define EXTRACOLORMAPLUMPS + void R_ReInitColormaps(UINT16 num); void R_ClearColormaps(void); -extracolormap_t *R_ColormapForName(char *name); +void R_AddColormapToList(extracolormap_t *extra_colormap); lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap); extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3); -const char *R_ColormapNameForNum(INT32 num); +#ifdef EXTRACOLORMAPLUMPS +extracolormap_t *R_ColormapForName(char *name); +const char *R_NameForColormap(extracolormap_t *extra_colormap); +#endif extern INT32 numtextures; diff --git a/src/r_defs.h b/src/r_defs.h index e81631eb9..8dd34cd15 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -52,15 +52,12 @@ typedef UINT8 lighttable_t; // ExtraColormap type. Use for extra_colormaps from now on. typedef struct extracolormap_s { - UINT16 maskcolor, fadecolor; - double maskamt, othermask; - UINT16 fadestart, fadeend; - UINT32 fadedist; - INT32 fog; + UINT8 fadestart, fadeend; + UINT8 fadedist; + boolean fog; - // mask rgb for colormap table generation - double cmaskr, cmaskg, cmaskb; - double cdestr, cdestg, cdestb; + // rgba for colormap table generation + UINT8 cr, cg, cb, ca, cfr, cfg, cfb, cfa; // rgba is used in hw mode for colored sector lighting INT32 rgba; // similar to maskcolor in sw mode @@ -68,7 +65,10 @@ typedef struct extracolormap_s lighttable_t *colormap; +#ifdef EXTRACOLORMAPLUMPS lumpnum_t lump; // for colormap lump matching, init to LUMPERROR + char lumpname[9]; // for netsyncing +#endif struct extracolormap_s *next; struct extracolormap_s *prev; From 1e4f5e8d45db305297c3f23088b8eec91d4d6274 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 20:41:12 -0400 Subject: [PATCH 033/132] Remove MAXCOLORMAPS --- src/r_state.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/r_state.h b/src/r_state.h index effa4e36c..91c2092e9 100644 --- a/src/r_state.h +++ b/src/r_state.h @@ -40,9 +40,6 @@ extern sprcache_t *spritecachedinfo; extern lighttable_t *colormaps; // Boom colormaps. -// Had to put a limit on colormaps :( -#define MAXCOLORMAPS 60 - extern extracolormap_t *extra_colormaps; // for global animation From 3da38f2a9be36ab980a61fae3a0b18dc58a7d1c0 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 20:52:37 -0400 Subject: [PATCH 034/132] Fixed colormap matching code again * Added debug messages for matching code --- src/p_saveg.c | 26 ++++++++++++++++++++++++++ src/r_data.c | 15 ++++++++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 68d00a42c..137b4ffd0 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -877,6 +877,7 @@ static void P_NetUnArchiveWorld(void) if (diff3 & SD_COLORMAP) { extracolormap_t *exc; + size_t dbg_i = 0; UINT8 fadestart = READUINT8(get), fadeend = READUINT8(get), @@ -920,8 +921,33 @@ static void P_NetUnArchiveWorld(void) break; } + for (exc = extra_colormaps; exc; exc = exc->next) + { +#ifdef EXTRACOLORMAPLUMPS + if (exc->lump != LUMPERROR) + { + dbg_i++; + continue; + } +#endif + if (cr == exc->cr && cg == exc->cg && cb == exc->cb && ca == exc->ca + && cfr == exc->cfr && cfg == exc->cfg && cfb == exc->cfb && cfa == exc->cfa + && fadestart == exc->fadestart + && fadeend == exc->fadeend + && fog == exc->fog) + { + CONS_Debug(DBG_RENDER, "P_NetUnArchiveWorld: Found map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", + dbg_i, cr, cg, cb, ca, cfr, cfg, cfb, cfa); + break; + } + dbg_i++; + } + if (!exc) { + CONS_Debug(DBG_RENDER, "P_NetUnArchiveWorld: Creating map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", + dbg_i, cr, cg, cb, ca, cfr, cfg, cfb, cfa); + exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL); exc->fadestart = fadestart; diff --git a/src/r_data.c b/src/r_data.c index 32cf17fa9..e51eb32e9 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1552,6 +1552,8 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) INT32 rgba, fadergba; + size_t dbg_i = 0; + #define HEX2INT(x) (UINT32)(x >= '0' && x <= '9' ? x - '0' : x >= 'a' && x <= 'f' ? x - 'a' + 10 : x >= 'A' && x <= 'F' ? x - 'A' + 10 : 0) #define ALPHA2INT(x) (x >= 'a' && x <= 'z' ? x - 'a' : x >= 'A' && x <= 'Z' ? x - 'A' : x >= '0' && x <= '9' ? 25 : 0) if (p1[0] == '#') @@ -1635,16 +1637,27 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) { #ifdef EXTRACOLORMAPLUMPS if (exc->lump != LUMPERROR) + { + dbg_i++; continue; + } #endif if (cr == exc->cr && cg == exc->cg && cb == exc->cb && ca == exc->ca && cfr == exc->cfr && cfg == exc->cfg && cfb == exc->cfb && cfa == exc->cfa && fadestart == exc->fadestart && fadeend == exc->fadeend && fog == exc->fog) - break; + { + CONS_Debug(DBG_RENDER, "R_CreateColormap: Found map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", + dbg_i, cr, cg, cb, ca, cfr, cfg, cfb, cfa); + return exc; + } + dbg_i++; } + CONS_Debug(DBG_RENDER, "R_CreateColormap: Creating map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", + dbg_i, cr, cg, cb, ca, cfr, cfg, cfb, cfa); + extra_colormap = Z_Calloc(sizeof (*extra_colormap), PU_LEVEL, NULL); extra_colormap->fadestart = (UINT16)fadestart; From c007dfacecb8b392e2c063f1f73373d78a29322b Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 21:12:56 -0400 Subject: [PATCH 035/132] Savegame fixes --- src/p_saveg.c | 18 +++++++++--------- src/r_defs.h | 1 - 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index eb49e9730..33923551d 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -655,8 +655,6 @@ static void P_NetArchiveWorld(void) WRITEINT32(put, ss->firsttag); WRITEINT32(put, ss->nexttag); } - if (diff3 & SD_MIDMAP) - WRITEINT32(put, ss->midmap); if (diff3 & SD_COLORMAP) { @@ -938,8 +936,8 @@ static void P_NetUnArchiveWorld(void) && fadeend == exc->fadeend && fog == exc->fog) { - CONS_Debug(DBG_RENDER, "P_NetUnArchiveWorld: Found map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", - dbg_i, cr, cg, cb, ca, cfr, cfg, cfb, cfa); + // CONS_Debug(DBG_RENDER, "P_NetUnArchiveWorld: Found map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", + // dbg_i, cr, cg, cb, ca, cfr, cfg, cfb, cfa); break; } dbg_i++; @@ -947,8 +945,8 @@ static void P_NetUnArchiveWorld(void) if (!exc) { - CONS_Debug(DBG_RENDER, "P_NetUnArchiveWorld: Creating map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", - dbg_i, cr, cg, cb, ca, cfr, cfg, cfb, cfa); + // CONS_Debug(DBG_RENDER, "P_NetUnArchiveWorld: Creating map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", + // dbg_i, cr, cg, cb, ca, cfr, cfg, cfb, cfa); exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL); @@ -973,14 +971,16 @@ static void P_NetUnArchiveWorld(void) R_AddColormapToList(exc); - sectors[i].extra_colormap = exc; - #ifdef EXTRACOLORMAPLUMPS exc->lump = LUMPERROR; exc->lumpname[0] = 0; - } // if (!exc) // if (!lumpname[0] || !R_ColormapForName(lumpname)) #endif } + + sectors[i].extra_colormap = exc; +#ifdef EXTRACOLORMAPLUMPS + } +#endif } if (diff & SD_FFLOORS) diff --git a/src/r_defs.h b/src/r_defs.h index 77b56bd30..8dd34cd15 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -393,7 +393,6 @@ typedef struct sector_s // these are saved for netgames, so do not let Lua touch these! INT32 spawn_nexttag, spawn_firsttag; // the actual nexttag/firsttag values may differ if the sector's tag was changed - INT32 spawn_bottommap, spawn_midmap, spawn_topmap; // offsets sector spawned with (via linedef type 7) fixed_t spawn_flr_xoffs, spawn_flr_yoffs; From 22746c1d9140446edc1bac8b0a9358b273a43fd7 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 21:12:56 -0400 Subject: [PATCH 036/132] Savegame fixes --- src/p_saveg.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 137b4ffd0..66db8a383 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -877,7 +877,7 @@ static void P_NetUnArchiveWorld(void) if (diff3 & SD_COLORMAP) { extracolormap_t *exc; - size_t dbg_i = 0; + //size_t dbg_i = 0; UINT8 fadestart = READUINT8(get), fadeend = READUINT8(get), @@ -926,7 +926,7 @@ static void P_NetUnArchiveWorld(void) #ifdef EXTRACOLORMAPLUMPS if (exc->lump != LUMPERROR) { - dbg_i++; + //dbg_i++; continue; } #endif @@ -936,17 +936,17 @@ static void P_NetUnArchiveWorld(void) && fadeend == exc->fadeend && fog == exc->fog) { - CONS_Debug(DBG_RENDER, "P_NetUnArchiveWorld: Found map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", - dbg_i, cr, cg, cb, ca, cfr, cfg, cfb, cfa); + // CONS_Debug(DBG_RENDER, "P_NetUnArchiveWorld: Found map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", + // dbg_i, cr, cg, cb, ca, cfr, cfg, cfb, cfa); break; } - dbg_i++; + //dbg_i++; } if (!exc) { - CONS_Debug(DBG_RENDER, "P_NetUnArchiveWorld: Creating map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", - dbg_i, cr, cg, cb, ca, cfr, cfg, cfb, cfa); + // CONS_Debug(DBG_RENDER, "P_NetUnArchiveWorld: Creating map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", + // dbg_i, cr, cg, cb, ca, cfr, cfg, cfb, cfa); exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL); @@ -971,14 +971,16 @@ static void P_NetUnArchiveWorld(void) R_AddColormapToList(exc); - sectors[i].extra_colormap = exc; - #ifdef EXTRACOLORMAPLUMPS exc->lump = LUMPERROR; exc->lumpname[0] = 0; - } // if (!exc) // if (!lumpname[0] || !R_ColormapForName(lumpname)) #endif } + + sectors[i].extra_colormap = exc; +#ifdef EXTRACOLORMAPLUMPS + } +#endif } if (diff & SD_FFLOORS) From 53b92a16011a2e235c9f158c321886017956b080 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 21:56:09 -0400 Subject: [PATCH 037/132] Make default extracolormap on init * Calc fadedist in R_CreateLightTable --- src/p_saveg.c | 5 +---- src/r_data.c | 28 ++++++++++++++++++++++------ src/r_defs.h | 1 - 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 66db8a383..7ee41dffd 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -660,7 +660,6 @@ static void P_NetArchiveWorld(void) { WRITEUINT8(put, ss->extra_colormap->fadestart); WRITEUINT8(put, ss->extra_colormap->fadeend); - WRITEUINT8(put, ss->extra_colormap->fadedist); WRITEUINT8(put, (UINT8)ss->extra_colormap->fog); WRITEUINT8(put, ss->extra_colormap->cr); @@ -880,8 +879,7 @@ static void P_NetUnArchiveWorld(void) //size_t dbg_i = 0; UINT8 fadestart = READUINT8(get), - fadeend = READUINT8(get), - fadedist = READUINT8(get); + fadeend = READUINT8(get); boolean fog = (boolean)READUINT8(get); @@ -952,7 +950,6 @@ static void P_NetUnArchiveWorld(void) exc->fadestart = fadestart; exc->fadeend = fadeend; - exc->fadedist = fadedist; exc->fog = fog; exc->cr = cr; diff --git a/src/r_data.c b/src/r_data.c index e51eb32e9..f1f04b2d2 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1330,7 +1330,25 @@ void R_ClearColormaps(void) memset(exc, 0, sizeof(*exc)); } - extra_colormaps = NULL; + // make a default extra_colormap + exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL); + exc->cr = exc->cg = exc->cb = 0xff; + exc->ca = 0; + exc->cfr = exc->cfg = exc->cfb = 0; + exc->cfa = 18; + exc->fadestart = 0; + exc->fadeend = 31; + exc->fog = 0; + exc->rgba = 0; + exc->fadergba = 0x19000000; + exc->colormap = R_CreateLightTable(exc); +#ifdef EXTRACOLORMAPLUMPS + exc->lump = LUMPERROR; + exc->lumpname[0] = 0; +#endif + exc->next = exc->prev = NULL; + + extra_colormaps = exc; } // @@ -1427,8 +1445,8 @@ lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap) cfb = extra_colormap->cfb; // cfa = extra_colormap->cfa; // unused in software - UINT32 fadestart = (UINT16)extra_colormap->fadestart, - fadedist = extra_colormap->fadedist; + UINT8 fadestart = extra_colormap->fadestart, + fadedist = extra_colormap->fadeend - extra_colormap->fadestart; lighttable_t *lighttable = NULL; size_t i; @@ -1548,7 +1566,7 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) extracolormap_t *extra_colormap, *exc; UINT8 cr, cg, cb, ca, cfr, cfg, cfb, cfa; - UINT32 fadestart = 0, fadeend = 31, fadedist = 31; + UINT32 fadestart = 0, fadeend = 31; INT32 rgba, fadergba; @@ -1596,7 +1614,6 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) fadestart = 0; if (fadeend > 31 || fadeend < 1) fadeend = 31; - fadedist = fadeend - fadestart; fog = (boolean)NUMFROMCHAR(p2[1]); } #undef NUMFROMCHAR @@ -1662,7 +1679,6 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) extra_colormap->fadestart = (UINT16)fadestart; extra_colormap->fadeend = (UINT16)fadeend; - extra_colormap->fadedist = fadedist; extra_colormap->fog = fog; extra_colormap->cr = cr; diff --git a/src/r_defs.h b/src/r_defs.h index 8dd34cd15..22d4fdf14 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -53,7 +53,6 @@ typedef UINT8 lighttable_t; typedef struct extracolormap_s { UINT8 fadestart, fadeend; - UINT8 fadedist; boolean fog; // rgba for colormap table generation From 43ae25c4fd3b0e912e6ff433701aaa0c19f35224 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 21:56:09 -0400 Subject: [PATCH 038/132] Make default extracolormap on init * Calc fadedist in R_CreateLightTable --- src/p_saveg.c | 5 +---- src/r_data.c | 28 ++++++++++++++++++++++------ src/r_defs.h | 1 - 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 66db8a383..7ee41dffd 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -660,7 +660,6 @@ static void P_NetArchiveWorld(void) { WRITEUINT8(put, ss->extra_colormap->fadestart); WRITEUINT8(put, ss->extra_colormap->fadeend); - WRITEUINT8(put, ss->extra_colormap->fadedist); WRITEUINT8(put, (UINT8)ss->extra_colormap->fog); WRITEUINT8(put, ss->extra_colormap->cr); @@ -880,8 +879,7 @@ static void P_NetUnArchiveWorld(void) //size_t dbg_i = 0; UINT8 fadestart = READUINT8(get), - fadeend = READUINT8(get), - fadedist = READUINT8(get); + fadeend = READUINT8(get); boolean fog = (boolean)READUINT8(get); @@ -952,7 +950,6 @@ static void P_NetUnArchiveWorld(void) exc->fadestart = fadestart; exc->fadeend = fadeend; - exc->fadedist = fadedist; exc->fog = fog; exc->cr = cr; diff --git a/src/r_data.c b/src/r_data.c index e51eb32e9..f1f04b2d2 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1330,7 +1330,25 @@ void R_ClearColormaps(void) memset(exc, 0, sizeof(*exc)); } - extra_colormaps = NULL; + // make a default extra_colormap + exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL); + exc->cr = exc->cg = exc->cb = 0xff; + exc->ca = 0; + exc->cfr = exc->cfg = exc->cfb = 0; + exc->cfa = 18; + exc->fadestart = 0; + exc->fadeend = 31; + exc->fog = 0; + exc->rgba = 0; + exc->fadergba = 0x19000000; + exc->colormap = R_CreateLightTable(exc); +#ifdef EXTRACOLORMAPLUMPS + exc->lump = LUMPERROR; + exc->lumpname[0] = 0; +#endif + exc->next = exc->prev = NULL; + + extra_colormaps = exc; } // @@ -1427,8 +1445,8 @@ lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap) cfb = extra_colormap->cfb; // cfa = extra_colormap->cfa; // unused in software - UINT32 fadestart = (UINT16)extra_colormap->fadestart, - fadedist = extra_colormap->fadedist; + UINT8 fadestart = extra_colormap->fadestart, + fadedist = extra_colormap->fadeend - extra_colormap->fadestart; lighttable_t *lighttable = NULL; size_t i; @@ -1548,7 +1566,7 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) extracolormap_t *extra_colormap, *exc; UINT8 cr, cg, cb, ca, cfr, cfg, cfb, cfa; - UINT32 fadestart = 0, fadeend = 31, fadedist = 31; + UINT32 fadestart = 0, fadeend = 31; INT32 rgba, fadergba; @@ -1596,7 +1614,6 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) fadestart = 0; if (fadeend > 31 || fadeend < 1) fadeend = 31; - fadedist = fadeend - fadestart; fog = (boolean)NUMFROMCHAR(p2[1]); } #undef NUMFROMCHAR @@ -1662,7 +1679,6 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) extra_colormap->fadestart = (UINT16)fadestart; extra_colormap->fadeend = (UINT16)fadeend; - extra_colormap->fadedist = fadedist; extra_colormap->fog = fog; extra_colormap->cr = cr; diff --git a/src/r_defs.h b/src/r_defs.h index 8dd34cd15..22d4fdf14 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -53,7 +53,6 @@ typedef UINT8 lighttable_t; typedef struct extracolormap_s { UINT8 fadestart, fadeend; - UINT8 fadedist; boolean fog; // rgba for colormap table generation From 9038ba4d9c941d4ae0d06c418d115cbb7b3ffe75 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 22:35:03 -0400 Subject: [PATCH 039/132] Add COLORMAPREVERSELIST ifdef to toggle Newest -> Oldest extra_colormaps order --- src/r_data.c | 7 +++++++ src/r_data.h | 3 +++ 2 files changed, 10 insertions(+) diff --git a/src/r_data.c b/src/r_data.c index f1f04b2d2..160539437 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1369,11 +1369,18 @@ void R_AddColormapToList(extracolormap_t *extra_colormap) return; } +#ifdef COLORMAPREVERSELIST + extra_colormaps->prev = extra_colormap; + extra_colormap->next = extra_colormaps; + extra_colormaps = extra_colormap; + extra_colormap->prev = 0; +#else for (exc = extra_colormaps; exc->next; exc = exc->next); exc->next = extra_colormap; extra_colormap->prev = exc; extra_colormap->next = 0; +#endif } #ifdef EXTRACOLORMAPLUMPS diff --git a/src/r_data.h b/src/r_data.h index 5600d36dc..e6eec41b4 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -100,6 +100,9 @@ INT32 R_CheckTextureNumForName(const char *name); // Uncomment to enable //#define EXTRACOLORMAPLUMPS +// Uncomment to make extra_colormaps order Newest -> Oldest +//#define COLORMAPREVERSELIST + void R_ReInitColormaps(UINT16 num); void R_ClearColormaps(void); void R_AddColormapToList(extracolormap_t *extra_colormap); From 17e101a24b81f8baaa8382b4ae26f28842330d2f Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 22:35:03 -0400 Subject: [PATCH 040/132] Add COLORMAPREVERSELIST ifdef to toggle Newest -> Oldest extra_colormaps order --- src/r_data.c | 7 +++++++ src/r_data.h | 3 +++ 2 files changed, 10 insertions(+) diff --git a/src/r_data.c b/src/r_data.c index f1f04b2d2..160539437 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1369,11 +1369,18 @@ void R_AddColormapToList(extracolormap_t *extra_colormap) return; } +#ifdef COLORMAPREVERSELIST + extra_colormaps->prev = extra_colormap; + extra_colormap->next = extra_colormaps; + extra_colormaps = extra_colormap; + extra_colormap->prev = 0; +#else for (exc = extra_colormaps; exc->next; exc = exc->next); exc->next = extra_colormap; extra_colormap->prev = exc; extra_colormap->next = 0; +#endif } #ifdef EXTRACOLORMAPLUMPS diff --git a/src/r_data.h b/src/r_data.h index 5600d36dc..e6eec41b4 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -100,6 +100,9 @@ INT32 R_CheckTextureNumForName(const char *name); // Uncomment to enable //#define EXTRACOLORMAPLUMPS +// Uncomment to make extra_colormaps order Newest -> Oldest +//#define COLORMAPREVERSELIST + void R_ReInitColormaps(UINT16 num); void R_ClearColormaps(void); void R_AddColormapToList(extracolormap_t *extra_colormap); From b7a216c78b6121642a9a9dafc501cfe565ac2ca3 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 10 Sep 2018 22:35:03 -0400 Subject: [PATCH 041/132] Add COLORMAPREVERSELIST ifdef to toggle Newest -> Oldest extra_colormaps order --- src/r_data.c | 9 +++++++++ src/r_data.h | 3 +++ 2 files changed, 12 insertions(+) diff --git a/src/r_data.c b/src/r_data.c index f1f04b2d2..ffc6cc7fd 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1359,7 +1359,9 @@ void R_ClearColormaps(void) // void R_AddColormapToList(extracolormap_t *extra_colormap) { +#ifndef COLORMAPREVERSELIST extracolormap_t *exc; +#endif if (!extra_colormaps) { @@ -1369,11 +1371,18 @@ void R_AddColormapToList(extracolormap_t *extra_colormap) return; } +#ifdef COLORMAPREVERSELIST + extra_colormaps->prev = extra_colormap; + extra_colormap->next = extra_colormaps; + extra_colormaps = extra_colormap; + extra_colormap->prev = 0; +#else for (exc = extra_colormaps; exc->next; exc = exc->next); exc->next = extra_colormap; extra_colormap->prev = exc; extra_colormap->next = 0; +#endif } #ifdef EXTRACOLORMAPLUMPS diff --git a/src/r_data.h b/src/r_data.h index 5600d36dc..e6eec41b4 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -100,6 +100,9 @@ INT32 R_CheckTextureNumForName(const char *name); // Uncomment to enable //#define EXTRACOLORMAPLUMPS +// Uncomment to make extra_colormaps order Newest -> Oldest +//#define COLORMAPREVERSELIST + void R_ReInitColormaps(UINT16 num); void R_ClearColormaps(void); void R_AddColormapToList(extracolormap_t *extra_colormap); From 36923ae7b0ae7da2459af0ecee5cf231b0419369 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 11 Sep 2018 10:05:25 -0400 Subject: [PATCH 042/132] Use percentage calc instead of interval decrement for tic-based timing --- src/p_lights.c | 32 ++++++++++++++++---------------- src/p_saveg.c | 12 ++++++------ src/p_spec.h | 8 ++++---- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/p_lights.c b/src/p_lights.c index 77d05dad3..95171155e 100644 --- a/src/p_lights.c +++ b/src/p_lights.c @@ -352,19 +352,17 @@ void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean P_AddThinker(&ll->thinker); // add thinker ll->sector = sector; + ll->sourcelevel = sector->lightlevel; ll->destlevel = destvalue; if (ticbased) { - ll->ticbased = ticbased; - ll->timer = abs(speed); - ll->speed = FixedFloor(FixedDiv(destvalue - sector->lightlevel, ll->timer))/FRACUNIT; - if (!ll->speed) - ll->speed = (destvalue < sector->lightlevel) ? -1 : 1; - ll->interval = max(FixedFloor(FixedDiv(ll->timer, abs(destvalue - sector->lightlevel)))/FRACUNIT, 1); + ll->ticbased = true; + ll->timer = ll->speed = abs(speed); // use ll->speed for total duration } else { + ll->ticbased = false; ll->timer = -1; ll->speed = abs(speed); } @@ -389,15 +387,17 @@ void T_LightFade(lightlevel_t *ll) { if (--ll->timer <= 0) { - ll->sector->lightlevel = (INT16)ll->destlevel; // set to dest lightlevel + ll->sector->lightlevel = ll->destlevel; // set to dest lightlevel P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker } - else if (!(ll->timer % ll->interval)) + else { - if (ll->speed < 0) - ll->sector->lightlevel = max(ll->sector->lightlevel + (INT16)ll->speed, (INT16)ll->destlevel); - else - ll->sector->lightlevel = min(ll->sector->lightlevel + (INT16)ll->speed, (INT16)ll->destlevel); + INT16 delta = abs(ll->destlevel - ll->sourcelevel); + fixed_t factor = min(FixedDiv(ll->speed - ll->timer, ll->speed), 1*FRACUNIT); + if (ll->destlevel < ll->sourcelevel) + ll->sector->lightlevel = max(min(ll->sector->lightlevel, ll->sourcelevel - (INT16)FixedMul(delta, factor)), ll->destlevel); + else if (ll->destlevel > ll->sourcelevel) + ll->sector->lightlevel = min(max(ll->sector->lightlevel, ll->sourcelevel + (INT16)FixedMul(delta, factor)), ll->destlevel); } return; } @@ -408,12 +408,12 @@ void T_LightFade(lightlevel_t *ll) if (ll->sector->lightlevel + ll->speed >= ll->destlevel) { // stop changing light level - ll->sector->lightlevel = (INT16)ll->destlevel; // set to dest lightlevel + ll->sector->lightlevel = ll->destlevel; // set to dest lightlevel P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker } else - ll->sector->lightlevel = (INT16)(ll->sector->lightlevel + (INT16)ll->speed); // move lightlevel + ll->sector->lightlevel += ll->speed; // move lightlevel } else { @@ -421,11 +421,11 @@ void T_LightFade(lightlevel_t *ll) if (ll->sector->lightlevel - ll->speed <= ll->destlevel) { // stop changing light level - ll->sector->lightlevel = (INT16)ll->destlevel; // set to dest lightlevel + ll->sector->lightlevel = ll->destlevel; // set to dest lightlevel P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker } else - ll->sector->lightlevel = (INT16)(ll->sector->lightlevel - (INT16)ll->speed); // move lightlevel + ll->sector->lightlevel -= ll->speed; // move lightlevel } } diff --git a/src/p_saveg.c b/src/p_saveg.c index eefee072d..e9f07de4c 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1537,11 +1537,11 @@ static void SaveLightlevelThinker(const thinker_t *th, const UINT8 type) const lightlevel_t *ht = (const void *)th; WRITEUINT8(save_p, type); WRITEUINT32(save_p, SaveSector(ht->sector)); - WRITEINT32(save_p, ht->destlevel); - WRITEINT32(save_p, ht->speed); + WRITEINT16(save_p, ht->sourcelevel); + WRITEINT16(save_p, ht->destlevel); + WRITEINT16(save_p, ht->speed); WRITEUINT8(save_p, (UINT8)ht->ticbased); WRITEINT32(save_p, ht->timer); - WRITEUINT32(save_p, ht->interval); } // @@ -2513,11 +2513,11 @@ static inline void LoadLightlevelThinker(actionf_p1 thinker) lightlevel_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); ht->thinker.function.acp1 = thinker; ht->sector = LoadSector(READUINT32(save_p)); - ht->destlevel = READINT32(save_p); - ht->speed = READINT32(save_p); + ht->sourcelevel = READINT16(save_p); + ht->destlevel = READINT16(save_p); + ht->speed = READINT16(save_p); ht->ticbased = (boolean)READUINT8(save_p); ht->timer = READINT32(save_p); - ht->interval = READUINT32(save_p); if (ht->sector) ht->sector->lightingdata = ht; P_AddThinker(&ht->thinker); diff --git a/src/p_spec.h b/src/p_spec.h index 1e327c5f2..69087d6c4 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -136,13 +136,13 @@ typedef struct { thinker_t thinker; ///< Thinker in use for the effect. sector_t *sector; ///< Sector where action is taking place. - INT32 destlevel; ///< Light level we're fading to. - INT32 speed; ///< Speed at which to change light level. + INT16 sourcelevel; ///< Light level we're fading from. + INT16 destlevel; ///< Light level we're fading to. + INT16 speed; ///< Speed at which to change light level. OR: Tic-based duration // Tic-based behavior boolean ticbased; ///< Tic-based logic - INT32 timer; ///< Tic-based timer - UINT32 interval; ///< Interval to deduct light level + INT32 timer; ///< Tic-based timer } lightlevel_t; #define GLOWSPEED 8 From 56b947ae95afe2ea1767ef3a82aac3fb4197e2e7 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 11 Sep 2018 13:10:14 -0400 Subject: [PATCH 043/132] Remove cr/cg/cb/ca in favor of rgba * Change default colormap values to be in sync with rgba/fadergba --- src/p_saveg.c | 51 +++++---------------------------------- src/r_data.c | 66 +++++++++++++-------------------------------------- src/r_defs.h | 6 ++--- 3 files changed, 24 insertions(+), 99 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 7ee41dffd..710c24821 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -662,15 +662,6 @@ static void P_NetArchiveWorld(void) WRITEUINT8(put, ss->extra_colormap->fadeend); WRITEUINT8(put, (UINT8)ss->extra_colormap->fog); - WRITEUINT8(put, ss->extra_colormap->cr); - WRITEUINT8(put, ss->extra_colormap->cg); - WRITEUINT8(put, ss->extra_colormap->cb); - WRITEUINT8(put, ss->extra_colormap->ca); - WRITEUINT8(put, ss->extra_colormap->cfr); - WRITEUINT8(put, ss->extra_colormap->cfg); - WRITEUINT8(put, ss->extra_colormap->cfb); - WRITEUINT8(put, ss->extra_colormap->cfa); - WRITEINT32(put, ss->extra_colormap->rgba); WRITEINT32(put, ss->extra_colormap->fadergba); @@ -883,15 +874,6 @@ static void P_NetUnArchiveWorld(void) boolean fog = (boolean)READUINT8(get); - UINT8 cr = READUINT8(get), - cg = READUINT8(get), - cb = READUINT8(get), - ca = READUINT8(get), - cfr = READUINT8(get), - cfg = READUINT8(get), - cfb = READUINT8(get), - cfa = READUINT8(get); - INT32 rgba = READINT32(get), fadergba = READINT32(get); @@ -905,20 +887,6 @@ static void P_NetUnArchiveWorld(void) { #endif - for (exc = extra_colormaps; exc; exc = exc->next) - { -#ifdef EXTRACOLORMAPLUMPS - if (exc->lump != LUMPERROR) - continue; -#endif - if (cr == exc->cr && cg == exc->cg && cb == exc->cb && ca == exc->ca - && cfr == exc->cfr && cfg == exc->cfg && cfb == exc->cfb && cfa == exc->cfa - && fadestart == exc->fadestart - && fadeend == exc->fadeend - && fog == exc->fog) - break; - } - for (exc = extra_colormaps; exc; exc = exc->next) { #ifdef EXTRACOLORMAPLUMPS @@ -928,14 +896,15 @@ static void P_NetUnArchiveWorld(void) continue; } #endif - if (cr == exc->cr && cg == exc->cg && cb == exc->cb && ca == exc->ca - && cfr == exc->cfr && cfg == exc->cfg && cfb == exc->cfb && cfa == exc->cfa + if (rgba == exc->rgba + && fadergba == exc->fadergba && fadestart == exc->fadestart && fadeend == exc->fadeend && fog == exc->fog) { // CONS_Debug(DBG_RENDER, "P_NetUnArchiveWorld: Found map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", - // dbg_i, cr, cg, cb, ca, cfr, cfg, cfb, cfa); + // dbg_i, (rgba)&0xFF, (rgba>>8)&0xFF, (rgba>>16)&0xFF, (rgba>>24)&0xFF, + // (fadergba)&0xFF, (fadergba>>8)&0xFF, (fadergba>>16)&0xFF, (fadergba>>24)&0xFF); break; } //dbg_i++; @@ -944,7 +913,8 @@ static void P_NetUnArchiveWorld(void) if (!exc) { // CONS_Debug(DBG_RENDER, "P_NetUnArchiveWorld: Creating map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", - // dbg_i, cr, cg, cb, ca, cfr, cfg, cfb, cfa); + // dbg_i, (rgba)&0xFF, (rgba>>8)&0xFF, (rgba>>16)&0xFF, (rgba>>24)&0xFF, + // (fadergba)&0xFF, (fadergba>>8)&0xFF, (fadergba>>16)&0xFF, (fadergba>>24)&0xFF); exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL); @@ -952,15 +922,6 @@ static void P_NetUnArchiveWorld(void) exc->fadeend = fadeend; exc->fog = fog; - exc->cr = cr; - exc->cg = cg; - exc->cb = cb; - exc->ca = ca; - exc->cfr = cfr; - exc->cfg = cfg; - exc->cfb = cfb; - exc->cfa = cfa; - exc->rgba = rgba; exc->fadergba = fadergba; diff --git a/src/r_data.c b/src/r_data.c index ffc6cc7fd..005056ec0 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1332,10 +1332,6 @@ void R_ClearColormaps(void) // make a default extra_colormap exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL); - exc->cr = exc->cg = exc->cb = 0xff; - exc->ca = 0; - exc->cfr = exc->cfg = exc->cfb = 0; - exc->cfa = 18; exc->fadestart = 0; exc->fadeend = 31; exc->fog = 0; @@ -1411,10 +1407,6 @@ extracolormap_t *R_ColormapForName(char *name) // We set all params of the colormap to normal because there // is no real way to tell how GL should handle a colormap lump anyway.. - exc->cr = exc->cg = exc->cb = 0xff; - exc->ca = 0; - exc->cfr = exc->cfg = exc->cfb = 0; - exc->cfa = 18; exc->fadestart = 0; exc->fadeend = 31; exc->fog = 0; @@ -1445,14 +1437,14 @@ lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap) double cmaskr, cmaskg, cmaskb, cdestr, cdestg, cdestb; double maskamt = 0, othermask = 0; - UINT8 cr = extra_colormap->cr, - cg = extra_colormap->cg, - cb = extra_colormap->cb, - ca = extra_colormap->ca, - cfr = extra_colormap->cfr, - cfg = extra_colormap->cfg, - cfb = extra_colormap->cfb; -// cfa = extra_colormap->cfa; // unused in software + UINT8 cr = (extra_colormap->rgba) & 0xFF, + cg = (extra_colormap->rgba >> 8) & 0xFF, + cb = (extra_colormap->rgba >> 16) & 0xFF, + ca = (extra_colormap->rgba >> 24) & 0xFF, + cfr = (extra_colormap->fadergba) & 0xFF, + cfg = (extra_colormap->fadergba >> 8) & 0xFF, + cfb = (extra_colormap->fadergba >> 16) & 0xFF; +// cfa = (extra_colormap->fadergba >> 24) & 0xFF; // unused in software UINT8 fadestart = extra_colormap->fadestart, fadedist = extra_colormap->fadeend - extra_colormap->fadestart; @@ -1594,22 +1586,13 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) else if (p1[7] >= 'A' && p1[7] <= 'Z') ca = (p1[7] - 'A'); else - ca = 24; + ca = 25; - // for opengl; generate on software too for netsync - rgba = (HEX2INT(p1[1]) << 4) + (HEX2INT(p1[2]) << 0) + - (HEX2INT(p1[3]) << 12) + (HEX2INT(p1[4]) << 8) + - (HEX2INT(p1[5]) << 20) + (HEX2INT(p1[6]) << 16); - - if ((p1[7] >= 'a' && p1[7] <= 'z') || (p1[7] >= 'A' && p1[7] <= 'Z')) - rgba += (ALPHA2INT(p1[7]) << 24); - else - rgba += (25 << 24); + rgba = cr + (cg << 8) + (cb << 16) + (ca << 24); } else { - cr = cg = cb = 0xff; - ca = 0; + cr = cg = cb = ca = 0; rgba = 0; } @@ -1638,22 +1621,14 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) else if (p1[7] >= 'A' && p1[7] <= 'Z') cfa = (p1[7] - 'A'); else - cfa = 18; + cfa = 25; - // for opengl; generate on software too for netsync - fadergba = (HEX2INT(p3[1]) << 4) + (HEX2INT(p3[2]) << 0) + - (HEX2INT(p3[3]) << 12) + (HEX2INT(p3[4]) << 8) + - (HEX2INT(p3[5]) << 20) + (HEX2INT(p3[6]) << 16); - - if ((p3[7] >= 'a' && p3[7] <= 'z') || (p3[7] >= 'A' && p3[7] <= 'Z')) - fadergba += (ALPHA2INT(p3[7]) << 24); - else - fadergba += (25 << 24); + fadergba = cfr + (cfg << 8) + (cfb << 16) + (cfa << 24); } else { cfr = cfg = cfb = 0; - cfa = 18; + cfa = 25; fadergba = 0x19000000; // default alpha for fade, (25 << 24) } #undef ALPHA2INT @@ -1668,8 +1643,8 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) continue; } #endif - if (cr == exc->cr && cg == exc->cg && cb == exc->cb && ca == exc->ca - && cfr == exc->cfr && cfg == exc->cfg && cfb == exc->cfb && cfa == exc->cfa + if (rgba == exc->rgba + && fadergba == exc->fadergba && fadestart == exc->fadestart && fadeend == exc->fadeend && fog == exc->fog) @@ -1690,15 +1665,6 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) extra_colormap->fadeend = (UINT16)fadeend; extra_colormap->fog = fog; - extra_colormap->cr = cr; - extra_colormap->cg = cg; - extra_colormap->cb = cb; - extra_colormap->ca = ca; - extra_colormap->cfr = cfr; - extra_colormap->cfg = cfg; - extra_colormap->cfb = cfb; - extra_colormap->cfa = cfa; - extra_colormap->rgba = rgba; extra_colormap->fadergba = fadergba; diff --git a/src/r_defs.h b/src/r_defs.h index 22d4fdf14..99fad2b44 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -55,10 +55,8 @@ typedef struct extracolormap_s UINT8 fadestart, fadeend; boolean fog; - // rgba for colormap table generation - UINT8 cr, cg, cb, ca, cfr, cfg, cfb, cfa; - - // rgba is used in hw mode for colored sector lighting + // store rgba values in combined bitwise + // also used in OpenGL instead lighttables INT32 rgba; // similar to maskcolor in sw mode INT32 fadergba; // The colour the colourmaps fade to From a818b9a1dc0598e88eb24d912979f0cfcff0c06d Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 11 Sep 2018 13:10:14 -0400 Subject: [PATCH 044/132] Remove cr/cg/cb/ca in favor of rgba * Change default colormap values to be in sync with rgba/fadergba --- src/p_saveg.c | 51 +++++---------------------------------- src/r_data.c | 66 +++++++++++++-------------------------------------- src/r_defs.h | 6 ++--- 3 files changed, 24 insertions(+), 99 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 7ee41dffd..710c24821 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -662,15 +662,6 @@ static void P_NetArchiveWorld(void) WRITEUINT8(put, ss->extra_colormap->fadeend); WRITEUINT8(put, (UINT8)ss->extra_colormap->fog); - WRITEUINT8(put, ss->extra_colormap->cr); - WRITEUINT8(put, ss->extra_colormap->cg); - WRITEUINT8(put, ss->extra_colormap->cb); - WRITEUINT8(put, ss->extra_colormap->ca); - WRITEUINT8(put, ss->extra_colormap->cfr); - WRITEUINT8(put, ss->extra_colormap->cfg); - WRITEUINT8(put, ss->extra_colormap->cfb); - WRITEUINT8(put, ss->extra_colormap->cfa); - WRITEINT32(put, ss->extra_colormap->rgba); WRITEINT32(put, ss->extra_colormap->fadergba); @@ -883,15 +874,6 @@ static void P_NetUnArchiveWorld(void) boolean fog = (boolean)READUINT8(get); - UINT8 cr = READUINT8(get), - cg = READUINT8(get), - cb = READUINT8(get), - ca = READUINT8(get), - cfr = READUINT8(get), - cfg = READUINT8(get), - cfb = READUINT8(get), - cfa = READUINT8(get); - INT32 rgba = READINT32(get), fadergba = READINT32(get); @@ -905,20 +887,6 @@ static void P_NetUnArchiveWorld(void) { #endif - for (exc = extra_colormaps; exc; exc = exc->next) - { -#ifdef EXTRACOLORMAPLUMPS - if (exc->lump != LUMPERROR) - continue; -#endif - if (cr == exc->cr && cg == exc->cg && cb == exc->cb && ca == exc->ca - && cfr == exc->cfr && cfg == exc->cfg && cfb == exc->cfb && cfa == exc->cfa - && fadestart == exc->fadestart - && fadeend == exc->fadeend - && fog == exc->fog) - break; - } - for (exc = extra_colormaps; exc; exc = exc->next) { #ifdef EXTRACOLORMAPLUMPS @@ -928,14 +896,15 @@ static void P_NetUnArchiveWorld(void) continue; } #endif - if (cr == exc->cr && cg == exc->cg && cb == exc->cb && ca == exc->ca - && cfr == exc->cfr && cfg == exc->cfg && cfb == exc->cfb && cfa == exc->cfa + if (rgba == exc->rgba + && fadergba == exc->fadergba && fadestart == exc->fadestart && fadeend == exc->fadeend && fog == exc->fog) { // CONS_Debug(DBG_RENDER, "P_NetUnArchiveWorld: Found map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", - // dbg_i, cr, cg, cb, ca, cfr, cfg, cfb, cfa); + // dbg_i, (rgba)&0xFF, (rgba>>8)&0xFF, (rgba>>16)&0xFF, (rgba>>24)&0xFF, + // (fadergba)&0xFF, (fadergba>>8)&0xFF, (fadergba>>16)&0xFF, (fadergba>>24)&0xFF); break; } //dbg_i++; @@ -944,7 +913,8 @@ static void P_NetUnArchiveWorld(void) if (!exc) { // CONS_Debug(DBG_RENDER, "P_NetUnArchiveWorld: Creating map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", - // dbg_i, cr, cg, cb, ca, cfr, cfg, cfb, cfa); + // dbg_i, (rgba)&0xFF, (rgba>>8)&0xFF, (rgba>>16)&0xFF, (rgba>>24)&0xFF, + // (fadergba)&0xFF, (fadergba>>8)&0xFF, (fadergba>>16)&0xFF, (fadergba>>24)&0xFF); exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL); @@ -952,15 +922,6 @@ static void P_NetUnArchiveWorld(void) exc->fadeend = fadeend; exc->fog = fog; - exc->cr = cr; - exc->cg = cg; - exc->cb = cb; - exc->ca = ca; - exc->cfr = cfr; - exc->cfg = cfg; - exc->cfb = cfb; - exc->cfa = cfa; - exc->rgba = rgba; exc->fadergba = fadergba; diff --git a/src/r_data.c b/src/r_data.c index ffc6cc7fd..005056ec0 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1332,10 +1332,6 @@ void R_ClearColormaps(void) // make a default extra_colormap exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL); - exc->cr = exc->cg = exc->cb = 0xff; - exc->ca = 0; - exc->cfr = exc->cfg = exc->cfb = 0; - exc->cfa = 18; exc->fadestart = 0; exc->fadeend = 31; exc->fog = 0; @@ -1411,10 +1407,6 @@ extracolormap_t *R_ColormapForName(char *name) // We set all params of the colormap to normal because there // is no real way to tell how GL should handle a colormap lump anyway.. - exc->cr = exc->cg = exc->cb = 0xff; - exc->ca = 0; - exc->cfr = exc->cfg = exc->cfb = 0; - exc->cfa = 18; exc->fadestart = 0; exc->fadeend = 31; exc->fog = 0; @@ -1445,14 +1437,14 @@ lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap) double cmaskr, cmaskg, cmaskb, cdestr, cdestg, cdestb; double maskamt = 0, othermask = 0; - UINT8 cr = extra_colormap->cr, - cg = extra_colormap->cg, - cb = extra_colormap->cb, - ca = extra_colormap->ca, - cfr = extra_colormap->cfr, - cfg = extra_colormap->cfg, - cfb = extra_colormap->cfb; -// cfa = extra_colormap->cfa; // unused in software + UINT8 cr = (extra_colormap->rgba) & 0xFF, + cg = (extra_colormap->rgba >> 8) & 0xFF, + cb = (extra_colormap->rgba >> 16) & 0xFF, + ca = (extra_colormap->rgba >> 24) & 0xFF, + cfr = (extra_colormap->fadergba) & 0xFF, + cfg = (extra_colormap->fadergba >> 8) & 0xFF, + cfb = (extra_colormap->fadergba >> 16) & 0xFF; +// cfa = (extra_colormap->fadergba >> 24) & 0xFF; // unused in software UINT8 fadestart = extra_colormap->fadestart, fadedist = extra_colormap->fadeend - extra_colormap->fadestart; @@ -1594,22 +1586,13 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) else if (p1[7] >= 'A' && p1[7] <= 'Z') ca = (p1[7] - 'A'); else - ca = 24; + ca = 25; - // for opengl; generate on software too for netsync - rgba = (HEX2INT(p1[1]) << 4) + (HEX2INT(p1[2]) << 0) + - (HEX2INT(p1[3]) << 12) + (HEX2INT(p1[4]) << 8) + - (HEX2INT(p1[5]) << 20) + (HEX2INT(p1[6]) << 16); - - if ((p1[7] >= 'a' && p1[7] <= 'z') || (p1[7] >= 'A' && p1[7] <= 'Z')) - rgba += (ALPHA2INT(p1[7]) << 24); - else - rgba += (25 << 24); + rgba = cr + (cg << 8) + (cb << 16) + (ca << 24); } else { - cr = cg = cb = 0xff; - ca = 0; + cr = cg = cb = ca = 0; rgba = 0; } @@ -1638,22 +1621,14 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) else if (p1[7] >= 'A' && p1[7] <= 'Z') cfa = (p1[7] - 'A'); else - cfa = 18; + cfa = 25; - // for opengl; generate on software too for netsync - fadergba = (HEX2INT(p3[1]) << 4) + (HEX2INT(p3[2]) << 0) + - (HEX2INT(p3[3]) << 12) + (HEX2INT(p3[4]) << 8) + - (HEX2INT(p3[5]) << 20) + (HEX2INT(p3[6]) << 16); - - if ((p3[7] >= 'a' && p3[7] <= 'z') || (p3[7] >= 'A' && p3[7] <= 'Z')) - fadergba += (ALPHA2INT(p3[7]) << 24); - else - fadergba += (25 << 24); + fadergba = cfr + (cfg << 8) + (cfb << 16) + (cfa << 24); } else { cfr = cfg = cfb = 0; - cfa = 18; + cfa = 25; fadergba = 0x19000000; // default alpha for fade, (25 << 24) } #undef ALPHA2INT @@ -1668,8 +1643,8 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) continue; } #endif - if (cr == exc->cr && cg == exc->cg && cb == exc->cb && ca == exc->ca - && cfr == exc->cfr && cfg == exc->cfg && cfb == exc->cfb && cfa == exc->cfa + if (rgba == exc->rgba + && fadergba == exc->fadergba && fadestart == exc->fadestart && fadeend == exc->fadeend && fog == exc->fog) @@ -1690,15 +1665,6 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) extra_colormap->fadeend = (UINT16)fadeend; extra_colormap->fog = fog; - extra_colormap->cr = cr; - extra_colormap->cg = cg; - extra_colormap->cb = cb; - extra_colormap->ca = ca; - extra_colormap->cfr = cfr; - extra_colormap->cfg = cfg; - extra_colormap->cfb = cfb; - extra_colormap->cfa = cfa; - extra_colormap->rgba = rgba; extra_colormap->fadergba = fadergba; diff --git a/src/r_defs.h b/src/r_defs.h index 22d4fdf14..99fad2b44 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -55,10 +55,8 @@ typedef struct extracolormap_s UINT8 fadestart, fadeend; boolean fog; - // rgba for colormap table generation - UINT8 cr, cg, cb, ca, cfr, cfg, cfb, cfa; - - // rgba is used in hw mode for colored sector lighting + // store rgba values in combined bitwise + // also used in OpenGL instead lighttables INT32 rgba; // similar to maskcolor in sw mode INT32 fadergba; // The colour the colourmaps fade to From 506ce43627c2d954da8f12bb1c76b2828a116189 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 11 Sep 2018 13:31:09 -0400 Subject: [PATCH 045/132] Initialize extra_colormaps to NULL on program start --- src/r_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_main.c b/src/r_main.c index 281058362..bfca180d0 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -118,7 +118,7 @@ lighttable_t *scalelightfixed[MAXLIGHTSCALE]; lighttable_t *zlight[LIGHTLEVELS][MAXLIGHTZ]; // Hack to support extra boom colormaps. -extracolormap_t *extra_colormaps; +extracolormap_t *extra_colormaps = NULL; static CV_PossibleValue_t drawdist_cons_t[] = { {256, "256"}, {512, "512"}, {768, "768"}, From 4ef016e40fe9fdb5b0abb9fd3e101e0efd2f7a98 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 11 Sep 2018 13:46:34 -0400 Subject: [PATCH 046/132] Clear colormaps properly (resolve sigsegv crash) --- src/r_data.c | 23 +++++++++++------------ src/r_data.h | 1 + 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/r_data.c b/src/r_data.c index 005056ec0..4358f7536 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1322,29 +1322,28 @@ void R_ReInitColormaps(UINT16 num) // void R_ClearColormaps(void) { - extracolormap_t *exc, *exc_next; + // Purged by PU_LEVEL, just overwrite the pointer + extra_colormaps = R_CreateDefaultColormap(true); +} - for (exc = extra_colormaps; exc; exc = exc_next) - { - exc_next = exc->next; - memset(exc, 0, sizeof(*exc)); - } - - // make a default extra_colormap - exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL); +// +// R_CreateDefaultColormap() +// +extracolormap_t *R_CreateDefaultColormap(boolean lighttable) +{ + extracolormap_t *exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL); exc->fadestart = 0; exc->fadeend = 31; exc->fog = 0; exc->rgba = 0; exc->fadergba = 0x19000000; - exc->colormap = R_CreateLightTable(exc); + exc->colormap = lighttable ? R_CreateLightTable(exc) : NULL; #ifdef EXTRACOLORMAPLUMPS exc->lump = LUMPERROR; exc->lumpname[0] = 0; #endif exc->next = exc->prev = NULL; - - extra_colormaps = exc; + return exc; } // diff --git a/src/r_data.h b/src/r_data.h index e6eec41b4..718abeccc 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -105,6 +105,7 @@ INT32 R_CheckTextureNumForName(const char *name); void R_ReInitColormaps(UINT16 num); void R_ClearColormaps(void); +extracolormap_t *R_CreateDefaultColormap(boolean lighttable); void R_AddColormapToList(extracolormap_t *extra_colormap); lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap); extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3); From ba88f8ebb66a55bf6d4966e72649f5151195e258 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 11 Sep 2018 15:01:05 -0400 Subject: [PATCH 047/132] Smarter string digit parsing; allow alpha-only values * GetDefaultColormap and CheckDefaultColormapValues methods --- src/p_setup.c | 11 ++- src/r_data.c | 182 +++++++++++++++++++++++++++++++++++++++----------- src/r_data.h | 2 + 3 files changed, 149 insertions(+), 46 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index b503b6a58..77d53812c 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1472,12 +1472,11 @@ static void P_LoadRawSideDefs2(void *data) case 606: //SoM: 4/4/2000: Just colormap transfer // SoM: R_CreateColormap will only create a colormap in software mode... // Perhaps we should just call it instead of doing the calculations here. - if ( - ((rendermode == render_soft || rendermode == render_none) && (msd->toptexture[0] == '#' || msd->bottomtexture[0] == '#')) -#ifdef HWRENDER - || (msd->toptexture[0] == '#' && msd->toptexture[1] && msd->toptexture[2] && msd->toptexture[3] && msd->toptexture[4] && msd->toptexture[5] && msd->toptexture[6]) - || (msd->bottomtexture[0] == '#' && msd->bottomtexture[1] && msd->bottomtexture[2] && msd->bottomtexture[3] && msd->bottomtexture[4] && msd->bottomtexture[5] && msd->bottomtexture[6]) -#endif + if (msd->toptexture[0] == '#' || msd->bottomtexture[0] == '#' + || (msd->toptexture[0] >= 'a' && msd->toptexture[0] <= 'z' && !msd->toptexture[1]) + || (msd->toptexture[0] >= 'A' && msd->toptexture[0] <= 'Z' && !msd->toptexture[1]) + || (msd->bottomtexture[0] >= 'a' && msd->bottomtexture[0] <= 'z' && !msd->bottomtexture[1]) + || (msd->bottomtexture[0] >= 'A' && msd->bottomtexture[0] <= 'Z' && !msd->bottomtexture[1]) ) { sec->extra_colormap = sec->spawn_extra_colormap = R_CreateColormap(msd->toptexture, msd->midtexture, diff --git a/src/r_data.c b/src/r_data.c index 4358f7536..958eeeb37 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1346,6 +1346,49 @@ extracolormap_t *R_CreateDefaultColormap(boolean lighttable) return exc; } +// +// R_GetDefaultColormap() +// +extracolormap_t *R_GetDefaultColormap(void) +{ +#ifdef COLORMAPREVERSELIST + extracolormap_t *exc; +#endif + + if (!extra_colormaps) + return (extra_colormaps = R_CreateDefaultColormap(true)); + +#ifdef COLORMAPREVERSELIST + for (exc = extra_colormaps; exc->next; exc = exc->next); + return exc; +#else + return extra_colormaps; +#endif +} + +// +// R_CheckDefaultColormap() +// +boolean R_CheckDefaultColormapValues(extracolormap_t *extra_colormap, boolean checkrgba, boolean checkfadergba, boolean checkparams) +{ + if (!extra_colormap) + return true; + else + return ( + (!checkparams ? true : + (extra_colormap->fadestart == 0 + && extra_colormap->fadeend == 31 + && !extra_colormap->fog) + ) + && (!checkrgba ? true : extra_colormap->rgba == 0) + && (!checkfadergba ? true : extra_colormap->fadergba == 0x19000000) +#ifdef EXTRACOLORMAPLUMPS + && extra_colormap->lump == LUMPERROR + && extra_colormap->lumpname[0] == 0 +#endif + ); +} + // // R_AddColormapToList // @@ -1562,77 +1605,133 @@ lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap) extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) { - boolean fog = false; extracolormap_t *extra_colormap, *exc; - UINT8 cr, cg, cb, ca, cfr, cfg, cfb, cfa; + // default values + UINT8 cr = 0, cg = 0, cb = 0, ca = 0, cfr = 0, cfg = 0, cfb = 0, cfa = 25; UINT32 fadestart = 0, fadeend = 31; - - INT32 rgba, fadergba; + boolean fog = false; + INT32 rgba = 0, fadergba = 0x19000000; size_t dbg_i = 0; #define HEX2INT(x) (UINT32)(x >= '0' && x <= '9' ? x - '0' : x >= 'a' && x <= 'f' ? x - 'a' + 10 : x >= 'A' && x <= 'F' ? x - 'A' + 10 : 0) #define ALPHA2INT(x) (x >= 'a' && x <= 'z' ? x - 'a' : x >= 'A' && x <= 'Z' ? x - 'A' : x >= '0' && x <= '9' ? 25 : 0) - if (p1[0] == '#') - { - cr = ((HEX2INT(p1[1]) * 16) + HEX2INT(p1[2])); - cg = ((HEX2INT(p1[3]) * 16) + HEX2INT(p1[4])); - cb = ((HEX2INT(p1[5]) * 16) + HEX2INT(p1[6])); - if (p1[7] >= 'a' && p1[7] <= 'z') - ca = (p1[7] - 'a'); - else if (p1[7] >= 'A' && p1[7] <= 'Z') - ca = (p1[7] - 'A'); + // Get base colormap value + // First alpha-only, then full value + if (p1[0] >= 'a' && p1[0] <= 'z' && !p1[1]) + ca = (p1[0] - 'a'); + else if (p1[0] == '#' && p1[1] >= 'a' && p1[1] <= 'z' && !p1[2]) + ca = (p1[1] - 'a'); + else if (p1[0] >= 'A' && p1[0] <= 'Z' && !p1[1]) + ca = (p1[0] - 'A'); + else if (p1[0] == '#' && p1[1] >= 'A' && p1[1] <= 'Z' && !p1[2]) + ca = (p1[1] - 'A'); + else if (p1[0] == '#') + { + // For each subsequent value, the value before it must exist + // If we don't get every value, then set alpha to max + if (p1[1] && p1[2]) + { + cr = ((HEX2INT(p1[1]) * 16) + HEX2INT(p1[2])); + if (p1[3] && p1[4]) + { + cg = ((HEX2INT(p1[3]) * 16) + HEX2INT(p1[4])); + if (p1[5] && p1[6]) + { + cb = ((HEX2INT(p1[5]) * 16) + HEX2INT(p1[6])); + + if (p1[7] >= 'a' && p1[7] <= 'z') + ca = (p1[7] - 'a'); + else if (p1[7] >= 'A' && p1[7] <= 'Z') + ca = (p1[7] - 'A'); + else + ca = 25; + } + else + ca = 25; + } + else + ca = 25; + } else ca = 25; - - rgba = cr + (cg << 8) + (cb << 16) + (ca << 24); - } - else - { - cr = cg = cb = ca = 0; - rgba = 0; } #define NUMFROMCHAR(c) (c >= '0' && c <= '9' ? c - '0' : 0) + + // Get parameters like fadestart, fadeend, and the fogflag if (p2[0] == '#') { - // Get parameters like fadestart, fadeend, and the fogflag - fadestart = NUMFROMCHAR(p2[3]) + (NUMFROMCHAR(p2[2]) * 10); - fadeend = NUMFROMCHAR(p2[5]) + (NUMFROMCHAR(p2[4]) * 10); + if (p2[1]) + { + fog = (boolean)NUMFROMCHAR(p2[1]); + if (p2[2] && p2[3]) + { + fadestart = NUMFROMCHAR(p2[3]) + (NUMFROMCHAR(p2[2]) * 10); + if (p2[4] && p2[5]) + fadeend = NUMFROMCHAR(p2[5]) + (NUMFROMCHAR(p2[4]) * 10); + } + } + if (fadestart > 30) fadestart = 0; if (fadeend > 31 || fadeend < 1) fadeend = 31; - fog = (boolean)NUMFROMCHAR(p2[1]); } + #undef NUMFROMCHAR - if (p3[0] == '#') + // Get fade (dark) colormap value + // First alpha-only, then full value + if (p3[0] >= 'a' && p3[0] <= 'z' && !p3[1]) + cfa = (p3[0] - 'a'); + else if (p3[0] == '#' && p3[1] >= 'a' && p3[1] <= 'z' && !p3[2]) + cfa = (p3[1] - 'a'); + else if (p3[0] >= 'A' && p3[0] <= 'Z' && !p3[1]) + cfa = (p3[0] - 'A'); + else if (p3[0] == '#' && p3[1] >= 'A' && p3[1] <= 'Z' && !p3[2]) + cfa = (p3[1] - 'A'); + else if (p3[0] == '#') { - cfr = ((HEX2INT(p3[1]) * 16) + HEX2INT(p3[2])); - cfg = ((HEX2INT(p3[3]) * 16) + HEX2INT(p3[4])); - cfb = ((HEX2INT(p3[5]) * 16) + HEX2INT(p3[6])); + // For each subsequent value, the value before it must exist + // If we don't get every value, then set alpha to max + if (p3[1] && p3[2]) + { + cfr = ((HEX2INT(p3[1]) * 16) + HEX2INT(p3[2])); + if (p3[3] && p3[4]) + { + cfg = ((HEX2INT(p3[3]) * 16) + HEX2INT(p3[4])); + if (p3[5] && p3[6]) + { + cfb = ((HEX2INT(p3[5]) * 16) + HEX2INT(p3[6])); - if (p1[7] >= 'a' && p1[7] <= 'z') - cfa = (p1[7] - 'a'); - else if (p1[7] >= 'A' && p1[7] <= 'Z') - cfa = (p1[7] - 'A'); + if (p3[7] >= 'a' && p3[7] <= 'z') + cfa = (p3[7] - 'a'); + else if (p3[7] >= 'A' && p3[7] <= 'Z') + cfa = (p3[7] - 'A'); + else + cfa = 25; + } + else + cfa = 25; + } + else + cfa = 25; + } else cfa = 25; - - fadergba = cfr + (cfg << 8) + (cfb << 16) + (cfa << 24); - } - else - { - cfr = cfg = cfb = 0; - cfa = 25; - fadergba = 0x19000000; // default alpha for fade, (25 << 24) } #undef ALPHA2INT #undef HEX2INT + // Pack rgba values into combined var + // OpenGL also uses this instead of lighttables for rendering + rgba = cr + (cg << 8) + (cb << 16) + (ca << 24); + fadergba = cfr + (cfg << 8) + (cfb << 16) + (cfa << 24); + + // Look for existing colormaps for (exc = extra_colormaps; exc; exc = exc->next) { #ifdef EXTRACOLORMAPLUMPS @@ -1672,6 +1771,9 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) extra_colormap->lumpname[0] = 0; #endif + // Having lighttables for alpha-only entries is kind of pointless, + // but if there happens to be a matching rgba entry that is NOT alpha-only (but has same rgb values), + // then it needs this lighttable because we share matching entries. extra_colormap->colormap = R_CreateLightTable(extra_colormap); R_AddColormapToList(extra_colormap); diff --git a/src/r_data.h b/src/r_data.h index 718abeccc..95ea44a83 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -106,6 +106,8 @@ INT32 R_CheckTextureNumForName(const char *name); void R_ReInitColormaps(UINT16 num); void R_ClearColormaps(void); extracolormap_t *R_CreateDefaultColormap(boolean lighttable); +extracolormap_t *R_GetDefaultColormap(void); +boolean R_CheckDefaultColormapValues(extracolormap_t *extra_colormap, boolean checkrgba, boolean checkfadergba, boolean checkparams); void R_AddColormapToList(extracolormap_t *extra_colormap); lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap); extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3); From 85d89287de8521fe320275716b1e924b177e3a6d Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 11 Sep 2018 15:20:30 -0400 Subject: [PATCH 048/132] Add R_CopyColormap --- src/r_data.c | 62 +++++++++++++++++++++++++++++++++++++++------------- src/r_data.h | 3 ++- 2 files changed, 49 insertions(+), 16 deletions(-) diff --git a/src/r_data.c b/src/r_data.c index 958eeeb37..ad27b442f 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1367,26 +1367,35 @@ extracolormap_t *R_GetDefaultColormap(void) } // -// R_CheckDefaultColormap() +// R_CopyColormap() // -boolean R_CheckDefaultColormapValues(extracolormap_t *extra_colormap, boolean checkrgba, boolean checkfadergba, boolean checkparams) +extracolormap_t *R_CopyColormap(extracolormap_t *extra_colormap, boolean lighttable) { + extracolormap_t *exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL); + if (!extra_colormap) - return true; - else - return ( - (!checkparams ? true : - (extra_colormap->fadestart == 0 - && extra_colormap->fadeend == 31 - && !extra_colormap->fog) - ) - && (!checkrgba ? true : extra_colormap->rgba == 0) - && (!checkfadergba ? true : extra_colormap->fadergba == 0x19000000) + extra_colormap = R_GetDefaultColormap(); + + *exc = *extra_colormap; + exc->next = exc->prev = NULL; + #ifdef EXTRACOLORMAPLUMPS - && extra_colormap->lump == LUMPERROR - && extra_colormap->lumpname[0] == 0 + strncpy(exc->lumpname, extra_colormap->lumpname, 9); + + if (exc->lump != LUMPERROR && lighttable) + { + // aligned on 8 bit for asm code + exc->colormap = Z_MallocAlign(W_LumpLength(lump), PU_LEVEL, NULL, 16); + W_ReadLump(lump, exc->colormap); + } + else #endif - ); + if (lighttable) + exc->colormap = R_CreateLightTable(exc); + else + exc->colormap = NULL; + + return exc; } // @@ -1423,6 +1432,29 @@ void R_AddColormapToList(extracolormap_t *extra_colormap) #endif } +// +// R_CheckDefaultColormap() +// +boolean R_CheckDefaultColormapValues(extracolormap_t *extra_colormap, boolean checkrgba, boolean checkfadergba, boolean checkparams) +{ + if (!extra_colormap) + return true; + else + return ( + (!checkparams ? true : + (extra_colormap->fadestart == 0 + && extra_colormap->fadeend == 31 + && !extra_colormap->fog) + ) + && (!checkrgba ? true : extra_colormap->rgba == 0) + && (!checkfadergba ? true : extra_colormap->fadergba == 0x19000000) +#ifdef EXTRACOLORMAPLUMPS + && extra_colormap->lump == LUMPERROR + && extra_colormap->lumpname[0] == 0 +#endif + ); +} + #ifdef EXTRACOLORMAPLUMPS extracolormap_t *R_ColormapForName(char *name) { diff --git a/src/r_data.h b/src/r_data.h index 95ea44a83..fc6d71299 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -107,8 +107,9 @@ void R_ReInitColormaps(UINT16 num); void R_ClearColormaps(void); extracolormap_t *R_CreateDefaultColormap(boolean lighttable); extracolormap_t *R_GetDefaultColormap(void); -boolean R_CheckDefaultColormapValues(extracolormap_t *extra_colormap, boolean checkrgba, boolean checkfadergba, boolean checkparams); +extracolormap_t *R_CopyColormap(extracolormap_t *extra_colormap, boolean lighttable); void R_AddColormapToList(extracolormap_t *extra_colormap); +boolean R_CheckDefaultColormapValues(extracolormap_t *extra_colormap, boolean checkrgba, boolean checkfadergba, boolean checkparams); lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap); extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3); #ifdef EXTRACOLORMAPLUMPS From 78aefc05cf8c871392ddb03ff7cc4b955202ce71 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 11 Sep 2018 15:50:12 -0400 Subject: [PATCH 049/132] Consolidate colormap matching into R_GetExistingColormap --- src/p_saveg.c | 30 +++---------------- src/r_data.c | 82 +++++++++++++++++++++++++++++++++++---------------- src/r_data.h | 5 ++++ 3 files changed, 65 insertions(+), 52 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 710c24821..d9158d99c 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -886,35 +886,13 @@ static void P_NetUnArchiveWorld(void) else { #endif - - for (exc = extra_colormaps; exc; exc = exc->next) - { -#ifdef EXTRACOLORMAPLUMPS - if (exc->lump != LUMPERROR) - { - //dbg_i++; - continue; - } -#endif - if (rgba == exc->rgba - && fadergba == exc->fadergba - && fadestart == exc->fadestart - && fadeend == exc->fadeend - && fog == exc->fog) - { - // CONS_Debug(DBG_RENDER, "P_NetUnArchiveWorld: Found map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", - // dbg_i, (rgba)&0xFF, (rgba>>8)&0xFF, (rgba>>16)&0xFF, (rgba>>24)&0xFF, - // (fadergba)&0xFF, (fadergba>>8)&0xFF, (fadergba>>16)&0xFF, (fadergba>>24)&0xFF); - break; - } - //dbg_i++; - } + exc = R_GetExistingColormapByValues(rgba, fadergba, fadestart, fadeend, fog); if (!exc) { - // CONS_Debug(DBG_RENDER, "P_NetUnArchiveWorld: Creating map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", - // dbg_i, (rgba)&0xFF, (rgba>>8)&0xFF, (rgba>>16)&0xFF, (rgba>>24)&0xFF, - // (fadergba)&0xFF, (fadergba>>8)&0xFF, (fadergba>>16)&0xFF, (fadergba>>24)&0xFF); + // CONS_Debug(DBG_RENDER, "Creating Colormap: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", + // (rgba)&0xFF, (rgba>>8)&0xFF, (rgba>>16)&0xFF, (rgba>>24)&0xFF, + // (fadergba)&0xFF, (fadergba>>8)&0xFF, (fadergba>>16)&0xFF, (fadergba>>24)&0xFF); exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL); diff --git a/src/r_data.c b/src/r_data.c index ad27b442f..0e4a67e2d 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1328,6 +1328,7 @@ void R_ClearColormaps(void) // // R_CreateDefaultColormap() +// NOTE: The result colormap is not added to the extra_colormaps chain. You must do that yourself! // extracolormap_t *R_CreateDefaultColormap(boolean lighttable) { @@ -1368,6 +1369,7 @@ extracolormap_t *R_GetDefaultColormap(void) // // R_CopyColormap() +// NOTE: The result colormap is not added to the extra_colormaps chain. You must do that yourself! // extracolormap_t *R_CopyColormap(extracolormap_t *extra_colormap, boolean lighttable) { @@ -1455,6 +1457,50 @@ boolean R_CheckDefaultColormapValues(extracolormap_t *extra_colormap, boolean ch ); } +// +// R_GetExistingColormapByValues() +// NOTE: Returns NULL if no match is found +// +#ifdef EXTRACOLORMAPLUMPS +extracolormap_t *R_GetExistingColormapByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog, lumpnum_t lump) +#else +extracolormap_t *R_GetExistingColormapByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog) +#endif +{ + extracolormap_t *exc; + size_t dbg_i = 0; + + for (exc = extra_colormaps; exc; exc = exc->next) + { + if (rgba == exc->rgba + && fadergba == exc->fadergba + && fadestart == exc->fadestart + && fadeend == exc->fadeend + && fog == exc->fog +#ifdef EXTRACOLORMAPLUMPS + && (lump != LUMPERROR && lump == exc->lump) +#endif + ) + { + CONS_Debug(DBG_RENDER, "Found Colormap %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", + dbg_i, (rgba)&0xFF, (rgba>>8)&0xFF, (rgba>>16)&0xFF, (rgba>>24)&0xFF, + (fadergba)&0xFF, (fadergba>>8)&0xFF, (fadergba>>16)&0xFF, (fadergba>>24)&0xFF); + return exc; + } + dbg_i++; + } + return NULL; +} + +extracolormap_t *R_GetExistingColormap(extracolormap_t *extra_colormap) +{ +#ifdef EXTRACOLORMAPLUMPS + return R_GetExistingColormapByValues(extra_colormap->rgba, extra_colormap->fadergba, extra_colormap->fadestart, extra_colormap->fadeend, extra_colormap->fog, extra_colormap->lump); +else + return R_GetExistingColormapByValues(extra_colormap->rgba, extra_colormap->fadergba, extra_colormap->fadestart, extra_colormap->fadeend, extra_colormap->fog); +#endif +} + #ifdef EXTRACOLORMAPLUMPS extracolormap_t *R_ColormapForName(char *name) { @@ -1465,9 +1511,9 @@ extracolormap_t *R_ColormapForName(char *name) if (lump == LUMPERROR) I_Error("R_ColormapForName: Cannot find colormap lump %.8s\n", name); - for (exc = extra_colormaps; exc; exc = exc->next) - if (lump == exc->lump) - return exc; + exc = R_GetExistingColormapByValues(0, 0x19000000, 0, 31, 0, lump); + if (exc) + return exc; exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL); @@ -1645,8 +1691,6 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) boolean fog = false; INT32 rgba = 0, fadergba = 0x19000000; - size_t dbg_i = 0; - #define HEX2INT(x) (UINT32)(x >= '0' && x <= '9' ? x - '0' : x >= 'a' && x <= 'f' ? x - 'a' + 10 : x >= 'A' && x <= 'F' ? x - 'A' + 10 : 0) #define ALPHA2INT(x) (x >= 'a' && x <= 'z' ? x - 'a' : x >= 'A' && x <= 'Z' ? x - 'A' : x >= '0' && x <= '9' ? 25 : 0) @@ -1764,30 +1808,16 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) fadergba = cfr + (cfg << 8) + (cfb << 16) + (cfa << 24); // Look for existing colormaps - for (exc = extra_colormaps; exc; exc = exc->next) - { #ifdef EXTRACOLORMAPLUMPS - if (exc->lump != LUMPERROR) - { - dbg_i++; - continue; - } + exc = R_GetExistingColormapByValues(rgba, fadergba, fadestart, fadeend, fog, LUMPERROR); +#else + exc = R_GetExistingColormapByValues(rgba, fadergba, fadestart, fadeend, fog); #endif - if (rgba == exc->rgba - && fadergba == exc->fadergba - && fadestart == exc->fadestart - && fadeend == exc->fadeend - && fog == exc->fog) - { - CONS_Debug(DBG_RENDER, "R_CreateColormap: Found map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", - dbg_i, cr, cg, cb, ca, cfr, cfg, cfb, cfa); - return exc; - } - dbg_i++; - } + if (exc) + return exc; - CONS_Debug(DBG_RENDER, "R_CreateColormap: Creating map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", - dbg_i, cr, cg, cb, ca, cfr, cfg, cfb, cfa); + CONS_Debug(DBG_RENDER, "Creating Colormap: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", + cr, cg, cb, ca, cfr, cfg, cfb, cfa); extra_colormap = Z_Calloc(sizeof (*extra_colormap), PU_LEVEL, NULL); diff --git a/src/r_data.h b/src/r_data.h index fc6d71299..a2db8ba5c 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -110,6 +110,11 @@ extracolormap_t *R_GetDefaultColormap(void); extracolormap_t *R_CopyColormap(extracolormap_t *extra_colormap, boolean lighttable); void R_AddColormapToList(extracolormap_t *extra_colormap); boolean R_CheckDefaultColormapValues(extracolormap_t *extra_colormap, boolean checkrgba, boolean checkfadergba, boolean checkparams); +#ifdef EXTRACOLORMAPLUMPS +extracolormap_t *R_GetExistingColormapByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog, lumpnum_t lump); +#else +extracolormap_t *R_GetExistingColormapByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog); +#endif lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap); extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3); #ifdef EXTRACOLORMAPLUMPS From c920827032429c013e410881f12102c7179b5e6e Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 11 Sep 2018 15:50:12 -0400 Subject: [PATCH 050/132] Consolidate colormap matching into R_GetColormapFromList --- src/p_saveg.c | 30 +++---------------- src/r_data.c | 82 +++++++++++++++++++++++++++++++++++---------------- src/r_data.h | 6 ++++ 3 files changed, 66 insertions(+), 52 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 710c24821..b887b8a73 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -886,35 +886,13 @@ static void P_NetUnArchiveWorld(void) else { #endif - - for (exc = extra_colormaps; exc; exc = exc->next) - { -#ifdef EXTRACOLORMAPLUMPS - if (exc->lump != LUMPERROR) - { - //dbg_i++; - continue; - } -#endif - if (rgba == exc->rgba - && fadergba == exc->fadergba - && fadestart == exc->fadestart - && fadeend == exc->fadeend - && fog == exc->fog) - { - // CONS_Debug(DBG_RENDER, "P_NetUnArchiveWorld: Found map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", - // dbg_i, (rgba)&0xFF, (rgba>>8)&0xFF, (rgba>>16)&0xFF, (rgba>>24)&0xFF, - // (fadergba)&0xFF, (fadergba>>8)&0xFF, (fadergba>>16)&0xFF, (fadergba>>24)&0xFF); - break; - } - //dbg_i++; - } + exc = R_GetColormapFromListByValues(rgba, fadergba, fadestart, fadeend, fog); if (!exc) { - // CONS_Debug(DBG_RENDER, "P_NetUnArchiveWorld: Creating map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", - // dbg_i, (rgba)&0xFF, (rgba>>8)&0xFF, (rgba>>16)&0xFF, (rgba>>24)&0xFF, - // (fadergba)&0xFF, (fadergba>>8)&0xFF, (fadergba>>16)&0xFF, (fadergba>>24)&0xFF); + // CONS_Debug(DBG_RENDER, "Creating Colormap: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", + // (rgba)&0xFF, (rgba>>8)&0xFF, (rgba>>16)&0xFF, (rgba>>24)&0xFF, + // (fadergba)&0xFF, (fadergba>>8)&0xFF, (fadergba>>16)&0xFF, (fadergba>>24)&0xFF); exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL); diff --git a/src/r_data.c b/src/r_data.c index ad27b442f..e679f27ba 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1328,6 +1328,7 @@ void R_ClearColormaps(void) // // R_CreateDefaultColormap() +// NOTE: The result colormap is not added to the extra_colormaps chain. You must do that yourself! // extracolormap_t *R_CreateDefaultColormap(boolean lighttable) { @@ -1368,6 +1369,7 @@ extracolormap_t *R_GetDefaultColormap(void) // // R_CopyColormap() +// NOTE: The result colormap is not added to the extra_colormaps chain. You must do that yourself! // extracolormap_t *R_CopyColormap(extracolormap_t *extra_colormap, boolean lighttable) { @@ -1455,6 +1457,50 @@ boolean R_CheckDefaultColormapValues(extracolormap_t *extra_colormap, boolean ch ); } +// +// R_GetColormapFromListByValues() +// NOTE: Returns NULL if no match is found +// +#ifdef EXTRACOLORMAPLUMPS +extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog, lumpnum_t lump) +#else +extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog) +#endif +{ + extracolormap_t *exc; + size_t dbg_i = 0; + + for (exc = extra_colormaps; exc; exc = exc->next) + { + if (rgba == exc->rgba + && fadergba == exc->fadergba + && fadestart == exc->fadestart + && fadeend == exc->fadeend + && fog == exc->fog +#ifdef EXTRACOLORMAPLUMPS + && (lump != LUMPERROR && lump == exc->lump) +#endif + ) + { + CONS_Debug(DBG_RENDER, "Found Colormap %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", + dbg_i, (rgba)&0xFF, (rgba>>8)&0xFF, (rgba>>16)&0xFF, (rgba>>24)&0xFF, + (fadergba)&0xFF, (fadergba>>8)&0xFF, (fadergba>>16)&0xFF, (fadergba>>24)&0xFF); + return exc; + } + dbg_i++; + } + return NULL; +} + +extracolormap_t *R_GetColormapFromList(extracolormap_t *extra_colormap) +{ +#ifdef EXTRACOLORMAPLUMPS + return R_GetColormapFromListByValues(extra_colormap->rgba, extra_colormap->fadergba, extra_colormap->fadestart, extra_colormap->fadeend, extra_colormap->fog, extra_colormap->lump); +else + return R_GetColormapFromListByValues(extra_colormap->rgba, extra_colormap->fadergba, extra_colormap->fadestart, extra_colormap->fadeend, extra_colormap->fog); +#endif +} + #ifdef EXTRACOLORMAPLUMPS extracolormap_t *R_ColormapForName(char *name) { @@ -1465,9 +1511,9 @@ extracolormap_t *R_ColormapForName(char *name) if (lump == LUMPERROR) I_Error("R_ColormapForName: Cannot find colormap lump %.8s\n", name); - for (exc = extra_colormaps; exc; exc = exc->next) - if (lump == exc->lump) - return exc; + exc = R_GetColormapFromListByValues(0, 0x19000000, 0, 31, 0, lump); + if (exc) + return exc; exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL); @@ -1645,8 +1691,6 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) boolean fog = false; INT32 rgba = 0, fadergba = 0x19000000; - size_t dbg_i = 0; - #define HEX2INT(x) (UINT32)(x >= '0' && x <= '9' ? x - '0' : x >= 'a' && x <= 'f' ? x - 'a' + 10 : x >= 'A' && x <= 'F' ? x - 'A' + 10 : 0) #define ALPHA2INT(x) (x >= 'a' && x <= 'z' ? x - 'a' : x >= 'A' && x <= 'Z' ? x - 'A' : x >= '0' && x <= '9' ? 25 : 0) @@ -1764,30 +1808,16 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) fadergba = cfr + (cfg << 8) + (cfb << 16) + (cfa << 24); // Look for existing colormaps - for (exc = extra_colormaps; exc; exc = exc->next) - { #ifdef EXTRACOLORMAPLUMPS - if (exc->lump != LUMPERROR) - { - dbg_i++; - continue; - } + exc = R_GetColormapFromListByValues(rgba, fadergba, fadestart, fadeend, fog, LUMPERROR); +#else + exc = R_GetColormapFromListByValues(rgba, fadergba, fadestart, fadeend, fog); #endif - if (rgba == exc->rgba - && fadergba == exc->fadergba - && fadestart == exc->fadestart - && fadeend == exc->fadeend - && fog == exc->fog) - { - CONS_Debug(DBG_RENDER, "R_CreateColormap: Found map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", - dbg_i, cr, cg, cb, ca, cfr, cfg, cfb, cfa); - return exc; - } - dbg_i++; - } + if (exc) + return exc; - CONS_Debug(DBG_RENDER, "R_CreateColormap: Creating map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", - dbg_i, cr, cg, cb, ca, cfr, cfg, cfb, cfa); + CONS_Debug(DBG_RENDER, "Creating Colormap: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", + cr, cg, cb, ca, cfr, cfg, cfb, cfa); extra_colormap = Z_Calloc(sizeof (*extra_colormap), PU_LEVEL, NULL); diff --git a/src/r_data.h b/src/r_data.h index fc6d71299..17d85fd8b 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -110,6 +110,12 @@ extracolormap_t *R_GetDefaultColormap(void); extracolormap_t *R_CopyColormap(extracolormap_t *extra_colormap, boolean lighttable); void R_AddColormapToList(extracolormap_t *extra_colormap); boolean R_CheckDefaultColormapValues(extracolormap_t *extra_colormap, boolean checkrgba, boolean checkfadergba, boolean checkparams); +#ifdef EXTRACOLORMAPLUMPS +extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog, lumpnum_t lump); +#else +extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog); +#endif +extracolormap_t *R_GetColormapFromList(extracolormap_t *extra_colormap); lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap); extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3); #ifdef EXTRACOLORMAPLUMPS From fb7ac4ccae6a345da7f716cbddde1eea737b06d1 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 11 Sep 2018 15:59:13 -0400 Subject: [PATCH 051/132] Ifdef typo --- src/r_data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_data.c b/src/r_data.c index e679f27ba..e08600cae 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1496,7 +1496,7 @@ extracolormap_t *R_GetColormapFromList(extracolormap_t *extra_colormap) { #ifdef EXTRACOLORMAPLUMPS return R_GetColormapFromListByValues(extra_colormap->rgba, extra_colormap->fadergba, extra_colormap->fadestart, extra_colormap->fadeend, extra_colormap->fog, extra_colormap->lump); -else +#else return R_GetColormapFromListByValues(extra_colormap->rgba, extra_colormap->fadergba, extra_colormap->fadestart, extra_colormap->fadeend, extra_colormap->fog); #endif } From 71ade23739a6eddce5b4c1c2d1b4210b4103a25d Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 11 Sep 2018 15:59:13 -0400 Subject: [PATCH 052/132] Ifdef typo --- src/r_data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_data.c b/src/r_data.c index e679f27ba..e08600cae 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1496,7 +1496,7 @@ extracolormap_t *R_GetColormapFromList(extracolormap_t *extra_colormap) { #ifdef EXTRACOLORMAPLUMPS return R_GetColormapFromListByValues(extra_colormap->rgba, extra_colormap->fadergba, extra_colormap->fadestart, extra_colormap->fadeend, extra_colormap->fog, extra_colormap->lump); -else +#else return R_GetColormapFromListByValues(extra_colormap->rgba, extra_colormap->fadergba, extra_colormap->fadestart, extra_colormap->fadeend, extra_colormap->fog); #endif } From bb6cf6a807f6946de1a8cfcc6b848fcec2daf351 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 11 Sep 2018 16:50:35 -0400 Subject: [PATCH 053/132] Added alpha-only, relative calc, and offset params to 447 Change Colormap --- src/p_spec.c | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index 21380584b..8d17c6de3 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3256,7 +3256,43 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) // This could even override existing colormaps I believe // -- Monster Iestyn 14/06/18 for (secnum = -1; (secnum = P_FindSectorFromLineTag(line, secnum)) >= 0 ;) - sectors[secnum].extra_colormap = line->frontsector->extra_colormap; + { + if (line->flags & ML_NOCLIMB) // set alpha only + { + if (sectors[secnum].extra_colormap) // does nothing without an existing colormap + { + extracolormap_t *dest_colormap = R_CopyColormap(sectors[secnum].extra_colormap, false); + INT16 alpha; + + // base rgba + alpha = (line->flags & ML_DONTPEGBOTTOM && line->sidenum[1] != 0xFFFF) ? + (sides[line->sidenum[1]].textureoffset >> FRACBITS) + : R_GetRgbaA(line->frontsector->extra_colormap->rgba); + if (line->flags & ML_EFFECT3) // relative calc + alpha = max(min(R_GetRgbaA(sectors[secnum].extra_colormap->rgba) + alpha, 25), 0); + dest_colormap->rgba = (dest_colormap->rgba & 0xFFFFFF) + (alpha << 24); + + // fade rgba + alpha = (line->flags & ML_DONTPEGBOTTOM && line->sidenum[1] != 0xFFFF) ? + (sides[line->sidenum[1]].rowoffset >> FRACBITS) + : R_GetRgbaA(line->frontsector->extra_colormap->fadergba); + if (line->flags & ML_EFFECT3) // relative calc + alpha = max(min(R_GetRgbaA(sectors[secnum].extra_colormap->fadergba) + alpha, 25), 0); + dest_colormap->fadergba = (dest_colormap->fadergba & 0xFFFFFF) + (alpha << 24); + + if (!(sectors[secnum].extra_colormap = R_GetColormapFromList(dest_colormap))) + { + dest_colormap->colormap = R_CreateLightTable(dest_colormap); + R_AddColormapToList(dest_colormap); + sectors[secnum].extra_colormap = dest_colormap; + } + else + memset(dest_colormap, 0, sizeof(*dest_colormap)); + } + } + else + sectors[secnum].extra_colormap = line->frontsector->extra_colormap; + } break; case 448: // Change skybox viewpoint/centerpoint From f703c195027c4c5c6b798ffb043ba5a50c591998 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 11 Sep 2018 17:06:44 -0400 Subject: [PATCH 054/132] Don't set sector's extra_colormap if we just made a default clone * Allow colormap parsing to proceed in p_setup always * Add R_CheckDefaultColormap * Add R_GetRgbaR/G/B/A macros --- src/p_setup.c | 30 +++-------------------- src/r_data.c | 68 ++++++++++++++++++++++++++++++++++----------------- src/r_data.h | 13 +++++++++- 3 files changed, 61 insertions(+), 50 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 0f4a267ad..498b9cb61 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1438,7 +1438,6 @@ static inline void P_LoadSideDefs(lumpnum_t lumpnum) static void P_LoadRawSideDefs2(void *data) { UINT16 i; - INT32 num; for (i = 0; i < numsides; i++) { @@ -1473,32 +1472,9 @@ static void P_LoadRawSideDefs2(void *data) case 447: // Change colormap of tagged sectors! -- Monster Iestyn 14/06/18 // SoM: R_CreateColormap will only create a colormap in software mode... // Perhaps we should just call it instead of doing the calculations here. - if (msd->toptexture[0] == '#' || msd->bottomtexture[0] == '#' - || (msd->toptexture[0] >= 'a' && msd->toptexture[0] <= 'z' && !msd->toptexture[1]) - || (msd->toptexture[0] >= 'A' && msd->toptexture[0] <= 'Z' && !msd->toptexture[1]) - || (msd->bottomtexture[0] >= 'a' && msd->bottomtexture[0] <= 'z' && !msd->bottomtexture[1]) - || (msd->bottomtexture[0] >= 'A' && msd->bottomtexture[0] <= 'Z' && !msd->bottomtexture[1]) - ) - { - sec->extra_colormap = sec->spawn_extra_colormap = R_CreateColormap(msd->toptexture, msd->midtexture, - msd->bottomtexture); - sd->toptexture = sd->bottomtexture = 0; - } - else - { - if ((num = R_CheckTextureNumForName(msd->toptexture)) == -1) - sd->toptexture = 0; - else - sd->toptexture = num; - if ((num = R_CheckTextureNumForName(msd->midtexture)) == -1) - sd->midtexture = 0; - else - sd->midtexture = num; - if ((num = R_CheckTextureNumForName(msd->bottomtexture)) == -1) - sd->bottomtexture = 0; - else - sd->bottomtexture = num; - } + sec->extra_colormap = sec->spawn_extra_colormap = R_CreateColormap(msd->toptexture, msd->midtexture, + msd->bottomtexture); + sd->toptexture = sd->midtexture = sd->bottomtexture = 0; break; case 413: // Change music diff --git a/src/r_data.c b/src/r_data.c index e08600cae..529507e9a 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1435,26 +1435,41 @@ void R_AddColormapToList(extracolormap_t *extra_colormap) } // -// R_CheckDefaultColormap() +// R_CheckDefaultColormapByValues() // -boolean R_CheckDefaultColormapValues(extracolormap_t *extra_colormap, boolean checkrgba, boolean checkfadergba, boolean checkparams) +#ifdef EXTRACOLORMAPLUMPS +boolean R_CheckDefaultColormapByValues(boolean checkrgba, boolean checkfadergba, boolean checkparams, + INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog, lumpnum_t lump) +#else +boolean R_CheckDefaultColormapByValues(boolean checkrgba, boolean checkfadergba, boolean checkparams, + INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog) +#endif +{ + return ( + (!checkparams ? true : + (fadestart == 0 + && fadeend == 31 + && !fog) + ) + && (!checkrgba ? true : rgba == 0) + && (!checkfadergba ? true : fadergba == 0x19000000) +#ifdef EXTRACOLORMAPLUMPS + && lump == LUMPERROR + && extra_colormap->lumpname[0] == 0 +#endif + ); +} + +boolean R_CheckDefaultColormap(extracolormap_t *extra_colormap, boolean checkrgba, boolean checkfadergba, boolean checkparams) { if (!extra_colormap) return true; - else - return ( - (!checkparams ? true : - (extra_colormap->fadestart == 0 - && extra_colormap->fadeend == 31 - && !extra_colormap->fog) - ) - && (!checkrgba ? true : extra_colormap->rgba == 0) - && (!checkfadergba ? true : extra_colormap->fadergba == 0x19000000) + #ifdef EXTRACOLORMAPLUMPS - && extra_colormap->lump == LUMPERROR - && extra_colormap->lumpname[0] == 0 + return R_CheckDefaultColormapByValues(checkrgba, checkfadergba, checkparams, extra_colormap->rgba, extra_colormap->fadergba, extra_colormap->fadestart, extra_colormap->fadeend, extra_colormap->fog, extra_colormap->lump); +#else + return R_CheckDefaultColormapByValues(checkrgba, checkfadergba, checkparams, extra_colormap->rgba, extra_colormap->fadergba, extra_colormap->fadestart, extra_colormap->fadeend, extra_colormap->fog); #endif - ); } // @@ -1557,14 +1572,14 @@ lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap) double cmaskr, cmaskg, cmaskb, cdestr, cdestg, cdestb; double maskamt = 0, othermask = 0; - UINT8 cr = (extra_colormap->rgba) & 0xFF, - cg = (extra_colormap->rgba >> 8) & 0xFF, - cb = (extra_colormap->rgba >> 16) & 0xFF, - ca = (extra_colormap->rgba >> 24) & 0xFF, - cfr = (extra_colormap->fadergba) & 0xFF, - cfg = (extra_colormap->fadergba >> 8) & 0xFF, - cfb = (extra_colormap->fadergba >> 16) & 0xFF; -// cfa = (extra_colormap->fadergba >> 24) & 0xFF; // unused in software + UINT8 cr = R_GetRgbaR(extra_colormap->rgba), + cg = R_GetRgbaG(extra_colormap->rgba), + cb = R_GetRgbaB(extra_colormap->rgba), + ca = R_GetRgbaA(extra_colormap->rgba), + cfr = R_GetRgbaR(extra_colormap->fadergba), + cfg = R_GetRgbaG(extra_colormap->fadergba), + cfb = R_GetRgbaB(extra_colormap->fadergba); +// cfa = R_GetRgbaA(extra_colormap->fadergba); // unused in software UINT8 fadestart = extra_colormap->fadestart, fadedist = extra_colormap->fadeend - extra_colormap->fadestart; @@ -1807,6 +1822,15 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) rgba = cr + (cg << 8) + (cb << 16) + (ca << 24); fadergba = cfr + (cfg << 8) + (cfb << 16) + (cfa << 24); + // Did we just make a default colormap? +#ifdef EXTRACOLORMAPLUMPS + if (R_CheckDefaultColormapByValues(true, true, true, rgba, fadergba, fadestart, fadeend, fog, LUMPERROR)) + return NULL; +#else + if (R_CheckDefaultColormapByValues(true, true, true, rgba, fadergba, fadestart, fadeend, fog)) + return NULL; +#endif + // Look for existing colormaps #ifdef EXTRACOLORMAPLUMPS exc = R_GetColormapFromListByValues(rgba, fadergba, fadestart, fadeend, fog, LUMPERROR); diff --git a/src/r_data.h b/src/r_data.h index 17d85fd8b..ee497d155 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -109,13 +109,19 @@ extracolormap_t *R_CreateDefaultColormap(boolean lighttable); extracolormap_t *R_GetDefaultColormap(void); extracolormap_t *R_CopyColormap(extracolormap_t *extra_colormap, boolean lighttable); void R_AddColormapToList(extracolormap_t *extra_colormap); -boolean R_CheckDefaultColormapValues(extracolormap_t *extra_colormap, boolean checkrgba, boolean checkfadergba, boolean checkparams); + #ifdef EXTRACOLORMAPLUMPS +boolean R_CheckDefaultColormapByValues(boolean checkrgba, boolean checkfadergba, boolean checkparams, + INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog, lumpnum_t lump); extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog, lumpnum_t lump); #else +boolean R_CheckDefaultColormapByValues(boolean checkrgba, boolean checkfadergba, boolean checkparams, + INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog); extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog); #endif +boolean R_CheckDefaultColormap(extracolormap_t *extra_colormap, boolean checkrgba, boolean checkfadergba, boolean checkparams); extracolormap_t *R_GetColormapFromList(extracolormap_t *extra_colormap); + lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap); extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3); #ifdef EXTRACOLORMAPLUMPS @@ -123,6 +129,11 @@ extracolormap_t *R_ColormapForName(char *name); const char *R_NameForColormap(extracolormap_t *extra_colormap); #endif +#define R_GetRgbaR(rgba) (rgba & 0xFF) +#define R_GetRgbaG(rgba) ((rgba >> 8) & 0xFF) +#define R_GetRgbaB(rgba) ((rgba >> 16) & 0xFF) +#define R_GetRgbaA(rgba) ((rgba >> 24) & 0xFF) + extern INT32 numtextures; #endif From 5523fc3a8d43e69dcc77f55b4d762c3c738c6931 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 11 Sep 2018 17:07:50 -0400 Subject: [PATCH 055/132] Account for NULL colormaps in alpha-only code 447 --- src/p_spec.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 8d17c6de3..adcd46462 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3267,7 +3267,9 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) // base rgba alpha = (line->flags & ML_DONTPEGBOTTOM && line->sidenum[1] != 0xFFFF) ? (sides[line->sidenum[1]].textureoffset >> FRACBITS) - : R_GetRgbaA(line->frontsector->extra_colormap->rgba); + : line->frontsector->extra_colormap ? + R_GetRgbaA(line->frontsector->extra_colormap->rgba) + : 0; if (line->flags & ML_EFFECT3) // relative calc alpha = max(min(R_GetRgbaA(sectors[secnum].extra_colormap->rgba) + alpha, 25), 0); dest_colormap->rgba = (dest_colormap->rgba & 0xFFFFFF) + (alpha << 24); @@ -3275,7 +3277,9 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) // fade rgba alpha = (line->flags & ML_DONTPEGBOTTOM && line->sidenum[1] != 0xFFFF) ? (sides[line->sidenum[1]].rowoffset >> FRACBITS) - : R_GetRgbaA(line->frontsector->extra_colormap->fadergba); + : line->frontsector->extra_colormap ? + R_GetRgbaA(line->frontsector->extra_colormap->fadergba) + : 0; if (line->flags & ML_EFFECT3) // relative calc alpha = max(min(R_GetRgbaA(sectors[secnum].extra_colormap->fadergba) + alpha, 25), 0); dest_colormap->fadergba = (dest_colormap->fadergba & 0xFFFFFF) + (alpha << 24); From 5975f261773418cd6eba4247582798e7d11ce0ec Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 11 Sep 2018 17:06:44 -0400 Subject: [PATCH 056/132] Don't set sector's extra_colormap if we just made a default clone * Allow colormap parsing to proceed in p_setup always * Add R_CheckDefaultColormap * Add R_GetRgbaR/G/B/A macros --- src/p_setup.c | 30 +++-------------------- src/r_data.c | 68 ++++++++++++++++++++++++++++++++++----------------- src/r_data.h | 13 +++++++++- 3 files changed, 61 insertions(+), 50 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 77d53812c..edde5e701 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1438,7 +1438,6 @@ static inline void P_LoadSideDefs(lumpnum_t lumpnum) static void P_LoadRawSideDefs2(void *data) { UINT16 i; - INT32 num; for (i = 0; i < numsides; i++) { @@ -1472,32 +1471,9 @@ static void P_LoadRawSideDefs2(void *data) case 606: //SoM: 4/4/2000: Just colormap transfer // SoM: R_CreateColormap will only create a colormap in software mode... // Perhaps we should just call it instead of doing the calculations here. - if (msd->toptexture[0] == '#' || msd->bottomtexture[0] == '#' - || (msd->toptexture[0] >= 'a' && msd->toptexture[0] <= 'z' && !msd->toptexture[1]) - || (msd->toptexture[0] >= 'A' && msd->toptexture[0] <= 'Z' && !msd->toptexture[1]) - || (msd->bottomtexture[0] >= 'a' && msd->bottomtexture[0] <= 'z' && !msd->bottomtexture[1]) - || (msd->bottomtexture[0] >= 'A' && msd->bottomtexture[0] <= 'Z' && !msd->bottomtexture[1]) - ) - { - sec->extra_colormap = sec->spawn_extra_colormap = R_CreateColormap(msd->toptexture, msd->midtexture, - msd->bottomtexture); - sd->toptexture = sd->bottomtexture = 0; - } - else - { - if ((num = R_CheckTextureNumForName(msd->toptexture)) == -1) - sd->toptexture = 0; - else - sd->toptexture = num; - if ((num = R_CheckTextureNumForName(msd->midtexture)) == -1) - sd->midtexture = 0; - else - sd->midtexture = num; - if ((num = R_CheckTextureNumForName(msd->bottomtexture)) == -1) - sd->bottomtexture = 0; - else - sd->bottomtexture = num; - } + sec->extra_colormap = sec->spawn_extra_colormap = R_CreateColormap(msd->toptexture, msd->midtexture, + msd->bottomtexture); + sd->toptexture = sd->midtexture = sd->bottomtexture = 0; break; case 413: // Change music diff --git a/src/r_data.c b/src/r_data.c index e08600cae..529507e9a 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1435,26 +1435,41 @@ void R_AddColormapToList(extracolormap_t *extra_colormap) } // -// R_CheckDefaultColormap() +// R_CheckDefaultColormapByValues() // -boolean R_CheckDefaultColormapValues(extracolormap_t *extra_colormap, boolean checkrgba, boolean checkfadergba, boolean checkparams) +#ifdef EXTRACOLORMAPLUMPS +boolean R_CheckDefaultColormapByValues(boolean checkrgba, boolean checkfadergba, boolean checkparams, + INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog, lumpnum_t lump) +#else +boolean R_CheckDefaultColormapByValues(boolean checkrgba, boolean checkfadergba, boolean checkparams, + INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog) +#endif +{ + return ( + (!checkparams ? true : + (fadestart == 0 + && fadeend == 31 + && !fog) + ) + && (!checkrgba ? true : rgba == 0) + && (!checkfadergba ? true : fadergba == 0x19000000) +#ifdef EXTRACOLORMAPLUMPS + && lump == LUMPERROR + && extra_colormap->lumpname[0] == 0 +#endif + ); +} + +boolean R_CheckDefaultColormap(extracolormap_t *extra_colormap, boolean checkrgba, boolean checkfadergba, boolean checkparams) { if (!extra_colormap) return true; - else - return ( - (!checkparams ? true : - (extra_colormap->fadestart == 0 - && extra_colormap->fadeend == 31 - && !extra_colormap->fog) - ) - && (!checkrgba ? true : extra_colormap->rgba == 0) - && (!checkfadergba ? true : extra_colormap->fadergba == 0x19000000) + #ifdef EXTRACOLORMAPLUMPS - && extra_colormap->lump == LUMPERROR - && extra_colormap->lumpname[0] == 0 + return R_CheckDefaultColormapByValues(checkrgba, checkfadergba, checkparams, extra_colormap->rgba, extra_colormap->fadergba, extra_colormap->fadestart, extra_colormap->fadeend, extra_colormap->fog, extra_colormap->lump); +#else + return R_CheckDefaultColormapByValues(checkrgba, checkfadergba, checkparams, extra_colormap->rgba, extra_colormap->fadergba, extra_colormap->fadestart, extra_colormap->fadeend, extra_colormap->fog); #endif - ); } // @@ -1557,14 +1572,14 @@ lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap) double cmaskr, cmaskg, cmaskb, cdestr, cdestg, cdestb; double maskamt = 0, othermask = 0; - UINT8 cr = (extra_colormap->rgba) & 0xFF, - cg = (extra_colormap->rgba >> 8) & 0xFF, - cb = (extra_colormap->rgba >> 16) & 0xFF, - ca = (extra_colormap->rgba >> 24) & 0xFF, - cfr = (extra_colormap->fadergba) & 0xFF, - cfg = (extra_colormap->fadergba >> 8) & 0xFF, - cfb = (extra_colormap->fadergba >> 16) & 0xFF; -// cfa = (extra_colormap->fadergba >> 24) & 0xFF; // unused in software + UINT8 cr = R_GetRgbaR(extra_colormap->rgba), + cg = R_GetRgbaG(extra_colormap->rgba), + cb = R_GetRgbaB(extra_colormap->rgba), + ca = R_GetRgbaA(extra_colormap->rgba), + cfr = R_GetRgbaR(extra_colormap->fadergba), + cfg = R_GetRgbaG(extra_colormap->fadergba), + cfb = R_GetRgbaB(extra_colormap->fadergba); +// cfa = R_GetRgbaA(extra_colormap->fadergba); // unused in software UINT8 fadestart = extra_colormap->fadestart, fadedist = extra_colormap->fadeend - extra_colormap->fadestart; @@ -1807,6 +1822,15 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) rgba = cr + (cg << 8) + (cb << 16) + (ca << 24); fadergba = cfr + (cfg << 8) + (cfb << 16) + (cfa << 24); + // Did we just make a default colormap? +#ifdef EXTRACOLORMAPLUMPS + if (R_CheckDefaultColormapByValues(true, true, true, rgba, fadergba, fadestart, fadeend, fog, LUMPERROR)) + return NULL; +#else + if (R_CheckDefaultColormapByValues(true, true, true, rgba, fadergba, fadestart, fadeend, fog)) + return NULL; +#endif + // Look for existing colormaps #ifdef EXTRACOLORMAPLUMPS exc = R_GetColormapFromListByValues(rgba, fadergba, fadestart, fadeend, fog, LUMPERROR); diff --git a/src/r_data.h b/src/r_data.h index 17d85fd8b..ee497d155 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -109,13 +109,19 @@ extracolormap_t *R_CreateDefaultColormap(boolean lighttable); extracolormap_t *R_GetDefaultColormap(void); extracolormap_t *R_CopyColormap(extracolormap_t *extra_colormap, boolean lighttable); void R_AddColormapToList(extracolormap_t *extra_colormap); -boolean R_CheckDefaultColormapValues(extracolormap_t *extra_colormap, boolean checkrgba, boolean checkfadergba, boolean checkparams); + #ifdef EXTRACOLORMAPLUMPS +boolean R_CheckDefaultColormapByValues(boolean checkrgba, boolean checkfadergba, boolean checkparams, + INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog, lumpnum_t lump); extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog, lumpnum_t lump); #else +boolean R_CheckDefaultColormapByValues(boolean checkrgba, boolean checkfadergba, boolean checkparams, + INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog); extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog); #endif +boolean R_CheckDefaultColormap(extracolormap_t *extra_colormap, boolean checkrgba, boolean checkfadergba, boolean checkparams); extracolormap_t *R_GetColormapFromList(extracolormap_t *extra_colormap); + lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap); extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3); #ifdef EXTRACOLORMAPLUMPS @@ -123,6 +129,11 @@ extracolormap_t *R_ColormapForName(char *name); const char *R_NameForColormap(extracolormap_t *extra_colormap); #endif +#define R_GetRgbaR(rgba) (rgba & 0xFF) +#define R_GetRgbaG(rgba) ((rgba >> 8) & 0xFF) +#define R_GetRgbaB(rgba) ((rgba >> 16) & 0xFF) +#define R_GetRgbaA(rgba) ((rgba >> 24) & 0xFF) + extern INT32 numtextures; #endif From 548f02eea14ab963fa2e4519740c927bef2ae3f5 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 11 Sep 2018 17:30:43 -0400 Subject: [PATCH 057/132] Extra macros R_GetRgbaRGB; R_PutRgbaR/G/B/A/RGB/RGBA --- src/r_data.c | 4 ++-- src/r_data.h | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/r_data.c b/src/r_data.c index 529507e9a..e0899e4cf 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1819,8 +1819,8 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) // Pack rgba values into combined var // OpenGL also uses this instead of lighttables for rendering - rgba = cr + (cg << 8) + (cb << 16) + (ca << 24); - fadergba = cfr + (cfg << 8) + (cfb << 16) + (cfa << 24); + rgba = R_PutRgbaRGBA(cr, cg, cb, ca); + fadergba = R_PutRgbaRGBA(cfr, cfg, cfb, cfa); // Did we just make a default colormap? #ifdef EXTRACOLORMAPLUMPS diff --git a/src/r_data.h b/src/r_data.h index ee497d155..d980e9c56 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -133,6 +133,13 @@ const char *R_NameForColormap(extracolormap_t *extra_colormap); #define R_GetRgbaG(rgba) ((rgba >> 8) & 0xFF) #define R_GetRgbaB(rgba) ((rgba >> 16) & 0xFF) #define R_GetRgbaA(rgba) ((rgba >> 24) & 0xFF) +#define R_GetRgbaRGB(rgba) (rgba & 0xFFFFFF) +#define R_PutRgbaR(r) (r) +#define R_PutRgbaG(g) (g << 8) +#define R_PutRgbaB(b) (b << 16) +#define R_PutRgbaA(a) (a << 24) +#define R_PutRgbaRGB(r, g, b) (R_PutRgbaR(r) + R_PutRgbaG(g) + R_PutRgbaB(b)) +#define R_PutRgbaRGBA(r, g, b, a) (R_PutRgbaRGB(r, g, b) + R_PutRgbaA(a)) extern INT32 numtextures; From b9e4cd40ca45936428467dcf7eaa7eb31679d946 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 11 Sep 2018 17:32:43 -0400 Subject: [PATCH 058/132] Use RGB/RGBA macros in 447 code --- src/p_spec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index adcd46462..f119c3e2f 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3272,7 +3272,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) : 0; if (line->flags & ML_EFFECT3) // relative calc alpha = max(min(R_GetRgbaA(sectors[secnum].extra_colormap->rgba) + alpha, 25), 0); - dest_colormap->rgba = (dest_colormap->rgba & 0xFFFFFF) + (alpha << 24); + dest_colormap->rgba = R_GetRgbaRGB(dest_colormap->rgba) + R_PutRgbaA(alpha); // fade rgba alpha = (line->flags & ML_DONTPEGBOTTOM && line->sidenum[1] != 0xFFFF) ? @@ -3282,7 +3282,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) : 0; if (line->flags & ML_EFFECT3) // relative calc alpha = max(min(R_GetRgbaA(sectors[secnum].extra_colormap->fadergba) + alpha, 25), 0); - dest_colormap->fadergba = (dest_colormap->fadergba & 0xFFFFFF) + (alpha << 24); + dest_colormap->fadergba = R_GetRgbaRGB(dest_colormap->fadergba) + R_PutRgbaA(alpha); if (!(sectors[secnum].extra_colormap = R_GetColormapFromList(dest_colormap))) { From a1a05c99721eb65da73ec822f3e32de97dd23112 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 11 Sep 2018 19:11:50 -0400 Subject: [PATCH 059/132] Add relative color change to 447 --- src/p_spec.c | 85 +++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 61 insertions(+), 24 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index f119c3e2f..4a23902c7 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3257,41 +3257,78 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) // -- Monster Iestyn 14/06/18 for (secnum = -1; (secnum = P_FindSectorFromLineTag(line, secnum)) >= 0 ;) { - if (line->flags & ML_NOCLIMB) // set alpha only + if (line->flags & ML_EFFECT3) // relative calc { if (sectors[secnum].extra_colormap) // does nothing without an existing colormap { - extracolormap_t *dest_colormap = R_CopyColormap(sectors[secnum].extra_colormap, false); - INT16 alpha; + extracolormap_t *target_colormap = R_CopyColormap(sectors[secnum].extra_colormap, false); + extracolormap_t *source_colormap = line->frontsector->extra_colormap ? line->frontsector->extra_colormap + : R_GetDefaultColormap(); + + INT16 red, green, blue, alpha; // base rgba - alpha = (line->flags & ML_DONTPEGBOTTOM && line->sidenum[1] != 0xFFFF) ? - (sides[line->sidenum[1]].textureoffset >> FRACBITS) - : line->frontsector->extra_colormap ? - R_GetRgbaA(line->frontsector->extra_colormap->rgba) - : 0; - if (line->flags & ML_EFFECT3) // relative calc - alpha = max(min(R_GetRgbaA(sectors[secnum].extra_colormap->rgba) + alpha, 25), 0); - dest_colormap->rgba = R_GetRgbaRGB(dest_colormap->rgba) + R_PutRgbaA(alpha); + red = max(min( + R_GetRgbaR(target_colormap->rgba) + + ((line->flags & ML_EFFECT1) ? -1 : 1) // subtract R + * R_GetRgbaR(source_colormap->rgba) + , 255), 0); + + green = max(min( + R_GetRgbaG(target_colormap->rgba) + + ((line->flags & ML_NOCLIMB) ? -1 : 1) // subtract G + * R_GetRgbaG(source_colormap->rgba) + , 255), 0); + + blue = max(min( + R_GetRgbaB(target_colormap->rgba) + + ((line->flags & ML_EFFECT2) ? -1 : 1) // subtract B + * R_GetRgbaB(source_colormap->rgba) + , 255), 0); + + alpha = (line->flags & ML_DONTPEGBOTTOM) ? // front (or back!) X offset; needed to subtract A + (sides[line->sidenum[line->sidenum[1] != 0xFFFF ? 1 : 0]].textureoffset >> FRACBITS) + : R_GetRgbaA(source_colormap->rgba); + alpha = max(min(R_GetRgbaA(target_colormap->rgba) + alpha, 25), 0); + + target_colormap->rgba = R_PutRgbaRGBA(red, green, blue, alpha); // fade rgba - alpha = (line->flags & ML_DONTPEGBOTTOM && line->sidenum[1] != 0xFFFF) ? - (sides[line->sidenum[1]].rowoffset >> FRACBITS) - : line->frontsector->extra_colormap ? - R_GetRgbaA(line->frontsector->extra_colormap->fadergba) - : 0; - if (line->flags & ML_EFFECT3) // relative calc - alpha = max(min(R_GetRgbaA(sectors[secnum].extra_colormap->fadergba) + alpha, 25), 0); - dest_colormap->fadergba = R_GetRgbaRGB(dest_colormap->fadergba) + R_PutRgbaA(alpha); + red = max(min( + R_GetRgbaR(target_colormap->fadergba) + + ((line->flags & ML_EFFECT1) ? -1 : 1) // subtract R + * R_GetRgbaR(source_colormap->fadergba) + , 255), 0); - if (!(sectors[secnum].extra_colormap = R_GetColormapFromList(dest_colormap))) + green = max(min( + R_GetRgbaG(target_colormap->fadergba) + + ((line->flags & ML_NOCLIMB) ? -1 : 1) // subtract G + * R_GetRgbaG(source_colormap->fadergba) + , 255), 0); + + blue = max(min( + R_GetRgbaB(target_colormap->fadergba) + + ((line->flags & ML_EFFECT2) ? -1 : 1) // subtract B + * R_GetRgbaB(source_colormap->fadergba) + , 255), 0); + + alpha = (line->flags & ML_DONTPEGBOTTOM) ? // front (or back!) Y offset; needed to subtract A + (sides[line->sidenum[line->sidenum[1] != 0xFFFF ? 1 : 0]].rowoffset >> FRACBITS) + : R_GetRgbaA(source_colormap->fadergba); + if (alpha == 25) + alpha = 0; // HACK: fadergba A defaults at 25, so don't add anything in this case + alpha = max(min(R_GetRgbaA(target_colormap->fadergba) + alpha, 25), 0); + + target_colormap->fadergba = R_PutRgbaRGBA(red, green, blue, alpha); + + if (!(sectors[secnum].extra_colormap = R_GetColormapFromList(target_colormap))) { - dest_colormap->colormap = R_CreateLightTable(dest_colormap); - R_AddColormapToList(dest_colormap); - sectors[secnum].extra_colormap = dest_colormap; + target_colormap->colormap = R_CreateLightTable(target_colormap); + R_AddColormapToList(target_colormap); + sectors[secnum].extra_colormap = target_colormap; } else - memset(dest_colormap, 0, sizeof(*dest_colormap)); + memset(target_colormap, 0, sizeof(*target_colormap)); } } else From 0fb594ad5829274ddff998cb393d2c1af07bd403 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 11 Sep 2018 21:02:58 -0400 Subject: [PATCH 060/132] R_AddColormaps method --- src/r_data.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/r_data.h | 5 +++ 2 files changed, 91 insertions(+) diff --git a/src/r_data.c b/src/r_data.c index 949a842cc..03de15d85 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1876,6 +1876,92 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) return extra_colormap; } +// +// R_AddColormaps() +// NOTE: The result colormap DOES get added to the extra_colormaps chain! +// +extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *exc_addend, + boolean subR, boolean subG, boolean subB, boolean subA, + boolean subFadeR, boolean subFadeG, boolean subFadeB, boolean subFadeA, + boolean useAltAlpha, INT16 altAlpha, INT16 altFadeAlpha, + boolean lighttable) +{ + extracolormap_t *exc; + + // exc_augend is added (or subtracted) onto by exc_addend + // In Rennaisance times, the first number was considered the augend, the second number the addend + // But since the commutative property was discovered, today they're both called addends! + // So let's be Olde English for a hot second. + + exc_augend = R_CopyColormap(exc_augend, false); + if(!exc_addend) + exc_addend = R_GetDefaultColormap(); + + INT16 red, green, blue, alpha; + + // base rgba + red = max(min( + R_GetRgbaR(exc_augend->rgba) + + (subR ? -1 : 1) // subtract R + * R_GetRgbaR(exc_addend->rgba) + , 255), 0); + + green = max(min( + R_GetRgbaG(exc_augend->rgba) + + (subG ? -1 : 1) // subtract G + * R_GetRgbaG(exc_addend->rgba) + , 255), 0); + + blue = max(min( + R_GetRgbaB(exc_augend->rgba) + + (subB ? -1 : 1) // subtract B + * R_GetRgbaB(exc_addend->rgba) + , 255), 0); + + alpha = useAltAlpha ? altAlpha : R_GetRgbaA(exc_addend->rgba); + alpha = max(min(R_GetRgbaA(exc_augend->rgba) + (subA ? -1 : 1) * alpha, 25), 0); + + exc_augend->rgba = R_PutRgbaRGBA(red, green, blue, alpha); + + // fade rgba + red = max(min( + R_GetRgbaR(exc_augend->fadergba) + + (subFadeR ? -1 : 1) // subtract R + * R_GetRgbaR(exc_addend->fadergba) + , 255), 0); + + green = max(min( + R_GetRgbaG(exc_augend->fadergba) + + (subFadeG ? -1 : 1) // subtract G + * R_GetRgbaG(exc_addend->fadergba) + , 255), 0); + + blue = max(min( + R_GetRgbaB(exc_augend->fadergba) + + (subFadeB ? -1 : 1) // subtract B + * R_GetRgbaB(exc_addend->fadergba) + , 255), 0); + + alpha = useAltAlpha ? altFadeAlpha : R_GetRgbaA(exc_addend->fadergba); + if (alpha == 25) + alpha = 0; // HACK: fadergba A defaults at 25, so don't add anything in this case + alpha = max(min(R_GetRgbaA(exc_augend->fadergba) + (subFadeA ? -1 : 1) * alpha, 25), 0); + + exc_augend->fadergba = R_PutRgbaRGBA(red, green, blue, alpha); + + if (!(exc = R_GetColormapFromList(exc_augend))) + { + exc_augend->colormap = lighttable ? R_CreateLightTable(exc_augend) : NULL; + R_AddColormapToList(exc_augend); + return exc_augend; + } + else + { + Z_Free(exc_augend); + return exc; + } +} + // Thanks to quake2 source! // utils3/qdata/images.c static UINT8 NearestColor(UINT8 r, UINT8 g, UINT8 b) diff --git a/src/r_data.h b/src/r_data.h index d980e9c56..6f8d08120 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -124,6 +124,11 @@ extracolormap_t *R_GetColormapFromList(extracolormap_t *extra_colormap); lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap); extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3); +extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *exc_addend, + boolean subR, boolean subG, boolean subB, boolean subA, + boolean subFadeR, boolean subFadeG, boolean subFadeB, boolean subFadeA, + boolean useAltAlpha, INT16 altAlpha, INT16 altFadeAlpha, + boolean lighttable); #ifdef EXTRACOLORMAPLUMPS extracolormap_t *R_ColormapForName(char *name); const char *R_NameForColormap(extracolormap_t *extra_colormap); From 54669a6cc83fca0b8793e867113cc16e3bb8ee40 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 11 Sep 2018 21:03:13 -0400 Subject: [PATCH 061/132] Use R_AddColormaps method in 447 relative calc --- src/p_spec.c | 87 +++++++++------------------------------------------- 1 file changed, 14 insertions(+), 73 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 4a23902c7..2c607f74e 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3258,79 +3258,20 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) for (secnum = -1; (secnum = P_FindSectorFromLineTag(line, secnum)) >= 0 ;) { if (line->flags & ML_EFFECT3) // relative calc - { - if (sectors[secnum].extra_colormap) // does nothing without an existing colormap - { - extracolormap_t *target_colormap = R_CopyColormap(sectors[secnum].extra_colormap, false); - extracolormap_t *source_colormap = line->frontsector->extra_colormap ? line->frontsector->extra_colormap - : R_GetDefaultColormap(); - - INT16 red, green, blue, alpha; - - // base rgba - red = max(min( - R_GetRgbaR(target_colormap->rgba) - + ((line->flags & ML_EFFECT1) ? -1 : 1) // subtract R - * R_GetRgbaR(source_colormap->rgba) - , 255), 0); - - green = max(min( - R_GetRgbaG(target_colormap->rgba) - + ((line->flags & ML_NOCLIMB) ? -1 : 1) // subtract G - * R_GetRgbaG(source_colormap->rgba) - , 255), 0); - - blue = max(min( - R_GetRgbaB(target_colormap->rgba) - + ((line->flags & ML_EFFECT2) ? -1 : 1) // subtract B - * R_GetRgbaB(source_colormap->rgba) - , 255), 0); - - alpha = (line->flags & ML_DONTPEGBOTTOM) ? // front (or back!) X offset; needed to subtract A - (sides[line->sidenum[line->sidenum[1] != 0xFFFF ? 1 : 0]].textureoffset >> FRACBITS) - : R_GetRgbaA(source_colormap->rgba); - alpha = max(min(R_GetRgbaA(target_colormap->rgba) + alpha, 25), 0); - - target_colormap->rgba = R_PutRgbaRGBA(red, green, blue, alpha); - - // fade rgba - red = max(min( - R_GetRgbaR(target_colormap->fadergba) - + ((line->flags & ML_EFFECT1) ? -1 : 1) // subtract R - * R_GetRgbaR(source_colormap->fadergba) - , 255), 0); - - green = max(min( - R_GetRgbaG(target_colormap->fadergba) - + ((line->flags & ML_NOCLIMB) ? -1 : 1) // subtract G - * R_GetRgbaG(source_colormap->fadergba) - , 255), 0); - - blue = max(min( - R_GetRgbaB(target_colormap->fadergba) - + ((line->flags & ML_EFFECT2) ? -1 : 1) // subtract B - * R_GetRgbaB(source_colormap->fadergba) - , 255), 0); - - alpha = (line->flags & ML_DONTPEGBOTTOM) ? // front (or back!) Y offset; needed to subtract A - (sides[line->sidenum[line->sidenum[1] != 0xFFFF ? 1 : 0]].rowoffset >> FRACBITS) - : R_GetRgbaA(source_colormap->fadergba); - if (alpha == 25) - alpha = 0; // HACK: fadergba A defaults at 25, so don't add anything in this case - alpha = max(min(R_GetRgbaA(target_colormap->fadergba) + alpha, 25), 0); - - target_colormap->fadergba = R_PutRgbaRGBA(red, green, blue, alpha); - - if (!(sectors[secnum].extra_colormap = R_GetColormapFromList(target_colormap))) - { - target_colormap->colormap = R_CreateLightTable(target_colormap); - R_AddColormapToList(target_colormap); - sectors[secnum].extra_colormap = target_colormap; - } - else - memset(target_colormap, 0, sizeof(*target_colormap)); - } - } + sectors[secnum].extra_colormap = R_AddColormaps( + sectors[secnum].extra_colormap, line->frontsector->extra_colormap, + line->flags & ML_EFFECT1, // subtract R + line->flags & ML_NOCLIMB, // subtract G + line->flags & ML_EFFECT2, // subtract B + false, // subtract A (no flag for this, just pass negative alpha) + line->flags & ML_EFFECT1, // subtract FadeR + line->flags & ML_NOCLIMB, // subtract FadeG + line->flags & ML_EFFECT2, // subtract FadeB + false, // subtract FadeA (no flag for this, just pass negative alpha) + line->flags & ML_DONTPEGBOTTOM, + (line->flags & ML_DONTPEGBOTTOM) ? (sides[line->sidenum[0]].textureoffset >> FRACBITS) : 0, + (line->flags & ML_DONTPEGBOTTOM) ? (sides[line->sidenum[0]].rowoffset >> FRACBITS) : 0, + true); else sectors[secnum].extra_colormap = line->frontsector->extra_colormap; } From f0c11eb13572e041b1f7762d569f9e821c336d10 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 11 Sep 2018 21:02:58 -0400 Subject: [PATCH 062/132] R_AddColormaps method --- src/r_data.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/r_data.h | 5 +++ 2 files changed, 91 insertions(+) diff --git a/src/r_data.c b/src/r_data.c index e0899e4cf..c84e61fce 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1867,6 +1867,92 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) return extra_colormap; } +// +// R_AddColormaps() +// NOTE: The result colormap DOES get added to the extra_colormaps chain! +// +extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *exc_addend, + boolean subR, boolean subG, boolean subB, boolean subA, + boolean subFadeR, boolean subFadeG, boolean subFadeB, boolean subFadeA, + boolean useAltAlpha, INT16 altAlpha, INT16 altFadeAlpha, + boolean lighttable) +{ + extracolormap_t *exc; + + // exc_augend is added (or subtracted) onto by exc_addend + // In Rennaisance times, the first number was considered the augend, the second number the addend + // But since the commutative property was discovered, today they're both called addends! + // So let's be Olde English for a hot second. + + exc_augend = R_CopyColormap(exc_augend, false); + if(!exc_addend) + exc_addend = R_GetDefaultColormap(); + + INT16 red, green, blue, alpha; + + // base rgba + red = max(min( + R_GetRgbaR(exc_augend->rgba) + + (subR ? -1 : 1) // subtract R + * R_GetRgbaR(exc_addend->rgba) + , 255), 0); + + green = max(min( + R_GetRgbaG(exc_augend->rgba) + + (subG ? -1 : 1) // subtract G + * R_GetRgbaG(exc_addend->rgba) + , 255), 0); + + blue = max(min( + R_GetRgbaB(exc_augend->rgba) + + (subB ? -1 : 1) // subtract B + * R_GetRgbaB(exc_addend->rgba) + , 255), 0); + + alpha = useAltAlpha ? altAlpha : R_GetRgbaA(exc_addend->rgba); + alpha = max(min(R_GetRgbaA(exc_augend->rgba) + (subA ? -1 : 1) * alpha, 25), 0); + + exc_augend->rgba = R_PutRgbaRGBA(red, green, blue, alpha); + + // fade rgba + red = max(min( + R_GetRgbaR(exc_augend->fadergba) + + (subFadeR ? -1 : 1) // subtract R + * R_GetRgbaR(exc_addend->fadergba) + , 255), 0); + + green = max(min( + R_GetRgbaG(exc_augend->fadergba) + + (subFadeG ? -1 : 1) // subtract G + * R_GetRgbaG(exc_addend->fadergba) + , 255), 0); + + blue = max(min( + R_GetRgbaB(exc_augend->fadergba) + + (subFadeB ? -1 : 1) // subtract B + * R_GetRgbaB(exc_addend->fadergba) + , 255), 0); + + alpha = useAltAlpha ? altFadeAlpha : R_GetRgbaA(exc_addend->fadergba); + if (alpha == 25) + alpha = 0; // HACK: fadergba A defaults at 25, so don't add anything in this case + alpha = max(min(R_GetRgbaA(exc_augend->fadergba) + (subFadeA ? -1 : 1) * alpha, 25), 0); + + exc_augend->fadergba = R_PutRgbaRGBA(red, green, blue, alpha); + + if (!(exc = R_GetColormapFromList(exc_augend))) + { + exc_augend->colormap = lighttable ? R_CreateLightTable(exc_augend) : NULL; + R_AddColormapToList(exc_augend); + return exc_augend; + } + else + { + Z_Free(exc_augend); + return exc; + } +} + // Thanks to quake2 source! // utils3/qdata/images.c static UINT8 NearestColor(UINT8 r, UINT8 g, UINT8 b) diff --git a/src/r_data.h b/src/r_data.h index d980e9c56..6f8d08120 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -124,6 +124,11 @@ extracolormap_t *R_GetColormapFromList(extracolormap_t *extra_colormap); lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap); extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3); +extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *exc_addend, + boolean subR, boolean subG, boolean subB, boolean subA, + boolean subFadeR, boolean subFadeG, boolean subFadeB, boolean subFadeA, + boolean useAltAlpha, INT16 altAlpha, INT16 altFadeAlpha, + boolean lighttable); #ifdef EXTRACOLORMAPLUMPS extracolormap_t *R_ColormapForName(char *name); const char *R_NameForColormap(extracolormap_t *extra_colormap); From ead14becd7184340102fbf5d5fc0d72a8be85053 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 11 Sep 2018 22:34:29 -0400 Subject: [PATCH 063/132] Add R_CheckEqualColormaps comparison method --- src/r_data.c | 27 +++++++++++++++++++++++++++ src/r_data.h | 1 + 2 files changed, 28 insertions(+) diff --git a/src/r_data.c b/src/r_data.c index c84e61fce..1de51fedd 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1472,6 +1472,33 @@ boolean R_CheckDefaultColormap(extracolormap_t *extra_colormap, boolean checkrgb #endif } +boolean R_CheckEqualColormaps(extracolormap_t *exc_a, extracolormap_t *exc_b, boolean checkrgba, boolean checkfadergba, boolean checkparams) +{ + // Treat NULL as default colormap + // We need this because what if one exc is a default colormap, and the other is NULL? They're really both equal. + if (!exc_a) + exc_a = R_GetDefaultColormap(); + if (!exc_b) + exc_b = R_GetDefaultColormap(); + + if (exc_a == exc_b) + return true; + + return ( + (!checkparams ? true : + (exc_a->fadestart == exc_b->fadestart + && exc_a->fadeend == exc_b->fadeend + && exc_a->fog == exc_b->fog) + ) + && (!checkrgba ? true : exc_a->rgba == exc_b->rgba) + && (!checkfadergba ? true : exc_a->fadergba == exc_b->fadergba) +#ifdef EXTRACOLORMAPLUMPS + && exc_a->lump == exc_b->lump + && !strncmp(exc_a->lumpname, exc_b->lumpname, 9) +#endif + ); +} + // // R_GetColormapFromListByValues() // NOTE: Returns NULL if no match is found diff --git a/src/r_data.h b/src/r_data.h index 6f8d08120..f6db2953d 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -120,6 +120,7 @@ boolean R_CheckDefaultColormapByValues(boolean checkrgba, boolean checkfadergba, extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog); #endif boolean R_CheckDefaultColormap(extracolormap_t *extra_colormap, boolean checkrgba, boolean checkfadergba, boolean checkparams); +boolean R_CheckEqualColormaps(extracolormap_t *exc_a, extracolormap_t *exc_b); extracolormap_t *R_GetColormapFromList(extracolormap_t *extra_colormap); lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap); From 90aeac5058bae5cdc6c7097ce13bc1f4dd688df3 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 11 Sep 2018 22:34:29 -0400 Subject: [PATCH 064/132] Add R_CheckEqualColormaps comparison method --- src/r_data.c | 27 +++++++++++++++++++++++++++ src/r_data.h | 1 + 2 files changed, 28 insertions(+) diff --git a/src/r_data.c b/src/r_data.c index c84e61fce..1de51fedd 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1472,6 +1472,33 @@ boolean R_CheckDefaultColormap(extracolormap_t *extra_colormap, boolean checkrgb #endif } +boolean R_CheckEqualColormaps(extracolormap_t *exc_a, extracolormap_t *exc_b, boolean checkrgba, boolean checkfadergba, boolean checkparams) +{ + // Treat NULL as default colormap + // We need this because what if one exc is a default colormap, and the other is NULL? They're really both equal. + if (!exc_a) + exc_a = R_GetDefaultColormap(); + if (!exc_b) + exc_b = R_GetDefaultColormap(); + + if (exc_a == exc_b) + return true; + + return ( + (!checkparams ? true : + (exc_a->fadestart == exc_b->fadestart + && exc_a->fadeend == exc_b->fadeend + && exc_a->fog == exc_b->fog) + ) + && (!checkrgba ? true : exc_a->rgba == exc_b->rgba) + && (!checkfadergba ? true : exc_a->fadergba == exc_b->fadergba) +#ifdef EXTRACOLORMAPLUMPS + && exc_a->lump == exc_b->lump + && !strncmp(exc_a->lumpname, exc_b->lumpname, 9) +#endif + ); +} + // // R_GetColormapFromListByValues() // NOTE: Returns NULL if no match is found diff --git a/src/r_data.h b/src/r_data.h index 6f8d08120..df0fe75b3 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -120,6 +120,7 @@ boolean R_CheckDefaultColormapByValues(boolean checkrgba, boolean checkfadergba, extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog); #endif boolean R_CheckDefaultColormap(extracolormap_t *extra_colormap, boolean checkrgba, boolean checkfadergba, boolean checkparams); +boolean R_CheckEqualColormaps(extracolormap_t *exc_a, extracolormap_t *exc_b, boolean checkrgba, boolean checkfadergba, boolean checkparams); extracolormap_t *R_GetColormapFromList(extracolormap_t *extra_colormap); lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap); From 92a97fb1a64ec3e2b88203011a5ca11abfeacef8 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 11 Sep 2018 22:44:31 -0400 Subject: [PATCH 065/132] Split colormap netsync to Load/SaveExtraColormap methods --- src/p_saveg.c | 131 +++++++++++++++++++++++++------------------------- 1 file changed, 66 insertions(+), 65 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index b887b8a73..fc767d9cf 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -474,6 +474,70 @@ static void P_NetUnArchivePlayers(void) } } +static void SaveExtraColormap(UINT8 *put, extracolormap_t *exc) +{ + WRITEUINT8(put, exc->fadestart); + WRITEUINT8(put, exc->fadeend); + WRITEUINT8(put, (UINT8)exc->fog); + + WRITEINT32(put, exc->rgba); + WRITEINT32(put, exc->fadergba); + +#ifdef EXTRACOLORMAPLUMPS + WRITESTRINGN(put, exc->lumpname, 9); +#endif +} + +static extracolormap_t *LoadExtraColormap(UINT8 *get) +{ + extracolormap_t *exc; + //size_t dbg_i = 0; + + UINT8 fadestart = READUINT8(get), + fadeend = READUINT8(get); + + boolean fog = (boolean)READUINT8(get); + + INT32 rgba = READINT32(get), + fadergba = READINT32(get); + +#ifdef EXTRACOLORMAPLUMPS + char lumpname[9]; + READSTRINGN(get, lumpname, 9); + + if (lumpname[0]) + return R_ColormapForName(lumpname); +#endif + exc = R_GetColormapFromListByValues(rgba, fadergba, fadestart, fadeend, fog); + + if (!exc) + { + // CONS_Debug(DBG_RENDER, "Creating Colormap: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", + // (rgba)&0xFF, (rgba>>8)&0xFF, (rgba>>16)&0xFF, (rgba>>24)&0xFF, + // (fadergba)&0xFF, (fadergba>>8)&0xFF, (fadergba>>16)&0xFF, (fadergba>>24)&0xFF); + + exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL); + + exc->fadestart = fadestart; + exc->fadeend = fadeend; + exc->fog = fog; + + exc->rgba = rgba; + exc->fadergba = fadergba; + + exc->colormap = R_CreateLightTable(exc); + + R_AddColormapToList(exc); + +#ifdef EXTRACOLORMAPLUMPS + exc->lump = LUMPERROR; + exc->lumpname[0] = 0; +#endif + } + + return exc; +} + #define SD_FLOORHT 0x01 #define SD_CEILHT 0x02 #define SD_FLOORPIC 0x04 @@ -657,18 +721,7 @@ static void P_NetArchiveWorld(void) } if (diff3 & SD_COLORMAP) - { - WRITEUINT8(put, ss->extra_colormap->fadestart); - WRITEUINT8(put, ss->extra_colormap->fadeend); - WRITEUINT8(put, (UINT8)ss->extra_colormap->fog); - - WRITEINT32(put, ss->extra_colormap->rgba); - WRITEINT32(put, ss->extra_colormap->fadergba); - -#ifdef EXTRACOLORMAPLUMPS - WRITESTRINGN(put, ss->extra_colormap->lumpname, 9); -#endif - } + SaveExtraColormap(put, ss->extra_colormap); // Special case: save the stats of all modified ffloors along with their ffloor "number"s // we don't bother with ffloors that haven't changed, that would just add to savegame even more than is really needed @@ -865,59 +918,7 @@ static void P_NetUnArchiveWorld(void) } if (diff3 & SD_COLORMAP) - { - extracolormap_t *exc; - //size_t dbg_i = 0; - - UINT8 fadestart = READUINT8(get), - fadeend = READUINT8(get); - - boolean fog = (boolean)READUINT8(get); - - INT32 rgba = READINT32(get), - fadergba = READINT32(get); - -#ifdef EXTRACOLORMAPLUMPS - char lumpname[9]; - READSTRINGN(get, lumpname, 9); - - if (lumpname[0]) - sectors[i].extra_colormap = R_ColormapForName(lumpname); - else - { -#endif - exc = R_GetColormapFromListByValues(rgba, fadergba, fadestart, fadeend, fog); - - if (!exc) - { - // CONS_Debug(DBG_RENDER, "Creating Colormap: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", - // (rgba)&0xFF, (rgba>>8)&0xFF, (rgba>>16)&0xFF, (rgba>>24)&0xFF, - // (fadergba)&0xFF, (fadergba>>8)&0xFF, (fadergba>>16)&0xFF, (fadergba>>24)&0xFF); - - exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL); - - exc->fadestart = fadestart; - exc->fadeend = fadeend; - exc->fog = fog; - - exc->rgba = rgba; - exc->fadergba = fadergba; - - exc->colormap = R_CreateLightTable(exc); - - R_AddColormapToList(exc); - -#ifdef EXTRACOLORMAPLUMPS - exc->lump = LUMPERROR; - exc->lumpname[0] = 0; -#endif - } - - sectors[i].extra_colormap = exc; -#ifdef EXTRACOLORMAPLUMPS - } -#endif - } + sectors[i].extra_colormap = LoadExtraColormap(get); if (diff & SD_FFLOORS) { From 5e59b8c55af1e79c1f5bf10ceb52676ed9b2624d Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 11 Sep 2018 22:49:32 -0400 Subject: [PATCH 066/132] Duplicate lines --- src/r_data.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/r_data.c b/src/r_data.c index 5598dafcd..1de51fedd 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1849,15 +1849,6 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) rgba = R_PutRgbaRGBA(cr, cg, cb, ca); fadergba = R_PutRgbaRGBA(cfr, cfg, cfb, cfa); - // Did we just make a default colormap? -#ifdef EXTRACOLORMAPLUMPS - if (R_CheckDefaultColormapByValues(true, true, true, rgba, fadergba, fadestart, fadeend, fog, LUMPERROR)) - return NULL; -#else - if (R_CheckDefaultColormapByValues(true, true, true, rgba, fadergba, fadestart, fadeend, fog)) - return NULL; -#endif - // Did we just make a default colormap? #ifdef EXTRACOLORMAPLUMPS if (R_CheckDefaultColormapByValues(true, true, true, rgba, fadergba, fadestart, fadeend, fog, LUMPERROR)) From 8754268abe34f70a3b71be70808c39351aed3f64 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 07:06:45 -0400 Subject: [PATCH 067/132] Add fadestart/fadeend/fog to R_AddColormaps --- src/r_data.c | 32 +++++++++++++++++++++++++++++++- src/r_data.h | 1 + 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/r_data.c b/src/r_data.c index 1de51fedd..53044bc2e 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1901,6 +1901,7 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *exc_addend, boolean subR, boolean subG, boolean subB, boolean subA, boolean subFadeR, boolean subFadeG, boolean subFadeB, boolean subFadeA, + boolean subFadeStart, boolean subFadeEnd, boolean ignoreFog, boolean useAltAlpha, INT16 altAlpha, INT16 altFadeAlpha, boolean lighttable) { @@ -1917,7 +1918,10 @@ extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *ex INT16 red, green, blue, alpha; + /////////////////// // base rgba + /////////////////// + red = max(min( R_GetRgbaR(exc_augend->rgba) + (subR ? -1 : 1) // subtract R @@ -1941,7 +1945,10 @@ extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *ex exc_augend->rgba = R_PutRgbaRGBA(red, green, blue, alpha); - // fade rgba + /////////////////// + // fade/dark rgba + /////////////////// + red = max(min( R_GetRgbaR(exc_augend->fadergba) + (subFadeR ? -1 : 1) // subtract R @@ -1967,6 +1974,29 @@ extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *ex exc_augend->fadergba = R_PutRgbaRGBA(red, green, blue, alpha); + /////////////////// + // parameters + /////////////////// + + exc_augend->fadestart = max(min( + exc_augend->fadestart + + (subFadeStart ? -1 : 1) // subtract fadestart + * exc_addend->fadestart + , 31), 0); + + exc_augend->fadeend = max(min( + exc_augend->fadeend + + (subFadeEnd ? -1 : 1) // subtract fadeend + * exc_addend->fadeend + , 31), 0); + + if (!ignoreFog) // overwrite fog with new value + exc_augend->fog = exc_addend->fog; + + /////////////////// + // put it together + /////////////////// + if (!(exc = R_GetColormapFromList(exc_augend))) { exc_augend->colormap = lighttable ? R_CreateLightTable(exc_augend) : NULL; diff --git a/src/r_data.h b/src/r_data.h index df0fe75b3..3a7740c96 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -128,6 +128,7 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3); extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *exc_addend, boolean subR, boolean subG, boolean subB, boolean subA, boolean subFadeR, boolean subFadeG, boolean subFadeB, boolean subFadeA, + boolean subFadeStart, boolean subFadeEnd, boolean ignoreFog, boolean useAltAlpha, INT16 altAlpha, INT16 altFadeAlpha, boolean lighttable); #ifdef EXTRACOLORMAPLUMPS From 6059b8edc909b1ac5cbbf65c6b821852c69f53cf Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 07:06:58 -0400 Subject: [PATCH 068/132] 447: Extra params for R_AddColormaps --- src/p_spec.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/p_spec.c b/src/p_spec.c index 2c607f74e..41756423a 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3268,6 +3268,9 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) line->flags & ML_NOCLIMB, // subtract FadeG line->flags & ML_EFFECT2, // subtract FadeB false, // subtract FadeA (no flag for this, just pass negative alpha) + false, // subtract FadeStart (we ran out of flags) + false, // subtract FadeEnd (we ran out of flags) + false, // ignore Fog (we ran out of flags) line->flags & ML_DONTPEGBOTTOM, (line->flags & ML_DONTPEGBOTTOM) ? (sides[line->sidenum[0]].textureoffset >> FRACBITS) : 0, (line->flags & ML_DONTPEGBOTTOM) ? (sides[line->sidenum[0]].rowoffset >> FRACBITS) : 0, From 133c3598a79828bbf140f844e306517a9aa79725 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 07:06:45 -0400 Subject: [PATCH 069/132] Add fadestart/fadeend/fog to R_AddColormaps --- src/r_data.c | 32 +++++++++++++++++++++++++++++++- src/r_data.h | 1 + 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/r_data.c b/src/r_data.c index 1de51fedd..53044bc2e 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1901,6 +1901,7 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *exc_addend, boolean subR, boolean subG, boolean subB, boolean subA, boolean subFadeR, boolean subFadeG, boolean subFadeB, boolean subFadeA, + boolean subFadeStart, boolean subFadeEnd, boolean ignoreFog, boolean useAltAlpha, INT16 altAlpha, INT16 altFadeAlpha, boolean lighttable) { @@ -1917,7 +1918,10 @@ extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *ex INT16 red, green, blue, alpha; + /////////////////// // base rgba + /////////////////// + red = max(min( R_GetRgbaR(exc_augend->rgba) + (subR ? -1 : 1) // subtract R @@ -1941,7 +1945,10 @@ extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *ex exc_augend->rgba = R_PutRgbaRGBA(red, green, blue, alpha); - // fade rgba + /////////////////// + // fade/dark rgba + /////////////////// + red = max(min( R_GetRgbaR(exc_augend->fadergba) + (subFadeR ? -1 : 1) // subtract R @@ -1967,6 +1974,29 @@ extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *ex exc_augend->fadergba = R_PutRgbaRGBA(red, green, blue, alpha); + /////////////////// + // parameters + /////////////////// + + exc_augend->fadestart = max(min( + exc_augend->fadestart + + (subFadeStart ? -1 : 1) // subtract fadestart + * exc_addend->fadestart + , 31), 0); + + exc_augend->fadeend = max(min( + exc_augend->fadeend + + (subFadeEnd ? -1 : 1) // subtract fadeend + * exc_addend->fadeend + , 31), 0); + + if (!ignoreFog) // overwrite fog with new value + exc_augend->fog = exc_addend->fog; + + /////////////////// + // put it together + /////////////////// + if (!(exc = R_GetColormapFromList(exc_augend))) { exc_augend->colormap = lighttable ? R_CreateLightTable(exc_augend) : NULL; diff --git a/src/r_data.h b/src/r_data.h index df0fe75b3..3a7740c96 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -128,6 +128,7 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3); extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *exc_addend, boolean subR, boolean subG, boolean subB, boolean subA, boolean subFadeR, boolean subFadeG, boolean subFadeB, boolean subFadeA, + boolean subFadeStart, boolean subFadeEnd, boolean ignoreFog, boolean useAltAlpha, INT16 altAlpha, INT16 altFadeAlpha, boolean lighttable); #ifdef EXTRACOLORMAPLUMPS From 87ad2a87f79cb9fbfabee5a8dc8550c1f3305f2e Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 07:14:23 -0400 Subject: [PATCH 070/132] Smarter default fadergbaA and fadeend for relative calc --- src/r_data.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/r_data.c b/src/r_data.c index 53044bc2e..5a642f1b2 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1968,7 +1968,7 @@ extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *ex , 255), 0); alpha = useAltAlpha ? altFadeAlpha : R_GetRgbaA(exc_addend->fadergba); - if (alpha == 25) + if (alpha == 25 && !useAltAlpha && !R_GetRgbaRGB(exc_addend->fadergba)) alpha = 0; // HACK: fadergba A defaults at 25, so don't add anything in this case alpha = max(min(R_GetRgbaA(exc_augend->fadergba) + (subFadeA ? -1 : 1) * alpha, 25), 0); @@ -1987,7 +1987,8 @@ extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *ex exc_augend->fadeend = max(min( exc_augend->fadeend + (subFadeEnd ? -1 : 1) // subtract fadeend - * exc_addend->fadeend + * (exc_addend->fadeend == 31 && !exc_addend->fadestart ? 0 : exc_addend->fadeend) + // HACK: fadeend defaults to 31, so don't add anything in this case , 31), 0); if (!ignoreFog) // overwrite fog with new value From 55c43a2161201ae4382565f3fd4616c0faddbca1 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 07:24:22 -0400 Subject: [PATCH 071/132] R_AddColormap will not return an existing colormap, and new colormap is not added to chain --- src/r_data.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/r_data.c b/src/r_data.c index 5a642f1b2..c8a648a0f 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1896,7 +1896,7 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) // // R_AddColormaps() -// NOTE: The result colormap DOES get added to the extra_colormaps chain! +// NOTE: The result colormap is not added to the extra_colormaps chain. You must do that yourself! // extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *exc_addend, boolean subR, boolean subG, boolean subB, boolean subA, @@ -1998,17 +1998,9 @@ extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *ex // put it together /////////////////// - if (!(exc = R_GetColormapFromList(exc_augend))) - { - exc_augend->colormap = lighttable ? R_CreateLightTable(exc_augend) : NULL; - R_AddColormapToList(exc_augend); - return exc_augend; - } - else - { - Z_Free(exc_augend); - return exc; - } + exc_augend->colormap = lighttable ? R_CreateLightTable(exc_augend) : NULL; + exc_augend->next = exc_augend->prev = NULL; + return exc_augend; } // Thanks to quake2 source! From 9a388af8ec6a38e6f3e90b3dee0b6b153612278b Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 07:31:10 -0400 Subject: [PATCH 072/132] 447: AddColormap no longer returns chained colormap, so chain it ourselves --- src/p_spec.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 41756423a..2742f1b44 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3258,7 +3258,8 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) for (secnum = -1; (secnum = P_FindSectorFromLineTag(line, secnum)) >= 0 ;) { if (line->flags & ML_EFFECT3) // relative calc - sectors[secnum].extra_colormap = R_AddColormaps( + { + extracolormap_t *exc = R_AddColormaps( sectors[secnum].extra_colormap, line->frontsector->extra_colormap, line->flags & ML_EFFECT1, // subtract R line->flags & ML_NOCLIMB, // subtract G @@ -3274,7 +3275,17 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) line->flags & ML_DONTPEGBOTTOM, (line->flags & ML_DONTPEGBOTTOM) ? (sides[line->sidenum[0]].textureoffset >> FRACBITS) : 0, (line->flags & ML_DONTPEGBOTTOM) ? (sides[line->sidenum[0]].rowoffset >> FRACBITS) : 0, - true); + false); + + if (!(sectors[secnum].extra_colormap = R_GetColormapFromList(exc))) + { + exc->colormap = R_CreateLightTable(exc); + R_AddColormapToList(exc); + sectors[secnum].extra_colormap = exc; + } + else + Z_Free(exc); + } else sectors[secnum].extra_colormap = line->frontsector->extra_colormap; } From 6f0b28c48f0256c6194dee11d7714a31f51eff59 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 07:38:51 -0400 Subject: [PATCH 073/132] 447: Allow alternate alpha without relative calc --- src/p_spec.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index 2742f1b44..637f90af8 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3287,7 +3287,25 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) Z_Free(exc); } else - sectors[secnum].extra_colormap = line->frontsector->extra_colormap; + { + if (line->flags & ML_DONTPEGBOTTOM) // alternate alpha (by texture offsets) + { + extracolormap_t *exc = R_CopyColormap(line->frontsector->extra_colormap, false); + exc->rgba = R_GetRgbaRGB(exc->rgba) + R_PutRgbaA(max(min(sides[line->sidenum[0]].textureoffset >> FRACBITS, 25), 0)); + exc->fadergba = R_GetRgbaRGB(exc->fadergba) + R_PutRgbaA(max(min(sides[line->sidenum[0]].rowoffset >> FRACBITS, 25), 0)); + + if (!(sectors[secnum].extra_colormap = R_GetColormapFromList(exc))) + { + exc->colormap = R_CreateLightTable(exc); + R_AddColormapToList(exc); + sectors[secnum].extra_colormap = exc; + } + else + Z_Free(exc); + } + else + sectors[secnum].extra_colormap = line->frontsector->extra_colormap; + } } break; From 4d26cf63304005ac745909ace8b85bbde6fa1425 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 07:55:47 -0400 Subject: [PATCH 074/132] 447: Allow relative calc from backside colormap (ML_TFERLINE) --- src/p_spec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index 637f90af8..914c9821e 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3260,7 +3260,8 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) if (line->flags & ML_EFFECT3) // relative calc { extracolormap_t *exc = R_AddColormaps( - sectors[secnum].extra_colormap, line->frontsector->extra_colormap, + (line->flags & ML_TFERLINE) ? line->backsector->extra_colormap : sectors[secnum].extra_colormap, // use back colormap instead of target sector + line->frontsector->extra_colormap, line->flags & ML_EFFECT1, // subtract R line->flags & ML_NOCLIMB, // subtract G line->flags & ML_EFFECT2, // subtract B From cb2ac9b4d3943ab9c569afcb52a9d4a76a75edc1 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 08:06:44 -0400 Subject: [PATCH 075/132] Formatting --- src/p_spec.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 914c9821e..fd02803cc 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3287,26 +3287,23 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) else Z_Free(exc); } - else + else if (line->flags & ML_DONTPEGBOTTOM) // alternate alpha (by texture offsets) { - if (line->flags & ML_DONTPEGBOTTOM) // alternate alpha (by texture offsets) - { - extracolormap_t *exc = R_CopyColormap(line->frontsector->extra_colormap, false); - exc->rgba = R_GetRgbaRGB(exc->rgba) + R_PutRgbaA(max(min(sides[line->sidenum[0]].textureoffset >> FRACBITS, 25), 0)); - exc->fadergba = R_GetRgbaRGB(exc->fadergba) + R_PutRgbaA(max(min(sides[line->sidenum[0]].rowoffset >> FRACBITS, 25), 0)); + extracolormap_t *exc = R_CopyColormap(line->frontsector->extra_colormap, false); + exc->rgba = R_GetRgbaRGB(exc->rgba) + R_PutRgbaA(max(min(sides[line->sidenum[0]].textureoffset >> FRACBITS, 25), 0)); + exc->fadergba = R_GetRgbaRGB(exc->fadergba) + R_PutRgbaA(max(min(sides[line->sidenum[0]].rowoffset >> FRACBITS, 25), 0)); - if (!(sectors[secnum].extra_colormap = R_GetColormapFromList(exc))) - { - exc->colormap = R_CreateLightTable(exc); - R_AddColormapToList(exc); - sectors[secnum].extra_colormap = exc; - } - else - Z_Free(exc); + if (!(sectors[secnum].extra_colormap = R_GetColormapFromList(exc))) + { + exc->colormap = R_CreateLightTable(exc); + R_AddColormapToList(exc); + sectors[secnum].extra_colormap = exc; } else - sectors[secnum].extra_colormap = line->frontsector->extra_colormap; + Z_Free(exc); } + else + sectors[secnum].extra_colormap = line->frontsector->extra_colormap; } break; From 9a6a8b0b8255a34c6b85d31887cc2390a640c500 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 08:07:34 -0400 Subject: [PATCH 076/132] Outdated comment; unused var --- src/p_setup.c | 3 --- src/r_data.c | 2 -- 2 files changed, 5 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index edde5e701..c08c2ac58 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1459,9 +1459,6 @@ static void P_LoadRawSideDefs2(void *data) sd->sector = sec = §ors[sector_num]; } - // refined to allow colormaps to work as wall textures if invalid as colormaps - // but valid as textures. - sd->sector = sec = §ors[SHORT(msd->sector)]; // Colormaps! diff --git a/src/r_data.c b/src/r_data.c index c8a648a0f..c2e28fe9f 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1905,8 +1905,6 @@ extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *ex boolean useAltAlpha, INT16 altAlpha, INT16 altFadeAlpha, boolean lighttable) { - extracolormap_t *exc; - // exc_augend is added (or subtracted) onto by exc_addend // In Rennaisance times, the first number was considered the augend, the second number the addend // But since the commutative property was discovered, today they're both called addends! From 14b71bdbc574c9255fb7a2eca5cfca3ba24ad36b Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 09:06:38 -0400 Subject: [PATCH 077/132] Fade colormap special 455! And stop fade colormap 456 * Added T_FadeColormap thinker and netsync * Added sector_t fadecolormapdata property --- src/p_saveg.c | 47 ++++++++++++- src/p_setup.c | 1 + src/p_spec.c | 189 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/p_spec.h | 14 ++++ src/r_defs.h | 1 + 5 files changed, 251 insertions(+), 1 deletion(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index fc767d9cf..b3953c53c 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1099,6 +1099,7 @@ typedef enum tc_noenemies, tc_eachtime, tc_disappear, + tc_fadecolormap, tc_planedisplace, #ifdef POLYOBJECTS tc_polyrotate, // haleyjd 03/26/06: polyobjects @@ -1663,6 +1664,22 @@ static void SaveDisappearThinker(const thinker_t *th, const UINT8 type) WRITEINT32(save_p, ht->exists); } +// +// SaveFadeColormapThinker +// +// Saves a fadecolormap_t thinker +// +static void SaveFadeColormapThinker(const thinker_t *th, const UINT8 type) +{ + const fadecolormap_t *ht = (const void *)th; + WRITEUINT8(save_p, type); + WRITEUINT32(save_p, SaveSector(ht->sector)); + SaveExtraColormap(save_p, ht->source_exc); + SaveExtraColormap(save_p, ht->dest_exc); + WRITEINT32(save_p, ht->duration); + WRITEINT32(save_p, ht->timer); +} + // // SavePlaneDisplaceThinker // @@ -1965,6 +1982,11 @@ static void P_NetArchiveThinkers(void) SaveDisappearThinker(th, tc_disappear); continue; } + else if (th->function.acp1 == (actionf_p1)T_FadeColormap) + { + SaveFadeColormapThinker(th, tc_fadecolormap); + continue; + } else if (th->function.acp1 == (actionf_p1)T_PlaneDisplace) { @@ -2641,6 +2663,25 @@ static inline void LoadDisappearThinker(actionf_p1 thinker) P_AddThinker(&ht->thinker); } +// +// LoadFadeColormapThinker +// +// Loads a fadecolormap_t from a save game +// +static inline void LoadFadeColormapThinker(actionf_p1 thinker) +{ + fadecolormap_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); + ht->thinker.function.acp1 = thinker; + ht->sector = LoadSector(READUINT32(save_p)); + ht->source_exc = LoadExtraColormap(save_p); + ht->dest_exc = LoadExtraColormap(save_p); + ht->duration = READINT32(save_p); + ht->timer = READINT32(save_p); + if (ht->sector) + ht->sector->fadecolormapdata = ht; + P_AddThinker(&ht->thinker); +} + // // LoadPlaneDisplaceThinker // @@ -2827,7 +2868,7 @@ static void P_NetUnArchiveThinkers(void) // clear sector thinker pointers so they don't point to non-existant thinkers for all of eternity for (i = 0; i < numsectors; i++) { - sectors[i].floordata = sectors[i].ceilingdata = sectors[i].lightingdata = NULL; + sectors[i].floordata = sectors[i].ceilingdata = sectors[i].lightingdata = sectors[i].fadecolormapdata = NULL; } // read in saved thinkers @@ -2944,6 +2985,10 @@ static void P_NetUnArchiveThinkers(void) LoadDisappearThinker((actionf_p1)T_Disappear); break; + case tc_fadecolormap: + LoadFadeColormapThinker((actionf_p1)T_FadeColormap); + break; + case tc_planedisplace: LoadPlaneDisplaceThinker((actionf_p1)T_PlaneDisplace); break; diff --git a/src/p_setup.c b/src/p_setup.c index c08c2ac58..b26459759 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1466,6 +1466,7 @@ static void P_LoadRawSideDefs2(void *data) { case 63: // variable colormap via 242 linedef case 606: //SoM: 4/4/2000: Just colormap transfer + case 455: // Fade colormaps! mazmazz 9/12/2018 (:flag_us:) // SoM: R_CreateColormap will only create a colormap in software mode... // Perhaps we should just call it instead of doing the calculations here. sec->extra_colormap = sec->spawn_extra_colormap = R_CreateColormap(msd->toptexture, msd->midtexture, diff --git a/src/p_spec.c b/src/p_spec.c index 5135676ab..e20d85af6 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -103,6 +103,9 @@ static void P_SpawnFriction(void); static void P_SpawnPushers(void); static void Add_Pusher(pushertype_e type, fixed_t x_mag, fixed_t y_mag, mobj_t *source, INT32 affectee, INT32 referrer, INT32 exclusive, INT32 slider); //SoM: 3/9/2000 static void Add_MasterDisappearer(tic_t appeartime, tic_t disappeartime, tic_t offset, INT32 line, INT32 sourceline); +static void P_ResetColormapFader(sector_t *sector); +static void Add_ColormapFader(sector_t *sector, extracolormap_t *source_exc, extracolormap_t *dest_exc, + INT32 duration); static void P_AddBlockThinker(sector_t *sec, line_t *sourceline); static void P_AddFloatThinker(sector_t *sec, INT32 tag, line_t *sourceline); //static void P_AddBridgeThinker(line_t *sourceline, sector_t *sec); @@ -3310,6 +3313,82 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; } + case 455: // Fade colormap + for (secnum = -1; (secnum = P_FindSectorFromLineTag(line, secnum)) >= 0 ;) + { + extracolormap_t *source_exc, *dest_exc, *exc; + + exc = (line->flags & ML_TFERLINE) ? line->backsector->extra_colormap // TFERLINE: use back colormap instead of target sector + : sectors[secnum].extra_colormap; + + if (!(line->flags & ML_BOUNCY) // BOUNCY: Do not override fade from default rgba + && !R_CheckDefaultColormap(line->frontsector->extra_colormap, true, false, false) + && R_CheckDefaultColormap(exc, true, false, false)) + { + exc = R_CopyColormap(exc, false); + exc->rgba = R_GetRgbaRGB(line->frontsector->extra_colormap->rgba) + R_PutRgbaA(R_GetRgbaA(exc->rgba)); + exc->fadergba = R_GetRgbaRGB(line->frontsector->extra_colormap->rgba) + R_PutRgbaA(R_GetRgbaA(exc->fadergba)); + + if (!(source_exc = R_GetColormapFromList(exc))) + { + exc->colormap = R_CreateLightTable(exc); + R_AddColormapToList(exc); + source_exc = exc; + } + else + Z_Free(exc); + } + else + source_exc = exc; + + if (line->flags & ML_EFFECT3) // relative calc + { + exc = R_AddColormaps( + source_exc, + line->frontsector->extra_colormap, + line->flags & ML_EFFECT1, // subtract R + line->flags & ML_NOCLIMB, // subtract G + line->flags & ML_EFFECT2, // subtract B + false, // subtract A (no flag for this, just pass negative alpha) + line->flags & ML_EFFECT1, // subtract FadeR + line->flags & ML_NOCLIMB, // subtract FadeG + line->flags & ML_EFFECT2, // subtract FadeB + false, // subtract FadeA (no flag for this, just pass negative alpha) + false, // subtract FadeStart (we ran out of flags) + false, // subtract FadeEnd (we ran out of flags) + false, // ignore Fog (we ran out of flags) + line->flags & ML_DONTPEGBOTTOM, + (line->flags & ML_DONTPEGBOTTOM) ? (sides[line->sidenum[0]].textureoffset >> FRACBITS) : 0, + (line->flags & ML_DONTPEGBOTTOM) ? (sides[line->sidenum[0]].rowoffset >> FRACBITS) : 0, + false); + } + else if (line->flags & ML_DONTPEGBOTTOM) // alternate alpha (by texture offsets) + { + exc = R_CopyColormap(line->frontsector->extra_colormap, false); + exc->rgba = R_GetRgbaRGB(exc->rgba) + R_PutRgbaA(max(min(sides[line->sidenum[0]].textureoffset >> FRACBITS, 25), 0)); + exc->fadergba = R_GetRgbaRGB(exc->fadergba) + R_PutRgbaA(max(min(sides[line->sidenum[0]].rowoffset >> FRACBITS, 25), 0)); + } + else + exc = R_CopyColormap(line->frontsector->extra_colormap, false); + + if (!(dest_exc = R_GetColormapFromList(exc))) + { + exc->colormap = R_CreateLightTable(exc); + R_AddColormapToList(exc); + dest_exc = exc; + } + else + Z_Free(exc); + + Add_ColormapFader(§ors[secnum], source_exc, dest_exc, + (line->sidenum[1] != 0xFFFF ? abs(sides[line->sidenum[1]].rowoffset >> FRACBITS) : abs(P_AproxDistance(line->dx, line->dy) >> FRACBITS))); + } + break; + + case 456: // Stop fade colormap + for (secnum = -1; (secnum = P_FindSectorFromLineTag(line, secnum)) >= 0 ;) + P_ResetColormapFader(§ors[secnum]); + #ifdef POLYOBJECTS case 480: // Polyobj_DoorSlide case 481: // Polyobj_DoorSwing @@ -7322,6 +7401,116 @@ void T_Disappear(disappear_t *d) } } +static void P_ResetColormapFader(sector_t *sector) +{ + if (sector->fadecolormapdata) + { + // The thinker is the first member in all the action structs, + // so just let the thinker get freed, and that will free the whole + // structure. + P_RemoveThinker(&((elevator_t *)sector->fadecolormapdata)->thinker); + sector->fadecolormapdata = NULL; + } +} + +static void Add_ColormapFader(sector_t *sector, extracolormap_t *source_exc, extracolormap_t *dest_exc, + INT32 duration) +{ + P_ResetColormapFader(sector); + + // nothing to do, set immediately + if (!duration || R_CheckEqualColormaps(source_exc, dest_exc, true, true, true)) + { + sector->extra_colormap = dest_exc; + return; + } + + fadecolormap_t *d = Z_Malloc(sizeof *d, PU_LEVSPEC, NULL); + d->thinker.function.acp1 = (actionf_p1)T_FadeColormap; + d->sector = sector; + d->source_exc = source_exc; + d->dest_exc = dest_exc; + d->duration = d->timer = duration; + + sector->fadecolormapdata = d; + P_AddThinker(&d->thinker); // add thinker +} + +void T_FadeColormap(fadecolormap_t *d) +{ + if (--d->timer <= 0) + { + d->sector->extra_colormap = d->dest_exc; + P_ResetColormapFader(d->sector); + } + else + { + extracolormap_t *exc; + fixed_t factor = min(FixedDiv(d->duration - d->timer, d->duration), 1*FRACUNIT); + INT16 cr, cg, cb, ca, fadestart, fadeend, fog; + INT32 rgba, fadergba; + + // For each var (rgba + fadergba + params = 11 vars), we apply + // percentage fading: currentval = sourceval + (delta * percent of duration elapsed) + // delta is negative when fading out (destval is lower) + // max/min are used to ensure progressive calcs don't go backwards and to cap values to dest. + +#define APPLYFADE(dest, src, cur) (\ +(dest-src < 0) ? \ + max(\ + min(cur,\ + src + (UINT8)FixedMul(dest-src, factor)),\ + dest)\ +: (dest-src > 0) ? \ + min(\ + max(cur,\ + src + (UINT8)FixedMul(dest-src, factor)),\ + dest)\ +: \ + dest\ +) + + cr = APPLYFADE(R_GetRgbaR(d->dest_exc->rgba), R_GetRgbaR(d->source_exc->rgba), R_GetRgbaR(d->sector->extra_colormap->rgba)); + cg = APPLYFADE(R_GetRgbaG(d->dest_exc->rgba), R_GetRgbaG(d->source_exc->rgba), R_GetRgbaG(d->sector->extra_colormap->rgba)); + cb = APPLYFADE(R_GetRgbaB(d->dest_exc->rgba), R_GetRgbaB(d->source_exc->rgba), R_GetRgbaB(d->sector->extra_colormap->rgba)); + ca = APPLYFADE(R_GetRgbaA(d->dest_exc->rgba), R_GetRgbaA(d->source_exc->rgba), R_GetRgbaA(d->sector->extra_colormap->rgba)); + + rgba = R_PutRgbaRGBA(cr, cg, cb, ca); + + cr = APPLYFADE(R_GetRgbaR(d->dest_exc->fadergba), R_GetRgbaR(d->source_exc->fadergba), R_GetRgbaR(d->sector->extra_colormap->fadergba)); + cg = APPLYFADE(R_GetRgbaG(d->dest_exc->fadergba), R_GetRgbaG(d->source_exc->fadergba), R_GetRgbaG(d->sector->extra_colormap->fadergba)); + cb = APPLYFADE(R_GetRgbaB(d->dest_exc->fadergba), R_GetRgbaB(d->source_exc->fadergba), R_GetRgbaB(d->sector->extra_colormap->fadergba)); + ca = APPLYFADE(R_GetRgbaA(d->dest_exc->fadergba), R_GetRgbaA(d->source_exc->fadergba), R_GetRgbaA(d->sector->extra_colormap->fadergba)); + + fadergba = R_PutRgbaRGBA(cr, cg, cb, ca); + + fadestart = APPLYFADE(d->dest_exc->fadestart, d->source_exc->fadestart, d->sector->extra_colormap->fadestart); + fadeend = APPLYFADE(d->dest_exc->fadeend, d->source_exc->fadeend, d->sector->extra_colormap->fadeend); + // fog: essentially we're switching from source_exc->fog to dest_exc->fog with a delta + // of 1 or -1, and hoping the factor rounds appropriately in the timing. + fog = APPLYFADE(d->dest_exc->fog, d->source_exc->fog, d->sector->extra_colormap->fog); + +#undef APPLYFADE + + ////////////////// + // setup new colormap + ////////////////// + + if (!(d->sector->extra_colormap = R_GetColormapFromListByValues(rgba, fadergba, fadestart, fadeend, fog))) + { + exc = R_CreateDefaultColormap(false); + exc->fadestart = fadestart; + exc->fadeend = fadeend; + exc->fog = (boolean)fog; + exc->rgba = rgba; + exc->fadergba = fadergba; + exc->colormap = R_CreateLightTable(exc); + R_AddColormapToList(exc); + d->sector->extra_colormap = exc; + } + } +} + /* SoM: 3/8/2000: Friction functions start. Add_Friction, diff --git a/src/p_spec.h b/src/p_spec.h index e0bcc18eb..9e0b7d5c4 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -453,6 +453,20 @@ typedef struct void T_Disappear(disappear_t *d); +// Model for fading colormaps + +typedef struct +{ + thinker_t thinker; ///< Thinker structure for effect. + sector_t *sector; ///< Sector where action is taking place. + extracolormap_t *source_exc; + extracolormap_t *dest_exc; + INT32 duration; ///< Total duration for tic-based logic + INT32 timer; ///< Timer for tic-based logic +} fadecolormap_t; + +void T_FadeColormap(fadecolormap_t *d); + // Prototype functions for pushers void T_Pusher(pusher_t *p); mobj_t *P_GetPushThing(UINT32 s); diff --git a/src/r_defs.h b/src/r_defs.h index 99fad2b44..8c610cd4d 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -315,6 +315,7 @@ typedef struct sector_s void *floordata; // floor move thinker void *ceilingdata; // ceiling move thinker void *lightingdata; // lighting change thinker + void *fadecolormapdata; // fade colormap thinker // floor and ceiling texture offsets fixed_t floor_xoffs, floor_yoffs; From 4d9925e8cf2459d8a4e8e81fddd3761dff914aab Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 09:09:10 -0400 Subject: [PATCH 078/132] 447: ResetColormapFader when changing colormap explicitly --- src/p_spec.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/p_spec.c b/src/p_spec.c index 7d6ffaf2a..b38fa37c4 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3260,6 +3260,8 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) // -- Monster Iestyn 14/06/18 for (secnum = -1; (secnum = P_FindSectorFromLineTag(line, secnum)) >= 0 ;) { + P_ResetColormapFader(§ors[secnum]); + if (line->flags & ML_EFFECT3) // relative calc { extracolormap_t *exc = R_AddColormaps( From 8190433b71fdf258280bb99724d5287259674c45 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 09:42:51 -0400 Subject: [PATCH 079/132] 456: Missing break --- src/p_spec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/p_spec.c b/src/p_spec.c index b38fa37c4..e8f1c3cb8 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3447,6 +3447,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) case 456: // Stop fade colormap for (secnum = -1; (secnum = P_FindSectorFromLineTag(line, secnum)) >= 0 ;) P_ResetColormapFader(§ors[secnum]); + break; #ifdef POLYOBJECTS case 480: // Polyobj_DoorSlide From e95cd0f962f2567bc060ff981a6f01d1fe81f6fd Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 11:01:12 -0400 Subject: [PATCH 080/132] Colormap savegame failsafe - Handle NULL (default colormap) --- src/p_saveg.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index b3953c53c..c18837e17 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -476,6 +476,9 @@ static void P_NetUnArchivePlayers(void) static void SaveExtraColormap(UINT8 *put, extracolormap_t *exc) { + if (!exc) // Just give it default values, we done goofed. (or sector->extra_colormap was intentionally set to default (NULL)) + exc = R_GetDefaultColormap(); + WRITEUINT8(put, exc->fadestart); WRITEUINT8(put, exc->fadeend); WRITEUINT8(put, (UINT8)exc->fog); @@ -490,7 +493,7 @@ static void SaveExtraColormap(UINT8 *put, extracolormap_t *exc) static extracolormap_t *LoadExtraColormap(UINT8 *get) { - extracolormap_t *exc; + extracolormap_t *exc, *exc_exist; //size_t dbg_i = 0; UINT8 fadestart = READUINT8(get), @@ -525,14 +528,21 @@ static extracolormap_t *LoadExtraColormap(UINT8 *get) exc->rgba = rgba; exc->fadergba = fadergba; - exc->colormap = R_CreateLightTable(exc); - - R_AddColormapToList(exc); - #ifdef EXTRACOLORMAPLUMPS exc->lump = LUMPERROR; exc->lumpname[0] = 0; #endif + + if (!(exc_exist = R_GetColormapFromList(exc))) + { + exc->colormap = R_CreateLightTable(exc); + R_AddColormapToList(exc); + } + else + { + Z_Free(exc); + exc = R_CheckDefaultColormap(exc_exist, true, true, true) ? NULL : exc_exist; + } } return exc; From d85019b4e4db8b9e2806b5a859a12b8ed325a6e7 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 11:11:22 -0400 Subject: [PATCH 081/132] More NULL failsafes --- src/p_spec.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index e8f1c3cb8..7ae3c7871 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3396,9 +3396,11 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) } else Z_Free(exc); + + sectors[secnum].extra_colormap = source_exc; } else - source_exc = exc; + source_exc = exc ? exc : R_GetDefaultColormap(); if (line->flags & ML_EFFECT3) // relative calc { @@ -7510,6 +7512,16 @@ void T_FadeColormap(fadecolormap_t *d) INT16 cr, cg, cb, ca, fadestart, fadeend, fog; INT32 rgba, fadergba; + // NULL failsafes (or intentionally set to signify default) + if (!d->sector->extra_colormap) + d->sector->extra_colormap = R_GetDefaultColormap(); + + if (!d->source_exc) + d->source_exc = R_GetDefaultColormap(); + + if (!d->dest_exc) + d->dest_exc = R_GetDefaultColormap(); + // For each var (rgba + fadergba + params = 11 vars), we apply // percentage fading: currentval = sourceval + (delta * percent of duration elapsed) // delta is negative when fading out (destval is lower) From 92c5cb82334a3066fd38c6881b236478611eca36 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 11:01:12 -0400 Subject: [PATCH 082/132] Colormap savegame failsafe - Handle NULL (default colormap) --- src/p_saveg.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index fc767d9cf..4084d8c13 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -476,6 +476,9 @@ static void P_NetUnArchivePlayers(void) static void SaveExtraColormap(UINT8 *put, extracolormap_t *exc) { + if (!exc) // Just give it default values, we done goofed. (or sector->extra_colormap was intentionally set to default (NULL)) + exc = R_GetDefaultColormap(); + WRITEUINT8(put, exc->fadestart); WRITEUINT8(put, exc->fadeend); WRITEUINT8(put, (UINT8)exc->fog); @@ -490,7 +493,7 @@ static void SaveExtraColormap(UINT8 *put, extracolormap_t *exc) static extracolormap_t *LoadExtraColormap(UINT8 *get) { - extracolormap_t *exc; + extracolormap_t *exc, *exc_exist; //size_t dbg_i = 0; UINT8 fadestart = READUINT8(get), @@ -525,14 +528,21 @@ static extracolormap_t *LoadExtraColormap(UINT8 *get) exc->rgba = rgba; exc->fadergba = fadergba; - exc->colormap = R_CreateLightTable(exc); - - R_AddColormapToList(exc); - #ifdef EXTRACOLORMAPLUMPS exc->lump = LUMPERROR; exc->lumpname[0] = 0; #endif + + if (!(exc_exist = R_GetColormapFromList(exc))) + { + exc->colormap = R_CreateLightTable(exc); + R_AddColormapToList(exc); + } + else + { + Z_Free(exc); + exc = R_CheckDefaultColormap(exc_exist, true, true, true) ? NULL : exc_exist; + } } return exc; From 51a298222649e6e5f7b4564c20c45b57663b0e8e Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 11:21:49 -0400 Subject: [PATCH 083/132] 455: TFERLINE - Set target sector's colormap first to control backsector's colormap --- src/p_spec.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 7ae3c7871..9e4d38f97 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3377,8 +3377,10 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) { extracolormap_t *source_exc, *dest_exc, *exc; - exc = (line->flags & ML_TFERLINE) ? line->backsector->extra_colormap // TFERLINE: use back colormap instead of target sector - : sectors[secnum].extra_colormap; + if (line->flags & ML_TFERLINE) // use back colormap instead of target sector + sectors[secnum].extra_colormap = line->backsector->extra_colormap; + + exc = sectors[secnum].extra_colormap; if (!(line->flags & ML_BOUNCY) // BOUNCY: Do not override fade from default rgba && !R_CheckDefaultColormap(line->frontsector->extra_colormap, true, false, false) From d2f636d5a2fcc678bbd0018dad00ca235a6f2fb6 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 11:33:44 -0400 Subject: [PATCH 084/132] T_FadeColormap: Fade subtraction error --- src/p_spec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 9e4d38f97..3e428c1f6 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -7533,12 +7533,12 @@ void T_FadeColormap(fadecolormap_t *d) (dest-src < 0) ? \ max(\ min(cur,\ - src + (UINT8)FixedMul(dest-src, factor)),\ + src + (INT16)FixedMul(dest-src, factor)),\ dest)\ : (dest-src > 0) ? \ min(\ max(cur,\ - src + (UINT8)FixedMul(dest-src, factor)),\ + src + (INT16)FixedMul(dest-src, factor)),\ dest)\ : \ dest\ From 7d36aae7c404b29f71dafacce4f09355e9a30de0 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 16:06:56 -0400 Subject: [PATCH 085/132] Make lightlists react to control sector colormap changes (double pointer) --- src/r_bsp.c | 14 +++++++------- src/r_defs.h | 2 +- src/r_segs.c | 6 +++--- src/r_things.c | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/r_bsp.c b/src/r_bsp.c index 01676572e..cbb012b28 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -925,11 +925,11 @@ static void R_Subsector(size_t num) light = R_GetPlaneLight(frontsector, floorcenterz, false); if (frontsector->floorlightsec == -1) floorlightlevel = *frontsector->lightlist[light].lightlevel; - floorcolormap = frontsector->lightlist[light].extra_colormap; + floorcolormap = *frontsector->lightlist[light].extra_colormap; light = R_GetPlaneLight(frontsector, ceilingcenterz, false); if (frontsector->ceilinglightsec == -1) ceilinglightlevel = *frontsector->lightlist[light].lightlevel; - ceilingcolormap = frontsector->lightlist[light].extra_colormap; + ceilingcolormap = *frontsector->lightlist[light].extra_colormap; } sub->sector->extra_colormap = frontsector->extra_colormap; @@ -1026,7 +1026,7 @@ static void R_Subsector(size_t num) ffloor[numffloors].plane = R_FindPlane(*rover->bottomheight, *rover->bottompic, *frontsector->lightlist[light].lightlevel, *rover->bottomxoffs, - *rover->bottomyoffs, *rover->bottomangle, frontsector->lightlist[light].extra_colormap, rover + *rover->bottomyoffs, *rover->bottomangle, *frontsector->lightlist[light].extra_colormap, rover #ifdef POLYOBJECTS_PLANES , NULL #endif @@ -1072,7 +1072,7 @@ static void R_Subsector(size_t num) ffloor[numffloors].plane = R_FindPlane(*rover->topheight, *rover->toppic, *frontsector->lightlist[light].lightlevel, *rover->topxoffs, *rover->topyoffs, *rover->topangle, - frontsector->lightlist[light].extra_colormap, rover + *frontsector->lightlist[light].extra_colormap, rover #ifdef POLYOBJECTS_PLANES , NULL #endif @@ -1264,7 +1264,7 @@ void R_Prep3DFloors(sector_t *sector) #endif sector->lightlist[0].lightlevel = §or->lightlevel; sector->lightlist[0].caster = NULL; - sector->lightlist[0].extra_colormap = sector->extra_colormap; + sector->lightlist[0].extra_colormap = §or->extra_colormap; sector->lightlist[0].flags = 0; maxheight = INT32_MAX; @@ -1339,12 +1339,12 @@ void R_Prep3DFloors(sector_t *sector) else if (best->flags & FF_COLORMAPONLY) { sector->lightlist[i].lightlevel = sector->lightlist[i-1].lightlevel; - sector->lightlist[i].extra_colormap = sec->extra_colormap; + sector->lightlist[i].extra_colormap = &sec->extra_colormap; } else { sector->lightlist[i].lightlevel = best->toplightlevel; - sector->lightlist[i].extra_colormap = sec->extra_colormap; + sector->lightlist[i].extra_colormap = &sec->extra_colormap; } if (best->flags & FF_DOUBLESHADOW) diff --git a/src/r_defs.h b/src/r_defs.h index 99fad2b44..63ca29aa1 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -194,7 +194,7 @@ typedef struct lightlist_s { fixed_t height; INT16 *lightlevel; - extracolormap_t *extra_colormap; + extracolormap_t **extra_colormap; // pointer-to-a-pointer, so we can react to colormap changes INT32 flags; ffloor_t *caster; #ifdef ESLOPE diff --git a/src/r_segs.c b/src/r_segs.c index a52b7cb61..cde019f66 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -413,7 +413,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) #endif rlight->startheight = rlight->height; // keep starting value here to reset for each repeat rlight->lightlevel = *light->lightlevel; - rlight->extra_colormap = light->extra_colormap; + rlight->extra_colormap = *light->extra_colormap; rlight->flags = light->flags; if (rlight->flags & FF_FOG || (rlight->extra_colormap && rlight->extra_colormap->fog)) @@ -944,7 +944,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) } rlight->lightlevel = *light->lightlevel; - rlight->extra_colormap = light->extra_colormap; + rlight->extra_colormap = *light->extra_colormap; // Check if the current light effects the colormap/lightlevel if (pfloor->flags & FF_FOG) @@ -2808,7 +2808,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) } rlight->lightlevel = *light->lightlevel; - rlight->extra_colormap = light->extra_colormap; + rlight->extra_colormap = *light->extra_colormap; p++; } diff --git a/src/r_things.c b/src/r_things.c index fb4664d90..f4a0fd28c 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -981,7 +981,7 @@ static void R_SplitSprite(vissprite_t *sprite) else spritelights = scalelight[lightnum]; - newsprite->extra_colormap = sector->lightlist[i].extra_colormap; + newsprite->extra_colormap = *sector->lightlist[i].extra_colormap; if (!((newsprite->cut & SC_FULLBRIGHT) && (!newsprite->extra_colormap || !(newsprite->extra_colormap->fog & 1)))) @@ -1360,7 +1360,7 @@ static void R_ProjectSprite(mobj_t *thing) vis->sz = (INT16)((centeryfrac - FixedMul(vis->gz - viewz, sortscale))>>FRACBITS); vis->cut = cut; if (thing->subsector->sector->numlights) - vis->extra_colormap = thing->subsector->sector->lightlist[light].extra_colormap; + vis->extra_colormap = *thing->subsector->sector->lightlist[light].extra_colormap; else vis->extra_colormap = thing->subsector->sector->extra_colormap; From 62b6950e3324e550a63234ef9c7aed5ef798b5e2 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 16:28:55 -0400 Subject: [PATCH 086/132] Use lightlist.extra_colormap double pointers in OpenGL --- src/hardware/hw_main.c | 30 +++++++++++++++--------------- src/hardware/hw_md2.c | 4 ++-- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 119be6b46..50399dbd6 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1126,7 +1126,7 @@ static void HWR_SplitWall(sector_t *sector, wallVert3D *wallVerts, INT32 texnum, else { lightnum = *list[i].lightlevel; - colormap = list[i].extra_colormap; + colormap = *list[i].extra_colormap; } } @@ -3486,12 +3486,12 @@ static void HWR_Subsector(size_t num) light = R_GetPlaneLight(gr_frontsector, locFloorHeight, false); if (gr_frontsector->floorlightsec == -1) floorlightlevel = *gr_frontsector->lightlist[light].lightlevel; - floorcolormap = gr_frontsector->lightlist[light].extra_colormap; + floorcolormap = *gr_frontsector->lightlist[light].extra_colormap; light = R_GetPlaneLight(gr_frontsector, locCeilingHeight, false); if (gr_frontsector->ceilinglightsec == -1) ceilinglightlevel = *gr_frontsector->lightlist[light].lightlevel; - ceilingcolormap = gr_frontsector->lightlist[light].extra_colormap; + ceilingcolormap = *gr_frontsector->lightlist[light].extra_colormap; } sub->sector->extra_colormap = gr_frontsector->extra_colormap; @@ -3617,7 +3617,7 @@ static void HWR_Subsector(size_t num) *rover->bottomheight, *gr_frontsector->lightlist[light].lightlevel, rover->alpha-1 > 255 ? 255 : rover->alpha-1, rover->master->frontsector, PF_Translucent, - false, gr_frontsector->lightlist[light].extra_colormap); + false, *gr_frontsector->lightlist[light].extra_colormap); #endif } else @@ -3625,7 +3625,7 @@ static void HWR_Subsector(size_t num) HWR_GetFlat(levelflats[*rover->bottompic].lumpnum); light = R_GetPlaneLight(gr_frontsector, centerHeight, dup_viewz < cullHeight ? true : false); HWR_RenderPlane(NULL, &extrasubsectors[num], false, *rover->bottomheight, PF_Occlude, *gr_frontsector->lightlist[light].lightlevel, levelflats[*rover->bottompic].lumpnum, - rover->master->frontsector, 255, false, gr_frontsector->lightlist[light].extra_colormap); + rover->master->frontsector, 255, false, *gr_frontsector->lightlist[light].extra_colormap); } } @@ -3680,7 +3680,7 @@ static void HWR_Subsector(size_t num) *rover->topheight, *gr_frontsector->lightlist[light].lightlevel, rover->alpha-1 > 255 ? 255 : rover->alpha-1, rover->master->frontsector, PF_Translucent, - false, gr_frontsector->lightlist[light].extra_colormap); + false, *gr_frontsector->lightlist[light].extra_colormap); #endif } @@ -3689,7 +3689,7 @@ static void HWR_Subsector(size_t num) HWR_GetFlat(levelflats[*rover->toppic].lumpnum); light = R_GetPlaneLight(gr_frontsector, centerHeight, dup_viewz < cullHeight ? true : false); HWR_RenderPlane(NULL, &extrasubsectors[num], true, *rover->topheight, PF_Occlude, *gr_frontsector->lightlist[light].lightlevel, levelflats[*rover->toppic].lumpnum, - rover->master->frontsector, 255, false, gr_frontsector->lightlist[light].extra_colormap); + rover->master->frontsector, 255, false, *gr_frontsector->lightlist[light].extra_colormap); } } } @@ -4200,8 +4200,8 @@ static void HWR_DrawSpriteShadow(gr_vissprite_t *spr, GLPatch_t *gpatch, float t if (!(spr->mobj->frame & FF_FULLBRIGHT)) lightlevel = *sector->lightlist[light].lightlevel; - if (sector->lightlist[light].extra_colormap) - colormap = sector->lightlist[light].extra_colormap; + if (*sector->lightlist[light].extra_colormap) + colormap = *sector->lightlist[light].extra_colormap; } else { @@ -4362,7 +4362,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) // Start with the lightlevel and colormap from the top of the sprite lightlevel = *list[sector->numlights - 1].lightlevel; - colormap = list[sector->numlights - 1].extra_colormap; + colormap = *list[sector->numlights - 1].extra_colormap; i = 0; temp = FLOAT_TO_FIXED(realtop); @@ -4378,7 +4378,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) { if (!(spr->mobj->frame & FF_FULLBRIGHT)) lightlevel = *list[i-1].lightlevel; - colormap = list[i-1].extra_colormap; + colormap = *list[i-1].extra_colormap; break; } } @@ -4386,7 +4386,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) i = R_GetPlaneLight(sector, temp, false); if (!(spr->mobj->frame & FF_FULLBRIGHT)) lightlevel = *list[i].lightlevel; - colormap = list[i].extra_colormap; + colormap = *list[i].extra_colormap; #endif for (i = 0; i < sector->numlights; i++) @@ -4402,7 +4402,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) { if (!(spr->mobj->frame & FF_FULLBRIGHT)) lightlevel = *list[i].lightlevel; - colormap = list[i].extra_colormap; + colormap = *list[i].extra_colormap; } #ifdef ESLOPE @@ -4734,8 +4734,8 @@ static inline void HWR_DrawPrecipitationSprite(gr_vissprite_t *spr) if (!(spr->mobj->frame & FF_FULLBRIGHT)) lightlevel = *sector->lightlist[light].lightlevel; - if (sector->lightlist[light].extra_colormap) - colormap = sector->lightlist[light].extra_colormap; + if (*sector->lightlist[light].extra_colormap) + colormap = *sector->lightlist[light].extra_colormap; } else { diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index bfb2638ee..d69233a9b 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1194,8 +1194,8 @@ void HWR_DrawMD2(gr_vissprite_t *spr) if (!(spr->mobj->frame & FF_FULLBRIGHT)) lightlevel = *sector->lightlist[light].lightlevel; - if (sector->lightlist[light].extra_colormap) - colormap = sector->lightlist[light].extra_colormap; + if (*sector->lightlist[light].extra_colormap) + colormap = *sector->lightlist[light].extra_colormap; } else { From ad9ef5d59316246b647d456c170da6d98293914a Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 17:39:30 -0400 Subject: [PATCH 087/132] Merge errors --- src/p_saveg.c | 2 -- src/p_spec.c | 2 +- src/r_defs.h | 1 - 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index f2e8dcdb7..c9b474b1d 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -730,8 +730,6 @@ static void P_NetArchiveWorld(void) WRITEINT32(put, ss->firsttag); WRITEINT32(put, ss->nexttag); } - if (diff3 & SD_MIDMAP) - WRITEINT32(put, ss->midmap); if (diff3 & SD_COLORMAP) SaveExtraColormap(put, ss->extra_colormap); diff --git a/src/p_spec.c b/src/p_spec.c index b5e862749..21380584b 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3256,7 +3256,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) // This could even override existing colormaps I believe // -- Monster Iestyn 14/06/18 for (secnum = -1; (secnum = P_FindSectorFromLineTag(line, secnum)) >= 0 ;) - sectors[secnum].midmap = line->frontsector->midmap; + sectors[secnum].extra_colormap = line->frontsector->extra_colormap; break; case 448: // Change skybox viewpoint/centerpoint diff --git a/src/r_defs.h b/src/r_defs.h index 1d1d471e5..63ca29aa1 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -390,7 +390,6 @@ typedef struct sector_s // these are saved for netgames, so do not let Lua touch these! INT32 spawn_nexttag, spawn_firsttag; // the actual nexttag/firsttag values may differ if the sector's tag was changed - INT32 spawn_bottommap, spawn_midmap, spawn_topmap; // offsets sector spawned with (via linedef type 7) fixed_t spawn_flr_xoffs, spawn_flr_yoffs; From f7ff440250ddaf9ee1a03a254cfad0834d6514e3 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 20:43:48 -0400 Subject: [PATCH 088/132] Add colormap_data to side_t and store colormaps there on setup --- src/p_setup.c | 2 +- src/p_spec.c | 4 ++-- src/r_defs.h | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 5d7fd3179..cc5ee3cc8 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1469,7 +1469,7 @@ static void P_LoadRawSideDefs2(void *data) case 447: // Change colormap of tagged sectors! -- Monster Iestyn 14/06/18 // SoM: R_CreateColormap will only create a colormap in software mode... // Perhaps we should just call it instead of doing the calculations here. - sec->extra_colormap = sec->spawn_extra_colormap = R_CreateColormap(msd->toptexture, msd->midtexture, + sd->colormap_data = R_CreateColormap(msd->toptexture, msd->midtexture, msd->bottomtexture); sd->toptexture = sd->midtexture = sd->bottomtexture = 0; break; diff --git a/src/p_spec.c b/src/p_spec.c index 21380584b..8e5a612c3 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3256,7 +3256,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) // This could even override existing colormaps I believe // -- Monster Iestyn 14/06/18 for (secnum = -1; (secnum = P_FindSectorFromLineTag(line, secnum)) >= 0 ;) - sectors[secnum].extra_colormap = line->frontsector->extra_colormap; + sectors[secnum].extra_colormap = sides[line->sidenum[0]].colormap_data; break; case 448: // Change skybox viewpoint/centerpoint @@ -6769,7 +6769,7 @@ void P_SpawnSpecials(INT32 fromnetsave) case 606: // HACK! Copy colormaps. Just plain colormaps. for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) - sectors[s].extra_colormap = sectors[s].spawn_extra_colormap = lines[i].frontsector->extra_colormap; + sectors[s].extra_colormap = sectors[s].spawn_extra_colormap = sides[lines[i].sidenum[0]].colormap_data; break; #ifdef ESLOPE // Slope copy specials. Handled here for sanity. diff --git a/src/r_defs.h b/src/r_defs.h index 63ca29aa1..1f2afdb99 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -476,6 +476,8 @@ typedef struct INT16 repeatcnt; // # of times to repeat midtexture char *text; // a concatination of all top, bottom, and mid texture names, for linedef specials that require a string. + + extracolormap_t *colormap_data; // storage for colormaps; not applied to sectors. } side_t; // From 05c91f1f81aea11738269d84e5cf5816b56bfe46 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 20:52:05 -0400 Subject: [PATCH 089/132] 455: Change to side->colormap_data --- src/p_spec.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 8797200c2..491671c40 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3379,17 +3379,18 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) extracolormap_t *source_exc, *dest_exc, *exc; if (line->flags & ML_TFERLINE) // use back colormap instead of target sector - sectors[secnum].extra_colormap = line->backsector->extra_colormap; + sectors[secnum].extra_colormap = (line->sidenum[1] != 0xFFFF) ? + sides[line->sidenum[1]].colormap_data : NULL; exc = sectors[secnum].extra_colormap; if (!(line->flags & ML_BOUNCY) // BOUNCY: Do not override fade from default rgba - && !R_CheckDefaultColormap(line->frontsector->extra_colormap, true, false, false) + && !R_CheckDefaultColormap(sides[line->sidenum[0]].colormap_data, true, false, false) && R_CheckDefaultColormap(exc, true, false, false)) { exc = R_CopyColormap(exc, false); - exc->rgba = R_GetRgbaRGB(line->frontsector->extra_colormap->rgba) + R_PutRgbaA(R_GetRgbaA(exc->rgba)); - exc->fadergba = R_GetRgbaRGB(line->frontsector->extra_colormap->rgba) + R_PutRgbaA(R_GetRgbaA(exc->fadergba)); + exc->rgba = R_GetRgbaRGB(sides[line->sidenum[0]].colormap_data->rgba) + R_PutRgbaA(R_GetRgbaA(exc->rgba)); + exc->fadergba = R_GetRgbaRGB(sides[line->sidenum[0]].colormap_data->rgba) + R_PutRgbaA(R_GetRgbaA(exc->fadergba)); if (!(source_exc = R_GetColormapFromList(exc))) { @@ -3409,7 +3410,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) { exc = R_AddColormaps( source_exc, - line->frontsector->extra_colormap, + sides[line->sidenum[0]].colormap_data, line->flags & ML_EFFECT1, // subtract R line->flags & ML_NOCLIMB, // subtract G line->flags & ML_EFFECT2, // subtract B @@ -3428,12 +3429,12 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) } else if (line->flags & ML_DONTPEGBOTTOM) // alternate alpha (by texture offsets) { - exc = R_CopyColormap(line->frontsector->extra_colormap, false); + exc = R_CopyColormap(sides[line->sidenum[0]].colormap_data, false); exc->rgba = R_GetRgbaRGB(exc->rgba) + R_PutRgbaA(max(min(sides[line->sidenum[0]].textureoffset >> FRACBITS, 25), 0)); exc->fadergba = R_GetRgbaRGB(exc->fadergba) + R_PutRgbaA(max(min(sides[line->sidenum[0]].rowoffset >> FRACBITS, 25), 0)); } else - exc = R_CopyColormap(line->frontsector->extra_colormap, false); + exc = R_CopyColormap(sides[line->sidenum[0]].colormap_data, false); if (!(dest_exc = R_GetColormapFromList(exc))) { From 0b2caa948fb89ab5a7d25d2164c01b01091237fa Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 21:05:50 -0400 Subject: [PATCH 090/132] Init side->colormap_data pointer to NULL (for paranoia) --- src/p_setup.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/p_setup.c b/src/p_setup.c index cc5ee3cc8..f0ce69598 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1461,6 +1461,8 @@ static void P_LoadRawSideDefs2(void *data) sd->sector = sec = §ors[SHORT(msd->sector)]; + sd->colormap_data = NULL; + // Colormaps! switch (sd->special) { From 41fe080a68b36df41d0a6161e570e59ad0bb037a Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 21:32:12 -0400 Subject: [PATCH 091/132] 420: Allow Back Y Offset for timing parameter --- src/p_spec.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index aa3a81f23..eed083cd9 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2779,8 +2779,14 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) case 420: // Fade light levels in tagged sectors to new value P_FadeLight(line->tag, - (line->flags & ML_DONTPEGBOTTOM) ? max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, 255), 0) : line->frontsector->lightlevel, - (line->flags & ML_DONTPEGBOTTOM) ? max(sides[line->sidenum[0]].rowoffset>>FRACBITS, 0) : P_AproxDistance(line->dx, line->dy)>>FRACBITS, + (line->flags & ML_DONTPEGBOTTOM) ? max(sides[line->sidenum[0]].textureoffset>>FRACBITS, 0) : line->frontsector->lightlevel, + // failsafe: if user specifies Back Y Offset and NOT Front Y Offset, use the Back Offset + // to be consistent with other light and fade specials + (line->flags & ML_DONTPEGBOTTOM) ? + ((line->sidenum[1] != 0xFFFF && !(sides[line->sidenum[0]].rowoffset>>FRACBITS)) ? + max(min(sides[line->sidenum[1]].rowoffset>>FRACBITS, 255), 0) + : max(min(sides[line->sidenum[0]].rowoffset>>FRACBITS, 255), 0)) + : abs(P_AproxDistance(line->dx, line->dy))>>FRACBITS), (line->flags & ML_EFFECT4)); break; From 63a3125df2a5f12fcecc28d7d4ccbcd4b6252b2b Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 21:47:53 -0400 Subject: [PATCH 092/132] 420: A parenthesis --- src/p_spec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index 85790041f..5ccdca671 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2786,7 +2786,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) ((line->sidenum[1] != 0xFFFF && !(sides[line->sidenum[0]].rowoffset>>FRACBITS)) ? max(min(sides[line->sidenum[1]].rowoffset>>FRACBITS, 255), 0) : max(min(sides[line->sidenum[0]].rowoffset>>FRACBITS, 255), 0)) - : abs(P_AproxDistance(line->dx, line->dy))>>FRACBITS), + : abs(P_AproxDistance(line->dx, line->dy))>>FRACBITS, (line->flags & ML_EFFECT4)); break; From 2f9e014aab5b41f078914114bd32524ce60f1a8b Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 21:58:20 -0400 Subject: [PATCH 093/132] 490 PolyVisible: Set proper spawn render flags instead of RENDERALL --- src/p_spec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index a20a339ed..65f7fcd67 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1218,7 +1218,7 @@ static void PolyVisible(line_t *line) po->flags |= POF_SOLID; po->flags &= ~POF_NOSPECIALS; - po->flags |= POF_RENDERALL; + po->flags |= (po->spawnflags & POF_RENDERALL); } // From 0697a1b90a6fa7763a9472d21e7e1e5e872f0f0e Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 12 Sep 2018 22:08:07 -0400 Subject: [PATCH 094/132] PolyObjFade: Apply RENDER, SOLID, and NOSPECIALS flags according to spawnflags --- src/p_polyobj.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/p_polyobj.c b/src/p_polyobj.c index a8616dba1..b47afed27 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -2898,7 +2898,7 @@ void T_PolyObjFade(polyfade_t *th) if (po->translucency >= NUMTRANSMAPS) // invisible po->flags &= ~POF_RENDERALL; else - po->flags |= POF_RENDERALL; + po->flags |= (po->spawnflags & POF_RENDERALL); // set collision if (th->docollision && th->speed) @@ -2910,14 +2910,15 @@ void T_PolyObjFade(polyfade_t *th) } else { - po->flags |= POF_SOLID; - po->flags &= ~POF_NOSPECIALS; + po->flags |= (po->spawnflags & POF_SOLID); + if (!(po->spawnflags & POF_NOSPECIALS)) + po->flags &= ~POF_NOSPECIALS; } } } else { - po->flags |= POF_RENDERALL; + po->flags |= (po->spawnflags & POF_RENDERALL); // set collision if (th->docollision && th->speed) @@ -2929,8 +2930,9 @@ void T_PolyObjFade(polyfade_t *th) } else { - po->flags |= POF_SOLID; - po->flags &= ~POF_NOSPECIALS; + po->flags |= (po->spawnflags & POF_SOLID); + if (!(po->spawnflags & POF_NOSPECIALS)) + po->flags &= ~POF_NOSPECIALS; } } } From 4ab3a986f319ec7632e4d0d0fde3f2e325f1704c Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 13 Sep 2018 00:04:50 -0400 Subject: [PATCH 095/132] 492 PolyObj Fade, 491 PolyObj Translucency, 490 PolyObj changes * 490: Set proper render flags according to spawnflags * 491: Add relative calc (EFFECT3) and Front X alpha param (DONTPEGTOP) * 492: * Tic-based (EFFECT4) and speed timing * Add relative calc (EFFECT3) and Front X alpha param (DONTPEGTOP) * Set proper render flags according to spawnflags * Fix OpenGL >= NUMTRANSMAPS render bug --- src/p_polyobj.c | 85 +++++++++++++++++++++++++++++++++++++------------ src/p_polyobj.h | 6 ++-- src/p_saveg.c | 6 ++-- src/p_spec.c | 57 +++++++++++++++++++++++++-------- 4 files changed, 116 insertions(+), 38 deletions(-) diff --git a/src/p_polyobj.c b/src/p_polyobj.c index b47afed27..f7545e5bd 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -2873,23 +2873,54 @@ void T_PolyObjFade(polyfade_t *th) if (po->thinker == NULL) po->thinker = &th->thinker; - stillfading = !(--(th->timer) <= 0); - - if (th->timer <= 0) + if (th->ticbased) { - po->translucency = th->destvalue; // set to dest translucency + stillfading = !(--(th->timer) <= 0); - // remove thinker - if (po->thinker == &th->thinker) - po->thinker = NULL; - P_RemoveThinker(&th->thinker); - } - else if (!(th->timer % th->interval)) - { - if (th->speed <= 0) - po->translucency = max(po->translucency + th->speed, th->destvalue); + if (th->timer <= 0) + { + po->translucency = max(min(th->destvalue, NUMTRANSMAPS), 0); + + // remove thinker + if (po->thinker == &th->thinker) + po->thinker = NULL; + P_RemoveThinker(&th->thinker); + } else - po->translucency = min(po->translucency + th->speed, th->destvalue); + { + INT16 delta = abs(th->destvalue - th->sourcevalue); + fixed_t factor = min(FixedDiv(th->speed - th->timer, th->speed), 1*FRACUNIT); + if (th->destvalue < th->sourcevalue) + po->translucency = max(min(po->translucency, th->sourcevalue - (INT16)FixedMul(delta, factor)), th->destvalue); + else if (th->destvalue > th->sourcevalue) + po->translucency = min(max(po->translucency, th->sourcevalue + (INT16)FixedMul(delta, factor)), th->destvalue); + } + } + else + { + fixed_t timerdest = FixedMul(FixedDiv(256, NUMTRANSMAPS), NUMTRANSMAPS-th->destvalue); + + if (th->destvalue > th->sourcevalue) // fading out, destvalue is higher + { + // for timer, lower is transparent, higher is opaque + stillfading = (th->timer > timerdest); + th->timer = max(timerdest, th->timer - th->speed); + } + else if (th->destvalue < th->sourcevalue) // fading in, destvalue is lower + { stillfading = (th->timer < timerdest); + th->timer = min(timerdest, th->timer + th->speed); + } + + if (!stillfading) + { + po->translucency = max(min(th->destvalue, NUMTRANSMAPS), 0); + // remove thinker + if (po->thinker == &th->thinker) + po->thinker = NULL; + P_RemoveThinker(&th->thinker); + } + else + po->translucency = FixedDiv(256-th->timer, FixedDiv(256, NUMTRANSMAPS)); } if (!stillfading) @@ -2901,9 +2932,9 @@ void T_PolyObjFade(polyfade_t *th) po->flags |= (po->spawnflags & POF_RENDERALL); // set collision - if (th->docollision && th->speed) + if (th->docollision) { - if (th->speed > 0) // faded out + if (th->destvalue > th->sourcevalue) // faded out { po->flags &= ~POF_SOLID; po->flags |= POF_NOSPECIALS; @@ -2918,10 +2949,14 @@ void T_PolyObjFade(polyfade_t *th) } else { + if (po->translucency >= NUMTRANSMAPS) + // HACK: OpenGL renders fully opaque when >= NUMTRANSMAPS + po->translucency = NUMTRANSMAPS-1; + po->flags |= (po->spawnflags & POF_RENDERALL); // set collision - if (th->docollision && th->speed) + if (th->docollision) { if (th->doghostfade) { @@ -2967,12 +3002,22 @@ INT32 EV_DoPolyObjFade(polyfadedata_t *pfdata) // set fields th->polyObjNum = pfdata->polyObjNum; + th->sourcevalue = po->translucency; th->destvalue = pfdata->destvalue; th->docollision = pfdata->docollision; th->doghostfade = pfdata->doghostfade; - th->timer = pfdata->timer; - th->speed = pfdata->speed; - th->interval = pfdata->interval; + + if (pfdata->ticbased) + { + th->ticbased = true; + th->timer = th->speed = abs(pfdata->speed); // use th->speed for total duration + } + else + { + th->ticbased = false; + th->timer = FixedMul(FixedDiv(256, NUMTRANSMAPS), NUMTRANSMAPS - po->translucency); // use as internal counter + th->speed = pfdata->speed; + } oldpo = po; diff --git a/src/p_polyobj.h b/src/p_polyobj.h index d5c07cb5b..61404112c 100644 --- a/src/p_polyobj.h +++ b/src/p_polyobj.h @@ -212,12 +212,13 @@ typedef struct polyfade_s thinker_t thinker; // must be first INT32 polyObjNum; + INT32 sourcevalue; INT32 destvalue; boolean docollision; boolean doghostfade; + boolean ticbased; INT32 timer; INT32 speed; - UINT32 interval; } polyfade_t; // @@ -285,9 +286,8 @@ typedef struct polyfadedata_s INT32 destvalue; boolean docollision; boolean doghostfade; - INT32 timer; + boolean ticbased; INT32 speed; - UINT32 interval; } polyfadedata_t; // diff --git a/src/p_saveg.c b/src/p_saveg.c index 403f05b00..2bfc5859a 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1705,12 +1705,13 @@ static void SavePolyfadeThinker(const thinker_t *th, const UINT8 type) const polyfade_t *ht = (const void *)th; WRITEUINT8(save_p, type); WRITEINT32(save_p, ht->polyObjNum); + WRITEINT32(save_p, ht->sourcevalue); WRITEINT32(save_p, ht->destvalue); WRITEUINT8(save_p, (UINT8)ht->docollision); WRITEUINT8(save_p, (UINT8)ht->doghostfade); + WRITEUINT8(save_p, (UINT8)ht->ticbased); WRITEINT32(save_p, ht->timer); WRITEINT32(save_p, ht->speed); - WRITEUINT32(save_p, ht->interval); } #endif @@ -2719,12 +2720,13 @@ static void LoadPolyfadeThinker(actionf_p1 thinker) polyfade_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); ht->thinker.function.acp1 = thinker; ht->polyObjNum = READINT32(save_p); + ht->sourcevalue = READINT32(save_p); ht->destvalue = READINT32(save_p); ht->docollision = (boolean)READUINT8(save_p); ht->doghostfade = (boolean)READUINT8(save_p); + ht->ticbased = (boolean)READUINT8(save_p); ht->timer = READINT32(save_p); ht->speed = READINT32(save_p); - ht->interval = READUINT32(save_p); P_AddThinker(&ht->thinker); } #endif diff --git a/src/p_spec.c b/src/p_spec.c index 65f7fcd67..49d266f99 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1242,7 +1242,21 @@ static void PolyTranslucency(line_t *line) if (po->isBad) return; - po->translucency = (line->frontsector->floorheight >> FRACBITS) / 100; + // if DONTPEGBOTTOM, specify raw translucency value in Front X Offset + // else, take it out of 1000. If Front X Offset is specified, use that. Else, use floorheight. + if (line->flags & ML_EFFECT3) // relative calc + po->translucency = max(min(po->translucency + ((line->flags & ML_DONTPEGBOTTOM) ? + max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), -NUMTRANSMAPS) + : (sides[line->sidenum[0]].textureoffset ? + max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, 1000), -1000) / 100 + : max(min(line->frontsector->floorheight>>FRACBITS, 1000), -1000) / 100)), + NUMTRANSMAPS), 0); + else + po->translucency = (line->flags & ML_DONTPEGBOTTOM) ? + max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), 0) + : (sides[line->sidenum[0]].textureoffset ? + max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, 1000), 0) / 100 + : max(min(line->frontsector->floorheight>>FRACBITS, 1000), 0) / 100); } // @@ -1265,22 +1279,39 @@ static boolean PolyFade(line_t *line) if (po->isBad) return 0; - // already equal, nothing to do - if (po->translucency == max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), 0)) - return 1; - polyfadedata_t pfd; pfd.polyObjNum = polyObjNum; - pfd.destvalue = max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), 0); - pfd.docollision = !(line->flags & ML_BOUNCY), // do not handle collision flags - pfd.doghostfade = (line->flags & ML_EFFECT1), // do ghost fade (no collision flags during fade) - pfd.timer = abs(sides[line->sidenum[0]].rowoffset>>FRACBITS); - pfd.speed = FixedFloor(FixedDiv(pfd.destvalue - po->translucency, pfd.timer))/FRACUNIT; - if (!pfd.speed) - pfd.speed = (pfd.destvalue < po->translucency) ? -1 : 1; - pfd.interval = max(FixedFloor(FixedDiv(pfd.timer, abs(pfd.destvalue - po->translucency)))/FRACUNIT, 1); + // if DONTPEGBOTTOM, specify raw translucency value in Front X Offset + // else, take it out of 1000 like type 491. If Front X Offset is specified, use that. Else, use floorheight. + if (line->flags & ML_EFFECT3) + pfd.destvalue = max(min(po->translucency + ((line->flags & ML_DONTPEGBOTTOM) ? + max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), -NUMTRANSMAPS) + : (sides[line->sidenum[0]].textureoffset ? + max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, 1000), -1000) / 100 + : max(min(line->frontsector->floorheight>>FRACBITS, 1000), -1000) / 100)), + NUMTRANSMAPS), 0); + else + pfd.destvalue = (line->flags & ML_DONTPEGBOTTOM) ? + max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), 0) + : (sides[line->sidenum[0]].textureoffset ? + max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, 1000), 0) / 100 + : max(min(line->frontsector->floorheight>>FRACBITS, 1000), 0) / 100); + + // already equal, nothing to do + if (po->translucency == pfd.destvalue) + return 1; + + pfd.docollision = !(line->flags & ML_BOUNCY); // do not handle collision flags + pfd.doghostfade = (line->flags & ML_EFFECT1); // do ghost fade (no collision flags during fade) + pfd.ticbased = (line->flags & ML_EFFECT4); // Speed = Tic Duration + + // allow Back Y Offset to be consistent with other fade specials + pfd.speed = (line->sidenum[1] != 0xFFFF && !sides[line->sidenum[0]].rowoffset) ? + abs(sides[line->sidenum[1]].rowoffset>>FRACBITS) + : abs(sides[line->sidenum[0]].rowoffset>>FRACBITS); + return EV_DoPolyObjFade(&pfd); } From 539092bec5a173c4a78b24e90df66a6498843966 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 13 Sep 2018 00:26:24 -0400 Subject: [PATCH 096/132] 491, 492: Allow BLOCKMONSTERS raw translucency value in floorheight --- src/p_spec.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 49d266f99..0502b5638 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1246,14 +1246,18 @@ static void PolyTranslucency(line_t *line) // else, take it out of 1000. If Front X Offset is specified, use that. Else, use floorheight. if (line->flags & ML_EFFECT3) // relative calc po->translucency = max(min(po->translucency + ((line->flags & ML_DONTPEGBOTTOM) ? - max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), -NUMTRANSMAPS) + (sides[line->sidenum[0]].textureoffset ? + max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), -NUMTRANSMAPS) + : max(min(line->frontsector->floorheight>>FRACBITS, NUMTRANSMAPS), -NUMTRANSMAPS)) : (sides[line->sidenum[0]].textureoffset ? max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, 1000), -1000) / 100 : max(min(line->frontsector->floorheight>>FRACBITS, 1000), -1000) / 100)), NUMTRANSMAPS), 0); else po->translucency = (line->flags & ML_DONTPEGBOTTOM) ? - max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), 0) + (sides[line->sidenum[0]].textureoffset ? + max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), 0) + : max(min(line->frontsector->floorheight>>FRACBITS, NUMTRANSMAPS), 0)) : (sides[line->sidenum[0]].textureoffset ? max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, 1000), 0) / 100 : max(min(line->frontsector->floorheight>>FRACBITS, 1000), 0) / 100); @@ -1284,17 +1288,21 @@ static boolean PolyFade(line_t *line) pfd.polyObjNum = polyObjNum; // if DONTPEGBOTTOM, specify raw translucency value in Front X Offset - // else, take it out of 1000 like type 491. If Front X Offset is specified, use that. Else, use floorheight. - if (line->flags & ML_EFFECT3) + // else, take it out of 1000. If Front X Offset is specified, use that. Else, use floorheight. + if (line->flags & ML_EFFECT3) // relative calc pfd.destvalue = max(min(po->translucency + ((line->flags & ML_DONTPEGBOTTOM) ? - max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), -NUMTRANSMAPS) + (sides[line->sidenum[0]].textureoffset ? + max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), -NUMTRANSMAPS) + : max(min(line->frontsector->floorheight>>FRACBITS, NUMTRANSMAPS), -NUMTRANSMAPS)) : (sides[line->sidenum[0]].textureoffset ? max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, 1000), -1000) / 100 : max(min(line->frontsector->floorheight>>FRACBITS, 1000), -1000) / 100)), NUMTRANSMAPS), 0); else pfd.destvalue = (line->flags & ML_DONTPEGBOTTOM) ? - max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), 0) + (sides[line->sidenum[0]].textureoffset ? + max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), 0) + : max(min(line->frontsector->floorheight>>FRACBITS, NUMTRANSMAPS), 0)) : (sides[line->sidenum[0]].textureoffset ? max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, 1000), 0) / 100 : max(min(line->frontsector->floorheight>>FRACBITS, 1000), 0) / 100); From 5aa66f887270733ebfe4bb3452fc58c8f4453995 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 13 Sep 2018 10:38:15 -0400 Subject: [PATCH 097/132] 455: Add speed increment timing (~EFFECT4) to FadeColormap --- src/p_saveg.c | 2 ++ src/p_spec.c | 25 +++++++++++++++++++------ src/p_spec.h | 5 +++-- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 1c8d46aa1..e0d3f1e94 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1687,6 +1687,7 @@ static void SaveFadeColormapThinker(const thinker_t *th, const UINT8 type) WRITEUINT32(save_p, SaveSector(ht->sector)); SaveExtraColormap(save_p, ht->source_exc); SaveExtraColormap(save_p, ht->dest_exc); + WRITEUINT8(save_p, (UINT8)ht->ticbased); WRITEINT32(save_p, ht->duration); WRITEINT32(save_p, ht->timer); } @@ -2686,6 +2687,7 @@ static inline void LoadFadeColormapThinker(actionf_p1 thinker) ht->sector = LoadSector(READUINT32(save_p)); ht->source_exc = LoadExtraColormap(save_p); ht->dest_exc = LoadExtraColormap(save_p); + ht->ticbased = (boolean)READUINT8(save_p); ht->duration = READINT32(save_p); ht->timer = READINT32(save_p); if (ht->sector) diff --git a/src/p_spec.c b/src/p_spec.c index 491671c40..bed5a89b4 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -105,7 +105,7 @@ static void Add_Pusher(pushertype_e type, fixed_t x_mag, fixed_t y_mag, mobj_t * static void Add_MasterDisappearer(tic_t appeartime, tic_t disappeartime, tic_t offset, INT32 line, INT32 sourceline); static void P_ResetColormapFader(sector_t *sector); static void Add_ColormapFader(sector_t *sector, extracolormap_t *source_exc, extracolormap_t *dest_exc, - INT32 duration); + boolean ticbased, INT32 duration); static void P_AddBlockThinker(sector_t *sec, line_t *sourceline); static void P_AddFloatThinker(sector_t *sec, INT32 tag, line_t *sourceline); //static void P_AddBridgeThinker(line_t *sourceline, sector_t *sec); @@ -3445,7 +3445,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) else Z_Free(exc); - Add_ColormapFader(§ors[secnum], source_exc, dest_exc, + Add_ColormapFader(§ors[secnum], source_exc, dest_exc, (line->flags & ML_EFFECT4), // tic-based timing (line->sidenum[1] != 0xFFFF ? abs(sides[line->sidenum[1]].rowoffset >> FRACBITS) : abs(P_AproxDistance(line->dx, line->dy) >> FRACBITS))); } break; @@ -7480,7 +7480,7 @@ static void P_ResetColormapFader(sector_t *sector) } static void Add_ColormapFader(sector_t *sector, extracolormap_t *source_exc, extracolormap_t *dest_exc, - INT32 duration) + boolean ticbased, INT32 duration) { P_ResetColormapFader(sector); @@ -7496,7 +7496,18 @@ static void Add_ColormapFader(sector_t *sector, extracolormap_t *source_exc, ext d->sector = sector; d->source_exc = source_exc; d->dest_exc = dest_exc; - d->duration = d->timer = duration; + + if (ticbased) + { + d->ticbased = true; + d->duration = d->timer = duration; + } + else + { + d->ticbased = false; + d->timer = 256; + d->duration = duration; // use as speed + } sector->fadecolormapdata = d; P_AddThinker(&d->thinker); // add thinker @@ -7504,7 +7515,8 @@ static void Add_ColormapFader(sector_t *sector, extracolormap_t *source_exc, ext void T_FadeColormap(fadecolormap_t *d) { - if (--d->timer <= 0) + if ((d->ticbased && --d->timer <= 0) + || (!d->ticbased && (d->timer -= d->duration) <= 0)) // d->duration used as speed decrement { d->sector->extra_colormap = d->dest_exc; P_ResetColormapFader(d->sector); @@ -7512,7 +7524,8 @@ void T_FadeColormap(fadecolormap_t *d) else { extracolormap_t *exc; - fixed_t factor = min(FixedDiv(d->duration - d->timer, d->duration), 1*FRACUNIT); + INT32 duration = d->ticbased ? d->duration : 256; + fixed_t factor = min(FixedDiv(duration - d->timer, duration), 1*FRACUNIT); INT16 cr, cg, cb, ca, fadestart, fadeend, fog; INT32 rgba, fadergba; diff --git a/src/p_spec.h b/src/p_spec.h index 9e0b7d5c4..0a798ffcc 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -461,8 +461,9 @@ typedef struct sector_t *sector; ///< Sector where action is taking place. extracolormap_t *source_exc; extracolormap_t *dest_exc; - INT32 duration; ///< Total duration for tic-based logic - INT32 timer; ///< Timer for tic-based logic + boolean ticbased; ///< Tic-based timing + INT32 duration; ///< Total duration for tic-based logic (OR: speed increment) + INT32 timer; ///< Timer for tic-based logic (OR: internal speed counter) } fadecolormap_t; void T_FadeColormap(fadecolormap_t *d); From 94939f661357bdf1c6c20b9894cf9d4aee33637b Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 13 Sep 2018 10:41:22 -0400 Subject: [PATCH 098/132] 455: Don't override fadergba on default/no colormap init (~BOUNCY) --- src/p_spec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index bed5a89b4..72b215163 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3390,7 +3390,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) { exc = R_CopyColormap(exc, false); exc->rgba = R_GetRgbaRGB(sides[line->sidenum[0]].colormap_data->rgba) + R_PutRgbaA(R_GetRgbaA(exc->rgba)); - exc->fadergba = R_GetRgbaRGB(sides[line->sidenum[0]].colormap_data->rgba) + R_PutRgbaA(R_GetRgbaA(exc->fadergba)); + //exc->fadergba = R_GetRgbaRGB(sides[line->sidenum[0]].colormap_data->rgba) + R_PutRgbaA(R_GetRgbaA(exc->fadergba)); if (!(source_exc = R_GetColormapFromList(exc))) { From 3fc8ed5a9f05d8a387517ae657f7e224cdddb196 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 13 Sep 2018 10:53:03 -0400 Subject: [PATCH 099/132] 455: Set timing by either Back Y or Front Y, but not line length --- src/p_spec.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index 72b215163..1d213b63e 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3446,7 +3446,9 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) Z_Free(exc); Add_ColormapFader(§ors[secnum], source_exc, dest_exc, (line->flags & ML_EFFECT4), // tic-based timing - (line->sidenum[1] != 0xFFFF ? abs(sides[line->sidenum[1]].rowoffset >> FRACBITS) : abs(P_AproxDistance(line->dx, line->dy) >> FRACBITS))); + ((line->flags & ML_DONTPEGBOTTOM) || !sides[line->sidenum[0]].rowoffset) && line->sidenum[1] != 0xFFFF ? + abs(sides[line->sidenum[1]].rowoffset >> FRACBITS) + : abs(sides[line->sidenum[0]].rowoffset >> FRACBITS)); } break; From 6824e6a3596031a11e78b9c1d4706deee592c83c Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 13 Sep 2018 12:08:46 -0400 Subject: [PATCH 100/132] Make extracolormap_t->fog UINT8; it's not boolean, but categorical --- src/p_saveg.c | 7 +++---- src/r_data.c | 10 +++++----- src/r_data.h | 8 ++++---- src/r_defs.h | 2 +- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index c9b474b1d..2d39ccfa2 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -481,7 +481,7 @@ static void SaveExtraColormap(UINT8 *put, extracolormap_t *exc) WRITEUINT8(put, exc->fadestart); WRITEUINT8(put, exc->fadeend); - WRITEUINT8(put, (UINT8)exc->fog); + WRITEUINT8(put, exc->fog); WRITEINT32(put, exc->rgba); WRITEINT32(put, exc->fadergba); @@ -497,9 +497,8 @@ static extracolormap_t *LoadExtraColormap(UINT8 *get) //size_t dbg_i = 0; UINT8 fadestart = READUINT8(get), - fadeend = READUINT8(get); - - boolean fog = (boolean)READUINT8(get); + fadeend = READUINT8(get), + fog = READUINT8(get); INT32 rgba = READINT32(get), fadergba = READINT32(get); diff --git a/src/r_data.c b/src/r_data.c index c2e28fe9f..e987da066 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1439,10 +1439,10 @@ void R_AddColormapToList(extracolormap_t *extra_colormap) // #ifdef EXTRACOLORMAPLUMPS boolean R_CheckDefaultColormapByValues(boolean checkrgba, boolean checkfadergba, boolean checkparams, - INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog, lumpnum_t lump) + INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, UINT8 fog, lumpnum_t lump) #else boolean R_CheckDefaultColormapByValues(boolean checkrgba, boolean checkfadergba, boolean checkparams, - INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog) + INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, UINT8 fog) #endif { return ( @@ -1504,9 +1504,9 @@ boolean R_CheckEqualColormaps(extracolormap_t *exc_a, extracolormap_t *exc_b, bo // NOTE: Returns NULL if no match is found // #ifdef EXTRACOLORMAPLUMPS -extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog, lumpnum_t lump) +extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, UINT8 fog, lumpnum_t lump) #else -extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog) +extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, UINT8 fog) #endif { extracolormap_t *exc; @@ -1730,7 +1730,7 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) // default values UINT8 cr = 0, cg = 0, cb = 0, ca = 0, cfr = 0, cfg = 0, cfb = 0, cfa = 25; UINT32 fadestart = 0, fadeend = 31; - boolean fog = false; + UINT8 fog = 0; INT32 rgba = 0, fadergba = 0x19000000; #define HEX2INT(x) (UINT32)(x >= '0' && x <= '9' ? x - '0' : x >= 'a' && x <= 'f' ? x - 'a' + 10 : x >= 'A' && x <= 'F' ? x - 'A' + 10 : 0) diff --git a/src/r_data.h b/src/r_data.h index 3a7740c96..54857661a 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -112,12 +112,12 @@ void R_AddColormapToList(extracolormap_t *extra_colormap); #ifdef EXTRACOLORMAPLUMPS boolean R_CheckDefaultColormapByValues(boolean checkrgba, boolean checkfadergba, boolean checkparams, - INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog, lumpnum_t lump); -extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog, lumpnum_t lump); + INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, UINT8 fog, lumpnum_t lump); +extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, UINT8 fog, lumpnum_t lump); #else boolean R_CheckDefaultColormapByValues(boolean checkrgba, boolean checkfadergba, boolean checkparams, - INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog); -extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog); + INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, UINT8 fog); +extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, UINT8 fog); #endif boolean R_CheckDefaultColormap(extracolormap_t *extra_colormap, boolean checkrgba, boolean checkfadergba, boolean checkparams); boolean R_CheckEqualColormaps(extracolormap_t *exc_a, extracolormap_t *exc_b, boolean checkrgba, boolean checkfadergba, boolean checkparams); diff --git a/src/r_defs.h b/src/r_defs.h index 1f2afdb99..b9c6fd7dc 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -53,7 +53,7 @@ typedef UINT8 lighttable_t; typedef struct extracolormap_s { UINT8 fadestart, fadeend; - boolean fog; + UINT8 fog; // 1 = disable sprite fullbright, 2 = force planes fullbright, see public gitlab !268 // store rgba values in combined bitwise // also used in OpenGL instead lighttables From 761150b12d3b0fcf1a7f392d609b4a43e75ae982 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 13 Sep 2018 12:18:10 -0400 Subject: [PATCH 101/132] 455: Fog flag fix for fading --- src/p_spec.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 1d213b63e..88a046b37 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -7577,9 +7577,7 @@ void T_FadeColormap(fadecolormap_t *d) fadestart = APPLYFADE(d->dest_exc->fadestart, d->source_exc->fadestart, d->sector->extra_colormap->fadestart); fadeend = APPLYFADE(d->dest_exc->fadeend, d->source_exc->fadeend, d->sector->extra_colormap->fadeend); - // fog: essentially we're switching from source_exc->fog to dest_exc->fog with a delta - // of 1 or -1, and hoping the factor rounds appropriately in the timing. - fog = APPLYFADE(d->dest_exc->fog, d->source_exc->fog, d->sector->extra_colormap->fog); + fog = abs(factor) > FRACUNIT/2 ? d->dest_exc->fog : d->source_exc->fog; // set new fog flag halfway through fade #undef APPLYFADE From 07af82aa8495101c8170a44b7f92cb5c3dc7eb69 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 13 Sep 2018 12:18:53 -0400 Subject: [PATCH 102/132] Missed fog boolean -> integer --- src/r_data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_data.c b/src/r_data.c index e987da066..f1cd519e0 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1784,7 +1784,7 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) { if (p2[1]) { - fog = (boolean)NUMFROMCHAR(p2[1]); + fog = NUMFROMCHAR(p2[1]); if (p2[2] && p2[3]) { fadestart = NUMFROMCHAR(p2[3]) + (NUMFROMCHAR(p2[2]) * 10); From 714464993ef49e8f6beb3133dce03380e0289c36 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 14 Sep 2018 08:26:52 -0400 Subject: [PATCH 103/132] 420: Removed unnecessary include (gametic no longer needed) --- src/p_lights.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/p_lights.c b/src/p_lights.c index 95171155e..8bcdd8ce0 100644 --- a/src/p_lights.c +++ b/src/p_lights.c @@ -13,7 +13,6 @@ /// Fire flicker, light flash, strobe flash, lightning flash, glow, and fade. #include "doomdef.h" -#include "doomstat.h" // gametic #include "p_local.h" #include "r_state.h" #include "z_zone.h" From 546fa383c1c74499552e031b11020ed71a6d8561 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 14 Sep 2018 21:01:07 +0100 Subject: [PATCH 104/132] Make sure that T_MarioBlockChecker is synced in netgames, so that the textures of Mario Blocks can change when there are no more items --- src/p_saveg.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/p_saveg.c b/src/p_saveg.c index d1ec8e5ab..6e0c704f6 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -950,6 +950,7 @@ typedef enum tc_bouncecheese, tc_startcrumble, tc_marioblock, + tc_marioblockchecker, tc_spikesector, tc_floatsector, tc_bridgethinker, @@ -1774,6 +1775,11 @@ static void P_NetArchiveThinkers(void) SaveSpecialLevelThinker(th, tc_marioblock); continue; } + else if (th->function.acp1 == (actionf_p1)T_MarioBlockChecker) + { + SaveSpecialLevelThinker(th, tc_marioblockchecker); + continue; + } else if (th->function.acp1 == (actionf_p1)T_SpikeSector) { SaveSpecialLevelThinker(th, tc_spikesector); @@ -2730,6 +2736,10 @@ static void P_NetUnArchiveThinkers(void) LoadSpecialLevelThinker((actionf_p1)T_MarioBlock, 3); break; + case tc_marioblockchecker: + LoadSpecialLevelThinker((actionf_p1)T_MarioBlockChecker, 0); + break; + case tc_spikesector: LoadSpecialLevelThinker((actionf_p1)T_SpikeSector, 0); break; From f85d1da54f700cfc88b1a4bcc56260c8141584a5 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 14 Sep 2018 21:42:52 -0400 Subject: [PATCH 105/132] Lua support for floorrover/ceilingrover --- src/lua_mobjlib.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 6efbeff8e..da0e99ab2 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -40,6 +40,8 @@ enum mobj_e { mobj_subsector, mobj_floorz, mobj_ceilingz, + mobj_floorrover, + mobj_ceilingrover, mobj_radius, mobj_height, mobj_momx, @@ -100,6 +102,8 @@ static const char *const mobj_opt[] = { "subsector", "floorz", "ceilingz", + "floorrover", + "ceilingrover", "radius", "height", "momx", @@ -208,6 +212,12 @@ static int mobj_get(lua_State *L) case mobj_ceilingz: lua_pushfixed(L, mo->ceilingz); break; + case mobj_floorrover: + LUA_PushUserdata(L, mo->floorrover, META_FFLOOR); + break; + case mobj_ceilingrover: + LUA_PushUserdata(L, mo->ceilingrover, META_FFLOOR); + break; case mobj_radius: lua_pushfixed(L, mo->radius); break; @@ -432,6 +442,10 @@ static int mobj_set(lua_State *L) return NOSETPOS; case mobj_ceilingz: return NOSETPOS; + case mobj_floorrover: + return NOSET; + case mobj_ceilingrover: + return NOSET; case mobj_radius: { mobj_t *ptmthing = tmthing; From 2f995f4cbeed00a5fb3646a4be8a086d0609fb5a Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 14 Sep 2018 22:35:08 -0400 Subject: [PATCH 106/132] Remove possibly wrong comment about extracolormap_t->fog --- src/r_defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_defs.h b/src/r_defs.h index b9c6fd7dc..e1c1d45c2 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -53,7 +53,7 @@ typedef UINT8 lighttable_t; typedef struct extracolormap_s { UINT8 fadestart, fadeend; - UINT8 fog; // 1 = disable sprite fullbright, 2 = force planes fullbright, see public gitlab !268 + UINT8 fog; // categorical value, not boolean // store rgba values in combined bitwise // also used in OpenGL instead lighttables From 57959522e20b0bce603fa51ff1d9f76abf30dafe Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 15 Sep 2018 00:48:34 -0400 Subject: [PATCH 107/132] Colormap overhaul r_data: Mixed D+C fix --- src/r_data.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/r_data.c b/src/r_data.c index f1cd519e0..ce0213b36 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1905,6 +1905,8 @@ extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *ex boolean useAltAlpha, INT16 altAlpha, INT16 altFadeAlpha, boolean lighttable) { + INT16 red, green, blue, alpha; + // exc_augend is added (or subtracted) onto by exc_addend // In Rennaisance times, the first number was considered the augend, the second number the addend // But since the commutative property was discovered, today they're both called addends! @@ -1914,8 +1916,6 @@ extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *ex if(!exc_addend) exc_addend = R_GetDefaultColormap(); - INT16 red, green, blue, alpha; - /////////////////// // base rgba /////////////////// From 1db8aee539dea8942dafa30a8281f29f2d8704c8 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 15 Sep 2018 00:51:55 -0400 Subject: [PATCH 108/132] 455: Mixed D+C fix --- src/p_spec.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index 88a046b37..a408b2140 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -7484,6 +7484,8 @@ static void P_ResetColormapFader(sector_t *sector) static void Add_ColormapFader(sector_t *sector, extracolormap_t *source_exc, extracolormap_t *dest_exc, boolean ticbased, INT32 duration) { + fadecolormap_t *d; + P_ResetColormapFader(sector); // nothing to do, set immediately @@ -7493,7 +7495,7 @@ static void Add_ColormapFader(sector_t *sector, extracolormap_t *source_exc, ext return; } - fadecolormap_t *d = Z_Malloc(sizeof *d, PU_LEVSPEC, NULL); + d = Z_Malloc(sizeof *d, PU_LEVSPEC, NULL); d->thinker.function.acp1 = (actionf_p1)T_FadeColormap; d->sector = sector; d->source_exc = source_exc; From ca4a94eca5ae9517b4d0d055d4a879b3dc45911e Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 15 Sep 2018 00:56:27 -0400 Subject: [PATCH 109/132] 492: Mixed D+C fix --- src/p_spec.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 0502b5638..2583c24f3 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1272,6 +1272,7 @@ static boolean PolyFade(line_t *line) { INT32 polyObjNum = line->tag; polyobj_t *po; + polyfadedata_t pfd; if (!(po = Polyobj_GetForNum(polyObjNum))) { @@ -1283,8 +1284,6 @@ static boolean PolyFade(line_t *line) if (po->isBad) return 0; - polyfadedata_t pfd; - pfd.polyObjNum = polyObjNum; // if DONTPEGBOTTOM, specify raw translucency value in Front X Offset From 6844ed37c5ae95dfb7294eaaaf84538cf45e6f27 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 15 Sep 2018 01:47:56 -0400 Subject: [PATCH 110/132] Colormap overhaul: %d format size_t -> UINT32 fix --- src/p_saveg.c | 5 ++--- src/r_data.c | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 2d39ccfa2..f9841717e 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -494,7 +494,6 @@ static void SaveExtraColormap(UINT8 *put, extracolormap_t *exc) static extracolormap_t *LoadExtraColormap(UINT8 *get) { extracolormap_t *exc, *exc_exist; - //size_t dbg_i = 0; UINT8 fadestart = READUINT8(get), fadeend = READUINT8(get), @@ -515,8 +514,8 @@ static extracolormap_t *LoadExtraColormap(UINT8 *get) if (!exc) { // CONS_Debug(DBG_RENDER, "Creating Colormap: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", - // (rgba)&0xFF, (rgba>>8)&0xFF, (rgba>>16)&0xFF, (rgba>>24)&0xFF, - // (fadergba)&0xFF, (fadergba>>8)&0xFF, (fadergba>>16)&0xFF, (fadergba>>24)&0xFF); + // R_GetRgbaR(rgba), R_GetRgbaG(rgba), R_GetRgbaB(rgba), R_GetRgbaA(rgba), + // R_GetRgbaR(fadergba), R_GetRgbaG(fadergba), R_GetRgbaB(fadergba), R_GetRgbaA(fadergba)); exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL); diff --git a/src/r_data.c b/src/r_data.c index ce0213b36..cfc1a734e 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1510,7 +1510,7 @@ extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 #endif { extracolormap_t *exc; - size_t dbg_i = 0; + UINT32 dbg_i = 0; for (exc = extra_colormaps; exc; exc = exc->next) { @@ -1525,8 +1525,8 @@ extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 ) { CONS_Debug(DBG_RENDER, "Found Colormap %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", - dbg_i, (rgba)&0xFF, (rgba>>8)&0xFF, (rgba>>16)&0xFF, (rgba>>24)&0xFF, - (fadergba)&0xFF, (fadergba>>8)&0xFF, (fadergba>>16)&0xFF, (fadergba>>24)&0xFF); + dbg_i, R_GetRgbaR(rgba), R_GetRgbaG(rgba), R_GetRgbaB(rgba), R_GetRgbaA(rgba), + R_GetRgbaR(fadergba), R_GetRgbaG(fadergba), R_GetRgbaB(fadergba), R_GetRgbaA(fadergba)); return exc; } dbg_i++; From efe0af960dd2d084f5a9ec8e9c56eda67ca57a65 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 15 Sep 2018 02:10:17 -0400 Subject: [PATCH 111/132] Colormap overhaul: Wrap R_CheckNumForNameList under ifdef EXTRACOLORMAPLUMPS --- src/r_data.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/r_data.c b/src/r_data.c index cfc1a734e..08e3d91b6 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1144,6 +1144,10 @@ void R_ParseTEXTURESLump(UINT16 wadNum, UINT16 lumpNum, INT32 *texindex) Z_Free((void *)texturesText); } +#ifdef EXTRACOLORMAPLUMPS +static lumplist_t *colormaplumps = NULL; ///\todo free leak +static size_t numcolormaplumps = 0; + static inline lumpnum_t R_CheckNumForNameList(const char *name, lumplist_t *list, size_t listsize) { size_t i; @@ -1160,10 +1164,6 @@ static inline lumpnum_t R_CheckNumForNameList(const char *name, lumplist_t *list return LUMPERROR; } -#ifdef EXTRACOLORMAPLUMPS -static lumplist_t *colormaplumps = NULL; ///\todo free leak -static size_t numcolormaplumps = 0; - static void R_InitExtraColormaps(void) { lumpnum_t startnum, endnum; From ab4a825385bee6aa3fd4577d4744e3e1e1830134 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 15 Sep 2018 19:00:50 -0400 Subject: [PATCH 112/132] 420: Combine speed and duration logic for fade lighting --- src/p_lights.c | 61 ++++++++++++++------------------------------------ src/p_saveg.c | 4 ++-- src/p_spec.h | 4 ++-- 3 files changed, 21 insertions(+), 48 deletions(-) diff --git a/src/p_lights.c b/src/p_lights.c index 8bcdd8ce0..6eb9b02ca 100644 --- a/src/p_lights.c +++ b/src/p_lights.c @@ -13,6 +13,7 @@ /// Fire flicker, light flash, strobe flash, lightning flash, glow, and fade. #include "doomdef.h" +#include "doomstat.h" #include "p_local.h" #include "r_state.h" #include "z_zone.h" @@ -327,7 +328,8 @@ glow_t *P_SpawnAdjustableGlowingLight(sector_t *minsector, sector_t *maxsector, * * \param sector Target sector * \param destvalue The final light value in these sectors. - * \param speed Speed of the fade; the change to the ligh + * \param speed If tic-based: total duration of effect. + * If speed-based: Speed of the fade; the change to the ligh * level in each sector per tic. * \param ticbased Use a specific duration for the fade, defined by speed * \sa T_LightFade @@ -357,13 +359,13 @@ void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean if (ticbased) { ll->ticbased = true; - ll->timer = ll->speed = abs(speed); // use ll->speed for total duration + ll->timer = ll->duration = abs(speed); // speed means duration } else { ll->ticbased = false; - ll->timer = -1; - ll->speed = abs(speed); + ll->timer = abs(ll->destlevel - ll->sourcelevel); + ll->duration = abs(speed); // ll->duration is used as speed } } @@ -382,49 +384,20 @@ void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased) */ void T_LightFade(lightlevel_t *ll) { - if (ll->ticbased) + if ((ll->ticbased && --ll->timer <= 0) + || (!ll->ticbased && (ll->timer -= ll->duration) <= 0)) { - if (--ll->timer <= 0) - { - ll->sector->lightlevel = ll->destlevel; // set to dest lightlevel - P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker - } - else - { - INT16 delta = abs(ll->destlevel - ll->sourcelevel); - fixed_t factor = min(FixedDiv(ll->speed - ll->timer, ll->speed), 1*FRACUNIT); - if (ll->destlevel < ll->sourcelevel) - ll->sector->lightlevel = max(min(ll->sector->lightlevel, ll->sourcelevel - (INT16)FixedMul(delta, factor)), ll->destlevel); - else if (ll->destlevel > ll->sourcelevel) - ll->sector->lightlevel = min(max(ll->sector->lightlevel, ll->sourcelevel + (INT16)FixedMul(delta, factor)), ll->destlevel); - } - return; - } - - if (ll->sector->lightlevel < ll->destlevel) - { - // increase the lightlevel - if (ll->sector->lightlevel + ll->speed >= ll->destlevel) - { - // stop changing light level - ll->sector->lightlevel = ll->destlevel; // set to dest lightlevel - - P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker - } - else - ll->sector->lightlevel += ll->speed; // move lightlevel + ll->sector->lightlevel = ll->destlevel; // set to dest lightlevel + P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker } else { - // decrease lightlevel - if (ll->sector->lightlevel - ll->speed <= ll->destlevel) - { - // stop changing light level - ll->sector->lightlevel = ll->destlevel; // set to dest lightlevel - - P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker - } - else - ll->sector->lightlevel -= ll->speed; // move lightlevel + INT16 delta = abs(ll->destlevel - ll->sourcelevel); + INT32 duration = ll->ticbased ? ll->duration : delta; // speed-based: timer's initial value is equal to delta + fixed_t factor = min(FixedDiv(duration - ll->timer, duration), 1*FRACUNIT); + if (ll->destlevel < ll->sourcelevel) + ll->sector->lightlevel = max(min(ll->sector->lightlevel, ll->sourcelevel - (INT16)FixedMul(delta, factor)), ll->destlevel); + else if (ll->destlevel > ll->sourcelevel) + ll->sector->lightlevel = min(max(ll->sector->lightlevel, ll->sourcelevel + (INT16)FixedMul(delta, factor)), ll->destlevel); } } diff --git a/src/p_saveg.c b/src/p_saveg.c index 574f871bb..b2d430d1e 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1561,8 +1561,8 @@ static void SaveLightlevelThinker(const thinker_t *th, const UINT8 type) WRITEUINT32(save_p, SaveSector(ht->sector)); WRITEINT16(save_p, ht->sourcelevel); WRITEINT16(save_p, ht->destlevel); - WRITEINT16(save_p, ht->speed); WRITEUINT8(save_p, (UINT8)ht->ticbased); + WRITEINT16(save_p, ht->duration); WRITEINT32(save_p, ht->timer); } @@ -2537,8 +2537,8 @@ static inline void LoadLightlevelThinker(actionf_p1 thinker) ht->sector = LoadSector(READUINT32(save_p)); ht->sourcelevel = READINT16(save_p); ht->destlevel = READINT16(save_p); - ht->speed = READINT16(save_p); ht->ticbased = (boolean)READUINT8(save_p); + ht->duration = READINT16(save_p); ht->timer = READINT32(save_p); if (ht->sector) ht->sector->lightingdata = ht; diff --git a/src/p_spec.h b/src/p_spec.h index 69087d6c4..daa6dd18a 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -138,11 +138,11 @@ typedef struct sector_t *sector; ///< Sector where action is taking place. INT16 sourcelevel; ///< Light level we're fading from. INT16 destlevel; ///< Light level we're fading to. - INT16 speed; ///< Speed at which to change light level. OR: Tic-based duration // Tic-based behavior boolean ticbased; ///< Tic-based logic - INT32 timer; ///< Tic-based timer + INT16 duration; ///< If tic-based: duration of effect. If speed-based: amount to increment + INT32 timer; ///< Internal timer } lightlevel_t; #define GLOWSPEED 8 From d939e597a5a5fa5a8e89c34edfcc12cce6e3fc2e Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 15 Sep 2018 20:03:43 -0400 Subject: [PATCH 113/132] 420: Unncessary include --- src/p_lights.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/p_lights.c b/src/p_lights.c index 6eb9b02ca..e4d7ebe9d 100644 --- a/src/p_lights.c +++ b/src/p_lights.c @@ -13,7 +13,6 @@ /// Fire flicker, light flash, strobe flash, lightning flash, glow, and fade. #include "doomdef.h" -#include "doomstat.h" #include "p_local.h" #include "r_state.h" #include "z_zone.h" From 350cd1435b55449a0ed9b6feee21cd8ba289fd19 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Sat, 15 Sep 2018 12:21:25 +0200 Subject: [PATCH 114/132] The thinker is entirely unified now, and there is no difference in the light levels between the "old" behavior and this one now. --- src/p_lights.c | 33 ++++++++++++++++----------------- src/p_saveg.c | 8 ++++---- src/p_spec.h | 16 ++++++++-------- 3 files changed, 28 insertions(+), 29 deletions(-) diff --git a/src/p_lights.c b/src/p_lights.c index e4d7ebe9d..00c0e960f 100644 --- a/src/p_lights.c +++ b/src/p_lights.c @@ -355,17 +355,21 @@ void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean ll->sourcelevel = sector->lightlevel; ll->destlevel = destvalue; + ll->fixedcurlevel = sector->lightlevel<ticbased = true; - ll->timer = ll->duration = abs(speed); // speed means duration + // Speed means duration. + ll->timer = abs(speed); + ll->fixedpertic = FixedDiv((destvalue<fixedcurlevel, speed<ticbased = false; - ll->timer = abs(ll->destlevel - ll->sourcelevel); - ll->duration = abs(speed); // ll->duration is used as speed + // Speed means increment per tic (literally speed). + ll->timer = FixedDiv((destvalue<fixedcurlevel, speed<>FRACBITS; + ll->fixedpertic = speed<sector->lightlevel, destvalue, ll->fixedpertic>>FRACBITS, ll->timer); } void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased) @@ -383,20 +387,15 @@ void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased) */ void T_LightFade(lightlevel_t *ll) { - if ((ll->ticbased && --ll->timer <= 0) - || (!ll->ticbased && (ll->timer -= ll->duration) <= 0)) + if (--ll->timer <= 0) { ll->sector->lightlevel = ll->destlevel; // set to dest lightlevel P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker + CONS_Printf("End tic, final light value: %d\n", ll->sector->lightlevel); + return; } - else - { - INT16 delta = abs(ll->destlevel - ll->sourcelevel); - INT32 duration = ll->ticbased ? ll->duration : delta; // speed-based: timer's initial value is equal to delta - fixed_t factor = min(FixedDiv(duration - ll->timer, duration), 1*FRACUNIT); - if (ll->destlevel < ll->sourcelevel) - ll->sector->lightlevel = max(min(ll->sector->lightlevel, ll->sourcelevel - (INT16)FixedMul(delta, factor)), ll->destlevel); - else if (ll->destlevel > ll->sourcelevel) - ll->sector->lightlevel = min(max(ll->sector->lightlevel, ll->sourcelevel + (INT16)FixedMul(delta, factor)), ll->destlevel); - } + + ll->fixedcurlevel = ll->fixedcurlevel + ll->fixedpertic; + ll->sector->lightlevel = (ll->fixedcurlevel)>>FRACBITS; + CONS_Printf("Light %d\n", ll->sector->lightlevel); } diff --git a/src/p_saveg.c b/src/p_saveg.c index b2d430d1e..c95a08361 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1561,8 +1561,8 @@ static void SaveLightlevelThinker(const thinker_t *th, const UINT8 type) WRITEUINT32(save_p, SaveSector(ht->sector)); WRITEINT16(save_p, ht->sourcelevel); WRITEINT16(save_p, ht->destlevel); - WRITEUINT8(save_p, (UINT8)ht->ticbased); - WRITEINT16(save_p, ht->duration); + WRITEFIXED(save_p, ht->fixedcurlevel); + WRITEFIXED(save_p, ht->fixedpertic); WRITEINT32(save_p, ht->timer); } @@ -2537,8 +2537,8 @@ static inline void LoadLightlevelThinker(actionf_p1 thinker) ht->sector = LoadSector(READUINT32(save_p)); ht->sourcelevel = READINT16(save_p); ht->destlevel = READINT16(save_p); - ht->ticbased = (boolean)READUINT8(save_p); - ht->duration = READINT16(save_p); + ht->fixedcurlevel = READFIXED(save_p); + ht->fixedpertic = READFIXED(save_p); ht->timer = READINT32(save_p); if (ht->sector) ht->sector->lightingdata = ht; diff --git a/src/p_spec.h b/src/p_spec.h index daa6dd18a..2c9e986ce 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -134,15 +134,15 @@ typedef struct */ typedef struct { - thinker_t thinker; ///< Thinker in use for the effect. - sector_t *sector; ///< Sector where action is taking place. - INT16 sourcelevel; ///< Light level we're fading from. - INT16 destlevel; ///< Light level we're fading to. + thinker_t thinker; ///< Thinker in use for the effect. + sector_t *sector; ///< Sector where action is taking place. + INT16 sourcelevel; ///< Light level we're fading from. + INT16 destlevel; ///< Light level we're fading to. - // Tic-based behavior - boolean ticbased; ///< Tic-based logic - INT16 duration; ///< If tic-based: duration of effect. If speed-based: amount to increment - INT32 timer; ///< Internal timer + fixed_t fixedcurlevel; ///< Fixed point for current light level. + fixed_t fixedpertic; ///< Fixed point for increment per tic. + // The reason for those two above to be fixed point is to deal with decimal values that would otherwise get trimmed away. + INT32 timer; ///< Internal timer. } lightlevel_t; #define GLOWSPEED 8 From 17e23f55eb700a28d19029e6b5a4938acdd21473 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 15 Sep 2018 20:00:04 -0400 Subject: [PATCH 115/132] 492: Merge speed and duration logic for fade polyobject --- src/p_polyobj.c | 68 ++++++++++++++++--------------------------------- src/p_polyobj.h | 2 +- src/p_saveg.c | 4 +-- 3 files changed, 25 insertions(+), 49 deletions(-) diff --git a/src/p_polyobj.c b/src/p_polyobj.c index f7545e5bd..bbcf4f42a 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -2873,54 +2873,29 @@ void T_PolyObjFade(polyfade_t *th) if (po->thinker == NULL) po->thinker = &th->thinker; - if (th->ticbased) + stillfading = th->ticbased ? !(--(th->timer) <= 0) + : !((th->timer -= th->duration) <= 0); + + if (th->timer <= 0) { - stillfading = !(--(th->timer) <= 0); + po->translucency = max(min(th->destvalue, NUMTRANSMAPS), 0); - if (th->timer <= 0) - { - po->translucency = max(min(th->destvalue, NUMTRANSMAPS), 0); - - // remove thinker - if (po->thinker == &th->thinker) - po->thinker = NULL; - P_RemoveThinker(&th->thinker); - } - else - { - INT16 delta = abs(th->destvalue - th->sourcevalue); - fixed_t factor = min(FixedDiv(th->speed - th->timer, th->speed), 1*FRACUNIT); - if (th->destvalue < th->sourcevalue) - po->translucency = max(min(po->translucency, th->sourcevalue - (INT16)FixedMul(delta, factor)), th->destvalue); - else if (th->destvalue > th->sourcevalue) - po->translucency = min(max(po->translucency, th->sourcevalue + (INT16)FixedMul(delta, factor)), th->destvalue); - } + // remove thinker + if (po->thinker == &th->thinker) + po->thinker = NULL; + P_RemoveThinker(&th->thinker); } else { - fixed_t timerdest = FixedMul(FixedDiv(256, NUMTRANSMAPS), NUMTRANSMAPS-th->destvalue); - - if (th->destvalue > th->sourcevalue) // fading out, destvalue is higher - { - // for timer, lower is transparent, higher is opaque - stillfading = (th->timer > timerdest); - th->timer = max(timerdest, th->timer - th->speed); - } - else if (th->destvalue < th->sourcevalue) // fading in, destvalue is lower - { stillfading = (th->timer < timerdest); - th->timer = min(timerdest, th->timer + th->speed); - } - - if (!stillfading) - { - po->translucency = max(min(th->destvalue, NUMTRANSMAPS), 0); - // remove thinker - if (po->thinker == &th->thinker) - po->thinker = NULL; - P_RemoveThinker(&th->thinker); - } - else - po->translucency = FixedDiv(256-th->timer, FixedDiv(256, NUMTRANSMAPS)); + INT16 delta = abs(th->destvalue - th->sourcevalue); + INT32 duration = th->ticbased ? th->duration + : abs(FixedMul(FixedDiv(256, NUMTRANSMAPS), NUMTRANSMAPS - th->destvalue) + - FixedMul(FixedDiv(256, NUMTRANSMAPS), NUMTRANSMAPS - th->sourcevalue)); // speed-based internal counter duration: delta in 256 scale + fixed_t factor = min(FixedDiv(duration - th->timer, duration), 1*FRACUNIT); + if (th->destvalue < th->sourcevalue) + po->translucency = max(min(po->translucency, th->sourcevalue - (INT16)FixedMul(delta, factor)), th->destvalue); + else if (th->destvalue > th->sourcevalue) + po->translucency = min(max(po->translucency, th->sourcevalue + (INT16)FixedMul(delta, factor)), th->destvalue); } if (!stillfading) @@ -3010,13 +2985,14 @@ INT32 EV_DoPolyObjFade(polyfadedata_t *pfdata) if (pfdata->ticbased) { th->ticbased = true; - th->timer = th->speed = abs(pfdata->speed); // use th->speed for total duration + th->timer = th->duration = abs(pfdata->speed); // pfdata->speed is duration } else { th->ticbased = false; - th->timer = FixedMul(FixedDiv(256, NUMTRANSMAPS), NUMTRANSMAPS - po->translucency); // use as internal counter - th->speed = pfdata->speed; + th->timer = abs(FixedMul(FixedDiv(256, NUMTRANSMAPS), NUMTRANSMAPS - th->destvalue) + - FixedMul(FixedDiv(256, NUMTRANSMAPS), NUMTRANSMAPS - th->sourcevalue)); // delta converted to 256 scale, use as internal counter + th->duration = abs(pfdata->speed); // use th->duration as speed decrement } oldpo = po; diff --git a/src/p_polyobj.h b/src/p_polyobj.h index 61404112c..524518f2a 100644 --- a/src/p_polyobj.h +++ b/src/p_polyobj.h @@ -217,8 +217,8 @@ typedef struct polyfade_s boolean docollision; boolean doghostfade; boolean ticbased; + INT32 duration; INT32 timer; - INT32 speed; } polyfade_t; // diff --git a/src/p_saveg.c b/src/p_saveg.c index 2bfc5859a..11c481be8 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1710,8 +1710,8 @@ static void SavePolyfadeThinker(const thinker_t *th, const UINT8 type) WRITEUINT8(save_p, (UINT8)ht->docollision); WRITEUINT8(save_p, (UINT8)ht->doghostfade); WRITEUINT8(save_p, (UINT8)ht->ticbased); + WRITEINT32(save_p, ht->duration); WRITEINT32(save_p, ht->timer); - WRITEINT32(save_p, ht->speed); } #endif @@ -2725,8 +2725,8 @@ static void LoadPolyfadeThinker(actionf_p1 thinker) ht->docollision = (boolean)READUINT8(save_p); ht->doghostfade = (boolean)READUINT8(save_p); ht->ticbased = (boolean)READUINT8(save_p); + ht->duration = READINT32(save_p); ht->timer = READINT32(save_p); - ht->speed = READINT32(save_p); P_AddThinker(&ht->thinker); } #endif From d49f0be4ee11b57678c8ef1230063463d6c0c432 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 16 Sep 2018 08:20:14 -0400 Subject: [PATCH 116/132] 420: Strip test comments --- src/p_lights.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/p_lights.c b/src/p_lights.c index 00c0e960f..2ea93b796 100644 --- a/src/p_lights.c +++ b/src/p_lights.c @@ -369,7 +369,6 @@ void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean ll->timer = FixedDiv((destvalue<fixedcurlevel, speed<>FRACBITS; ll->fixedpertic = speed<sector->lightlevel, destvalue, ll->fixedpertic>>FRACBITS, ll->timer); } void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased) @@ -391,11 +390,9 @@ void T_LightFade(lightlevel_t *ll) { ll->sector->lightlevel = ll->destlevel; // set to dest lightlevel P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker - CONS_Printf("End tic, final light value: %d\n", ll->sector->lightlevel); return; } ll->fixedcurlevel = ll->fixedcurlevel + ll->fixedpertic; ll->sector->lightlevel = (ll->fixedcurlevel)>>FRACBITS; - CONS_Printf("Light %d\n", ll->sector->lightlevel); } From 4cdbc7249ff5a6af8d1b01994950359b16554c73 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 16 Sep 2018 20:02:29 -0400 Subject: [PATCH 117/132] Streamlined colormap netsyncing so duplicates are not saved to $$$.sav per sector --- src/p_saveg.c | 196 +++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 155 insertions(+), 41 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index f9841717e..a63ef1276 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -474,50 +474,144 @@ static void P_NetUnArchivePlayers(void) } } -static void SaveExtraColormap(UINT8 *put, extracolormap_t *exc) +/// +/// Colormaps +/// + +static extracolormap_t *net_colormaps = NULL; +static UINT32 num_net_colormaps = 0; + +// Copypasta from r_data.c AddColormapToList +// But also check for equality and return the matching index +static UINT32 CheckAddNetColormapToList(extracolormap_t *extra_colormap) { - if (!exc) // Just give it default values, we done goofed. (or sector->extra_colormap was intentionally set to default (NULL)) - exc = R_GetDefaultColormap(); + extracolormap_t *exc; + UINT32 i = 0; - WRITEUINT8(put, exc->fadestart); - WRITEUINT8(put, exc->fadeend); - WRITEUINT8(put, exc->fog); + if (!net_colormaps) + { + net_colormaps = extra_colormap; + net_colormaps->next = 0; + net_colormaps->prev = 0; + return i; + } - WRITEINT32(put, exc->rgba); - WRITEINT32(put, exc->fadergba); + for (exc = net_colormaps; exc->next; exc = exc->next) + { + if (R_CheckEqualColormaps(exc, extra_colormap, true, true, true)) + return i; + i++; + } -#ifdef EXTRACOLORMAPLUMPS - WRITESTRINGN(put, exc->lumpname, 9); -#endif + exc->next = extra_colormap; + extra_colormap->prev = exc; + extra_colormap->next = 0; + + num_net_colormaps = i; + return i; } -static extracolormap_t *LoadExtraColormap(UINT8 *get) +static extracolormap_t *GetNetColormapFromList(UINT32 index) { - extracolormap_t *exc, *exc_exist; + // For loading, we have to be tricky: + // We load the sectors BEFORE knowing the colormap values + // So if an index doesn't exist, fill our list with dummy colormaps + // until we get the index we want + // Then when we load the color data, we set up the dummy colormaps - UINT8 fadestart = READUINT8(get), - fadeend = READUINT8(get), - fog = READUINT8(get); + extracolormap_t *exc, *last_exc = NULL; + UINT32 i = 0; - INT32 rgba = READINT32(get), - fadergba = READINT32(get); + for (exc = net_colormaps; exc; last_exc = exc, exc = exc->next) + { + if (i++ == index) + return exc; + } + + // our index doesn't exist, so just make the entry + for (; i <= index && i < num_net_colormaps; i++) + { + exc = R_CreateDefaultColormap(false); + if (last_exc) + last_exc->next = exc; + exc->prev = last_exc; + exc->next = NULL; + last_exc = exc; + } + return exc; +} + +static void ClearNetColormaps(void) +{ + // We're actually Z_Freeing each entry here, + // so don't call this in P_NetUnArchiveColormaps (where entries will be used in-game) + extracolormap_t *exc, *exc_next; + + for (exc = net_colormaps; exc; exc = exc_next) + { + exc_next = exc->next; + Z_Free(exc); + } + num_net_colormaps = 0; + net_colormaps = NULL; +} + +static void P_NetArchiveColormaps() +{ + // We save and then we clean up our colormap mess + extracolormap_t *exc, *exc_next; + + WRITEUINT32(save_p, num_net_colormaps); // save for safety + + for (exc = net_colormaps; exc; exc = exc_next) + { + WRITEUINT8(save_p, exc->fadestart); + WRITEUINT8(save_p, exc->fadeend); + WRITEUINT8(save_p, exc->fog); + + WRITEINT32(save_p, exc->rgba); + WRITEINT32(save_p, exc->fadergba); #ifdef EXTRACOLORMAPLUMPS - char lumpname[9]; - READSTRINGN(get, lumpname, 9); - - if (lumpname[0]) - return R_ColormapForName(lumpname); + WRITESTRINGN(save_p, exc->lumpname, 9); #endif - exc = R_GetColormapFromListByValues(rgba, fadergba, fadestart, fadeend, fog); - if (!exc) + exc_next = exc->next; + Z_Free(exc); // don't need anymore + } + + num_net_colormaps = 0; +} + +static void P_NetUnArchiveColormaps() +{ + // When we reach this point, we already populated our list with + // dummy colormaps. Now that we are loading the color data, + // set up the dummies. + extracolormap_t *exc, *existing_exc; + num_net_colormaps = READUINT32(save_p); + + for (exc = net_colormaps; exc; exc = exc->next) { - // CONS_Debug(DBG_RENDER, "Creating Colormap: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", - // R_GetRgbaR(rgba), R_GetRgbaG(rgba), R_GetRgbaB(rgba), R_GetRgbaA(rgba), - // R_GetRgbaR(fadergba), R_GetRgbaG(fadergba), R_GetRgbaB(fadergba), R_GetRgbaA(fadergba)); + UINT8 fadestart = READUINT8(save_p), + fadeend = READUINT8(save_p), + fog = READUINT8(save_p); - exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL); + INT32 rgba = READINT32(save_p), + fadergba = READINT32(save_p); + +#ifdef EXTRACOLORMAPLUMPS + char lumpname[9]; + READSTRINGN(save_p, lumpname, 9); + + if (lumpname[0]) + { + existing_exc = R_ColormapForName(lumpname); + *exc = *existing_exc; + R_AddColormapToList(exc); // see HACK note below on why we're adding duplicates + continue; + } +#endif exc->fadestart = fadestart; exc->fadeend = fadeend; @@ -531,21 +625,32 @@ static extracolormap_t *LoadExtraColormap(UINT8 *get) exc->lumpname[0] = 0; #endif - if (!(exc_exist = R_GetColormapFromList(exc))) - { - exc->colormap = R_CreateLightTable(exc); - R_AddColormapToList(exc); - } + existing_exc = R_GetColormapFromListByValues(rgba, fadergba, fadestart, fadeend, fog); + + if (existing_exc) + exc->colormap = existing_exc->colormap; else - { - Z_Free(exc); - exc = R_CheckDefaultColormap(exc_exist, true, true, true) ? NULL : exc_exist; - } + // CONS_Debug(DBG_RENDER, "Creating Colormap: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", + // R_GetRgbaR(rgba), R_GetRgbaG(rgba), R_GetRgbaB(rgba), R_GetRgbaA(rgba), + // R_GetRgbaR(fadergba), R_GetRgbaG(fadergba), R_GetRgbaB(fadergba), R_GetRgbaA(fadergba)); + exc->colormap = R_CreateLightTable(exc); + + // HACK: If this dummy is a duplicate, we're going to add it + // to the extra_colormaps list anyway. I think this is faster + // than going through every loaded sector and correcting their + // colormap address to the pre-existing one, PER net_colormap entry + R_AddColormapToList(exc); } - return exc; + // Don't need these anymore + num_net_colormaps = 0; + net_colormaps = NULL; } +/// +/// World Archiving +/// + #define SD_FLOORHT 0x01 #define SD_CEILHT 0x02 #define SD_FLOORPIC 0x04 @@ -595,6 +700,9 @@ static void P_NetArchiveWorld(void) const side_t *si; UINT8 *put; + // initialize colormap vars because paranoia + ClearNetColormaps(); + // reload the map just to see difference mapsector_t *ms; mapsidedef_t *msd; @@ -730,7 +838,8 @@ static void P_NetArchiveWorld(void) } if (diff3 & SD_COLORMAP) - SaveExtraColormap(put, ss->extra_colormap); + WRITEUINT32(put, CheckAddNetColormapToList(ss->extra_colormap)); + // returns existing index if already added, or appends to net_colormaps and returns new index // Special case: save the stats of all modified ffloors along with their ffloor "number"s // we don't bother with ffloors that haven't changed, that would just add to savegame even more than is really needed @@ -865,6 +974,9 @@ static void P_NetUnArchiveWorld(void) if (READUINT32(save_p) != ARCHIVEBLOCK_WORLD) I_Error("Bad $$$.sav at archive block World"); + // initialize colormap vars because paranoia + ClearNetColormaps(); + get = save_p; for (;;) @@ -927,7 +1039,7 @@ static void P_NetUnArchiveWorld(void) } if (diff3 & SD_COLORMAP) - sectors[i].extra_colormap = LoadExtraColormap(get); + sectors[i].extra_colormap = GetNetColormapFromList(READUINT32(get)); if (diff & SD_FFLOORS) { @@ -3536,6 +3648,7 @@ void P_SaveNetGame(void) #endif P_NetArchiveThinkers(); P_NetArchiveSpecials(); + P_NetArchiveColormaps(); } #ifdef HAVE_BLUA LUA_Archive(); @@ -3578,6 +3691,7 @@ boolean P_LoadNetGame(void) #endif P_NetUnArchiveThinkers(); P_NetUnArchiveSpecials(); + P_NetUnArchiveColormaps(); P_RelinkPointers(); P_FinishMobjs(); } From d4a18fd456749c6d3db6c1055bf2e1972d60c460 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 16 Sep 2018 20:27:24 -0400 Subject: [PATCH 118/132] 455: Fade colormap netsync use new colormap saving --- src/p_saveg.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index cea40a4e9..109102dfc 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1795,8 +1795,8 @@ static void SaveFadeColormapThinker(const thinker_t *th, const UINT8 type) const fadecolormap_t *ht = (const void *)th; WRITEUINT8(save_p, type); WRITEUINT32(save_p, SaveSector(ht->sector)); - SaveExtraColormap(save_p, ht->source_exc); - SaveExtraColormap(save_p, ht->dest_exc); + WRITEUINT32(save_p, CheckAddNetColormapToList(ht->source_exc)); + WRITEUINT32(save_p, CheckAddNetColormapToList(ht->dest_exc)); WRITEUINT8(save_p, (UINT8)ht->ticbased); WRITEINT32(save_p, ht->duration); WRITEINT32(save_p, ht->timer); @@ -2795,8 +2795,8 @@ static inline void LoadFadeColormapThinker(actionf_p1 thinker) fadecolormap_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); ht->thinker.function.acp1 = thinker; ht->sector = LoadSector(READUINT32(save_p)); - ht->source_exc = LoadExtraColormap(save_p); - ht->dest_exc = LoadExtraColormap(save_p); + ht->source_exc = GetNetColormapFromList(READUINT32(save_p)); + ht->dest_exc = GetNetColormapFromList(READUINT32(save_p)); ht->ticbased = (boolean)READUINT8(save_p); ht->duration = READINT32(save_p); ht->timer = READINT32(save_p); From 0a998fec02a84981008fad81163d40765d979341 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 16 Sep 2018 22:41:08 -0400 Subject: [PATCH 119/132] New colormap netsync fixes --- src/p_saveg.c | 79 ++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 59 insertions(+), 20 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 109102dfc..517211726 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -485,29 +485,30 @@ static UINT32 num_net_colormaps = 0; // But also check for equality and return the matching index static UINT32 CheckAddNetColormapToList(extracolormap_t *extra_colormap) { - extracolormap_t *exc; + extracolormap_t *exc, *exc_prev; UINT32 i = 0; if (!net_colormaps) { - net_colormaps = extra_colormap; + net_colormaps = R_CopyColormap(extra_colormap, false); net_colormaps->next = 0; net_colormaps->prev = 0; + num_net_colormaps = i+1; return i; } - for (exc = net_colormaps; exc->next; exc = exc->next) + for (exc = net_colormaps; exc; exc_prev = exc, exc = exc->next) { if (R_CheckEqualColormaps(exc, extra_colormap, true, true, true)) return i; i++; } - exc->next = extra_colormap; - extra_colormap->prev = exc; + exc_prev->next = R_CopyColormap(extra_colormap, false); + extra_colormap->prev = exc_prev; extra_colormap->next = 0; - num_net_colormaps = i; + num_net_colormaps = i+1; return i; } @@ -522,14 +523,24 @@ static extracolormap_t *GetNetColormapFromList(UINT32 index) extracolormap_t *exc, *last_exc = NULL; UINT32 i = 0; + if (!net_colormaps) // initialize our list + net_colormaps = R_CreateDefaultColormap(false); + for (exc = net_colormaps; exc; last_exc = exc, exc = exc->next) { if (i++ == index) return exc; } + + // LET'S HOPE that index is a sane value, because we create up to [index] + // entries in net_colormaps. At this point, we don't know + // what the total colormap count is + if (index >= numsectors*3) // if every sector had a unique colormap change AND a fade thinker which has two colormap entries + I_Error("Colormap %d from server is too high for sectors %d", index, numsectors); + // our index doesn't exist, so just make the entry - for (; i <= index && i < num_net_colormaps; i++) + for (; i <= index; i++) { exc = R_CreateDefaultColormap(false); if (last_exc) @@ -556,15 +567,20 @@ static void ClearNetColormaps(void) net_colormaps = NULL; } -static void P_NetArchiveColormaps() +static void P_NetArchiveColormaps(void) { // We save and then we clean up our colormap mess extracolormap_t *exc, *exc_next; - + UINT32 i = 0; WRITEUINT32(save_p, num_net_colormaps); // save for safety - for (exc = net_colormaps; exc; exc = exc_next) + for (exc = net_colormaps; i < num_net_colormaps; i++, exc = exc_next) { + // We must save num_net_colormaps worth of data + // So fill non-existent entries with default. + if (!exc) + exc = R_CreateDefaultColormap(false); + WRITEUINT8(save_p, exc->fadestart); WRITEUINT8(save_p, exc->fadeend); WRITEUINT8(save_p, exc->fog); @@ -581,31 +597,44 @@ static void P_NetArchiveColormaps() } num_net_colormaps = 0; + net_colormaps = NULL; } -static void P_NetUnArchiveColormaps() +static void P_NetUnArchiveColormaps(void) { // When we reach this point, we already populated our list with // dummy colormaps. Now that we are loading the color data, // set up the dummies. - extracolormap_t *exc, *existing_exc; + extracolormap_t *exc, *existing_exc, *exc_next = NULL; num_net_colormaps = READUINT32(save_p); + UINT32 i = 0; - for (exc = net_colormaps; exc; exc = exc->next) + for (exc = net_colormaps; i < num_net_colormaps; i++, exc = exc_next) { - UINT8 fadestart = READUINT8(save_p), - fadeend = READUINT8(save_p), - fog = READUINT8(save_p); - - INT32 rgba = READINT32(save_p), - fadergba = READINT32(save_p); - + UINT8 fadestart, fadeend, fog; + INT32 rgba, fadergba; #ifdef EXTRACOLORMAPLUMPS char lumpname[9]; +#endif + + fadestart = READUINT8(save_p); + fadeend = READUINT8(save_p); + fog = READUINT8(save_p); + + rgba = READINT32(save_p); + fadergba = READINT32(save_p); + +#ifdef EXTRACOLORMAPLUMPS READSTRINGN(save_p, lumpname, 9); if (lumpname[0]) { + if (!exc) + // no point making a new entry since nothing points to it, + // but we needed to read the data so now continue + continue; + + exc_next = exc->next; // this gets overwritten during our operations here, so get it now existing_exc = R_ColormapForName(lumpname); *exc = *existing_exc; R_AddColormapToList(exc); // see HACK note below on why we're adding duplicates @@ -613,6 +642,13 @@ static void P_NetUnArchiveColormaps() } #endif + if (!exc) + // no point making a new entry since nothing points to it, + // but we needed to read the data so now continue + continue; + + exc_next = exc->next; // this gets overwritten during our operations here, so get it now + exc->fadestart = fadestart; exc->fadeend = fadeend; exc->fog = fog; @@ -640,6 +676,9 @@ static void P_NetUnArchiveColormaps() // than going through every loaded sector and correcting their // colormap address to the pre-existing one, PER net_colormap entry R_AddColormapToList(exc); + + if (i < num_net_colormaps-1 && !exc_next) + exc_next = R_CreateDefaultColormap(false); } // Don't need these anymore From 4b55415add356e051d494cd5bc8d36c316f54456 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 16 Sep 2018 22:41:08 -0400 Subject: [PATCH 120/132] New colormap netsync fixes --- src/p_saveg.c | 79 ++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 59 insertions(+), 20 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index a63ef1276..34d08d709 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -485,29 +485,30 @@ static UINT32 num_net_colormaps = 0; // But also check for equality and return the matching index static UINT32 CheckAddNetColormapToList(extracolormap_t *extra_colormap) { - extracolormap_t *exc; + extracolormap_t *exc, *exc_prev; UINT32 i = 0; if (!net_colormaps) { - net_colormaps = extra_colormap; + net_colormaps = R_CopyColormap(extra_colormap, false); net_colormaps->next = 0; net_colormaps->prev = 0; + num_net_colormaps = i+1; return i; } - for (exc = net_colormaps; exc->next; exc = exc->next) + for (exc = net_colormaps; exc; exc_prev = exc, exc = exc->next) { if (R_CheckEqualColormaps(exc, extra_colormap, true, true, true)) return i; i++; } - exc->next = extra_colormap; - extra_colormap->prev = exc; + exc_prev->next = R_CopyColormap(extra_colormap, false); + extra_colormap->prev = exc_prev; extra_colormap->next = 0; - num_net_colormaps = i; + num_net_colormaps = i+1; return i; } @@ -522,14 +523,24 @@ static extracolormap_t *GetNetColormapFromList(UINT32 index) extracolormap_t *exc, *last_exc = NULL; UINT32 i = 0; + if (!net_colormaps) // initialize our list + net_colormaps = R_CreateDefaultColormap(false); + for (exc = net_colormaps; exc; last_exc = exc, exc = exc->next) { if (i++ == index) return exc; } + + // LET'S HOPE that index is a sane value, because we create up to [index] + // entries in net_colormaps. At this point, we don't know + // what the total colormap count is + if (index >= numsectors*3) // if every sector had a unique colormap change AND a fade thinker which has two colormap entries + I_Error("Colormap %d from server is too high for sectors %d", index, numsectors); + // our index doesn't exist, so just make the entry - for (; i <= index && i < num_net_colormaps; i++) + for (; i <= index; i++) { exc = R_CreateDefaultColormap(false); if (last_exc) @@ -556,15 +567,20 @@ static void ClearNetColormaps(void) net_colormaps = NULL; } -static void P_NetArchiveColormaps() +static void P_NetArchiveColormaps(void) { // We save and then we clean up our colormap mess extracolormap_t *exc, *exc_next; - + UINT32 i = 0; WRITEUINT32(save_p, num_net_colormaps); // save for safety - for (exc = net_colormaps; exc; exc = exc_next) + for (exc = net_colormaps; i < num_net_colormaps; i++, exc = exc_next) { + // We must save num_net_colormaps worth of data + // So fill non-existent entries with default. + if (!exc) + exc = R_CreateDefaultColormap(false); + WRITEUINT8(save_p, exc->fadestart); WRITEUINT8(save_p, exc->fadeend); WRITEUINT8(save_p, exc->fog); @@ -581,31 +597,44 @@ static void P_NetArchiveColormaps() } num_net_colormaps = 0; + net_colormaps = NULL; } -static void P_NetUnArchiveColormaps() +static void P_NetUnArchiveColormaps(void) { // When we reach this point, we already populated our list with // dummy colormaps. Now that we are loading the color data, // set up the dummies. - extracolormap_t *exc, *existing_exc; + extracolormap_t *exc, *existing_exc, *exc_next = NULL; num_net_colormaps = READUINT32(save_p); + UINT32 i = 0; - for (exc = net_colormaps; exc; exc = exc->next) + for (exc = net_colormaps; i < num_net_colormaps; i++, exc = exc_next) { - UINT8 fadestart = READUINT8(save_p), - fadeend = READUINT8(save_p), - fog = READUINT8(save_p); - - INT32 rgba = READINT32(save_p), - fadergba = READINT32(save_p); - + UINT8 fadestart, fadeend, fog; + INT32 rgba, fadergba; #ifdef EXTRACOLORMAPLUMPS char lumpname[9]; +#endif + + fadestart = READUINT8(save_p); + fadeend = READUINT8(save_p); + fog = READUINT8(save_p); + + rgba = READINT32(save_p); + fadergba = READINT32(save_p); + +#ifdef EXTRACOLORMAPLUMPS READSTRINGN(save_p, lumpname, 9); if (lumpname[0]) { + if (!exc) + // no point making a new entry since nothing points to it, + // but we needed to read the data so now continue + continue; + + exc_next = exc->next; // this gets overwritten during our operations here, so get it now existing_exc = R_ColormapForName(lumpname); *exc = *existing_exc; R_AddColormapToList(exc); // see HACK note below on why we're adding duplicates @@ -613,6 +642,13 @@ static void P_NetUnArchiveColormaps() } #endif + if (!exc) + // no point making a new entry since nothing points to it, + // but we needed to read the data so now continue + continue; + + exc_next = exc->next; // this gets overwritten during our operations here, so get it now + exc->fadestart = fadestart; exc->fadeend = fadeend; exc->fog = fog; @@ -640,6 +676,9 @@ static void P_NetUnArchiveColormaps() // than going through every loaded sector and correcting their // colormap address to the pre-existing one, PER net_colormap entry R_AddColormapToList(exc); + + if (i < num_net_colormaps-1 && !exc_next) + exc_next = R_CreateDefaultColormap(false); } // Don't need these anymore From f3e1d280d07a234c7070384f6d514fba32085808 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 17 Sep 2018 00:26:58 -0400 Subject: [PATCH 121/132] Colormap netsync: Mixed D+C fixes --- src/p_saveg.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 34d08d709..ec0ef2e7a 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -606,9 +606,10 @@ static void P_NetUnArchiveColormaps(void) // dummy colormaps. Now that we are loading the color data, // set up the dummies. extracolormap_t *exc, *existing_exc, *exc_next = NULL; - num_net_colormaps = READUINT32(save_p); UINT32 i = 0; + num_net_colormaps = READUINT32(save_p); + for (exc = net_colormaps; i < num_net_colormaps; i++, exc = exc_next) { UINT8 fadestart, fadeend, fog; @@ -739,9 +740,6 @@ static void P_NetArchiveWorld(void) const side_t *si; UINT8 *put; - // initialize colormap vars because paranoia - ClearNetColormaps(); - // reload the map just to see difference mapsector_t *ms; mapsidedef_t *msd; @@ -749,6 +747,9 @@ static void P_NetArchiveWorld(void) const sector_t *ss = sectors; UINT8 diff, diff2, diff3; + // initialize colormap vars because paranoia + ClearNetColormaps(); + WRITEUINT32(save_p, ARCHIVEBLOCK_WORLD); put = save_p; From 752a9630372d787625459050053ffae98a8a6689 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 17 Sep 2018 08:05:51 -0400 Subject: [PATCH 122/132] Colormap netsync: String format numsectors to UINT32 (thanks buildbot) --- src/p_saveg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index ec0ef2e7a..b98a34436 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -537,7 +537,7 @@ static extracolormap_t *GetNetColormapFromList(UINT32 index) // entries in net_colormaps. At this point, we don't know // what the total colormap count is if (index >= numsectors*3) // if every sector had a unique colormap change AND a fade thinker which has two colormap entries - I_Error("Colormap %d from server is too high for sectors %d", index, numsectors); + I_Error("Colormap %d from server is too high for sectors %d", index, (UINT32)numsectors); // our index doesn't exist, so just make the entry for (; i <= index; i++) From d417f733e5b00c54233c36d8b61b69f14d5ba996 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 17 Sep 2018 10:24:55 -0400 Subject: [PATCH 123/132] Colormap netsync: Handle unaccounted dummy colormaps properly --- src/p_saveg.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/p_saveg.c b/src/p_saveg.c index b98a34436..c0f98d88b 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -682,6 +682,20 @@ static void P_NetUnArchiveColormaps(void) exc_next = R_CreateDefaultColormap(false); } + // if we still have a valid net_colormap after iterating up to num_net_colormaps, + // some sector had a colormap index higher than num_net_colormaps. We done goofed or $$$ was corrupted. + // In any case, add them to the colormap list too so that at least the sectors' colormap + // addresses are valid and accounted properly + if (exc_next) + { + existing_exc = R_GetDefaultColormap(); + for (exc = exc_next; exc; exc = exc->next) + { + exc->colormap = existing_exc->colormap; // all our dummies are default values + R_AddColormapToList(exc); + } + } + // Don't need these anymore num_net_colormaps = 0; net_colormaps = NULL; From 69a4906911aa206ac0dffc10a5b5536e692edbb7 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 17 Sep 2018 10:38:09 -0400 Subject: [PATCH 124/132] Colormap netsync: Count ffloors for colormap loading upper limit --- src/p_saveg.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index c0f98d88b..b8af7cff6 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -480,6 +480,7 @@ static void P_NetUnArchivePlayers(void) static extracolormap_t *net_colormaps = NULL; static UINT32 num_net_colormaps = 0; +static UINT32 num_ffloors = 0; // for loading // Copypasta from r_data.c AddColormapToList // But also check for equality and return the matching index @@ -536,7 +537,9 @@ static extracolormap_t *GetNetColormapFromList(UINT32 index) // LET'S HOPE that index is a sane value, because we create up to [index] // entries in net_colormaps. At this point, we don't know // what the total colormap count is - if (index >= numsectors*3) // if every sector had a unique colormap change AND a fade thinker which has two colormap entries + if (index >= numsectors*3 + num_ffloors) + // if every sector had a unique colormap change AND a fade color thinker which has two colormap entries + // AND every ffloor had a fade FOF thinker with one colormap entry I_Error("Colormap %d from server is too high for sectors %d", index, (UINT32)numsectors); // our index doesn't exist, so just make the entry @@ -564,6 +567,7 @@ static void ClearNetColormaps(void) Z_Free(exc); } num_net_colormaps = 0; + num_ffloors = 0; net_colormaps = NULL; } @@ -597,6 +601,7 @@ static void P_NetArchiveColormaps(void) } num_net_colormaps = 0; + num_ffloors = 0; net_colormaps = NULL; } @@ -698,6 +703,7 @@ static void P_NetUnArchiveColormaps(void) // Don't need these anymore num_net_colormaps = 0; + num_ffloors = 0; net_colormaps = NULL; } @@ -1031,6 +1037,14 @@ static void P_NetUnArchiveWorld(void) // initialize colormap vars because paranoia ClearNetColormaps(); + // count the level's ffloors so that colormap loading can have an upper limit + for (i = 0; i < numsectors; i++) + { + ffloor_t *rover; + for (rover = sectors[i].ffloors; rover; rover = rover->next) + num_ffloors++; + } + get = save_p; for (;;) From 20c4702986f6f3f99d30bf3efe19a10bc13141cc Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 17 Sep 2018 14:12:16 -0400 Subject: [PATCH 125/132] Line exec trigger netsync: Save var2s in addition to vars --- src/p_saveg.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/p_saveg.c b/src/p_saveg.c index 6e0c704f6..6010a1d24 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1260,7 +1260,10 @@ static void SaveSpecialLevelThinker(const thinker_t *th, const UINT8 type) size_t i; WRITEUINT8(save_p, type); for (i = 0; i < 16; i++) + { WRITEFIXED(save_p, ht->vars[i]); //var[16] + WRITEFIXED(save_p, ht->var2s[i]); //var[16] + } WRITEUINT32(save_p, SaveLine(ht->sourceline)); WRITEUINT32(save_p, SaveSector(ht->sector)); } @@ -2163,7 +2166,10 @@ static void LoadSpecialLevelThinker(actionf_p1 thinker, UINT8 floorOrCeiling) size_t i; ht->thinker.function.acp1 = thinker; for (i = 0; i < 16; i++) + { ht->vars[i] = READFIXED(save_p); //var[16] + ht->var2s[i] = READFIXED(save_p); //var[16] + } ht->sourceline = LoadLine(READUINT32(save_p)); ht->sector = LoadSector(READUINT32(save_p)); From 64b96c7192565b1f47561c9f4210ef2425e60b94 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 17 Sep 2018 21:16:27 -0400 Subject: [PATCH 126/132] 455: Don't interrupt current color fading --- src/p_spec.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/p_spec.c b/src/p_spec.c index a408b2140..b855e9641 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3378,6 +3378,11 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) { extracolormap_t *source_exc, *dest_exc, *exc; + // Prevent continuous execs from interfering on an existing fade + if (!(line->flags & ML_EFFECT5) + && sectors[secnum].fadecolormapdata) + continue; + if (line->flags & ML_TFERLINE) // use back colormap instead of target sector sectors[secnum].extra_colormap = (line->sidenum[1] != 0xFFFF) ? sides[line->sidenum[1]].colormap_data : NULL; From 56ee711f332daad06ecec3d612d0d8b84318be59 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 18 Sep 2018 05:45:28 -0400 Subject: [PATCH 127/132] 455: Commented out, but allow existing fade overlap of 2 tics (or speed*2) --- src/p_spec.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index b855e9641..95119cfd3 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3377,11 +3377,18 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) for (secnum = -1; (secnum = P_FindSectorFromLineTag(line, secnum)) >= 0 ;) { extracolormap_t *source_exc, *dest_exc, *exc; + INT32 speed = (INT32)((line->flags & ML_DONTPEGBOTTOM) || !sides[line->sidenum[0]].rowoffset) && line->sidenum[1] != 0xFFFF ? + abs(sides[line->sidenum[1]].rowoffset >> FRACBITS) + : abs(sides[line->sidenum[0]].rowoffset >> FRACBITS); // Prevent continuous execs from interfering on an existing fade if (!(line->flags & ML_EFFECT5) && sectors[secnum].fadecolormapdata) + //&& ((fadecolormap_t*)sectors[secnum].fadecolormapdata)->timer > (ticbased ? 2 : speed*2)) + { + CONS_Debug(DBG_GAMELOGIC, "Line type 455 Executor: Fade color thinker already exists, timer: %d", ((fadecolormap_t*)sectors[secnum].fadecolormapdata)->timer); continue; + } if (line->flags & ML_TFERLINE) // use back colormap instead of target sector sectors[secnum].extra_colormap = (line->sidenum[1] != 0xFFFF) ? @@ -3451,9 +3458,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) Z_Free(exc); Add_ColormapFader(§ors[secnum], source_exc, dest_exc, (line->flags & ML_EFFECT4), // tic-based timing - ((line->flags & ML_DONTPEGBOTTOM) || !sides[line->sidenum[0]].rowoffset) && line->sidenum[1] != 0xFFFF ? - abs(sides[line->sidenum[1]].rowoffset >> FRACBITS) - : abs(sides[line->sidenum[0]].rowoffset >> FRACBITS)); + speed); } break; From 9778cc2ad57bbc1c4c4a51a93b4aea4e88f91a38 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 18 Sep 2018 07:07:30 -0400 Subject: [PATCH 128/132] 455: A line break --- src/p_spec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index 95119cfd3..80580403c 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3386,7 +3386,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) && sectors[secnum].fadecolormapdata) //&& ((fadecolormap_t*)sectors[secnum].fadecolormapdata)->timer > (ticbased ? 2 : speed*2)) { - CONS_Debug(DBG_GAMELOGIC, "Line type 455 Executor: Fade color thinker already exists, timer: %d", ((fadecolormap_t*)sectors[secnum].fadecolormapdata)->timer); + CONS_Debug(DBG_GAMELOGIC, "Line type 455 Executor: Fade color thinker already exists, timer: %d\n", ((fadecolormap_t*)sectors[secnum].fadecolormapdata)->timer); continue; } From 6567872229cb3535c7dbf3e79027ca89a51aa947 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 18 Sep 2018 07:06:59 -0400 Subject: [PATCH 129/132] 492: Don't interrupt existing polyobj fader unless EFFECT5 --- src/p_spec.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index 2583c24f3..481580b79 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1276,7 +1276,7 @@ static boolean PolyFade(line_t *line) if (!(po = Polyobj_GetForNum(polyObjNum))) { - CONS_Debug(DBG_POLYOBJ, "EV_DoPolyObjWaypoint: bad polyobj %d\n", polyObjNum); + CONS_Debug(DBG_POLYOBJ, "PolyFade: bad polyobj %d\n", polyObjNum); return 0; } @@ -1284,6 +1284,15 @@ static boolean PolyFade(line_t *line) if (po->isBad) return 0; + // Prevent continuous execs from interfering on an existing fade + if (!(line->flags & ML_EFFECT5) + && po->thinker + && po->thinker->function.acp1 == (actionf_p1)T_PolyObjFade) + { + CONS_Debug(DBG_POLYOBJ, "Line type 492 Executor: Fade PolyObject thinker already exists\n"); + return 0; + } + pfd.polyObjNum = polyObjNum; // if DONTPEGBOTTOM, specify raw translucency value in Front X Offset From 5029c01c2b4e9ae9cfba49e76e805b0f73e817cf Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 18 Sep 2018 07:11:31 -0400 Subject: [PATCH 130/132] 492: Remove pre-existing thinker when setting up new fade --- src/p_polyobj.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/p_polyobj.c b/src/p_polyobj.c index bbcf4f42a..c2b3ba399 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -2969,6 +2969,9 @@ INT32 EV_DoPolyObjFade(polyfadedata_t *pfdata) if (po->translucency == pfdata->destvalue) return 1; + if (po->thinker && po->thinker->function.acp1 == (actionf_p1)T_PolyObjFade) + P_RemoveThinker(po->thinker); + // create a new thinker th = Z_Malloc(sizeof(polyfade_t), PU_LEVSPEC, NULL); th->thinker.function.acp1 = (actionf_p1)T_PolyObjFade; From e7ecd84e80e5c57d64ff0827bb49d21b927bdc2c Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 18 Sep 2018 07:36:38 -0400 Subject: [PATCH 131/132] p_setup: Don't fudge texture offsets if EFFECT5 and a linedef exec --- src/p_setup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/p_setup.c b/src/p_setup.c index f0ce69598..ae44c4cea 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1331,7 +1331,8 @@ static void P_LoadLineDefs2(void) ld->backsector = ld->sidenum[1] != 0xffff ? sides[ld->sidenum[1]].sector : 0; // Repeat count for midtexture - if ((ld->flags & ML_EFFECT5) && (ld->sidenum[1] != 0xffff)) + if ((ld->flags & ML_EFFECT5) && (ld->sidenum[1] != 0xffff) + && !(ld->special >= 300 && ld->special < 500)) // exempt linedef exec specials { sides[ld->sidenum[0]].repeatcnt = (INT16)(((unsigned)sides[ld->sidenum[0]].textureoffset >> FRACBITS) >> 12); sides[ld->sidenum[0]].textureoffset = (((unsigned)sides[ld->sidenum[0]].textureoffset >> FRACBITS) & 2047) << FRACBITS; From c45d523e8f2e1505283e614695bfe05d71b1ff82 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Tue, 18 Sep 2018 06:27:30 -0400 Subject: [PATCH 132/132] 420: Don't interrupt existing light fade on duration timing except EFFECT5 (cherry picked from commit 3b957c32517a8f5148940c0067af7e88a51d1fee) --- src/lua_baselib.c | 3 ++- src/p_lights.c | 12 +++++++++++- src/p_spec.c | 3 ++- src/p_spec.h | 2 +- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 840863eb0..ce017620c 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1810,9 +1810,10 @@ static int lib_pFadeLight(lua_State *L) INT32 destvalue = (INT32)luaL_checkinteger(L, 2); INT32 speed = (INT32)luaL_checkinteger(L, 3); boolean ticbased = lua_optboolean(L, 4); + boolean force = lua_optboolean(L, 5); NOHUD INLEVEL - P_FadeLight(tag, destvalue, speed, ticbased); + P_FadeLight(tag, destvalue, speed, ticbased, force); return 0; } diff --git a/src/p_lights.c b/src/p_lights.c index 2ea93b796..12abc9e05 100644 --- a/src/p_lights.c +++ b/src/p_lights.c @@ -371,12 +371,22 @@ void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean } } -void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased) +void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased, boolean force) { INT32 i; // search all sectors for ones with tag for (i = -1; (i = P_FindSectorFromTag(tag, i)) >= 0 ;) + { + if (!force && ticbased // always let speed fader execute + && sectors[i].lightingdata + && ((lightlevel_t*)sectors[i].lightingdata)->thinker.function.acp1 == (actionf_p1)T_LightFade) + // && ((lightlevel_t*)sectors[i].lightingdata)->timer > 2) + { + CONS_Debug(DBG_GAMELOGIC, "Line type 420 Executor: Fade light thinker already exists, timer: %d\n", ((lightlevel_t*)sectors[i].lightingdata)->timer); + continue; + } P_FadeLightBySector(§ors[i], destvalue, speed, ticbased); + } } /** Fades the light level in a sector to a new value. diff --git a/src/p_spec.c b/src/p_spec.c index b0a976a10..42cff1282 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2877,7 +2877,8 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) max(min(sides[line->sidenum[1]].rowoffset>>FRACBITS, 255), 0) : max(min(sides[line->sidenum[0]].rowoffset>>FRACBITS, 255), 0)) : abs(P_AproxDistance(line->dx, line->dy))>>FRACBITS, - (line->flags & ML_EFFECT4)); + (line->flags & ML_EFFECT4), + (line->flags & ML_EFFECT5)); break; case 421: // Stop lighting effect in tagged sectors diff --git a/src/p_spec.h b/src/p_spec.h index 56684b496..848b80ecf 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -162,7 +162,7 @@ void T_Glow(glow_t *g); glow_t *P_SpawnAdjustableGlowingLight(sector_t *minsector, sector_t *maxsector, INT32 length); void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean ticbased); -void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased); +void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased, boolean force); void T_LightFade(lightlevel_t *ll); typedef enum