Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions source/client/gui/components/OptionList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ void OptionList::initDefaultMenu()
OPTION(Boolean, m_bInvertMouse, "Invert Y-axis");
OPTION(Boolean, m_bSplitControls, "Split controls"); idxSplit = currentIndex;
OPTION(Boolean, m_bFlyCheat, "Flight hax");
OPTION(Boolean, m_bFlyNoclip, "Flight noclip");
}

HEADER("Multiplayer");
Expand Down
1 change: 1 addition & 0 deletions source/client/options/Options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ void Options::_initDefaultValues()
field_23E = 0;
m_fMasterVolume = 1.0f;
m_bFlyCheat = false;
m_bFlyNoclip = false;
field_241 = 0;
field_8 = 0.5f;
field_24C = 0;
Expand Down
1 change: 1 addition & 0 deletions source/client/options/Options.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class Options
bool m_bThirdPerson;
uint8_t field_23E;
bool m_bFlyCheat;
bool m_bFlyNoclip;
uint8_t field_240;
uint8_t field_241;
float field_244;
Expand Down
2 changes: 1 addition & 1 deletion source/client/player/input/ControllerTurnInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ TurnDelta ControllerTurnInput::getTurnDelta()
deltaX = deltaTime * xt;
deltaY = deltaTime * -yt;
}
else if (field_8 != 2 || (!field_18 && !isTouched))
else if (field_8 != 2 || (!field_18 && !isTouched))
{
deltaX = 0.0f;
deltaY = -0.0f;
Expand Down
1 change: 1 addition & 0 deletions source/client/player/input/IMoveInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
IMoveInput::IMoveInput() :
m_horzInput(0.0f),
m_vertInput(0.0f),
m_flyInput(0.0f),
field_C(false),
m_bJumpButton(false),
m_bSneakButton(false)
Expand Down
3 changes: 3 additions & 0 deletions source/client/player/input/IMoveInput.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ enum
INPUT_RIGHT,
INPUT_JUMP,
INPUT_SNEAK,
INPUT_FLY_UP,
INPUT_FLY_DOWN,
};

