Fix floor spawning WITHOUT breaking maps

also fix camera jank when respawning on maps where the world origin is
inside a gravflip section
This commit is contained in:
GenericHeroGuy 2025-11-25 20:21:17 +01:00
parent 166e7335ff
commit 3780d75767
2 changed files with 10 additions and 10 deletions

View file

@ -989,7 +989,7 @@ void P_TouchStarPost(mobj_t *post, player_t *player, boolean snaptopost)
//player->starposttime = leveltime;
player->starpostx = toucher->x;
player->starposty = toucher->y;
player->starpostz = toucher->eflags & MFE_VERTICALFLIP ? toucher->ceilingz : toucher->floorz;//post->z;
player->starpostz = post->z;
player->starpostangle = post->angle;
player->starpostflip = post->spawnpoint->options & MTF_OBJECTFLIP; // store flipping
}

View file

@ -12433,6 +12433,9 @@ void P_AfterPlayerSpawn(INT32 playernum)
mobj_t *mobj = p->mo;
UINT8 i;
// fix the verticalflip flag to prevent camera jank (the player mobj initially spawns at the origin)
P_CheckGravity(players[playernum].mo, false);
// Update interpolation
mobj->old_x = mobj->x;
mobj->old_y = mobj->y;
@ -12582,18 +12585,15 @@ void P_MovePlayerToStarpost(INT32 playernum)
sector->c_slope ? P_GetSlopeZAt(sector->c_slope, mobj->x, mobj->y) :
sector->ceilingheight;
z = CLAMP(p->starpostz, floor, ceiling); // no more copyslope floorspawning jank
if (mobj->player->starpostflip)
z = p->starpostz - 128*mapobjectscale - mobj->height;
z -= 128*mapobjectscale + mobj->height;
else
z = p->starpostz + 128*mapobjectscale;
z += 128*mapobjectscale;
//z = (p->starpostz + 128) << FRACBITS; // reverse gravity exists, pls
mobj->player->starpostflip = 0;
if (z < floor)
z = floor;
else if (z > ceiling - mobjinfo[MT_PLAYER].height)
z = ceiling - mobjinfo[MT_PLAYER].height;
z = CLAMP(z, floor, ceiling - mobjinfo[MT_PLAYER].height);
//mobj->player->starpostflip = 0; // why???
mobj->floorz = floor;
mobj->ceilingz = ceiling;