Skip to content

Commit

Permalink
Fix if third person is disabled on a map, zoom distance of non-active…
Browse files Browse the repository at this point in the history
… third person camera(s) is not reset to default (Thanks Goodly)
  • Loading branch information
UnknownShadow200 committed Apr 5, 2021
1 parent 0421d68 commit 65845f6
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/Camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,16 @@ static Vec2 ThirdPersonCamera_GetOrientation(void) {
return v;
}

static float ThirdPersonCamera_GetZoom(void) {
float dist = cam_isForwardThird ? dist_forward : dist_third;
/* Don't allow zooming out when -fly */
if (dist > DEF_ZOOM && !LocalPlayer_CheckCanZoom()) dist = DEF_ZOOM;
return dist;
}

static Vec3 ThirdPersonCamera_GetPosition(float t) {
struct Entity* p = &LocalPlayer_Instance.Base;
float dist = cam_isForwardThird ? dist_forward : dist_third;
float dist = ThirdPersonCamera_GetZoom();
Vec3 target, dir;
Vec2 rot;

Expand All @@ -198,9 +205,6 @@ static cc_bool ThirdPersonCamera_Zoom(float amount) {
float* dist = cam_isForwardThird ? &dist_forward : &dist_third;
float newDist = *dist - amount;

/* Don't allow zooming out when -fly */
if (newDist > DEF_ZOOM && !LocalPlayer_CheckCanZoom()) newDist = DEF_ZOOM;

*dist = max(newDist, 2.0f);
return true;
}
Expand Down Expand Up @@ -234,8 +238,6 @@ static void OnHacksChanged(void* obj) {
struct HacksComp* h = &LocalPlayer_Instance.Hacks;
/* Leave third person if not allowed anymore */
if (!h->CanUseThirdPerson || !h->Enabled) Camera_CycleActive();
/* Check if third person camera is allowed to be scrolled out */
if (Camera.Active->isThirdPerson) ThirdPersonCamera_Zoom(0);
}

void Camera_CycleActive(void) {
Expand Down

0 comments on commit 65845f6

Please sign in to comment.