mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-21 20:11:12 +00:00
Refactor linedef type 5 (Camera Scanner)
This commit is contained in:
parent
1db163f942
commit
7fdcba5014
7 changed files with 86 additions and 73 deletions
|
@ -1706,7 +1706,7 @@ void T_RaiseSector(raise_t *raise)
|
|||
P_RecalcPrecipInSector(§ors[i]);
|
||||
}
|
||||
|
||||
void T_CameraScanner(elevator_t *elevator)
|
||||
void T_CameraScanner(scanner_t *scanner)
|
||||
{
|
||||
// leveltime is compared to make multiple scanners in one map function correctly.
|
||||
static tic_t lastleveltime = 32000; // any number other than 0 should do here
|
||||
|
@ -1720,58 +1720,28 @@ void T_CameraScanner(elevator_t *elevator)
|
|||
|
||||
if (players[displayplayer].mo)
|
||||
{
|
||||
if (players[displayplayer].mo->subsector->sector == elevator->actionsector)
|
||||
if (players[displayplayer].mo->subsector->sector == scanner->actionsector)
|
||||
{
|
||||
if (t_cam_dist == -42)
|
||||
t_cam_dist = cv_cam_dist.value;
|
||||
if (t_cam_height == -42)
|
||||
t_cam_height = cv_cam_height.value;
|
||||
if (t_cam_rotate == -42)
|
||||
t_cam_rotate = cv_cam_rotate.value;
|
||||
CV_SetValue(&cv_cam_height, FixedInt(elevator->sector->floorheight));
|
||||
CV_SetValue(&cv_cam_dist, FixedInt(elevator->sector->ceilingheight));
|
||||
CV_SetValue(&cv_cam_rotate, elevator->distance);
|
||||
camera.scanner.height = scanner->height;
|
||||
camera.scanner.dist = scanner->dist;
|
||||
camera.scanner.rotate = &scanner->rotate;
|
||||
camerascanned = true;
|
||||
}
|
||||
else if (!camerascanned)
|
||||
{
|
||||
if (t_cam_height != -42 && cv_cam_height.value != t_cam_height)
|
||||
CV_Set(&cv_cam_height, va("%f", (double)FIXED_TO_FLOAT(t_cam_height)));
|
||||
if (t_cam_dist != -42 && cv_cam_dist.value != t_cam_dist)
|
||||
CV_Set(&cv_cam_dist, va("%f", (double)FIXED_TO_FLOAT(t_cam_dist)));
|
||||
if (t_cam_rotate != -42 && cv_cam_rotate.value != t_cam_rotate)
|
||||
CV_Set(&cv_cam_rotate, va("%f", (double)t_cam_rotate));
|
||||
|
||||
t_cam_dist = t_cam_height = t_cam_rotate = -42;
|
||||
}
|
||||
P_ResetCameraScanner(&camera);
|
||||
}
|
||||
|
||||
if (splitscreen && players[secondarydisplayplayer].mo)
|
||||
{
|
||||
if (players[secondarydisplayplayer].mo->subsector->sector == elevator->actionsector)
|
||||
if (players[secondarydisplayplayer].mo->subsector->sector == scanner->actionsector)
|
||||
{
|
||||
if (t_cam2_rotate == -42)
|
||||
t_cam2_dist = cv_cam2_dist.value;
|
||||
if (t_cam2_rotate == -42)
|
||||
t_cam2_height = cv_cam2_height.value;
|
||||
if (t_cam2_rotate == -42)
|
||||
t_cam2_rotate = cv_cam2_rotate.value;
|
||||
CV_SetValue(&cv_cam2_height, FixedInt(elevator->sector->floorheight));
|
||||
CV_SetValue(&cv_cam2_dist, FixedInt(elevator->sector->ceilingheight));
|
||||
CV_SetValue(&cv_cam2_rotate, elevator->distance);
|
||||
camera2.scanner.height = scanner->height;
|
||||
camera2.scanner.dist = scanner->dist;
|
||||
camera2.scanner.rotate = &scanner->rotate;
|
||||
camerascanned2 = true;
|
||||
}
|
||||
else if (!camerascanned2)
|
||||
{
|
||||
if (t_cam2_height != -42 && cv_cam2_height.value != t_cam2_height)
|
||||
CV_Set(&cv_cam2_height, va("%f", (double)FIXED_TO_FLOAT(t_cam2_height)));
|
||||
if (t_cam2_dist != -42 && cv_cam2_dist.value != t_cam2_dist)
|
||||
CV_Set(&cv_cam2_dist, va("%f", (double)FIXED_TO_FLOAT(t_cam2_dist)));
|
||||
if (t_cam2_rotate != -42 && cv_cam2_rotate.value != t_cam2_rotate)
|
||||
CV_Set(&cv_cam2_rotate, va("%f", (double)t_cam2_rotate));
|
||||
|
||||
t_cam2_dist = t_cam2_height = t_cam2_rotate = -42;
|
||||
}
|
||||
P_ResetCameraScanner(&camera2);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -89,10 +89,7 @@ typedef struct camera_s
|
|||
angle_t startangle;
|
||||
|
||||
// Camera demobjerization
|
||||
// Info for drawing: position.
|
||||
fixed_t x, y, z;
|
||||
|
||||
//More drawing info: to determine current sprite.
|
||||
angle_t angle; // orientation
|
||||
|
||||
struct subsector_s *subsector;
|
||||
|
@ -109,6 +106,14 @@ typedef struct camera_s
|
|||
|
||||
// Momentums, used to update position.
|
||||
fixed_t momx, momy, momz;
|
||||
|
||||
// Camera scanner effect (linedef type 5).
|
||||
struct
|
||||
{
|
||||
fixed_t *height;
|
||||
fixed_t *dist;
|
||||
INT32 *rotate;
|
||||
} scanner;
|
||||
} camera_t;
|
||||
|
||||
extern camera_t camera, camera2;
|
||||
|
@ -122,16 +127,15 @@ extern consvar_t cv_cam_savedist[2][2], cv_cam_saveheight[2][2];
|
|||
void CV_UpdateCamDist(void);
|
||||
void CV_UpdateCam2Dist(void);
|
||||
|
||||
extern fixed_t t_cam_dist, t_cam_height, t_cam_rotate;
|
||||
extern fixed_t t_cam2_dist, t_cam2_height, t_cam2_rotate;
|
||||
void P_ResetCamera(player_t *player, camera_t *thiscam);
|
||||
void P_ResetCameraScanner(camera_t *thiscam);
|
||||
boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam);
|
||||
void P_SlideCameraMove(camera_t *thiscam);
|
||||
boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcalled);
|
||||
|
||||
INT32 P_GetPlayerControlDirection(player_t *player);
|
||||
void P_AddPlayerScore(player_t *player, UINT32 amount);
|
||||
void P_StealPlayerScore(player_t *player, UINT32 amount);
|
||||
void P_ResetCamera(player_t *player, camera_t *thiscam);
|
||||
boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam);
|
||||
void P_SlideCameraMove(camera_t *thiscam);
|
||||
boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcalled);
|
||||
pflags_t P_GetJumpFlags(player_t *player);
|
||||
boolean P_PlayerInPain(player_t *player);
|
||||
void P_DoPlayerPain(player_t *player, mobj_t *source, mobj_t *inflictor);
|
||||
|
|
|
@ -2210,6 +2210,15 @@ static inline void SaveDynamicSlopeThinker(const thinker_t *th, const UINT8 type
|
|||
WRITEMEM(save_p, ht->vex, sizeof(ht->vex));
|
||||
}
|
||||
|
||||
static void SaveScannerThinker(const thinker_t *th, const UINT8 type)
|
||||
{
|
||||
const scanner_t *ht = (const void *)th;
|
||||
WRITEUINT8(save_p, type);
|
||||
WRITEUINT32(save_p, SaveSector(ht->sector));
|
||||
WRITEUINT32(save_p, SaveSector(ht->actionsector));
|
||||
WRITEINT32(save_p, ht->rotate);
|
||||
}
|
||||
|
||||
static inline void SavePolyrotatetThinker(const thinker_t *th, const UINT8 type)
|
||||
{
|
||||
const polyrotate_t *ht = (const void *)th;
|
||||
|
@ -2407,7 +2416,7 @@ static void P_NetArchiveThinkers(void)
|
|||
}
|
||||
else if (th->function.acp1 == (actionf_p1)T_CameraScanner)
|
||||
{
|
||||
SaveElevatorThinker(th, tc_camerascanner);
|
||||
SaveScannerThinker(th, tc_camerascanner);
|
||||
continue;
|
||||
}
|
||||
else if (th->function.acp1 == (actionf_p1)T_Scroll)
|
||||
|
@ -3381,6 +3390,18 @@ static inline thinker_t* LoadDynamicSlopeThinker(actionf_p1 thinker)
|
|||
return &ht->thinker;
|
||||
}
|
||||
|
||||
static thinker_t* LoadScannerThinker(actionf_p1 thinker)
|
||||
{
|
||||
scanner_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL);
|
||||
ht->thinker.function.acp1 = thinker;
|
||||
ht->sector = LoadSector(READUINT32(save_p));
|
||||
ht->actionsector = LoadSector(READUINT32(save_p));
|
||||
ht->height = &ht->sector->floorheight;
|
||||
ht->dist = &ht->sector->ceilingheight;
|
||||
ht->rotate = READINT32(save_p);
|
||||
return &ht->thinker;
|
||||
}
|
||||
|
||||
static inline thinker_t* LoadPolyrotatetThinker(actionf_p1 thinker)
|
||||
{
|
||||
polyrotate_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL);
|
||||
|
@ -3602,7 +3623,7 @@ static void P_NetUnArchiveThinkers(void)
|
|||
break;
|
||||
|
||||
case tc_camerascanner:
|
||||
th = LoadElevatorThinker((actionf_p1)T_CameraScanner, false);
|
||||
th = LoadScannerThinker((actionf_p1)T_CameraScanner);
|
||||
break;
|
||||
|
||||
case tc_bouncecheese:
|
||||
|
|
|
@ -3755,6 +3755,9 @@ static void P_SetupCamera(void)
|
|||
camera.subsector = R_PointInSubsector(camera.x, camera.y); // make sure camera has a subsector set -- Monster Iestyn (12/11/18)
|
||||
}
|
||||
}
|
||||
|
||||
P_ResetCameraScanner(&camera);
|
||||
P_ResetCameraScanner(&camera2);
|
||||
}
|
||||
|
||||
static void P_InitCamera(void)
|
||||
|
|
22
src/p_spec.c
22
src/p_spec.c
|
@ -5896,21 +5896,21 @@ static void P_AddEachTimeThinker(line_t *sourceline)
|
|||
*/
|
||||
static inline void P_AddCameraScanner(sector_t *sourcesec, sector_t *actionsector, angle_t angle)
|
||||
{
|
||||
elevator_t *elevator; // Why not? LOL
|
||||
scanner_t *scanner;
|
||||
|
||||
CONS_Alert(CONS_WARNING, M_GetText("Detected a camera scanner effect (linedef type 5). This effect is deprecated and will be removed in the future!\n"));
|
||||
//CONS_Alert(CONS_WARNING, M_GetText("Detected a camera scanner effect (linedef type 5). This effect is deprecated and will be removed in the future!\n"));
|
||||
|
||||
// create and initialize new elevator thinker
|
||||
elevator = Z_Calloc(sizeof (*elevator), PU_LEVSPEC, NULL);
|
||||
P_AddThinker(THINK_MAIN, &elevator->thinker);
|
||||
// create and initialize the new scanner thinker
|
||||
scanner = Z_Calloc(sizeof (*scanner), PU_LEVSPEC, NULL);
|
||||
P_AddThinker(THINK_MAIN, &scanner->thinker);
|
||||
|
||||
elevator->thinker.function.acp1 = (actionf_p1)T_CameraScanner;
|
||||
elevator->type = elevateBounce;
|
||||
scanner->thinker.function.acp1 = (actionf_p1)T_CameraScanner;
|
||||
scanner->sector = sourcesec;
|
||||
scanner->actionsector = actionsector;
|
||||
|
||||
// set up the fields according to the type of elevator action
|
||||
elevator->sector = sourcesec;
|
||||
elevator->actionsector = actionsector;
|
||||
elevator->distance = FixedInt(AngleFixed(angle));
|
||||
scanner->height = &sourcesec->floorheight;
|
||||
scanner->dist = &sourcesec->ceilingheight;
|
||||
scanner->rotate = FixedInt(AngleFixed(angle));
|
||||
}
|
||||
|
||||
/** Flashes a laser block.
|
||||
|
|
12
src/p_spec.h
12
src/p_spec.h
|
@ -407,6 +407,16 @@ typedef struct
|
|||
boolean triggerOnExit;
|
||||
} eachtime_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
thinker_t thinker;
|
||||
sector_t *sector;
|
||||
sector_t *actionsector;
|
||||
fixed_t *height;
|
||||
fixed_t *dist;
|
||||
INT32 rotate;
|
||||
} scanner_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
RF_REVERSE = 1, //Lower when stood on
|
||||
|
@ -464,7 +474,7 @@ void T_MarioBlockChecker(mariocheck_t *block);
|
|||
void T_ThwompSector(thwomp_t *thwomp);
|
||||
void T_NoEnemiesSector(noenemies_t *nobaddies);
|
||||
void T_EachTimeThinker(eachtime_t *eachtime);
|
||||
void T_CameraScanner(elevator_t *elevator);
|
||||
void T_CameraScanner(scanner_t *scanner);
|
||||
void T_RaiseSector(raise_t *raise);
|
||||
|
||||
typedef struct
|
||||
|
|
23
src/p_user.c
23
src/p_user.c
|
@ -9721,13 +9721,6 @@ void CV_UpdateCam2Dist(void)
|
|||
CV_Set(&cv_cam2_height, va("%f", FIXED_TO_FLOAT(cv_cam_saveheight[cv_useranalog[1].value][1].value)));
|
||||
}
|
||||
|
||||
fixed_t t_cam_dist = -42;
|
||||
fixed_t t_cam_height = -42;
|
||||
fixed_t t_cam_rotate = -42;
|
||||
fixed_t t_cam2_dist = -42;
|
||||
fixed_t t_cam2_height = -42;
|
||||
fixed_t t_cam2_rotate = -42;
|
||||
|
||||
#define MAXCAMERADIST 140*FRACUNIT // Max distance the camera can be in front of the player (2D mode)
|
||||
|
||||
void P_ResetCamera(player_t *player, camera_t *thiscam)
|
||||
|
@ -9915,6 +9908,13 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
|
|||
camheight = FixedMul(cv_cam2_height.value, mo->scale);
|
||||
}
|
||||
|
||||
if (thiscam->scanner.height)
|
||||
camheight = (*thiscam->scanner.height);
|
||||
if (thiscam->scanner.dist)
|
||||
camdist = (*thiscam->scanner.dist);
|
||||
if (thiscam->scanner.rotate)
|
||||
camrotate = (*thiscam->scanner.rotate);
|
||||
|
||||
if (!(twodlevel || (mo->flags2 & MF2_TWOD)) && !(player->powers[pw_carry] == CR_NIGHTSMODE))
|
||||
camheight = FixedMul(camheight, player->camerascale);
|
||||
|
||||
|
@ -9966,8 +9966,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
|
|||
else
|
||||
angle = focusangle + FixedAngle(camrotate*FRACUNIT);
|
||||
|
||||
if (!resetcalled && (cv_analog[0].value || demoplayback) && ((thiscam == &camera && t_cam_rotate != -42) || (thiscam == &camera2
|
||||
&& t_cam2_rotate != -42)))
|
||||
if (!resetcalled && (cv_analog[0].value || demoplayback) && thiscam->scanner.rotate)
|
||||
{
|
||||
angle = FixedAngle(camrotate*FRACUNIT);
|
||||
thiscam->angle = angle;
|
||||
|
@ -10468,7 +10467,13 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
|
|||
}
|
||||
|
||||
return (x == thiscam->x && y == thiscam->y && z == thiscam->z && angle == thiscam->aiming);
|
||||
}
|
||||
|
||||
void P_ResetCameraScanner(camera_t *thiscam)
|
||||
{
|
||||
thiscam->scanner.height = NULL;
|
||||
thiscam->scanner.dist = NULL;
|
||||
thiscam->scanner.rotate = NULL;
|
||||
}
|
||||
|
||||
boolean P_SpectatorJoinGame(player_t *player)
|
||||
|
|
Loading…
Reference in a new issue