Skip to content
Permalink
Browse files

Fix if motd is changed to -hax +thirdperson, you are still sent back …

…into first person, even though you can still use third person (Thanks cybertoon)
  • Loading branch information
UnknownShadow200 committed Mar 22, 2020
1 parent cc5c9f8 commit 8a0c0850ca12d5fa39d42ccd5ee8ecfff8d3172c
Showing with 18 additions and 17 deletions.
  1. +2 −2 src/Camera.c
  2. +7 −6 src/EntityComponents.c
  3. +1 −1 src/EntityComponents.h
  4. +3 −3 src/Input.c
  5. +5 −5 src/Protocol.c
@@ -228,7 +228,7 @@ static void HandleRawMouseMoved(void* obj, int idx, int deltaX, int deltaY) {

static void Camera_CheckThirdPerson(void* obj) {
struct HacksComp* h = &LocalPlayer_Instance.Hacks;
if (!h->CanUseThirdPersonCamera || !h->Enabled) Camera_CycleActive();
if (!h->CanUseThirdPerson || !h->Enabled) Camera_CycleActive();
}

void Camera_Init(void) {
@@ -254,7 +254,7 @@ void Camera_CycleActive(void) {
if (Game_ClassicMode) return;
Camera.Active = Camera.Active->next;

if (!p->Hacks.CanUseThirdPersonCamera || !p->Hacks.Enabled) {
if (!p->Hacks.CanUseThirdPerson || !p->Hacks.Enabled) {
Camera.Active = &cam_FirstPerson;
}
cam_isForwardThird = Camera.Active == &cam_ForwardThird;
@@ -149,7 +149,7 @@ static void HacksComp_SetAll(struct HacksComp* hacks, cc_bool allowed) {
hacks->CanAnyHacks = allowed; hacks->CanFly = allowed;
hacks->CanNoclip = allowed; hacks->CanRespawn = allowed;
hacks->CanSpeed = allowed; hacks->CanPushbackBlocks = allowed;
hacks->CanUseThirdPersonCamera = allowed;
hacks->CanUseThirdPerson = allowed;
}

void HacksComp_Init(struct HacksComp* hacks) {
@@ -249,11 +249,12 @@ void HacksComp_RecheckFlags(struct HacksComp* hacks) {
HacksComp_SetAll(hacks, hax);
hacks->CanBePushed = true;

HacksComp_ParseFlag(hacks, "+fly", "-fly", &hacks->CanFly);
HacksComp_ParseFlag(hacks, "+noclip", "-noclip", &hacks->CanNoclip);
HacksComp_ParseFlag(hacks, "+speed", "-speed", &hacks->CanSpeed);
HacksComp_ParseFlag(hacks, "+respawn", "-respawn", &hacks->CanRespawn);
HacksComp_ParseFlag(hacks, "+push", "-push", &hacks->CanBePushed);
HacksComp_ParseFlag(hacks, "+fly", "-fly", &hacks->CanFly);
HacksComp_ParseFlag(hacks, "+noclip", "-noclip", &hacks->CanNoclip);
HacksComp_ParseFlag(hacks, "+speed", "-speed", &hacks->CanSpeed);
HacksComp_ParseFlag(hacks, "+respawn", "-respawn", &hacks->CanRespawn);
HacksComp_ParseFlag(hacks, "+push", "-push", &hacks->CanBePushed);
HacksComp_ParseFlag(hacks, "+thirdperson", "-thirdperson", &hacks->CanUseThirdPerson);

if (hacks->IsOp) HacksComp_ParseAllFlag(hacks, "+ophax", "-ophax");
hacks->BaseHorSpeed = HacksComp_ParseFlagFloat("horspeed=", hacks);
@@ -47,7 +47,7 @@ struct HacksComp {
/* Whether user has allowed hacks as an option. Note 'can use X' set by the server override this */
cc_bool Enabled;

cc_bool CanAnyHacks, CanUseThirdPersonCamera, CanSpeed, CanFly;
cc_bool CanAnyHacks, CanUseThirdPerson, CanSpeed, CanFly;
cc_bool CanRespawn, CanNoclip, CanPushbackBlocks,CanSeeAllNames;
cc_bool CanDoubleJump, CanBePushed;
float BaseHorSpeed;
@@ -806,7 +806,7 @@ static void CycleViewDistanceBackwards(const short* viewDists, int count) {

cc_bool InputHandler_SetFOV(int fov) {
struct HacksComp* h = &LocalPlayer_Instance.Hacks;
if (!h->Enabled || !h->CanUseThirdPersonCamera) return false;
if (!h->Enabled || !h->CanUseThirdPerson) return false;

Game_ZoomFov = fov;
Game_SetFov(fov);
@@ -818,7 +818,7 @@ static cc_bool InputHandler_DoFovZoom(float deltaPrecise) {
if (!KeyBind_IsPressed(KEYBIND_ZOOM_SCROLL)) return false;

h = &LocalPlayer_Instance.Hacks;
if (!h->Enabled || !h->CanUseThirdPersonCamera) return false;
if (!h->Enabled || !h->CanUseThirdPerson) return false;

if (input_fovIndex == -1.0f) input_fovIndex = (float)Game_ZoomFov;
input_fovIndex -= deltaPrecise * 5.0f;
@@ -829,7 +829,7 @@ static cc_bool InputHandler_DoFovZoom(float deltaPrecise) {

static void InputHandler_CheckZoomFov(void* obj) {
struct HacksComp* h = &LocalPlayer_Instance.Hacks;
if (!h->Enabled || !h->CanUseThirdPersonCamera) Game_SetFov(Game_DefaultFov);
if (!h->Enabled || !h->CanUseThirdPerson) Game_SetFov(Game_DefaultFov);
}

static cc_bool HandleBlockKey(int key) {
@@ -1097,11 +1097,11 @@ static void CPE_HackControl(cc_uint8* data) {
struct PhysicsComp* physics;
int jumpHeight;

p->Hacks.CanFly = data[0] != 0;
p->Hacks.CanNoclip = data[1] != 0;
p->Hacks.CanSpeed = data[2] != 0;
p->Hacks.CanRespawn = data[3] != 0;
p->Hacks.CanUseThirdPersonCamera = data[4] != 0;
p->Hacks.CanFly = data[0] != 0;
p->Hacks.CanNoclip = data[1] != 0;
p->Hacks.CanSpeed = data[2] != 0;
p->Hacks.CanRespawn = data[3] != 0;
p->Hacks.CanUseThirdPerson = data[4] != 0;
HacksComp_Update(&p->Hacks);

jumpHeight = Stream_GetU16_BE(data + 5);

0 comments on commit 8a0c085

Please sign in to comment.
You can’t perform that action at this time.