use P_SetupCamera for P_MoveCameraToSpawn

also modify P_SetupCamera to always just move the camera to the playerstarts
This commit is contained in:
Alug committed 2025-09-18 10:51:33 +02:00
1 parent f12f5b8bd1
commit fb02389922
3 files changed
+52 -82

No files matched your search

+3 -1
View File
@@ -175,16 +175,18 @@ extern fixed_t t_cam_rotate[MAXSPLITSCREENPLAYERS];
fixed_t P_GetPlayerHeight(player_t *player);
fixed_t P_GetPlayerSpinHeight(player_t *player);
void P_AddPlayerScore(player_t *player, UINT32 amount);
void P_SetupCamera(camera_t *cam);
void P_ResetCamera(player_t *player, camera_t *thiscam);
boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam);
#ifndef NOCLIPCAM
void P_SlideCameraMove(camera_t *thiscam);
#endif
//void P_DemoCameraMovement(camera_t *cam, UINT8 num);
boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcalled);
void P_ResetLocalCamAiming(player_t *player);
void P_ToggleDemoCamera(UINT8 viewnum);
void P_CalcChasePostImg(player_t *player, camera_t *thiscam);
boolean P_PlayerInPain(player_t *player);
void P_DoPlayerPain(player_t *player, mobj_t *source, mobj_t *inflictor);
void P_ResetPlayer(player_t *player);
+3 -51
View File
@@ -2373,44 +2373,6 @@ static void P_LoadRecordGhosts(void)
free(gpath);
}
static void P_SetupCamera(UINT8 pnum, camera_t *cam)
{
if (players[pnum].mo && (server || addedtogame))
{
cam->x = players[pnum].mo->x;
cam->y = players[pnum].mo->y;
cam->z = players[pnum].mo->z;
cam->angle = players[pnum].mo->angle;
}
else
{
mapthing_t *thing;
switch (gametype)
{
case GT_MATCH:
case GT_TAG:
thing = deathmatchstarts[0];
break;
default:
thing = playerstarts[0];
break;
}
if (!thing)
return; // we can't do jack shit
cam->x = thing->x;
cam->y = thing->y;
cam->z = thing->z;
cam->angle = FixedAngle((fixed_t)thing->angle << FRACBITS);
}
cam->subsector = R_PointInSubsectorFast(cam->x, cam->y); // make sure camera has a subsector set -- Monster Iestyn (12/11/18)
cam->chase = false; // tell camera to reset its position next tic
}
static void P_InitCamera(void)
{
INT32 i;
@@ -2420,10 +2382,7 @@ static void P_InitCamera(void)
for (i = 0; i <= splitscreen; i++)
{
if (camera[i].freecam)
continue;
P_SetupCamera(displayplayers[i], &camera[i]);
P_SetupCamera(&camera[i]);
}
// Though, I don't think anyone would care about cam_rotate being reset back to the only value that makes sense :P
@@ -2431,6 +2390,8 @@ static void P_InitCamera(void)
{
if (!cv_cam_rotate[i].changed)
CV_Set(&cv_cam_rotate[i], cv_cam_rotate[i].defaultvalue);
if (!cv_chasecam[i].changed)
CV_SetValue(&cv_chasecam[i], true); // srb2kart: always on
}
displayplayers[0] = consoleplayer; // Start with your OWN view, please!
@@ -2787,15 +2748,6 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate)
&& atoi(mapheaderinfo[gamemap-1]->forcecharacter) != 255)
P_ForceCharacter(mapheaderinfo[gamemap-1]->forcecharacter);
if (!dedicated)
{
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{
if (!cv_chasecam[i].changed)
CV_SetValue(&cv_chasecam[i], true); // srb2kart: always on
}
}
// Initial height of PointOfView
// will be set by player think.
players[consoleplayer].viewz = 1;
+46 -30
View File
@@ -3439,14 +3439,41 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num)
cam->subsector = R_PointInSubsectorFast(cam->x, cam->y);
}
void P_SetupCamera(camera_t *cam)
{
mapthing_t *thing;
switch (gametype)
{
case GT_MATCH:
case GT_TAG:
thing = deathmatchstarts[0];
break;
default:
thing = playerstarts[0];
break;
}
if (!thing)
return; // we can't do jack shit
cam->x = thing->x << FRACBITS;
cam->y = thing->y << FRACBITS;
cam->angle = FixedAngle(thing->angle*FRACUNIT);
cam->subsector = R_PointInSubsectorFast(cam->x, cam->y); // make sure camera has a subsector set -- Monster Iestyn (12/11/18)
cam->z = P_GetSectorFloorZAt(cam->subsector->sector, cam->x, cam->y) + (32<<FRACBITS);
cam->chase = false; // tell camera to reset its position next tic
}
void P_ResetCamera(player_t *player, camera_t *thiscam)
{
tic_t tries = 0;
fixed_t x, y, z;
UINT8 i;
if (thiscam->freecam)
return; // do not reset the camera there.
return; // do not reset the camera there.
if (!player->mo)
return;
@@ -3455,17 +3482,15 @@ void P_ResetCamera(player_t *player, camera_t *thiscam)
return;
thiscam->chase = true;
x = player->mo->x - P_ReturnThrustX(player->mo, thiscam->angle, player->mo->radius);
y = player->mo->y - P_ReturnThrustY(player->mo, thiscam->angle, player->mo->radius);
if (player->mo->eflags & MFE_VERTICALFLIP)
z = player->mo->z + player->mo->height - (32<<FRACBITS) - 16*FRACUNIT;
else
z = player->mo->z + (32<<FRACBITS);
// set bits for the camera
thiscam->x = x;
thiscam->y = y;
thiscam->z = z;
thiscam->x = player->mo->x - P_ReturnThrustX(player->mo, thiscam->angle, player->mo->radius);
thiscam->y = player->mo->y - P_ReturnThrustY(player->mo, thiscam->angle, player->mo->radius);
if (player->mo->eflags & MFE_VERTICALFLIP)
thiscam->z = player->mo->z + player->mo->height - (32<<FRACBITS) - 16*FRACUNIT;
else
thiscam->z = player->mo->z + (32<<FRACBITS);
thiscam->reset = true;
for (i = 0; i <= splitscreen; i++)
@@ -3480,14 +3505,14 @@ void P_ResetCamera(player_t *player, camera_t *thiscam)
thiscam->relativex = 0;
thiscam->subsector = R_PointInSubsectorFast(thiscam->x,thiscam->y);
thiscam->subsector = R_PointInSubsectorFast(thiscam->x, thiscam->y);
thiscam->radius = 20*FRACUNIT;
thiscam->height = 16*FRACUNIT;
thiscam->reset_aiming = true;
while (!P_MoveChaseCamera(player,thiscam,true) && ++tries < 2*TICRATE);
while (!P_MoveChaseCamera(player, thiscam, true) && ++tries < 2*TICRATE);
}
#ifndef NOCLIPCAM // Disable all z-clipping for noclip cam
@@ -3696,28 +3721,19 @@ static boolean P_CheckNoclipCameraPosition(player_t *player, camera_t *thiscam,
}
#endif
// Freecam toggle button is a "shortcut" to reset
// the camera to "spawn" position when spectator
static void P_MoveCameraToSpawn(UINT8 playernum)
{
camera_t *thiscam = &camera[playernum];
player_t *player = P_GetLocalPlayerForNum(playernum);
if (!thiscam || !player->mo)
if (!thiscam)
return;
thiscam->x = player->mo->x - P_ReturnThrustX(player->mo, thiscam->angle, player->mo->radius);
thiscam->y = player->mo->y - P_ReturnThrustY(player->mo, thiscam->angle, player->mo->radius);
if (player->mo->eflags & MFE_VERTICALFLIP)
thiscam->z = player->mo->z + player->mo->height - (32<<FRACBITS) - 16*FRACUNIT;
else
thiscam->z = player->mo->z + (32<<FRACBITS);
P_SetupCamera(thiscam);
thiscam->reset = true;
thiscam->angle = player->mo->angle;
thiscam->aiming = 0;
thiscam->subsector = R_PointInSubsectorFast(thiscam->x,thiscam->y);
thiscam->reset = true;
thiscam->reset_aiming = true;
R_ResetViewInterpolation(playernum);
@@ -3783,14 +3799,14 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
if (player->spectator) // force cam off for spectators
return true;
if (!cv_chasecam[num].value && thiscam == &camera[num])
if (!cv_chasecam[num].value)
return true;
}
if (!thiscam->chase && !resetcalled)
{
focusangle = ((P_IsLocalPlayer(player)) ? localangle[num] : mo->angle);
camrotate = ((thiscam == &camera[num]) ? cv_cam_rotate[num].value : 0);
camrotate = cv_cam_rotate[num].value;
if (leveltime < introtime) // Whoooshy camera!
{
@@ -3912,7 +3928,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
}
if (!resetcalled && (leveltime > starttime && timeover != 2)
&& (thiscam == &camera[num] && t_cam_rotate[num] != -42))
&& (t_cam_rotate[num] != -42))
{
angle = FixedAngle(camrotate*FRACUNIT);
thiscam->angle = angle;