From 1eb04a48ee3ec4114adc4334e6fbcc7561834025 Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 7 Jun 2014 13:45:00 -0700 Subject: Implemented milk, added documentation to Pawn.h --- src/ClientHandle.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/ClientHandle.cpp') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index e4bb9d8e9..7b114b927 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -850,7 +850,7 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB case DIG_STATUS_SHOOT_EAT: { cItemHandler * ItemHandler = cItemHandler::GetItemHandler(m_Player->GetEquippedItem()); - if (ItemHandler->IsFood()) + if (ItemHandler->IsFood() || ItemHandler->IsDrinkable()) { m_Player->AbortEating(); return; @@ -1182,9 +1182,9 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e { HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler); } - else if (ItemHandler->IsFood() && !m_Player->IsGameModeCreative()) + else if ((ItemHandler->IsFood() || ItemHandler->IsDrinkable()) && !m_Player->IsGameModeCreative()) { - if (m_Player->IsSatiated()) + if (m_Player->IsSatiated() && !ItemHandler->IsDrinkable()) { // The player is satiated, they cannot eat return; -- cgit v1.2.3 From 2185c72c2ca2d66b238d7d3234c173bd820d32ac Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 7 Jun 2014 16:32:37 -0700 Subject: Implemented drinkable potions, noeffect entity effect, Clears entity effects on death --- src/ClientHandle.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/ClientHandle.cpp') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 7b114b927..ab36bff91 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -850,7 +850,7 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB case DIG_STATUS_SHOOT_EAT: { cItemHandler * ItemHandler = cItemHandler::GetItemHandler(m_Player->GetEquippedItem()); - if (ItemHandler->IsFood() || ItemHandler->IsDrinkable()) + if (ItemHandler->IsFood() || ItemHandler->IsDrinkable(&m_Player->GetEquippedItem())) { m_Player->AbortEating(); return; @@ -1182,9 +1182,9 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e { HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler); } - else if ((ItemHandler->IsFood() || ItemHandler->IsDrinkable()) && !m_Player->IsGameModeCreative()) + else if ((ItemHandler->IsFood() || ItemHandler->IsDrinkable(&Equipped)) && !m_Player->IsGameModeCreative()) { - if (m_Player->IsSatiated() && !ItemHandler->IsDrinkable()) + if (m_Player->IsSatiated() && !ItemHandler->IsDrinkable(&Equipped)) { // The player is satiated, they cannot eat return; -- cgit v1.2.3 From 3766ac96d77329c679d01d1ab1a846384acab42f Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 8 Jun 2014 17:06:15 -0700 Subject: ItemHandler: changed IsDrinkable() to take a short argument --- src/ClientHandle.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/ClientHandle.cpp') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index ab36bff91..9443cf2c9 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -850,7 +850,7 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB case DIG_STATUS_SHOOT_EAT: { cItemHandler * ItemHandler = cItemHandler::GetItemHandler(m_Player->GetEquippedItem()); - if (ItemHandler->IsFood() || ItemHandler->IsDrinkable(&m_Player->GetEquippedItem())) + if (ItemHandler->IsFood() || ItemHandler->IsDrinkable(m_Player->GetEquippedItem().m_ItemDamage)) { m_Player->AbortEating(); return; @@ -1176,15 +1176,16 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e return; } + short EquippedDamage = Equipped.m_ItemDamage; cItemHandler * ItemHandler = cItemHandler::GetItemHandler(Equipped.m_ItemType); if (ItemHandler->IsPlaceable() && (a_BlockFace != BLOCK_FACE_NONE)) { HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler); } - else if ((ItemHandler->IsFood() || ItemHandler->IsDrinkable(&Equipped)) && !m_Player->IsGameModeCreative()) + else if ((ItemHandler->IsFood() || ItemHandler->IsDrinkable(EquippedDamage)) && !m_Player->IsGameModeCreative()) { - if (m_Player->IsSatiated() && !ItemHandler->IsDrinkable(&Equipped)) + if (m_Player->IsSatiated() && !ItemHandler->IsDrinkable(EquippedDamage)) { // The player is satiated, they cannot eat return; -- cgit v1.2.3 From 563f706422554d1d8ff1121b9613ab9d34951a3b Mon Sep 17 00:00:00 2001 From: Mattes D Date: Fri, 27 Jun 2014 19:34:53 +0200 Subject: Removed the md5 library, obsoleted by PolarSSL. Fixes #1130. --- src/ClientHandle.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'src/ClientHandle.cpp') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 46083a8f1..611995148 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -30,7 +30,7 @@ #include "CompositeChat.h" #include "Items/ItemSword.h" -#include "md5/md5.h" +#include "polarssl/md5.h" @@ -239,18 +239,14 @@ AString cClientHandle::GenerateOfflineUUID(const AString & a_Username) // xxxxxxxx-xxxx-3xxx-yxxx-xxxxxxxxxxxx where x is any hexadecimal digit and y is one of 8, 9, A, or B // Generate an md5 checksum, and use it as base for the ID: - MD5 Checksum(a_Username); - AString UUID = Checksum.hexdigest(); - UUID[12] = '3'; // Version 3 UUID - UUID[16] = '8'; // Variant 1 UUID - - // Now the digest doesn't have the UUID slashes, but the client requires them, so add them into the appropriate positions: - UUID.insert(8, "-"); - UUID.insert(13, "-"); - UUID.insert(18, "-"); - UUID.insert(23, "-"); - - return UUID; + unsigned char MD5[16]; + md5((const unsigned char *)a_Username.c_str(), a_Username.length(), MD5); + return Printf("%02x%02x%02x%02x-%02x%02x-3%01x%02x-8%01x%02x-%02x%02x%02x%02x%02x%02x", + MD5[0], MD5[1], MD5[2], MD5[3], + MD5[4], MD5[5], MD5[6], MD5[7], + MD5[8], MD5[9], MD5[10], MD5[11], + MD5[12], MD5[13], MD5[14], MD5[15] + ); } -- cgit v1.2.3 From 9926abd4f55d668dec9e06c2ba23fa3bb9209eeb Mon Sep 17 00:00:00 2001 From: Mattes D Date: Fri, 27 Jun 2014 20:56:29 +0200 Subject: Added generic entity-collecting. Now any cEntity can be collected, not only cPickups. This should help PR #1098. --- src/ClientHandle.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/ClientHandle.cpp') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 46083a8f1..16cfe1aec 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -2077,9 +2077,9 @@ void cClientHandle::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializ -void cClientHandle::SendCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player) +void cClientHandle::SendCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player) { - m_Protocol->SendCollectPickup(a_Pickup, a_Player); + m_Protocol->SendCollectEntity(a_Entity, a_Player); } -- cgit v1.2.3 From 5e66d9aeabcb759319c1045680443e72f0c1d75b Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 28 Jun 2014 20:45:05 +0100 Subject: Fixed issue with breaking blocks at -1 coordinates --- src/ClientHandle.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'src/ClientHandle.cpp') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 16cfe1aec..e7b876b24 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1085,12 +1085,7 @@ void cClientHandle::HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_Blo void cClientHandle::FinishDigAnimation() { - if ( - !m_HasStartedDigging || // Hasn't received the DIG_STARTED packet - (m_LastDigBlockX == -1) || - (m_LastDigBlockY == -1) || - (m_LastDigBlockZ == -1) - ) + if (!m_HasStartedDigging) // Hasn't received the DIG_STARTED packet { return; } -- cgit v1.2.3 From 50e112788bc46460ec2c1972f811264c1a9b04cc Mon Sep 17 00:00:00 2001 From: Howaner Date: Sun, 29 Jun 2014 01:40:15 +0200 Subject: Send statistics to the player, when he logged in. --- src/ClientHandle.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/ClientHandle.cpp') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 95dfaffb2..abe9a86f5 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -361,6 +361,9 @@ void cClientHandle::Authenticate(const AString & a_Name, const AString & a_UUID) // Send scoreboard data World->GetScoreBoard().SendTo(*this); + // Send statistics + SendStatistics(m_Player->GetStatManager()); + // Delay the first ping until the client "settles down" // This should fix #889, "BadCast exception, cannot convert bit to fm" error in client cTimer t1; -- cgit v1.2.3 From 3c631fc0f95f383c53d18cd7760ab2e3a8609240 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Sun, 29 Jun 2014 18:27:41 +0200 Subject: Fixed offline UUID generator. It generated invalid UUIDs, too many hex chars. --- src/ClientHandle.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/ClientHandle.cpp') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index abe9a86f5..662ee7927 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -241,9 +241,11 @@ AString cClientHandle::GenerateOfflineUUID(const AString & a_Username) // Generate an md5 checksum, and use it as base for the ID: unsigned char MD5[16]; md5((const unsigned char *)a_Username.c_str(), a_Username.length(), MD5); + MD5[6] &= 0x0f; // Need to trim to 4 bits only... + MD5[8] &= 0x0f; // ... otherwise %01x overflows into two chars return Printf("%02x%02x%02x%02x-%02x%02x-3%01x%02x-8%01x%02x-%02x%02x%02x%02x%02x%02x", - MD5[0], MD5[1], MD5[2], MD5[3], - MD5[4], MD5[5], MD5[6], MD5[7], + MD5[0], MD5[1], MD5[2], MD5[3], + MD5[4], MD5[5], MD5[6], MD5[7], MD5[8], MD5[9], MD5[10], MD5[11], MD5[12], MD5[13], MD5[14], MD5[15] ); -- cgit v1.2.3 From b9d4431f6f2b60802d66da03f0b915bbd2c846cb Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 29 Jun 2014 22:44:01 +0100 Subject: Fixed respawning * Fixes #1103 --- src/ClientHandle.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/ClientHandle.cpp') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 662ee7927..6b71f0924 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -2397,9 +2397,9 @@ void cClientHandle::SendRemoveEntityEffect(const cEntity & a_Entity, int a_Effec -void cClientHandle::SendRespawn(const cWorld & a_World) +void cClientHandle::SendRespawn(const cWorld & a_World, bool a_ShouldIgnoreDimensionChecks) { - m_Protocol->SendRespawn(a_World); + m_Protocol->SendRespawn(a_World, a_ShouldIgnoreDimensionChecks); } -- cgit v1.2.3 From 4ded58bfd1066d237588c542e511759e504c5c95 Mon Sep 17 00:00:00 2001 From: Howaner Date: Mon, 30 Jun 2014 14:19:31 +0200 Subject: Unnecessary return --- src/ClientHandle.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/ClientHandle.cpp') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 6b71f0924..efa734b44 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1223,9 +1223,7 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e { // A plugin won't let us eat, abort (send the proper packets to the client, too): m_Player->AbortEating(); - return; } - return; } else { -- cgit v1.2.3 From e11f41d04821c9c00796066b45c4ace86415beb3 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 13 Jul 2014 00:12:32 +0100 Subject: Revert failed fix for #31 This reverts commit 69dc9b4c9aea58ebd95e2dbd0205701dfc4ce54e. --- src/ClientHandle.cpp | 31 ++++--------------------------- 1 file changed, 4 insertions(+), 27 deletions(-) (limited to 'src/ClientHandle.cpp') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index efa734b44..56275a9b2 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -40,9 +40,6 @@ /** Maximum number of block change interactions a player can perform per tick - exceeding this causes a kick */ #define MAX_BLOCK_CHANGE_INTERACTIONS 20 -/** How many ticks before the socket is closed after the client is destroyed (#31) */ -static const int TICKS_BEFORE_CLOSE = 20; - @@ -79,7 +76,6 @@ cClientHandle::cClientHandle(const cSocket * a_Socket, int a_ViewDistance) : m_PingID(1), m_BlockDigAnimStage(-1), m_HasStartedDigging(false), - m_TicksSinceDestruction(0), m_State(csConnected), m_ShouldCheckDownloaded(false), m_NumExplosionsThisTick(0), @@ -104,7 +100,7 @@ cClientHandle::cClientHandle(const cSocket * a_Socket, int a_ViewDistance) : cClientHandle::~cClientHandle() { - ASSERT(m_State >= csDestroyedWaiting); // Has Destroy() been called? + ASSERT(m_State == csDestroyed); // Has Destroy() been called? LOGD("Deleting client \"%s\" at %p", GetUsername().c_str(), this); @@ -169,7 +165,7 @@ void cClientHandle::Destroy(void) RemoveFromAllChunks(); m_Player->GetWorld()->RemoveClientFromChunkSender(this); } - m_State = csDestroyedWaiting; + m_State = csDestroyed; } @@ -1823,18 +1819,7 @@ bool cClientHandle::CheckBlockInteractionsRate(void) void cClientHandle::Tick(float a_Dt) -{ - // Handle clients that are waiting for final close while destroyed: - if (m_State == csDestroyedWaiting) - { - m_TicksSinceDestruction += 1; // This field is misused for the timeout counting - if (m_TicksSinceDestruction > TICKS_BEFORE_CLOSE) - { - m_State = csDestroyed; - } - return; - } - +{ // Process received network data: AString IncomingData; { @@ -1900,15 +1885,7 @@ void cClientHandle::Tick(float a_Dt) void cClientHandle::ServerTick(float a_Dt) -{ - // Handle clients that are waiting for final close while destroyed: - if (m_State == csDestroyedWaiting) - { - // Do not wait while the client is not in the world, simply cut them off. - m_State = csDestroyed; - return; - } - +{ // Process received network data: AString IncomingData; { -- cgit v1.2.3 From d529971e279609ae928d9077404b95bd595b5e52 Mon Sep 17 00:00:00 2001 From: Howaner Date: Sun, 13 Jul 2014 02:08:02 +0200 Subject: Changed BroadcastSoundEffect function to take floating pos. --- src/ClientHandle.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/ClientHandle.cpp') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 56275a9b2..340db6394 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1361,7 +1361,7 @@ void cClientHandle::HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, e NewBlock->OnPlacedByPlayer(ChunkInterface,*World, m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, BlockType, BlockMeta); // Step sound with 0.8f pitch is used as block placement sound - World->BroadcastSoundEffect(NewBlock->GetStepSound(), a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 1.0f, 0.8f); + World->BroadcastSoundEffect(NewBlock->GetStepSound(), (double)a_BlockX, (double)a_BlockY, (double)a_BlockZ, 1.0f, 0.8f); cRoot::Get()->GetPluginManager()->CallHookPlayerPlacedBlock(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, BlockType, BlockMeta); } @@ -2426,9 +2426,9 @@ void cClientHandle::SendDisplayObjective(const AString & a_Objective, cScoreboar -void cClientHandle::SendSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) +void cClientHandle::SendSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch) { - m_Protocol->SendSoundEffect(a_SoundName, a_SrcX, a_SrcY, a_SrcZ, a_Volume, a_Pitch); + m_Protocol->SendSoundEffect(a_SoundName, a_X, a_Y, a_Z, a_Volume, a_Pitch); } -- cgit v1.2.3 From 4e24f711abd3d6a93f01ee7c297eb67c8aedbd37 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 14 Jul 2014 19:49:31 +0100 Subject: Player properties are now retrieved --- src/ClientHandle.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/ClientHandle.cpp') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 56275a9b2..fcd8d2bcd 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -290,17 +290,18 @@ void cClientHandle::Kick(const AString & a_Reason) -void cClientHandle::Authenticate(const AString & a_Name, const AString & a_UUID) +void cClientHandle::Authenticate(const AString & a_Name, const AString & a_UUID, const AString & a_Properties) { if (m_State != csAuthenticating) { return; } - ASSERT( m_Player == NULL ); + ASSERT(m_Player == NULL); m_Username = a_Name; m_UUID = a_UUID; + m_Properties = a_Properties; // Send login success (if the protocol supports it): m_Protocol->SendLoginSuccess(); @@ -324,7 +325,7 @@ void cClientHandle::Authenticate(const AString & a_Name, const AString & a_UUID) if (!cRoot::Get()->GetPluginManager()->CallHookPlayerJoined(*m_Player)) { cRoot::Get()->BroadcastChatJoin(Printf("%s has joined the game", GetUsername().c_str())); - LOGINFO("Player %s has joined the game.", m_Username.c_str()); + LOGINFO("Player %s has joined the game", m_Username.c_str()); } m_ConfirmPosition = m_Player->GetPosition(); -- cgit v1.2.3 From 1f6854792cdd6792b27c4f9f3d7d857df9dd64bf Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 16 Jul 2014 00:03:47 +0100 Subject: Store properties as Json::Value --- src/ClientHandle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ClientHandle.cpp') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index fcd8d2bcd..c749d41ab 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -290,7 +290,7 @@ void cClientHandle::Kick(const AString & a_Reason) -void cClientHandle::Authenticate(const AString & a_Name, const AString & a_UUID, const AString & a_Properties) +void cClientHandle::Authenticate(const AString & a_Name, const AString & a_UUID, const Json::Value & a_Properties) { if (m_State != csAuthenticating) { -- cgit v1.2.3 From 993fd14ddfc881cf5be951df77da0338124d68cc Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 17 Jul 2014 16:33:09 +0200 Subject: Fixed basic whitespace problems. Indenting by spaces and alignment by spaces, as well as trailing whitespace on non-empty lines. --- src/ClientHandle.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/ClientHandle.cpp') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index bd6fc1287..bf66e7db1 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -85,7 +85,7 @@ cClientHandle::cClientHandle(const cSocket * a_Socket, int a_ViewDistance) : { m_Protocol = new cProtocolRecognizer(this); - s_ClientCount++; // Not protected by CS because clients are always constructed from the same thread + s_ClientCount++; // Not protected by CS because clients are always constructed from the same thread m_UniqueID = s_ClientCount; cTimer t1; @@ -531,7 +531,7 @@ void cClientHandle::HandlePing(void) AString Reply; const cServer & Server = *cRoot::Get()->GetServer(); - Printf(Reply, "%s%s%i%s%i", + Printf(Reply, "%s%s%i%s%i", Server.GetDescription().c_str(), cChatColor::Delimiter.c_str(), Server.GetNumPlayers(), @@ -1169,7 +1169,7 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e if ((Equipped.m_ItemType != a_HeldItem.m_ItemType) && (a_HeldItem.m_ItemType != -1)) { // Only compare ItemType, not meta (torches have different metas) - // The -1 check is there because sometimes the client sends -1 instead of the held item + // The -1 check is there because sometimes the client sends -1 instead of the held item // ( http://forum.mc-server.org/showthread.php?tid=549&pid=4502#pid4502 ) LOGWARN("Player %s tried to place a block that was not equipped (exp %d, got %d)", m_Username.c_str(), Equipped.m_ItemType, a_HeldItem.m_ItemType @@ -1390,7 +1390,7 @@ void cClientHandle::HandleChat(const AString & a_Message) Color = AString("@") + Color[2]; } else - { + { Color.clear(); } Msg.AddTextPart(AString("<") + m_Player->GetName() + "> ", Color); @@ -1449,7 +1449,7 @@ void cClientHandle::HandleAnimation(char a_Animation) a_Animation--; // Offset by -1 break; } - case 5: + case 5: case 6: case 7: { @@ -1517,8 +1517,8 @@ void cClientHandle::HandleWindowClick(char a_WindowID, short a_SlotNum, eClickAc void cClientHandle::HandleUpdateSign( - int a_BlockX, int a_BlockY, int a_BlockZ, - const AString & a_Line1, const AString & a_Line2, + int a_BlockX, int a_BlockY, int a_BlockZ, + const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4 ) { @@ -1821,7 +1821,7 @@ bool cClientHandle::CheckBlockInteractionsRate(void) void cClientHandle::Tick(float a_Dt) -{ +{ // Process received network data: AString IncomingData; { @@ -1887,7 +1887,7 @@ void cClientHandle::Tick(float a_Dt) void cClientHandle::ServerTick(float a_Dt) -{ +{ // Process received network data: AString IncomingData; { @@ -2345,7 +2345,7 @@ void cClientHandle::SendPlayerSpawn(const cPlayer & a_Player) return; } - LOGD("Spawning player \"%s\" on client \"%s\" @ %s", + LOGD("Spawning player \"%s\" on client \"%s\" @ %s", a_Player.GetName().c_str(), GetPlayer()->GetName().c_str(), GetIPString().c_str() ); -- cgit v1.2.3 From 7fff12bfacbb4bef1c02cea0ec10fdc9a6fb64e4 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 17 Jul 2014 19:13:23 +0200 Subject: Fixed spaces around single-line comments. There should be at least two spaces in front and one space after //-style comments. --- src/ClientHandle.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'src/ClientHandle.cpp') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index bf66e7db1..afa99008a 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -589,7 +589,7 @@ void cClientHandle::HandleCreativeInventory(short a_SlotNum, const cItem & a_Hel void cClientHandle::HandlePlayerAbilities(bool a_CanFly, bool a_IsFlying, float FlyingSpeed, float WalkingSpeed) { - UNUSED(FlyingSpeed); // Ignore the client values for these + UNUSED(FlyingSpeed); // Ignore the client values for these UNUSED(WalkingSpeed); m_Player->SetCanFly(a_CanFly); @@ -668,7 +668,7 @@ void cClientHandle::HandlePluginMessage(const AString & a_Channel, const AString if (HasPluginChannel(a_Channel)) { SendPluginMessage("UNREGISTER", a_Channel); - return; // Can't register again if already taken - kinda defeats the point of plugin messaging! + return; // Can't register again if already taken - kinda defeats the point of plugin messaging! } RegisterPluginChannels(BreakApartPluginChannels(a_Message)); @@ -842,7 +842,7 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB } if ( - ((a_Status == DIG_STATUS_STARTED) || (a_Status == DIG_STATUS_FINISHED)) && // Only do a radius check for block destruction - things like pickup tossing send coordinates that are to be ignored + ((a_Status == DIG_STATUS_STARTED) || (a_Status == DIG_STATUS_FINISHED)) && // Only do a radius check for block destruction - things like pickup tossing send coordinates that are to be ignored ((Diff(m_Player->GetPosX(), (double)a_BlockX) > 6) || (Diff(m_Player->GetPosY(), (double)a_BlockY) > 6) || (Diff(m_Player->GetPosZ(), (double)a_BlockZ) > 6)) @@ -926,7 +926,7 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB // A plugin doesn't agree with the tossing. The plugin itself is responsible for handling the consequences (possible inventory mismatch) return; } - m_Player->TossEquippedItem(64); // Toss entire slot - if there aren't enough items, the maximum will be ejected + m_Player->TossEquippedItem(64); // Toss entire slot - if there aren't enough items, the maximum will be ejected return; } @@ -989,7 +989,7 @@ void cClientHandle::HandleBlockDigStarted(int a_BlockX, int a_BlockY, int a_Bloc int pY = a_BlockY; int pZ = a_BlockZ; - AddFaceDirection(pX, pY, pZ, a_BlockFace); // Get the block in front of the clicked coordinates (m_bInverse defaulted to false) + AddFaceDirection(pX, pY, pZ, a_BlockFace); // Get the block in front of the clicked coordinates (m_bInverse defaulted to false) cBlockHandler * Handler = cBlockInfo::GetHandler(m_Player->GetWorld()->GetBlock(pX, pY, pZ)); if (Handler->IsClickedThrough()) @@ -1083,7 +1083,7 @@ void cClientHandle::HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_Blo void cClientHandle::FinishDigAnimation() { - if (!m_HasStartedDigging) // Hasn't received the DIG_STARTED packet + if (!m_HasStartedDigging) // Hasn't received the DIG_STARTED packet { return; } @@ -1441,23 +1441,25 @@ void cClientHandle::HandleAnimation(char a_Animation) // Because the animation ID sent to servers by clients are different to those sent back, we need this switch (a_Animation) { - case 0: // No animation - wiki.vg doesn't say that client has something specific for it, so I suppose it will just become -1 + case 0: // No animation - wiki.vg doesn't say that client has something specific for it, so I suppose it will just become -1 case 1: case 2: case 3: { - a_Animation--; // Offset by -1 + a_Animation--; // Offset by -1 break; } case 5: case 6: case 7: { - a_Animation -= 2; // Offset by -2 + a_Animation -= 2; // Offset by -2 break; } - default: // Anything else is the same + default: // Anything else is the same + { break; + } } m_Player->GetWorld()->BroadcastEntityAnimation(*m_Player, a_Animation, this); @@ -2473,7 +2475,7 @@ void cClientHandle::SendSpawnObject(const cEntity & a_Entity, char a_ObjectType, -void cClientHandle::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleType, char a_VehicleSubType) // VehicleSubType is specific to Minecarts +void cClientHandle::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleType, char a_VehicleSubType) // VehicleSubType is specific to Minecarts { m_Protocol->SendSpawnVehicle(a_Vehicle, a_VehicleType, a_VehicleSubType); } -- cgit v1.2.3 From 2423fbf2efa39e28cc348acc11b9269e573dcdef Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 17 Jul 2014 22:15:34 +0200 Subject: Normalized comments. This was mostly done automatically and then visually inspected for obvious errors. All //-style comments should have a 2-space separation from the code, and 1 space after the comment sign. --- src/ClientHandle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ClientHandle.cpp') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index afa99008a..97466c331 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -60,7 +60,7 @@ int cClientHandle::s_ClientCount = 0; -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // cClientHandle: cClientHandle::cClientHandle(const cSocket * a_Socket, int a_ViewDistance) : -- cgit v1.2.3 From 9529a4255999efc0970d82385ef1ff07c62a7a02 Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 18 Jul 2014 01:56:26 -0700 Subject: Fixed creative players not being able to drink Fixes #1215 --- src/ClientHandle.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/ClientHandle.cpp') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 97466c331..58247a836 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1209,11 +1209,12 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e { HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler); } - else if ((ItemHandler->IsFood() || ItemHandler->IsDrinkable(EquippedDamage)) && !m_Player->IsGameModeCreative()) + else if ((ItemHandler->IsFood() || ItemHandler->IsDrinkable(EquippedDamage))) { - if (m_Player->IsSatiated() && !ItemHandler->IsDrinkable(EquippedDamage)) + if ((m_Player->IsSatiated() || m_Player->IsGameModeCreative()) && + ItemHandler->IsFood()) { - // The player is satiated, they cannot eat + // The player is satiated or in creative, and trying to eat return; } m_Player->StartEating(); -- cgit v1.2.3