From 9f233b4197898f45abed13d0a7f6d730ba7b472c Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Mon, 24 Dec 2018 08:43:45 +1100 Subject: [PATCH] Fix playerclick pressed/released being switched (thanks sirvoid) --- src/PacketHandlers.c | 4 ++-- src/PacketHandlers.h | 2 +- src/ServerConnection.c | 2 +- src/ServerConnection.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/PacketHandlers.c b/src/PacketHandlers.c index 113dd25e7..10f442459 100644 --- a/src/PacketHandlers.c +++ b/src/PacketHandlers.c @@ -741,13 +741,13 @@ const char* cpe_clientExtensions[30] = { static void CPE_SetMapEnvUrl(uint8_t* data); #define Ext_Deg2Packed(x) ((int16_t)((x) * 65536.0f / 360.0f)) -void CPE_WritePlayerClick(MouseButton button, bool buttonDown, uint8_t targetId, struct PickedPos* pos) { +void CPE_WritePlayerClick(MouseButton button, bool pressed, uint8_t targetId, struct PickedPos* pos) { struct Entity* p = &LocalPlayer_Instance.Base; uint8_t* data = ServerConnection_WriteBuffer; *data++ = OPCODE_PLAYER_CLICK; { *data++ = button; - *data++ = buttonDown; + *data++ = !pressed; Stream_SetU16_BE(data, Ext_Deg2Packed(p->HeadY)); data += 2; Stream_SetU16_BE(data, Ext_Deg2Packed(p->HeadX)); data += 2; diff --git a/src/PacketHandlers.h b/src/PacketHandlers.h index 8a6603ee7..d5813130d 100644 --- a/src/PacketHandlers.h +++ b/src/PacketHandlers.h @@ -18,5 +18,5 @@ void Classic_WriteChat(const String* text, bool partial); void Classic_WritePosition(Vector3 pos, float rotY, float headX); void Classic_WriteSetBlock(int x, int y, int z, bool place, BlockID block); void Classic_WriteLogin(const String* username, const String* verKey); -void CPE_WritePlayerClick(MouseButton button, bool buttonDown, uint8_t targetId, struct PickedPos* pos); +void CPE_WritePlayerClick(MouseButton button, bool pressed, uint8_t targetId, struct PickedPos* pos); #endif diff --git a/src/ServerConnection.c b/src/ServerConnection.c index 0fd6ad504..49ba9f9c0 100644 --- a/src/ServerConnection.c +++ b/src/ServerConnection.c @@ -221,7 +221,7 @@ static void SPConnection_SendChat(const String* text) { } static void SPConnection_SendPosition(Vector3 pos, float rotY, float headX) { } -static void SPConnection_SendPlayerClick(MouseButton button, bool isDown, EntityID targetId, struct PickedPos* pos) { } +static void SPConnection_SendPlayerClick(MouseButton button, bool pressed, EntityID targetId, struct PickedPos* pos) { } static void SPConnection_Tick(struct ScheduledTask* task) { if (ServerConnection_Disconnected) return; diff --git a/src/ServerConnection.h b/src/ServerConnection.h index 63630a11d..376946a92 100644 --- a/src/ServerConnection.h +++ b/src/ServerConnection.h @@ -71,7 +71,7 @@ struct ServerConnectionFuncs { /* Sends a position update to the server. */ void (*SendPosition)(Vector3 pos, float rotY, float headX); /* Sends a PlayerClick packet to the server. */ - void (*SendPlayerClick)(MouseButton button, bool isDown, EntityID targetId, struct PickedPos* pos); + void (*SendPlayerClick)(MouseButton button, bool pressed, EntityID targetId, struct PickedPos* pos); }; /* Currently active connection to a server. */