class IMoveInput
Expand All @@ -35,6 +37,7 @@ class IMoveInput
public:
float m_horzInput;
float m_vertInput;
float m_flyInput;
bool field_C;
bool m_bJumpButton;
bool m_bSneakButton;
Expand Down
17 changes: 11 additions & 6 deletions source/client/player/input/KeyboardInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ void KeyboardInput::setKey(int keyCode, bool b)
{
int index = -1;

if (m_pOptions->getKey(KM_FORWARD) == keyCode) index = 0;
if (m_pOptions->getKey(KM_BACKWARD) == keyCode) index = 1;
if (m_pOptions->getKey(KM_LEFT) == keyCode) index = 2;
if (m_pOptions->getKey(KM_RIGHT) == keyCode) index = 3;
if (m_pOptions->getKey(KM_JUMP) == keyCode) index = 4;
if (m_pOptions->getKey(KM_SNEAK) == keyCode) index = 5;
if (m_pOptions->getKey(KM_FORWARD) == keyCode) index = INPUT_FORWARD;
if (m_pOptions->getKey(KM_BACKWARD) == keyCode) index = INPUT_BACKWARD;
if (m_pOptions->getKey(KM_LEFT) == keyCode) index = INPUT_LEFT;
if (m_pOptions->getKey(KM_RIGHT) == keyCode) index = INPUT_RIGHT;
if (m_pOptions->getKey(KM_JUMP) == keyCode) index = INPUT_JUMP;
if (m_pOptions->getKey(KM_SNEAK) == keyCode) index = INPUT_SNEAK;
if (m_pOptions->getKey(KM_FLY_UP) == keyCode) index = INPUT_FLY_UP;
if (m_pOptions->getKey(KM_FLY_DOWN) == keyCode) index = INPUT_FLY_DOWN;

if (index == -1)
return;
Expand All @@ -49,11 +51,14 @@ void KeyboardInput::tick(Player* pPlayer)
{
m_horzInput = 0.0f;
m_vertInput = 0.0f;
m_flyInput = 0.0f;

if (m_keys[INPUT_FORWARD]) m_vertInput += 1.0f;
if (m_keys[INPUT_BACKWARD]) m_vertInput -= 1.0f;
if (m_keys[INPUT_LEFT]) m_horzInput += 1.0f;
if (m_keys[INPUT_RIGHT]) m_horzInput -= 1.0f;
if (m_keys[INPUT_FLY_UP]) m_flyInput += 0.2f;
if (m_keys[INPUT_FLY_DOWN]) m_flyInput -= 0.2f;

m_bJumpButton = m_keys[INPUT_JUMP];
m_bSneakButton = m_keys[INPUT_SNEAK];
Expand Down
51 changes: 39 additions & 12 deletions source/client/player/input/TouchscreenInput_TestFps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
TouchscreenInput_TestFps::TouchscreenInput_TestFps(Minecraft* pMinecraft, Options* pOptions) :
m_rectArea(0.0f, 0.0f, 1.0f, 1.0f),
m_pOptions(pOptions),
field_40(false),
m_bJumpBeingHeld(false),
m_bForwardHeld(false),
m_bJumpingHeld(false),
m_bFlyActive(false),
m_jumpTick(0),
m_pMinecraft(pMinecraft),
m_pAreaLeft(nullptr),
m_pAreaRight(nullptr),
Expand All @@ -38,6 +40,7 @@ void TouchscreenInput_TestFps::releaseAllKeys()
{
m_horzInput = 0.0f;
m_vertInput = 0.0f;
m_flyInput = 0.0f;
for (int i = 0; i < 5; i++)
field_6C[i] = false;
}
Expand Down Expand Up @@ -135,6 +138,7 @@ void TouchscreenInput_TestFps::tick(Player* pPlayer)
{
m_horzInput = 0.0f;
m_vertInput = 0.0f;
m_flyInput = 0.0f;
m_bJumpButton = false;

for (int i = 0; i < 5; i++)
Expand All @@ -143,7 +147,7 @@ void TouchscreenInput_TestFps::tick(Player* pPlayer)
const int* activePointers;
int activePointerCount = Multitouch::getActivePointerIds(&activePointers);

bool bJumpPressed = false, bForwardPressed = false;
bool bJumpPressed = false, bForwardPressed = false, bBackwardPressed = false;

for (int i = 0; i < activePointerCount; i++)
{
Expand All @@ -167,13 +171,26 @@ void TouchscreenInput_TestFps::tick(Player* pPlayer)

if (pointerId == 100 + INPUT_JUMP) // jump
{
if (pPlayer->isInWater())
if (Multitouch::isPressed(finger))
{
m_bJumpButton = true;
else if (Multitouch::isPressed(finger))
int tick = getTimeMs();
if (tick - m_jumpTick < 300)
{
m_jumpTick = 0;
m_bFlyActive = !m_bFlyActive;
m_pMinecraft->getOptions()->m_bFlyCheat = m_bFlyActive;
m_bJumpButton = false;
}
else m_jumpTick = tick;
}
else if (m_bFlyActive)
bJumpPressed = true;
else if (pPlayer->isInWater())
m_bJumpButton = true;
else if (field_40)
else if (m_bForwardHeld)
{
pointerId = 100; // forward
pointerId = 100 + INPUT_FORWARD;
bJumpPressed = true;
m_vertInput += 1.0f;
}
Expand All @@ -182,7 +199,7 @@ void TouchscreenInput_TestFps::tick(Player* pPlayer)
switch (pointerId)
{
case 100 + INPUT_FORWARD:
if (pPlayer->isInWater())
if (pPlayer->isInWater() && !m_bFlyActive)
m_bJumpButton = true;
else
bForwardPressed = true;
Expand All @@ -191,6 +208,7 @@ void TouchscreenInput_TestFps::tick(Player* pPlayer)
break;

case 100 + INPUT_BACKWARD:
bBackwardPressed = true;
m_vertInput -= 1.0f;
break;

Expand All @@ -204,20 +222,29 @@ void TouchscreenInput_TestFps::tick(Player* pPlayer)
}
}

field_40 = bForwardPressed;
m_bForwardHeld = bForwardPressed;

if (bJumpPressed)
{
// Don't allow the player to hold jump to repeatedly jump.
// Only let them jump once - have them jump again
if (!m_bJumpBeingHeld)
if (!m_bJumpingHeld && !m_bFlyActive)
m_bJumpButton = true;

m_bJumpBeingHeld = true;
m_bJumpingHeld = true;
}
else if (m_bFlyActive && m_bJumpingHeld && (bForwardPressed || bBackwardPressed))
{
if (bForwardPressed)
m_flyInput += 0.2f;
if (bBackwardPressed)
m_flyInput -= 0.2f;

m_vertInput = 0.0f;
}
else
{
m_bJumpBeingHeld = false;
m_bJumpingHeld = false;
}
}

Expand Down
6 changes: 4 additions & 2 deletions source/client/player/input/TouchscreenInput_TestFps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ class TouchscreenInput_TestFps : public IMoveInput, public GuiComponent
RectangleArea m_rectArea;
bool field_30[10];
Options* m_pOptions;
bool field_40;
bool m_bJumpBeingHeld;
bool m_bForwardHeld;
bool m_bJumpingHeld;
bool m_bFlyActive;
int m_jumpTick;
TouchAreaModel m_touchAreaModel;
Minecraft* m_pMinecraft;
PolygonArea* m_pAreaLeft;
Expand Down
14 changes: 4 additions & 10 deletions source/world/entity/LocalPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,12 @@ void LocalPlayer::animateRespawn()

void LocalPlayer::calculateFlight(float x, float y, float z)
{
float f1 = m_pMinecraft->getOptions()->field_244;
float f1 = m_pMinecraft->getOptions()->field_8;
float f2 = f1 * 0.35f;
float x1 = f1 * x;
float z1 = f1 * z;

float y1 = 0.0f;
if (Keyboard::isKeyDown(m_pMinecraft->getOptions()->getKey(KM_FLY_UP)))
y1 = f1 * 0.2f;
if (Keyboard::isKeyDown(m_pMinecraft->getOptions()->getKey(KM_FLY_DOWN)))
y1 = f1 * -0.2f;

field_BFC += x1;
float f2 = m_pMinecraft->getOptions()->field_8 * 0.35f;
float f3 = f2 * (field_BFC - field_C00);
float f4 = field_C04 + 0.5f * (f3 - field_C04);
field_C04 = f4;
Expand All @@ -84,7 +78,7 @@ void LocalPlayer::calculateFlight(float x, float y, float z)
field_C00 += f4;
field_BF0 = f4 * 10.0f;

field_C08 += y1;
field_C08 += m_pMoveInput->m_flyInput * f1;
float f5 = f2 * (field_C08 - field_C0C);
float f6 = field_C10 + 0.5f * (f5 - field_C10);
field_C10 = f6;
Expand Down Expand Up @@ -127,7 +121,7 @@ int LocalPlayer::move(float x, float y, float z)
if (Minecraft::DEADMAU5_CAMERA_CHEATS && pLP == this && m_pMinecraft->getOptions()->m_bFlyCheat)
{
//@HUH: Using m_pMinecraft->m_pLocalPlayer instead of this, even though they're the same
pLP->m_bNoCollision = true;
pLP->m_bNoCollision = m_pMinecraft->getOptions()->m_bFlyNoclip;

float field_94_old = field_94;

Expand Down