Clamp chase_dist and chase_height because integer overflow is a thing.

This commit is contained in:
Randy Heit 2014-12-26 15:15:42 -06:00
parent ec98937c88
commit e0667544d2

View file

@ -4279,7 +4279,7 @@ CVAR(Float, chase_dist, 90.f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
void P_AimCamera(AActor *t1, fixed_t &CameraX, fixed_t &CameraY, fixed_t &CameraZ, sector_t *&CameraSector) void P_AimCamera(AActor *t1, fixed_t &CameraX, fixed_t &CameraY, fixed_t &CameraZ, sector_t *&CameraSector)
{ {
fixed_t distance = (fixed_t)(chase_dist * FRACUNIT); fixed_t distance = (fixed_t)(clamp<double>(chase_dist, 0, 30000) * FRACUNIT);
angle_t angle = (t1->angle - ANG180) >> ANGLETOFINESHIFT; angle_t angle = (t1->angle - ANG180) >> ANGLETOFINESHIFT;
angle_t pitch = (angle_t)(t1->pitch) >> ANGLETOFINESHIFT; angle_t pitch = (angle_t)(t1->pitch) >> ANGLETOFINESHIFT;
FTraceResults trace; FTraceResults trace;
@ -4289,7 +4289,7 @@ void P_AimCamera(AActor *t1, fixed_t &CameraX, fixed_t &CameraY, fixed_t &Camera
vy = FixedMul(finecosine[pitch], finesine[angle]); vy = FixedMul(finecosine[pitch], finesine[angle]);
vz = finesine[pitch]; vz = finesine[pitch];
sz = t1->z - t1->floorclip + t1->height + (fixed_t)(chase_height * FRACUNIT); sz = t1->z - t1->floorclip + t1->height + (fixed_t)(clamp<double>(chase_height, -1000, 1000) * FRACUNIT);
if (Trace(t1->x, t1->y, sz, t1->Sector, if (Trace(t1->x, t1->y, sz, t1->Sector,
vx, vy, vz, distance, 0, 0, NULL, trace) && vx, vy, vz, distance, 0, 0, NULL, trace) &&