Merge branch 'master' into le-fadefof

This commit is contained in:
mazmazz 2018-09-18 17:11:33 -04:00
commit 81ad8f0681
11 changed files with 188 additions and 16 deletions

View File

@ -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;
}

View File

@ -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;
@ -396,6 +406,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;
}
@ -430,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;
@ -439,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;
}
@ -451,6 +469,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;
}

View File

@ -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(&sectors[i], destvalue, speed, ticbased);
}
}
/** Fades the light level in a sector to a new value.

View File

@ -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;

View File

@ -52,6 +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;
#ifdef ESLOPE
pslope_t *tmfloorslope, *tmceilingslope;
#endif
@ -101,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;
}
@ -1417,6 +1420,7 @@ static boolean PIT_CheckThing(mobj_t *thing)
if (thing->z + thing->height > tmfloorz)
{
tmfloorz = thing->z + thing->height;
tmfloorrover = NULL;
#ifdef ESLOPE
tmfloorslope = NULL;
#endif
@ -1437,6 +1441,7 @@ static boolean PIT_CheckThing(mobj_t *thing)
return false;
tmfloorz = tmceilingz = topz; // block while in air
tmceilingrover = NULL;
#ifdef ESLOPE
tmceilingslope = NULL;
#endif
@ -1445,6 +1450,7 @@ static boolean PIT_CheckThing(mobj_t *thing)
else if (topz < tmceilingz && tmthing->z <= thing->z+thing->height)
{
tmceilingz = topz;
tmceilingrover = NULL;
#ifdef ESLOPE
tmceilingslope = NULL;
#endif
@ -1461,6 +1467,7 @@ static boolean PIT_CheckThing(mobj_t *thing)
if (thing->z < tmceilingz)
{
tmceilingz = thing->z;
tmceilingrover = NULL;
#ifdef ESLOPE
tmceilingslope = NULL;
#endif
@ -1481,6 +1488,7 @@ static boolean PIT_CheckThing(mobj_t *thing)
return false;
tmfloorz = tmceilingz = topz; // block while in air
tmfloorrover = NULL;
#ifdef ESLOPE
tmfloorslope = NULL;
#endif
@ -1489,6 +1497,7 @@ static boolean PIT_CheckThing(mobj_t *thing)
else if (topz > tmfloorz && tmthing->z+tmthing->height >= thing->z)
{
tmfloorz = topz;
tmfloorrover = NULL;
#ifdef ESLOPE
tmfloorslope = NULL;
#endif
@ -1640,6 +1649,7 @@ static boolean PIT_CheckLine(line_t *ld)
{
tmceilingz = opentop;
ceilingline = ld;
tmceilingrover = NULL;
#ifdef ESLOPE
tmceilingslope = opentopslope;
#endif
@ -1648,6 +1658,7 @@ static boolean PIT_CheckLine(line_t *ld)
if (openbottom > tmfloorz)
{
tmfloorz = openbottom;
tmfloorrover = NULL;
#ifdef ESLOPE
tmfloorslope = openbottomslope;
#endif
@ -1729,6 +1740,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;
tmceilingrover = NULL;
#ifdef ESLOPE
tmfloorslope = newsubsec->sector->f_slope;
tmceilingslope = newsubsec->sector->c_slope;
@ -1772,6 +1785,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y)
{
if (tmfloorz < topheight - sinklevel) {
tmfloorz = topheight - sinklevel;
tmfloorrover = rover;
#ifdef ESLOPE
tmfloorslope = *rover->t_slope;
#endif
@ -1781,6 +1795,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y)
{
if (tmceilingz > bottomheight + sinklevel) {
tmceilingz = bottomheight + sinklevel;
tmceilingrover = rover;
#ifdef ESLOPE
tmceilingslope = *rover->b_slope;
#endif
@ -1805,6 +1820,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y)
{
if (tmfloorz < thing->z) {
tmfloorz = thing->z;
tmfloorrover = rover;
#ifdef ESLOPE
tmfloorslope = NULL;
#endif
@ -1823,6 +1839,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y)
&& !(rover->flags & FF_REVERSEPLATFORM))
{
tmfloorz = tmdropoffz = topheight;
tmfloorrover = rover;
#ifdef ESLOPE
tmfloorslope = *rover->t_slope;
#endif
@ -1832,6 +1849,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;
#ifdef ESLOPE
tmceilingslope = *rover->b_slope;
#endif
@ -2328,6 +2346,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;
#ifdef ESLOPE
pslope_t *oldfslope = tmfloorslope;
pslope_t *oldcslope = tmceilingslope;
@ -2344,6 +2364,8 @@ boolean PIT_PushableMoved(mobj_t *thing)
P_SetTarget(&tmthing, oldthing);
ceilingline = oldceilline;
blockingline = oldblockline;
tmfloorrover = oldflrrover;
tmceilingrover = oldceilrover;
#ifdef ESLOPE
tmfloorslope = oldfslope;
tmceilingslope = oldcslope;
@ -2465,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
@ -2472,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
@ -2479,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
@ -2486,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
@ -2557,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))
@ -2637,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;
@ -2663,7 +2693,10 @@ static boolean P_ThingHeightClip(mobj_t *thing)
{
boolean floormoved;
fixed_t oldfloorz = thing->floorz;
ffloor_t *oldfloorrover = thing->floorrover;
ffloor_t *oldceilingrover = thing->ceilingrover;
boolean onfloor = P_IsObjectOnGround(thing);//(thing->z <= thing->floorz);
ffloor_t *rover = NULL;
if (thing->flags & MF_NOCLIPHEIGHT)
return true;
@ -2678,6 +2711,8 @@ static boolean P_ThingHeightClip(mobj_t *thing)
thing->floorz = tmfloorz;
thing->ceilingz = tmceilingz;
thing->floorrover = tmfloorrover;
thing->ceilingrover = tmceilingrover;
// Ugly hack?!?! As long as just ceilingz is the lowest,
// you'll still get crushed, right?
@ -2686,16 +2721,23 @@ 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;
rover = (thing->eflags & MFE_VERTICALFLIP) ? oldceilingrover : oldfloorrover;
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) && (rover->flags & FF_SOLID)))
{
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)
{

View File

@ -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
{
@ -8627,6 +8631,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 +8897,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;

View File

@ -282,6 +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.
struct ffloor_s *floorrover; // FOF referred by floorz
struct ffloor_s *ceilingrover; // FOF referred by ceilingz
// For movement checking.
fixed_t radius;
@ -398,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

View File

@ -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;
}
}

View File

@ -1250,11 +1250,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;
@ -1452,6 +1454,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;
@ -1475,6 +1481,46 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type)
WRITEFIXED(save_p, mobj->floorz);
WRITEFIXED(save_p, mobj->ceilingz);
if (diff2 & MD2_FLOORROVER)
{
ffloor_t *rover;
size_t i = 0;
UINT32 roverindex = 0;
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, rover ? roverindex : i); // store max index to denote invalid ffloor ref
}
if (diff2 & MD2_CEILINGROVER)
{
ffloor_t *rover;
size_t i = 0;
UINT32 roverindex = 0;
for (rover = mobj->ceilingrover->target->ffloors; rover; rover = rover->next)
{
if (rover == mobj->ceilingrover)
{
roverindex = i;
break;
}
i++;
}
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)
{
size_t z;
@ -2355,6 +2401,7 @@ static void LoadMobjThinker(actionf_p1 thinker)
UINT16 diff2;
INT32 i;
fixed_t z, floorz, ceilingz;
ffloor_t *floorrover = NULL, *ceilingrover = NULL;
diff = READUINT32(save_p);
if (diff & MD_MORE)
@ -2368,6 +2415,38 @@ static void LoadMobjThinker(actionf_p1 thinker)
floorz = READFIXED(save_p);
ceilingz = READFIXED(save_p);
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[floor_sectornum].ffloors; rover; rover = rover->next)
{
if (rovernum == floor_rovernum)
break;
rovernum++;
}
floorrover = rover;
}
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)
{
UINT16 spawnpointnum = READUINT16(save_p);
@ -2392,6 +2471,8 @@ static void LoadMobjThinker(actionf_p1 thinker)
mobj->z = z;
mobj->floorz = floorz;
mobj->ceilingz = ceilingz;
mobj->floorrover = floorrover;
mobj->ceilingrover = ceilingrover;
if (diff & MD_TYPE)
mobj->type = READUINT32(save_p);

View File

@ -2886,7 +2886,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

View File

@ -164,7 +164,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