mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Merge branch 'fix-reverse-gravity-respawn' into 'master'
Fix flipped waypoint respawning w/r/t sector gravity Closes #535 See merge request KartKrew/Kart!1202
This commit is contained in:
commit
d3ecb719c9
2 changed files with 23 additions and 13 deletions
|
|
@ -34,20 +34,10 @@ fixed_t K_RespawnOffset(player_t *player, boolean flip)
|
||||||
|
|
||||||
if (flip == true)
|
if (flip == true)
|
||||||
{
|
{
|
||||||
// Lat 24/7/20: Okay so before we even think about applying this flag, check if the sector we're in doesn't already have reverse gravity for that.
|
|
||||||
// Otherwise, we would reverse the reverse gravity and cancel it out. Yes, this is absolutely fucking dumb.
|
|
||||||
// I'm honestly not sure if this flag is even necessary anymore but we'll keep it just in case.
|
|
||||||
|
|
||||||
if (P_GetMobjGravity(player->mo) < 0)
|
|
||||||
player->mo->flags2 |= MF2_OBJECTFLIP;
|
|
||||||
|
|
||||||
player->mo->eflags |= MFE_VERTICALFLIP;
|
|
||||||
z -= ((128 * mapobjectscale) + (player->mo->height));
|
z -= ((128 * mapobjectscale) + (player->mo->height));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
player->mo->flags2 &= ~MF2_OBJECTFLIP;
|
|
||||||
player->mo->eflags &= ~MFE_VERTICALFLIP;
|
|
||||||
z += (128 * mapobjectscale);
|
z += (128 * mapobjectscale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -261,7 +251,7 @@ void K_DoIngameRespawn(player_t *player)
|
||||||
|
|
||||||
s = R_PointInSubsector(beststart->x << FRACBITS, beststart->y << FRACBITS)->sector;
|
s = R_PointInSubsector(beststart->x << FRACBITS, beststart->y << FRACBITS)->sector;
|
||||||
|
|
||||||
player->respawn.flip = (beststart->options & MTF_OBJECTFLIP);
|
player->respawn.flip = (beststart->options & MTF_OBJECTFLIP) != 0;
|
||||||
|
|
||||||
if (player->respawn.flip == true)
|
if (player->respawn.flip == true)
|
||||||
{
|
{
|
||||||
|
|
@ -447,6 +437,13 @@ static void K_MovePlayerToRespawnPoint(player_t *player)
|
||||||
player->respawn.wp = player->respawn.wp->nextwaypoints[nwp];
|
player->respawn.wp = player->respawn.wp->nextwaypoints[nwp];
|
||||||
K_RespawnAtWaypoint(player, player->respawn.wp);
|
K_RespawnAtWaypoint(player, player->respawn.wp);
|
||||||
|
|
||||||
|
player->mo->eflags &= ~(MFE_VERTICALFLIP);
|
||||||
|
|
||||||
|
if (player->respawn.flip)
|
||||||
|
{
|
||||||
|
player->mo->eflags |= MFE_VERTICALFLIP;
|
||||||
|
}
|
||||||
|
|
||||||
dest.x = player->respawn.pointx;
|
dest.x = player->respawn.pointx;
|
||||||
dest.y = player->respawn.pointy;
|
dest.y = player->respawn.pointy;
|
||||||
dest.z = player->respawn.pointz;
|
dest.z = player->respawn.pointz;
|
||||||
|
|
@ -560,7 +557,7 @@ static void K_MovePlayerToRespawnPoint(player_t *player)
|
||||||
dest.x = laserwp->mobj->x;
|
dest.x = laserwp->mobj->x;
|
||||||
dest.y = laserwp->mobj->y;
|
dest.y = laserwp->mobj->y;
|
||||||
dest.z = laserwp->mobj->z;
|
dest.z = laserwp->mobj->z;
|
||||||
laserflip = (laserwp->mobj->flags2 & MF2_OBJECTFLIP);
|
laserflip = (laserwp->mobj->flags2 & MF2_OBJECTFLIP) ? true : false; // K_RespawnOffset wants a boolean!
|
||||||
|
|
||||||
if (laserflip == true)
|
if (laserflip == true)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
15
src/p_mobj.c
15
src/p_mobj.c
|
|
@ -1119,6 +1119,19 @@ fixed_t P_GetMobjGravity(mobj_t *mo)
|
||||||
|
|
||||||
if (mo->player)
|
if (mo->player)
|
||||||
{
|
{
|
||||||
|
if (mo->player->respawn.state != RESPAWNST_NONE)
|
||||||
|
{
|
||||||
|
// Respawning forces gravity to match waypoint configuration
|
||||||
|
mo->flags2 &= ~(MF2_OBJECTFLIP);
|
||||||
|
|
||||||
|
// If this sector's gravity doesn't already match
|
||||||
|
if ((gravityadd > 0) != mo->player->respawn.flip)
|
||||||
|
{
|
||||||
|
mo->flags2 |= MF2_OBJECTFLIP;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MF2_OBJECTFLIP is relative -- flips sector reverse gravity back to normal
|
||||||
if (mo->flags2 & MF2_OBJECTFLIP)
|
if (mo->flags2 & MF2_OBJECTFLIP)
|
||||||
{
|
{
|
||||||
gravityadd = -gravityadd;
|
gravityadd = -gravityadd;
|
||||||
|
|
@ -11956,7 +11969,7 @@ void P_MovePlayerToSpawn(INT32 playernum, mapthing_t *mthing)
|
||||||
fixed_t offset = mthing->z << FRACBITS;
|
fixed_t offset = mthing->z << FRACBITS;
|
||||||
|
|
||||||
if (p->respawn.state != RESPAWNST_NONE || p->spectator)
|
if (p->respawn.state != RESPAWNST_NONE || p->spectator)
|
||||||
offset += K_RespawnOffset(p, (mthing->options & MTF_OBJECTFLIP));
|
offset += K_RespawnOffset(p, (mthing->options & MTF_OBJECTFLIP) != 0);
|
||||||
|
|
||||||
// Setting the spawnpoint's args[0] will make the player start on the ceiling
|
// Setting the spawnpoint's args[0] will make the player start on the ceiling
|
||||||
// Objectflip inverts
|
// Objectflip inverts
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue