2013-07-29 07:13:03 -04:00
|
|
|
|
|
|
|
// ProtocolRecognizer.cpp
|
|
|
|
|
2014-07-17 16:50:58 -04:00
|
|
|
// Implements the cProtocolRecognizer class representing the meta-protocol that recognizes possibly multiple
|
2013-07-29 07:13:03 -04:00
|
|
|
// protocol versions and redirects everything to them
|
|
|
|
|
|
|
|
#include "Globals.h"
|
|
|
|
|
|
|
|
#include "ProtocolRecognizer.h"
|
2016-12-15 14:21:43 -05:00
|
|
|
#include "Protocol_1_8.h"
|
|
|
|
#include "Protocol_1_9.h"
|
|
|
|
#include "Protocol_1_10.h"
|
|
|
|
#include "Protocol_1_11.h"
|
2017-06-14 05:22:51 -04:00
|
|
|
#include "Protocol_1_12.h"
|
2018-07-31 19:21:44 -04:00
|
|
|
#include "Protocol_1_13.h"
|
2013-07-29 07:13:03 -04:00
|
|
|
#include "../ClientHandle.h"
|
|
|
|
#include "../Root.h"
|
2013-08-11 13:18:06 -04:00
|
|
|
#include "../Server.h"
|
2013-07-29 07:13:03 -04:00
|
|
|
#include "../World.h"
|
2020-05-09 10:51:15 -04:00
|
|
|
#include "../JsonUtils.h"
|
2018-08-28 20:51:25 -04:00
|
|
|
#include "../Bindings/PluginManager.h"
|
2013-07-29 07:13:03 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-07-17 13:46:50 -04:00
|
|
|
struct sUnsupportedButPingableProtocolException : public std::runtime_error
|
|
|
|
{
|
|
|
|
explicit sUnsupportedButPingableProtocolException() :
|
|
|
|
std::runtime_error("")
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct sTriedToJoinWithUnsupportedProtocolException : public std::runtime_error
|
|
|
|
{
|
|
|
|
explicit sTriedToJoinWithUnsupportedProtocolException(const std::string & a_Message) :
|
|
|
|
std::runtime_error(a_Message)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cMultiVersionProtocol::cMultiVersionProtocol() :
|
|
|
|
HandleIncomingData(std::bind(&cMultiVersionProtocol::HandleIncomingDataInRecognitionStage, this, std::placeholders::_1, std::placeholders::_2)),
|
|
|
|
m_Buffer(8 KiB) // We need a larger buffer to support BungeeCord - it sends one huge packet at the start
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-07-17 13:46:50 -04:00
|
|
|
AString cMultiVersionProtocol::GetVersionTextFromInt(int a_ProtocolVersion)
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
|
|
|
switch (a_ProtocolVersion)
|
|
|
|
{
|
2016-09-02 13:22:06 -04:00
|
|
|
case PROTO_VERSION_1_8_0: return "1.8";
|
|
|
|
case PROTO_VERSION_1_9_0: return "1.9";
|
|
|
|
case PROTO_VERSION_1_9_1: return "1.9.1";
|
|
|
|
case PROTO_VERSION_1_9_2: return "1.9.2";
|
|
|
|
case PROTO_VERSION_1_9_4: return "1.9.4";
|
2016-12-15 14:21:43 -05:00
|
|
|
case PROTO_VERSION_1_10_0: return "1.10";
|
|
|
|
case PROTO_VERSION_1_11_0: return "1.11";
|
2017-02-21 10:11:28 -05:00
|
|
|
case PROTO_VERSION_1_11_1: return "1.11.1";
|
2017-06-14 05:22:51 -04:00
|
|
|
case PROTO_VERSION_1_12: return "1.12";
|
2017-08-17 10:25:53 -04:00
|
|
|
case PROTO_VERSION_1_12_1: return "1.12.1";
|
2020-07-14 12:56:42 -04:00
|
|
|
case PROTO_VERSION_1_12_2: return "1.12.2";
|
2020-01-03 08:30:51 -05:00
|
|
|
case PROTO_VERSION_1_13: return "1.13";
|
2013-07-29 07:13:03 -04:00
|
|
|
}
|
|
|
|
ASSERT(!"Unknown protocol version");
|
|
|
|
return Printf("Unknown protocol (%d)", a_ProtocolVersion);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-07-17 13:46:50 -04:00
|
|
|
void cMultiVersionProtocol::HandleIncomingDataInRecognitionStage(cClientHandle & a_Client, std::string_view a_Data)
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
2020-07-17 13:46:50 -04:00
|
|
|
// We read more than the handshake packet here, oh well.
|
|
|
|
if (!m_Buffer.Write(a_Data.data(), a_Data.size()))
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
2020-07-17 13:46:50 -04:00
|
|
|
a_Client.Kick("Your client sent too much data; please try again later.");
|
2017-06-16 08:03:13 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-07-17 13:46:50 -04:00
|
|
|
try
|
2017-06-16 08:03:13 -04:00
|
|
|
{
|
2020-07-17 13:46:50 -04:00
|
|
|
// Note that a_Data is assigned to a subview containing the data to pass to m_Protocol or UnsupportedPing
|
2017-06-16 08:03:13 -04:00
|
|
|
|
2020-07-17 13:46:50 -04:00
|
|
|
TryRecognizeProtocol(a_Client, a_Data);
|
|
|
|
if (m_Protocol == nullptr)
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
2017-07-16 19:19:09 -04:00
|
|
|
m_Buffer.ResetRead();
|
2013-07-29 07:13:03 -04:00
|
|
|
return;
|
|
|
|
}
|
2020-07-17 13:46:50 -04:00
|
|
|
|
|
|
|
// The protocol recogniser succesfully identified, switch mode:
|
|
|
|
HandleIncomingData = [this](cClientHandle &, const std::string_view a_In)
|
2017-06-16 08:03:13 -04:00
|
|
|
{
|
2020-07-17 13:46:50 -04:00
|
|
|
// TODO: make it take our a_ReceivedData
|
|
|
|
m_Protocol->DataReceived(a_In.data(), a_In.size());
|
|
|
|
};
|
|
|
|
}
|
|
|
|
catch (const sUnsupportedButPingableProtocolException &)
|
|
|
|
{
|
|
|
|
// Got a server list ping for an unrecognised version,
|
|
|
|
// switch into responding to unknown protocols mode:
|
|
|
|
HandleIncomingData = [this](cClientHandle & a_Clyent, const std::string_view a_In)
|
|
|
|
{
|
|
|
|
HandleIncomingDataInOldPingResponseStage(a_Clyent, a_In);
|
|
|
|
};
|
2017-07-16 19:19:09 -04:00
|
|
|
}
|
2020-07-17 13:46:50 -04:00
|
|
|
catch (const std::exception & Oops)
|
|
|
|
{
|
|
|
|
a_Client.Kick(Oops.what());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Explicitly process any remaining data with the new handler:
|
|
|
|
HandleIncomingData(a_Client, a_Data);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-07-16 19:19:09 -04:00
|
|
|
|
2020-07-17 13:46:50 -04:00
|
|
|
|
|
|
|
void cMultiVersionProtocol::HandleIncomingDataInOldPingResponseStage(cClientHandle & a_Client, const std::string_view a_Data)
|
|
|
|
{
|
|
|
|
if (!m_Buffer.Write(a_Data.data(), a_Data.size()))
|
2017-07-16 19:19:09 -04:00
|
|
|
{
|
2020-07-17 13:46:50 -04:00
|
|
|
a_Client.Kick("Server list ping failed, too much data.");
|
2017-07-16 19:19:09 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-07-17 13:46:50 -04:00
|
|
|
cByteBuffer OutPacketBuffer(6 KiB);
|
|
|
|
|
2017-07-16 19:19:09 -04:00
|
|
|
// Handle server list ping packets
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
UInt32 PacketLen;
|
|
|
|
UInt32 PacketID;
|
|
|
|
if (
|
|
|
|
!m_Buffer.ReadVarInt32(PacketLen) ||
|
|
|
|
!m_Buffer.CanReadBytes(PacketLen) ||
|
|
|
|
!m_Buffer.ReadVarInt32(PacketID)
|
|
|
|
)
|
1.9 / 1.9.2 / 1.9.3 / 1.9.4 protocol support (#3135)
* Semistable update to 15w31a
I'm going through snapshots in a sequential order since it should make things easier, and since protocol version history is written.
* Update to 15w34b protocol
Also, fix an issue with the Entity Equipment packet from the past version. Clients are able to connect and do stuff!
* Partially update to 15w35e
Chunk data doesn't work, but the client joins. I'm waiting to do chunk data because chunk data has an incomplete format until 15w36d.
* Add '/blk' debug command
This command lets one see what block they are looking at, and makes figuring out what's supposed to be where in a highly broken chunk possible.
* Fix CRLF normalization in CheckBasicStyle.lua
Normally, this doesn't cause an issue, but when running from cygwin, it detects the CR as whitespace and creates thousands of violations for every single line. Lua, when run on windows, will normalize automatically, but when run via cygwin, it won't.
The bug was simply that gsub was returning a replaced version, but not changing the parameter, so the replaced version was ignored.
* Update to 15w40b
This includes chunk serialization. Fully functional chunk serialization for 1.9.
I'm not completely happy with the chunk serialization as-is (correct use of palettes would be great), but cuberite also doesn't skip sending empty chunks so this performance optimization should probably come later. The creation of a full buffer is suboptimal, but it's the easiest way to implement this code.
* Write long-by-long rather than creating a buffer
This is a bit faster and should be equivalent. However, the code still doesn't look too good.
* Update to 15w41a protocol
This includes the new set passengers packet, which works off of the ridden entity, not the rider. That means, among other things, that information about the previously ridden vehicle is needed when detaching. So a new method with that info was added.
* Update to 15w45a
* 15w51b protocol
* Update to 1.9.0 protocol
Closes #3067. There are still a few things that need to be worked out (picking up items, effects, particles, and most importantly inventory), but in general this should work. I'll make a few more changes tomorrow to get the rest of the protocol set up, along with 1.9.1/1.9.2 (which did make a few changes). Chunks, however, _are_ working, along with most other parts of the game (placing/breaking blocks).
* Fix item pickup packet not working
That was a silly mistake, but at least it was an easy one.
* 1.9.2 protocol support
* Fix version info found in server list ping
Thus, the client reports that it can connect rather than saying that the server is out of date. This required creating separate classes for 1.9.1 and 1.9.2, unfortunately.
* Fix build errors generated by clang
These didn't happen in MSVC.
* Add protocol19x.cpp and protocol19x.h to CMakeLists
* Ignore warnings in protocol19x that are ignored in protocol18x
* Document BLOCK_FACE and DIG_STATUS constants
* Fix BLOCK_FACE links and add separate section for DIG_STATUS
* Fix bat animation and object spawning
The causes of both of these are explained in #3135, but the gist is that both were typos.
* Implement Use Item packet
This means that buckets, bows, fishing rods, and several other similar items now work when not looking at a block.
* Handle DIG_STATUS_SWAP_ITEM_IN_HAND
* Add support for spawn eggs and potions
The items are transformed from the 1.9 version to the 1.8 version when reading and transformed back when sending.
* Remove spammy potion debug logging
* Fix wolf collar color metadata
The wrong type was being used, causing several clientside issues (including the screen going black).
* Fix 1.9 chunk sending in the nether
The nether and the end don't send skylight.
* Fix clang build errors
* Fix water bottles becoming mundane potions
This happened because the can become splash potion bit got set incorrectly. Water bottles and mundane potions are only differentiated by the fact that water bottles have a metadata of 0, so setting that bit made it a mundane potion.
Also add missing break statements to the read item NBT switch, which would otherwise break items with custom names and also cause incorrect "Unimplemented NBT data when parsing!" logging.
* Copy Protocol18x as Protocol19x
Aditionally, method and class names have been swapped to clean up other diffs. This commit is only added to make the following diffs more readable; it doesn't make any other changes (beyond class names).
* Make thrown potions use the correct appearence
This was caused by potions now using metadata.
* Add missing api doc for cSplashPotionEntity::GetItem
* Fix compile error in SplashPotionEntity.cpp
* Fix fix of cSplashPotionEntity API doc
* Temporarilly disable fall damage particles
These were causing issues in 1.9 due to the changed effect ID.
* Properly send a kick packet when connecting with an invalid version
This means that the client no longer waits on the server screen with no indication whatsoever. However, right now the server list ping isn't implemented for unknown versions, so it'll only load "Old" on the ping.
I also added a GetVarIntSize method to cByteBuffer. This helps clean up part of the code here (and I think it could clean up other parts), but it may make sense for it to be moved elsewhere (or declared in a different way).
* Handle server list pings from unrecognized versions
This isn't the cleanest way of writing it (it feels odd to use ProtocolRecognizer to send packets, and the addition of m_InPingForUnrecognizedVersion feels like the wrong technique), but it works and I can't think of a better way (apart from creating a full separate protocol class to handle only the ping... which would be worse).
* Use cPacketizer for the disconnect packet
This also should fix clang build errors.
* Add 1.9.3 / 1.9.4 support
* Fix incorrect indentation in APIDesc
2016-05-14 15:12:42 -04:00
|
|
|
{
|
2017-07-16 19:19:09 -04:00
|
|
|
// Not enough data
|
|
|
|
m_Buffer.ResetRead();
|
|
|
|
break;
|
1.9 / 1.9.2 / 1.9.3 / 1.9.4 protocol support (#3135)
* Semistable update to 15w31a
I'm going through snapshots in a sequential order since it should make things easier, and since protocol version history is written.
* Update to 15w34b protocol
Also, fix an issue with the Entity Equipment packet from the past version. Clients are able to connect and do stuff!
* Partially update to 15w35e
Chunk data doesn't work, but the client joins. I'm waiting to do chunk data because chunk data has an incomplete format until 15w36d.
* Add '/blk' debug command
This command lets one see what block they are looking at, and makes figuring out what's supposed to be where in a highly broken chunk possible.
* Fix CRLF normalization in CheckBasicStyle.lua
Normally, this doesn't cause an issue, but when running from cygwin, it detects the CR as whitespace and creates thousands of violations for every single line. Lua, when run on windows, will normalize automatically, but when run via cygwin, it won't.
The bug was simply that gsub was returning a replaced version, but not changing the parameter, so the replaced version was ignored.
* Update to 15w40b
This includes chunk serialization. Fully functional chunk serialization for 1.9.
I'm not completely happy with the chunk serialization as-is (correct use of palettes would be great), but cuberite also doesn't skip sending empty chunks so this performance optimization should probably come later. The creation of a full buffer is suboptimal, but it's the easiest way to implement this code.
* Write long-by-long rather than creating a buffer
This is a bit faster and should be equivalent. However, the code still doesn't look too good.
* Update to 15w41a protocol
This includes the new set passengers packet, which works off of the ridden entity, not the rider. That means, among other things, that information about the previously ridden vehicle is needed when detaching. So a new method with that info was added.
* Update to 15w45a
* 15w51b protocol
* Update to 1.9.0 protocol
Closes #3067. There are still a few things that need to be worked out (picking up items, effects, particles, and most importantly inventory), but in general this should work. I'll make a few more changes tomorrow to get the rest of the protocol set up, along with 1.9.1/1.9.2 (which did make a few changes). Chunks, however, _are_ working, along with most other parts of the game (placing/breaking blocks).
* Fix item pickup packet not working
That was a silly mistake, but at least it was an easy one.
* 1.9.2 protocol support
* Fix version info found in server list ping
Thus, the client reports that it can connect rather than saying that the server is out of date. This required creating separate classes for 1.9.1 and 1.9.2, unfortunately.
* Fix build errors generated by clang
These didn't happen in MSVC.
* Add protocol19x.cpp and protocol19x.h to CMakeLists
* Ignore warnings in protocol19x that are ignored in protocol18x
* Document BLOCK_FACE and DIG_STATUS constants
* Fix BLOCK_FACE links and add separate section for DIG_STATUS
* Fix bat animation and object spawning
The causes of both of these are explained in #3135, but the gist is that both were typos.
* Implement Use Item packet
This means that buckets, bows, fishing rods, and several other similar items now work when not looking at a block.
* Handle DIG_STATUS_SWAP_ITEM_IN_HAND
* Add support for spawn eggs and potions
The items are transformed from the 1.9 version to the 1.8 version when reading and transformed back when sending.
* Remove spammy potion debug logging
* Fix wolf collar color metadata
The wrong type was being used, causing several clientside issues (including the screen going black).
* Fix 1.9 chunk sending in the nether
The nether and the end don't send skylight.
* Fix clang build errors
* Fix water bottles becoming mundane potions
This happened because the can become splash potion bit got set incorrectly. Water bottles and mundane potions are only differentiated by the fact that water bottles have a metadata of 0, so setting that bit made it a mundane potion.
Also add missing break statements to the read item NBT switch, which would otherwise break items with custom names and also cause incorrect "Unimplemented NBT data when parsing!" logging.
* Copy Protocol18x as Protocol19x
Aditionally, method and class names have been swapped to clean up other diffs. This commit is only added to make the following diffs more readable; it doesn't make any other changes (beyond class names).
* Make thrown potions use the correct appearence
This was caused by potions now using metadata.
* Add missing api doc for cSplashPotionEntity::GetItem
* Fix compile error in SplashPotionEntity.cpp
* Fix fix of cSplashPotionEntity API doc
* Temporarilly disable fall damage particles
These were causing issues in 1.9 due to the changed effect ID.
* Properly send a kick packet when connecting with an invalid version
This means that the client no longer waits on the server screen with no indication whatsoever. However, right now the server list ping isn't implemented for unknown versions, so it'll only load "Old" on the ping.
I also added a GetVarIntSize method to cByteBuffer. This helps clean up part of the code here (and I think it could clean up other parts), but it may make sense for it to be moved elsewhere (or declared in a different way).
* Handle server list pings from unrecognized versions
This isn't the cleanest way of writing it (it feels odd to use ProtocolRecognizer to send packets, and the addition of m_InPingForUnrecognizedVersion feels like the wrong technique), but it works and I can't think of a better way (apart from creating a full separate protocol class to handle only the ping... which would be worse).
* Use cPacketizer for the disconnect packet
This also should fix clang build errors.
* Add 1.9.3 / 1.9.4 support
* Fix incorrect indentation in APIDesc
2016-05-14 15:12:42 -04:00
|
|
|
}
|
|
|
|
|
2017-07-16 19:19:09 -04:00
|
|
|
if ((PacketID == 0x00) && (PacketLen == 1)) // Request packet
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
2020-07-17 13:46:50 -04:00
|
|
|
HandlePacketStatusRequest(a_Client, OutPacketBuffer);
|
|
|
|
SendPacket(a_Client, OutPacketBuffer);
|
2017-07-16 19:19:09 -04:00
|
|
|
}
|
|
|
|
else if ((PacketID == 0x01) && (PacketLen == 9)) // Ping packet
|
|
|
|
{
|
2020-07-17 13:46:50 -04:00
|
|
|
HandlePacketStatusPing(a_Client, OutPacketBuffer);
|
|
|
|
SendPacket(a_Client, OutPacketBuffer);
|
2017-07-16 19:19:09 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-07-17 13:46:50 -04:00
|
|
|
a_Client.Kick("Server list ping failed, unrecognized packet.");
|
2013-07-29 07:13:03 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-07-17 13:46:50 -04:00
|
|
|
m_Buffer.CommitRead();
|
|
|
|
}
|
1.9 / 1.9.2 / 1.9.3 / 1.9.4 protocol support (#3135)
* Semistable update to 15w31a
I'm going through snapshots in a sequential order since it should make things easier, and since protocol version history is written.
* Update to 15w34b protocol
Also, fix an issue with the Entity Equipment packet from the past version. Clients are able to connect and do stuff!
* Partially update to 15w35e
Chunk data doesn't work, but the client joins. I'm waiting to do chunk data because chunk data has an incomplete format until 15w36d.
* Add '/blk' debug command
This command lets one see what block they are looking at, and makes figuring out what's supposed to be where in a highly broken chunk possible.
* Fix CRLF normalization in CheckBasicStyle.lua
Normally, this doesn't cause an issue, but when running from cygwin, it detects the CR as whitespace and creates thousands of violations for every single line. Lua, when run on windows, will normalize automatically, but when run via cygwin, it won't.
The bug was simply that gsub was returning a replaced version, but not changing the parameter, so the replaced version was ignored.
* Update to 15w40b
This includes chunk serialization. Fully functional chunk serialization for 1.9.
I'm not completely happy with the chunk serialization as-is (correct use of palettes would be great), but cuberite also doesn't skip sending empty chunks so this performance optimization should probably come later. The creation of a full buffer is suboptimal, but it's the easiest way to implement this code.
* Write long-by-long rather than creating a buffer
This is a bit faster and should be equivalent. However, the code still doesn't look too good.
* Update to 15w41a protocol
This includes the new set passengers packet, which works off of the ridden entity, not the rider. That means, among other things, that information about the previously ridden vehicle is needed when detaching. So a new method with that info was added.
* Update to 15w45a
* 15w51b protocol
* Update to 1.9.0 protocol
Closes #3067. There are still a few things that need to be worked out (picking up items, effects, particles, and most importantly inventory), but in general this should work. I'll make a few more changes tomorrow to get the rest of the protocol set up, along with 1.9.1/1.9.2 (which did make a few changes). Chunks, however, _are_ working, along with most other parts of the game (placing/breaking blocks).
* Fix item pickup packet not working
That was a silly mistake, but at least it was an easy one.
* 1.9.2 protocol support
* Fix version info found in server list ping
Thus, the client reports that it can connect rather than saying that the server is out of date. This required creating separate classes for 1.9.1 and 1.9.2, unfortunately.
* Fix build errors generated by clang
These didn't happen in MSVC.
* Add protocol19x.cpp and protocol19x.h to CMakeLists
* Ignore warnings in protocol19x that are ignored in protocol18x
* Document BLOCK_FACE and DIG_STATUS constants
* Fix BLOCK_FACE links and add separate section for DIG_STATUS
* Fix bat animation and object spawning
The causes of both of these are explained in #3135, but the gist is that both were typos.
* Implement Use Item packet
This means that buckets, bows, fishing rods, and several other similar items now work when not looking at a block.
* Handle DIG_STATUS_SWAP_ITEM_IN_HAND
* Add support for spawn eggs and potions
The items are transformed from the 1.9 version to the 1.8 version when reading and transformed back when sending.
* Remove spammy potion debug logging
* Fix wolf collar color metadata
The wrong type was being used, causing several clientside issues (including the screen going black).
* Fix 1.9 chunk sending in the nether
The nether and the end don't send skylight.
* Fix clang build errors
* Fix water bottles becoming mundane potions
This happened because the can become splash potion bit got set incorrectly. Water bottles and mundane potions are only differentiated by the fact that water bottles have a metadata of 0, so setting that bit made it a mundane potion.
Also add missing break statements to the read item NBT switch, which would otherwise break items with custom names and also cause incorrect "Unimplemented NBT data when parsing!" logging.
* Copy Protocol18x as Protocol19x
Aditionally, method and class names have been swapped to clean up other diffs. This commit is only added to make the following diffs more readable; it doesn't make any other changes (beyond class names).
* Make thrown potions use the correct appearence
This was caused by potions now using metadata.
* Add missing api doc for cSplashPotionEntity::GetItem
* Fix compile error in SplashPotionEntity.cpp
* Fix fix of cSplashPotionEntity API doc
* Temporarilly disable fall damage particles
These were causing issues in 1.9 due to the changed effect ID.
* Properly send a kick packet when connecting with an invalid version
This means that the client no longer waits on the server screen with no indication whatsoever. However, right now the server list ping isn't implemented for unknown versions, so it'll only load "Old" on the ping.
I also added a GetVarIntSize method to cByteBuffer. This helps clean up part of the code here (and I think it could clean up other parts), but it may make sense for it to be moved elsewhere (or declared in a different way).
* Handle server list pings from unrecognized versions
This isn't the cleanest way of writing it (it feels odd to use ProtocolRecognizer to send packets, and the addition of m_InPingForUnrecognizedVersion feels like the wrong technique), but it works and I can't think of a better way (apart from creating a full separate protocol class to handle only the ping... which would be worse).
* Use cPacketizer for the disconnect packet
This also should fix clang build errors.
* Add 1.9.3 / 1.9.4 support
* Fix incorrect indentation in APIDesc
2016-05-14 15:12:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-07-17 13:46:50 -04:00
|
|
|
void cMultiVersionProtocol::SendDisconnect(cClientHandle & a_Client, const AString & a_Reason)
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
2014-10-20 16:55:07 -04:00
|
|
|
if (m_Protocol != nullptr)
|
2014-09-27 17:13:37 -04:00
|
|
|
{
|
|
|
|
m_Protocol->SendDisconnect(a_Reason);
|
2020-07-17 13:46:50 -04:00
|
|
|
return;
|
2014-09-27 17:13:37 -04:00
|
|
|
}
|
2013-07-29 07:13:03 -04:00
|
|
|
|
2020-07-17 13:46:50 -04:00
|
|
|
const AString Message = Printf("{\"text\":\"%s\"}", EscapeString(a_Reason).c_str());
|
|
|
|
const auto PacketID = GetPacketID(cProtocol::ePacketType::pktDisconnectDuringLogin);
|
|
|
|
cByteBuffer Out(
|
|
|
|
cByteBuffer::GetVarIntSize(PacketID) +
|
|
|
|
cByteBuffer::GetVarIntSize(static_cast<UInt32>(Message.size())) + Message.size()
|
|
|
|
);
|
2013-07-29 07:13:03 -04:00
|
|
|
|
2020-07-17 13:46:50 -04:00
|
|
|
VERIFY(Out.WriteVarInt32(PacketID));
|
|
|
|
VERIFY(Out.WriteVarUTF8String(Message));
|
|
|
|
SendPacket(a_Client, Out);
|
2013-07-29 07:13:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-07-17 13:46:50 -04:00
|
|
|
void cMultiVersionProtocol::TryRecognizeProtocol(cClientHandle & a_Client, std::string_view & a_Data)
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
2020-07-17 13:46:50 -04:00
|
|
|
// NOTE: If a new protocol is added or an old one is removed, adjust MCS_CLIENT_VERSIONS and MCS_PROTOCOL_VERSIONS macros in the header file
|
2013-07-29 07:13:03 -04:00
|
|
|
|
2020-07-17 13:46:50 -04:00
|
|
|
// Lengthed protocol, try if it has the entire initial handshake packet:
|
|
|
|
UInt32 PacketLen;
|
|
|
|
if (!m_Buffer.ReadVarInt(PacketLen))
|
|
|
|
{
|
|
|
|
// Not enough bytes for the packet length, keep waiting
|
|
|
|
return;
|
|
|
|
}
|
2013-07-29 07:13:03 -04:00
|
|
|
|
2020-07-17 13:46:50 -04:00
|
|
|
if (!m_Buffer.CanReadBytes(PacketLen))
|
|
|
|
{
|
|
|
|
// Not enough bytes for the packet, keep waiting
|
|
|
|
// More of a sanity check to make sure no one tries anything funny (since ReadXXX can wait for data themselves):
|
|
|
|
return;
|
|
|
|
}
|
2013-07-29 07:13:03 -04:00
|
|
|
|
2020-07-17 13:46:50 -04:00
|
|
|
m_Protocol = TryRecognizeLengthedProtocol(a_Client, a_Data);
|
2014-10-20 16:55:07 -04:00
|
|
|
ASSERT(m_Protocol != nullptr);
|
2013-07-29 07:13:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-07-17 13:46:50 -04:00
|
|
|
std::unique_ptr<cProtocol> cMultiVersionProtocol::TryRecognizeLengthedProtocol(cClientHandle & a_Client, std::string_view & a_Data)
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
2020-07-17 13:46:50 -04:00
|
|
|
UInt32 PacketType;
|
|
|
|
UInt32 ProtocolVersion;
|
|
|
|
AString ServerAddress;
|
|
|
|
UInt16 ServerPort;
|
|
|
|
UInt32 NextState;
|
2013-07-29 07:13:03 -04:00
|
|
|
|
2020-07-17 13:46:50 -04:00
|
|
|
if (!m_Buffer.ReadVarInt(PacketType) || (PacketType != 0x00))
|
|
|
|
{
|
|
|
|
// Not an initial handshake packet, we don't know how to talk to them
|
|
|
|
LOGINFO("Client \"%s\" uses an unsupported protocol (lengthed, initial packet %u)",
|
|
|
|
a_Client.GetIPString().c_str(), PacketType
|
|
|
|
);
|
2013-07-29 07:13:03 -04:00
|
|
|
|
2020-07-17 13:46:50 -04:00
|
|
|
throw sTriedToJoinWithUnsupportedProtocolException(
|
|
|
|
Printf("Your client isn't supported.\nTry connecting with Minecraft " MCS_CLIENT_VERSIONS, ProtocolVersion)
|
|
|
|
);
|
|
|
|
}
|
2013-07-29 07:13:03 -04:00
|
|
|
|
2020-07-17 13:46:50 -04:00
|
|
|
if (
|
|
|
|
!m_Buffer.ReadVarInt(ProtocolVersion) ||
|
|
|
|
!m_Buffer.ReadVarUTF8String(ServerAddress) ||
|
|
|
|
!m_Buffer.ReadBEUInt16(ServerPort) ||
|
|
|
|
!m_Buffer.ReadVarInt(NextState)
|
|
|
|
)
|
|
|
|
{
|
|
|
|
// TryRecognizeProtocol guarantees that we will have as much
|
|
|
|
// data to read as the client claims in the protocol length field:
|
|
|
|
throw sTriedToJoinWithUnsupportedProtocolException("Incorrect amount of data received - hacked client?");
|
|
|
|
}
|
2013-07-29 07:13:03 -04:00
|
|
|
|
2020-07-17 13:46:50 -04:00
|
|
|
// TODO: this should be a protocol property, not ClientHandle:
|
|
|
|
a_Client.SetProtocolVersion(ProtocolVersion);
|
2013-07-29 07:13:03 -04:00
|
|
|
|
2020-07-17 13:46:50 -04:00
|
|
|
// The protocol has just been recognized, advance data start
|
|
|
|
// to after the handshake and leave the rest to the protocol:
|
|
|
|
a_Data = a_Data.substr(m_Buffer.GetUsedSpace() - m_Buffer.GetReadableSpace());
|
2013-07-29 07:13:03 -04:00
|
|
|
|
2020-07-17 13:46:50 -04:00
|
|
|
// We read more than we can handle, purge the rest:
|
|
|
|
[[maybe_unused]] const bool Success =
|
|
|
|
m_Buffer.SkipRead(m_Buffer.GetReadableSpace());
|
|
|
|
ASSERT(Success);
|
2013-07-29 07:13:03 -04:00
|
|
|
|
2020-07-17 13:46:50 -04:00
|
|
|
// All good, eat up the data:
|
|
|
|
m_Buffer.CommitRead();
|
2013-07-29 07:13:03 -04:00
|
|
|
|
2020-07-17 13:46:50 -04:00
|
|
|
switch (ProtocolVersion)
|
|
|
|
{
|
|
|
|
case PROTO_VERSION_1_8_0: return std::make_unique<cProtocol_1_8_0>(&a_Client, ServerAddress, ServerPort, NextState);
|
|
|
|
case PROTO_VERSION_1_9_0: return std::make_unique<cProtocol_1_9_0>(&a_Client, ServerAddress, ServerPort, NextState);
|
|
|
|
case PROTO_VERSION_1_9_1: return std::make_unique<cProtocol_1_9_1>(&a_Client, ServerAddress, ServerPort, NextState);
|
|
|
|
case PROTO_VERSION_1_9_2: return std::make_unique<cProtocol_1_9_2>(&a_Client, ServerAddress, ServerPort, NextState);
|
|
|
|
case PROTO_VERSION_1_9_4: return std::make_unique<cProtocol_1_9_4>(&a_Client, ServerAddress, ServerPort, NextState);
|
|
|
|
case PROTO_VERSION_1_10_0: return std::make_unique<cProtocol_1_10_0>(&a_Client, ServerAddress, ServerPort, NextState);
|
|
|
|
case PROTO_VERSION_1_11_0: return std::make_unique<cProtocol_1_11_0>(&a_Client, ServerAddress, ServerPort, NextState);
|
|
|
|
case PROTO_VERSION_1_11_1: return std::make_unique<cProtocol_1_11_1>(&a_Client, ServerAddress, ServerPort, NextState);
|
|
|
|
case PROTO_VERSION_1_12: return std::make_unique<cProtocol_1_12>(&a_Client, ServerAddress, ServerPort, NextState);
|
|
|
|
case PROTO_VERSION_1_12_1: return std::make_unique<cProtocol_1_12_1>(&a_Client, ServerAddress, ServerPort, NextState);
|
|
|
|
case PROTO_VERSION_1_12_2: return std::make_unique<cProtocol_1_12_2>(&a_Client, ServerAddress, ServerPort, NextState);
|
|
|
|
case PROTO_VERSION_1_13: return std::make_unique<cProtocol_1_13>(&a_Client, ServerAddress, ServerPort, NextState);
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
LOGD("Client \"%s\" uses an unsupported protocol (lengthed, version %u (0x%x))",
|
|
|
|
a_Client.GetIPString().c_str(), ProtocolVersion, ProtocolVersion
|
|
|
|
);
|
2013-07-29 07:13:03 -04:00
|
|
|
|
2020-07-17 13:46:50 -04:00
|
|
|
if (NextState != 1)
|
|
|
|
{
|
|
|
|
throw sTriedToJoinWithUnsupportedProtocolException(
|
|
|
|
Printf("Unsupported protocol version %u.\nTry connecting with Minecraft " MCS_CLIENT_VERSIONS, ProtocolVersion)
|
|
|
|
);
|
|
|
|
}
|
2013-07-29 07:13:03 -04:00
|
|
|
|
2020-07-17 13:46:50 -04:00
|
|
|
throw sUnsupportedButPingableProtocolException();
|
2014-09-03 18:29:36 -04:00
|
|
|
}
|
2013-10-30 18:24:46 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1.9 / 1.9.2 / 1.9.3 / 1.9.4 protocol support (#3135)
* Semistable update to 15w31a
I'm going through snapshots in a sequential order since it should make things easier, and since protocol version history is written.
* Update to 15w34b protocol
Also, fix an issue with the Entity Equipment packet from the past version. Clients are able to connect and do stuff!
* Partially update to 15w35e
Chunk data doesn't work, but the client joins. I'm waiting to do chunk data because chunk data has an incomplete format until 15w36d.
* Add '/blk' debug command
This command lets one see what block they are looking at, and makes figuring out what's supposed to be where in a highly broken chunk possible.
* Fix CRLF normalization in CheckBasicStyle.lua
Normally, this doesn't cause an issue, but when running from cygwin, it detects the CR as whitespace and creates thousands of violations for every single line. Lua, when run on windows, will normalize automatically, but when run via cygwin, it won't.
The bug was simply that gsub was returning a replaced version, but not changing the parameter, so the replaced version was ignored.
* Update to 15w40b
This includes chunk serialization. Fully functional chunk serialization for 1.9.
I'm not completely happy with the chunk serialization as-is (correct use of palettes would be great), but cuberite also doesn't skip sending empty chunks so this performance optimization should probably come later. The creation of a full buffer is suboptimal, but it's the easiest way to implement this code.
* Write long-by-long rather than creating a buffer
This is a bit faster and should be equivalent. However, the code still doesn't look too good.
* Update to 15w41a protocol
This includes the new set passengers packet, which works off of the ridden entity, not the rider. That means, among other things, that information about the previously ridden vehicle is needed when detaching. So a new method with that info was added.
* Update to 15w45a
* 15w51b protocol
* Update to 1.9.0 protocol
Closes #3067. There are still a few things that need to be worked out (picking up items, effects, particles, and most importantly inventory), but in general this should work. I'll make a few more changes tomorrow to get the rest of the protocol set up, along with 1.9.1/1.9.2 (which did make a few changes). Chunks, however, _are_ working, along with most other parts of the game (placing/breaking blocks).
* Fix item pickup packet not working
That was a silly mistake, but at least it was an easy one.
* 1.9.2 protocol support
* Fix version info found in server list ping
Thus, the client reports that it can connect rather than saying that the server is out of date. This required creating separate classes for 1.9.1 and 1.9.2, unfortunately.
* Fix build errors generated by clang
These didn't happen in MSVC.
* Add protocol19x.cpp and protocol19x.h to CMakeLists
* Ignore warnings in protocol19x that are ignored in protocol18x
* Document BLOCK_FACE and DIG_STATUS constants
* Fix BLOCK_FACE links and add separate section for DIG_STATUS
* Fix bat animation and object spawning
The causes of both of these are explained in #3135, but the gist is that both were typos.
* Implement Use Item packet
This means that buckets, bows, fishing rods, and several other similar items now work when not looking at a block.
* Handle DIG_STATUS_SWAP_ITEM_IN_HAND
* Add support for spawn eggs and potions
The items are transformed from the 1.9 version to the 1.8 version when reading and transformed back when sending.
* Remove spammy potion debug logging
* Fix wolf collar color metadata
The wrong type was being used, causing several clientside issues (including the screen going black).
* Fix 1.9 chunk sending in the nether
The nether and the end don't send skylight.
* Fix clang build errors
* Fix water bottles becoming mundane potions
This happened because the can become splash potion bit got set incorrectly. Water bottles and mundane potions are only differentiated by the fact that water bottles have a metadata of 0, so setting that bit made it a mundane potion.
Also add missing break statements to the read item NBT switch, which would otherwise break items with custom names and also cause incorrect "Unimplemented NBT data when parsing!" logging.
* Copy Protocol18x as Protocol19x
Aditionally, method and class names have been swapped to clean up other diffs. This commit is only added to make the following diffs more readable; it doesn't make any other changes (beyond class names).
* Make thrown potions use the correct appearence
This was caused by potions now using metadata.
* Add missing api doc for cSplashPotionEntity::GetItem
* Fix compile error in SplashPotionEntity.cpp
* Fix fix of cSplashPotionEntity API doc
* Temporarilly disable fall damage particles
These were causing issues in 1.9 due to the changed effect ID.
* Properly send a kick packet when connecting with an invalid version
This means that the client no longer waits on the server screen with no indication whatsoever. However, right now the server list ping isn't implemented for unknown versions, so it'll only load "Old" on the ping.
I also added a GetVarIntSize method to cByteBuffer. This helps clean up part of the code here (and I think it could clean up other parts), but it may make sense for it to be moved elsewhere (or declared in a different way).
* Handle server list pings from unrecognized versions
This isn't the cleanest way of writing it (it feels odd to use ProtocolRecognizer to send packets, and the addition of m_InPingForUnrecognizedVersion feels like the wrong technique), but it works and I can't think of a better way (apart from creating a full separate protocol class to handle only the ping... which would be worse).
* Use cPacketizer for the disconnect packet
This also should fix clang build errors.
* Add 1.9.3 / 1.9.4 support
* Fix incorrect indentation in APIDesc
2016-05-14 15:12:42 -04:00
|
|
|
|
2020-07-17 13:46:50 -04:00
|
|
|
void cMultiVersionProtocol::SendPacket(cClientHandle & a_Client, cByteBuffer & a_OutPacketBuffer)
|
2015-03-22 14:46:08 -04:00
|
|
|
{
|
1.9 / 1.9.2 / 1.9.3 / 1.9.4 protocol support (#3135)
* Semistable update to 15w31a
I'm going through snapshots in a sequential order since it should make things easier, and since protocol version history is written.
* Update to 15w34b protocol
Also, fix an issue with the Entity Equipment packet from the past version. Clients are able to connect and do stuff!
* Partially update to 15w35e
Chunk data doesn't work, but the client joins. I'm waiting to do chunk data because chunk data has an incomplete format until 15w36d.
* Add '/blk' debug command
This command lets one see what block they are looking at, and makes figuring out what's supposed to be where in a highly broken chunk possible.
* Fix CRLF normalization in CheckBasicStyle.lua
Normally, this doesn't cause an issue, but when running from cygwin, it detects the CR as whitespace and creates thousands of violations for every single line. Lua, when run on windows, will normalize automatically, but when run via cygwin, it won't.
The bug was simply that gsub was returning a replaced version, but not changing the parameter, so the replaced version was ignored.
* Update to 15w40b
This includes chunk serialization. Fully functional chunk serialization for 1.9.
I'm not completely happy with the chunk serialization as-is (correct use of palettes would be great), but cuberite also doesn't skip sending empty chunks so this performance optimization should probably come later. The creation of a full buffer is suboptimal, but it's the easiest way to implement this code.
* Write long-by-long rather than creating a buffer
This is a bit faster and should be equivalent. However, the code still doesn't look too good.
* Update to 15w41a protocol
This includes the new set passengers packet, which works off of the ridden entity, not the rider. That means, among other things, that information about the previously ridden vehicle is needed when detaching. So a new method with that info was added.
* Update to 15w45a
* 15w51b protocol
* Update to 1.9.0 protocol
Closes #3067. There are still a few things that need to be worked out (picking up items, effects, particles, and most importantly inventory), but in general this should work. I'll make a few more changes tomorrow to get the rest of the protocol set up, along with 1.9.1/1.9.2 (which did make a few changes). Chunks, however, _are_ working, along with most other parts of the game (placing/breaking blocks).
* Fix item pickup packet not working
That was a silly mistake, but at least it was an easy one.
* 1.9.2 protocol support
* Fix version info found in server list ping
Thus, the client reports that it can connect rather than saying that the server is out of date. This required creating separate classes for 1.9.1 and 1.9.2, unfortunately.
* Fix build errors generated by clang
These didn't happen in MSVC.
* Add protocol19x.cpp and protocol19x.h to CMakeLists
* Ignore warnings in protocol19x that are ignored in protocol18x
* Document BLOCK_FACE and DIG_STATUS constants
* Fix BLOCK_FACE links and add separate section for DIG_STATUS
* Fix bat animation and object spawning
The causes of both of these are explained in #3135, but the gist is that both were typos.
* Implement Use Item packet
This means that buckets, bows, fishing rods, and several other similar items now work when not looking at a block.
* Handle DIG_STATUS_SWAP_ITEM_IN_HAND
* Add support for spawn eggs and potions
The items are transformed from the 1.9 version to the 1.8 version when reading and transformed back when sending.
* Remove spammy potion debug logging
* Fix wolf collar color metadata
The wrong type was being used, causing several clientside issues (including the screen going black).
* Fix 1.9 chunk sending in the nether
The nether and the end don't send skylight.
* Fix clang build errors
* Fix water bottles becoming mundane potions
This happened because the can become splash potion bit got set incorrectly. Water bottles and mundane potions are only differentiated by the fact that water bottles have a metadata of 0, so setting that bit made it a mundane potion.
Also add missing break statements to the read item NBT switch, which would otherwise break items with custom names and also cause incorrect "Unimplemented NBT data when parsing!" logging.
* Copy Protocol18x as Protocol19x
Aditionally, method and class names have been swapped to clean up other diffs. This commit is only added to make the following diffs more readable; it doesn't make any other changes (beyond class names).
* Make thrown potions use the correct appearence
This was caused by potions now using metadata.
* Add missing api doc for cSplashPotionEntity::GetItem
* Fix compile error in SplashPotionEntity.cpp
* Fix fix of cSplashPotionEntity API doc
* Temporarilly disable fall damage particles
These were causing issues in 1.9 due to the changed effect ID.
* Properly send a kick packet when connecting with an invalid version
This means that the client no longer waits on the server screen with no indication whatsoever. However, right now the server list ping isn't implemented for unknown versions, so it'll only load "Old" on the ping.
I also added a GetVarIntSize method to cByteBuffer. This helps clean up part of the code here (and I think it could clean up other parts), but it may make sense for it to be moved elsewhere (or declared in a different way).
* Handle server list pings from unrecognized versions
This isn't the cleanest way of writing it (it feels odd to use ProtocolRecognizer to send packets, and the addition of m_InPingForUnrecognizedVersion feels like the wrong technique), but it works and I can't think of a better way (apart from creating a full separate protocol class to handle only the ping... which would be worse).
* Use cPacketizer for the disconnect packet
This also should fix clang build errors.
* Add 1.9.3 / 1.9.4 support
* Fix incorrect indentation in APIDesc
2016-05-14 15:12:42 -04:00
|
|
|
// Writes out the packet normally.
|
2020-07-17 13:46:50 -04:00
|
|
|
UInt32 PacketLen = static_cast<UInt32>(a_OutPacketBuffer.GetUsedSpace());
|
|
|
|
cByteBuffer OutPacketLenBuffer(cByteBuffer::GetVarIntSize(PacketLen));
|
1.9 / 1.9.2 / 1.9.3 / 1.9.4 protocol support (#3135)
* Semistable update to 15w31a
I'm going through snapshots in a sequential order since it should make things easier, and since protocol version history is written.
* Update to 15w34b protocol
Also, fix an issue with the Entity Equipment packet from the past version. Clients are able to connect and do stuff!
* Partially update to 15w35e
Chunk data doesn't work, but the client joins. I'm waiting to do chunk data because chunk data has an incomplete format until 15w36d.
* Add '/blk' debug command
This command lets one see what block they are looking at, and makes figuring out what's supposed to be where in a highly broken chunk possible.
* Fix CRLF normalization in CheckBasicStyle.lua
Normally, this doesn't cause an issue, but when running from cygwin, it detects the CR as whitespace and creates thousands of violations for every single line. Lua, when run on windows, will normalize automatically, but when run via cygwin, it won't.
The bug was simply that gsub was returning a replaced version, but not changing the parameter, so the replaced version was ignored.
* Update to 15w40b
This includes chunk serialization. Fully functional chunk serialization for 1.9.
I'm not completely happy with the chunk serialization as-is (correct use of palettes would be great), but cuberite also doesn't skip sending empty chunks so this performance optimization should probably come later. The creation of a full buffer is suboptimal, but it's the easiest way to implement this code.
* Write long-by-long rather than creating a buffer
This is a bit faster and should be equivalent. However, the code still doesn't look too good.
* Update to 15w41a protocol
This includes the new set passengers packet, which works off of the ridden entity, not the rider. That means, among other things, that information about the previously ridden vehicle is needed when detaching. So a new method with that info was added.
* Update to 15w45a
* 15w51b protocol
* Update to 1.9.0 protocol
Closes #3067. There are still a few things that need to be worked out (picking up items, effects, particles, and most importantly inventory), but in general this should work. I'll make a few more changes tomorrow to get the rest of the protocol set up, along with 1.9.1/1.9.2 (which did make a few changes). Chunks, however, _are_ working, along with most other parts of the game (placing/breaking blocks).
* Fix item pickup packet not working
That was a silly mistake, but at least it was an easy one.
* 1.9.2 protocol support
* Fix version info found in server list ping
Thus, the client reports that it can connect rather than saying that the server is out of date. This required creating separate classes for 1.9.1 and 1.9.2, unfortunately.
* Fix build errors generated by clang
These didn't happen in MSVC.
* Add protocol19x.cpp and protocol19x.h to CMakeLists
* Ignore warnings in protocol19x that are ignored in protocol18x
* Document BLOCK_FACE and DIG_STATUS constants
* Fix BLOCK_FACE links and add separate section for DIG_STATUS
* Fix bat animation and object spawning
The causes of both of these are explained in #3135, but the gist is that both were typos.
* Implement Use Item packet
This means that buckets, bows, fishing rods, and several other similar items now work when not looking at a block.
* Handle DIG_STATUS_SWAP_ITEM_IN_HAND
* Add support for spawn eggs and potions
The items are transformed from the 1.9 version to the 1.8 version when reading and transformed back when sending.
* Remove spammy potion debug logging
* Fix wolf collar color metadata
The wrong type was being used, causing several clientside issues (including the screen going black).
* Fix 1.9 chunk sending in the nether
The nether and the end don't send skylight.
* Fix clang build errors
* Fix water bottles becoming mundane potions
This happened because the can become splash potion bit got set incorrectly. Water bottles and mundane potions are only differentiated by the fact that water bottles have a metadata of 0, so setting that bit made it a mundane potion.
Also add missing break statements to the read item NBT switch, which would otherwise break items with custom names and also cause incorrect "Unimplemented NBT data when parsing!" logging.
* Copy Protocol18x as Protocol19x
Aditionally, method and class names have been swapped to clean up other diffs. This commit is only added to make the following diffs more readable; it doesn't make any other changes (beyond class names).
* Make thrown potions use the correct appearence
This was caused by potions now using metadata.
* Add missing api doc for cSplashPotionEntity::GetItem
* Fix compile error in SplashPotionEntity.cpp
* Fix fix of cSplashPotionEntity API doc
* Temporarilly disable fall damage particles
These were causing issues in 1.9 due to the changed effect ID.
* Properly send a kick packet when connecting with an invalid version
This means that the client no longer waits on the server screen with no indication whatsoever. However, right now the server list ping isn't implemented for unknown versions, so it'll only load "Old" on the ping.
I also added a GetVarIntSize method to cByteBuffer. This helps clean up part of the code here (and I think it could clean up other parts), but it may make sense for it to be moved elsewhere (or declared in a different way).
* Handle server list pings from unrecognized versions
This isn't the cleanest way of writing it (it feels odd to use ProtocolRecognizer to send packets, and the addition of m_InPingForUnrecognizedVersion feels like the wrong technique), but it works and I can't think of a better way (apart from creating a full separate protocol class to handle only the ping... which would be worse).
* Use cPacketizer for the disconnect packet
This also should fix clang build errors.
* Add 1.9.3 / 1.9.4 support
* Fix incorrect indentation in APIDesc
2016-05-14 15:12:42 -04:00
|
|
|
|
|
|
|
// Compression doesn't apply to this state, send raw data:
|
2020-07-17 13:46:50 -04:00
|
|
|
VERIFY(OutPacketLenBuffer.WriteVarInt32(PacketLen));
|
1.9 / 1.9.2 / 1.9.3 / 1.9.4 protocol support (#3135)
* Semistable update to 15w31a
I'm going through snapshots in a sequential order since it should make things easier, and since protocol version history is written.
* Update to 15w34b protocol
Also, fix an issue with the Entity Equipment packet from the past version. Clients are able to connect and do stuff!
* Partially update to 15w35e
Chunk data doesn't work, but the client joins. I'm waiting to do chunk data because chunk data has an incomplete format until 15w36d.
* Add '/blk' debug command
This command lets one see what block they are looking at, and makes figuring out what's supposed to be where in a highly broken chunk possible.
* Fix CRLF normalization in CheckBasicStyle.lua
Normally, this doesn't cause an issue, but when running from cygwin, it detects the CR as whitespace and creates thousands of violations for every single line. Lua, when run on windows, will normalize automatically, but when run via cygwin, it won't.
The bug was simply that gsub was returning a replaced version, but not changing the parameter, so the replaced version was ignored.
* Update to 15w40b
This includes chunk serialization. Fully functional chunk serialization for 1.9.
I'm not completely happy with the chunk serialization as-is (correct use of palettes would be great), but cuberite also doesn't skip sending empty chunks so this performance optimization should probably come later. The creation of a full buffer is suboptimal, but it's the easiest way to implement this code.
* Write long-by-long rather than creating a buffer
This is a bit faster and should be equivalent. However, the code still doesn't look too good.
* Update to 15w41a protocol
This includes the new set passengers packet, which works off of the ridden entity, not the rider. That means, among other things, that information about the previously ridden vehicle is needed when detaching. So a new method with that info was added.
* Update to 15w45a
* 15w51b protocol
* Update to 1.9.0 protocol
Closes #3067. There are still a few things that need to be worked out (picking up items, effects, particles, and most importantly inventory), but in general this should work. I'll make a few more changes tomorrow to get the rest of the protocol set up, along with 1.9.1/1.9.2 (which did make a few changes). Chunks, however, _are_ working, along with most other parts of the game (placing/breaking blocks).
* Fix item pickup packet not working
That was a silly mistake, but at least it was an easy one.
* 1.9.2 protocol support
* Fix version info found in server list ping
Thus, the client reports that it can connect rather than saying that the server is out of date. This required creating separate classes for 1.9.1 and 1.9.2, unfortunately.
* Fix build errors generated by clang
These didn't happen in MSVC.
* Add protocol19x.cpp and protocol19x.h to CMakeLists
* Ignore warnings in protocol19x that are ignored in protocol18x
* Document BLOCK_FACE and DIG_STATUS constants
* Fix BLOCK_FACE links and add separate section for DIG_STATUS
* Fix bat animation and object spawning
The causes of both of these are explained in #3135, but the gist is that both were typos.
* Implement Use Item packet
This means that buckets, bows, fishing rods, and several other similar items now work when not looking at a block.
* Handle DIG_STATUS_SWAP_ITEM_IN_HAND
* Add support for spawn eggs and potions
The items are transformed from the 1.9 version to the 1.8 version when reading and transformed back when sending.
* Remove spammy potion debug logging
* Fix wolf collar color metadata
The wrong type was being used, causing several clientside issues (including the screen going black).
* Fix 1.9 chunk sending in the nether
The nether and the end don't send skylight.
* Fix clang build errors
* Fix water bottles becoming mundane potions
This happened because the can become splash potion bit got set incorrectly. Water bottles and mundane potions are only differentiated by the fact that water bottles have a metadata of 0, so setting that bit made it a mundane potion.
Also add missing break statements to the read item NBT switch, which would otherwise break items with custom names and also cause incorrect "Unimplemented NBT data when parsing!" logging.
* Copy Protocol18x as Protocol19x
Aditionally, method and class names have been swapped to clean up other diffs. This commit is only added to make the following diffs more readable; it doesn't make any other changes (beyond class names).
* Make thrown potions use the correct appearence
This was caused by potions now using metadata.
* Add missing api doc for cSplashPotionEntity::GetItem
* Fix compile error in SplashPotionEntity.cpp
* Fix fix of cSplashPotionEntity API doc
* Temporarilly disable fall damage particles
These were causing issues in 1.9 due to the changed effect ID.
* Properly send a kick packet when connecting with an invalid version
This means that the client no longer waits on the server screen with no indication whatsoever. However, right now the server list ping isn't implemented for unknown versions, so it'll only load "Old" on the ping.
I also added a GetVarIntSize method to cByteBuffer. This helps clean up part of the code here (and I think it could clean up other parts), but it may make sense for it to be moved elsewhere (or declared in a different way).
* Handle server list pings from unrecognized versions
This isn't the cleanest way of writing it (it feels odd to use ProtocolRecognizer to send packets, and the addition of m_InPingForUnrecognizedVersion feels like the wrong technique), but it works and I can't think of a better way (apart from creating a full separate protocol class to handle only the ping... which would be worse).
* Use cPacketizer for the disconnect packet
This also should fix clang build errors.
* Add 1.9.3 / 1.9.4 support
* Fix incorrect indentation in APIDesc
2016-05-14 15:12:42 -04:00
|
|
|
AString LengthData;
|
2020-07-17 13:46:50 -04:00
|
|
|
OutPacketLenBuffer.ReadAll(LengthData);
|
|
|
|
a_Client.SendData(LengthData.data(), LengthData.size());
|
1.9 / 1.9.2 / 1.9.3 / 1.9.4 protocol support (#3135)
* Semistable update to 15w31a
I'm going through snapshots in a sequential order since it should make things easier, and since protocol version history is written.
* Update to 15w34b protocol
Also, fix an issue with the Entity Equipment packet from the past version. Clients are able to connect and do stuff!
* Partially update to 15w35e
Chunk data doesn't work, but the client joins. I'm waiting to do chunk data because chunk data has an incomplete format until 15w36d.
* Add '/blk' debug command
This command lets one see what block they are looking at, and makes figuring out what's supposed to be where in a highly broken chunk possible.
* Fix CRLF normalization in CheckBasicStyle.lua
Normally, this doesn't cause an issue, but when running from cygwin, it detects the CR as whitespace and creates thousands of violations for every single line. Lua, when run on windows, will normalize automatically, but when run via cygwin, it won't.
The bug was simply that gsub was returning a replaced version, but not changing the parameter, so the replaced version was ignored.
* Update to 15w40b
This includes chunk serialization. Fully functional chunk serialization for 1.9.
I'm not completely happy with the chunk serialization as-is (correct use of palettes would be great), but cuberite also doesn't skip sending empty chunks so this performance optimization should probably come later. The creation of a full buffer is suboptimal, but it's the easiest way to implement this code.
* Write long-by-long rather than creating a buffer
This is a bit faster and should be equivalent. However, the code still doesn't look too good.
* Update to 15w41a protocol
This includes the new set passengers packet, which works off of the ridden entity, not the rider. That means, among other things, that information about the previously ridden vehicle is needed when detaching. So a new method with that info was added.
* Update to 15w45a
* 15w51b protocol
* Update to 1.9.0 protocol
Closes #3067. There are still a few things that need to be worked out (picking up items, effects, particles, and most importantly inventory), but in general this should work. I'll make a few more changes tomorrow to get the rest of the protocol set up, along with 1.9.1/1.9.2 (which did make a few changes). Chunks, however, _are_ working, along with most other parts of the game (placing/breaking blocks).
* Fix item pickup packet not working
That was a silly mistake, but at least it was an easy one.
* 1.9.2 protocol support
* Fix version info found in server list ping
Thus, the client reports that it can connect rather than saying that the server is out of date. This required creating separate classes for 1.9.1 and 1.9.2, unfortunately.
* Fix build errors generated by clang
These didn't happen in MSVC.
* Add protocol19x.cpp and protocol19x.h to CMakeLists
* Ignore warnings in protocol19x that are ignored in protocol18x
* Document BLOCK_FACE and DIG_STATUS constants
* Fix BLOCK_FACE links and add separate section for DIG_STATUS
* Fix bat animation and object spawning
The causes of both of these are explained in #3135, but the gist is that both were typos.
* Implement Use Item packet
This means that buckets, bows, fishing rods, and several other similar items now work when not looking at a block.
* Handle DIG_STATUS_SWAP_ITEM_IN_HAND
* Add support for spawn eggs and potions
The items are transformed from the 1.9 version to the 1.8 version when reading and transformed back when sending.
* Remove spammy potion debug logging
* Fix wolf collar color metadata
The wrong type was being used, causing several clientside issues (including the screen going black).
* Fix 1.9 chunk sending in the nether
The nether and the end don't send skylight.
* Fix clang build errors
* Fix water bottles becoming mundane potions
This happened because the can become splash potion bit got set incorrectly. Water bottles and mundane potions are only differentiated by the fact that water bottles have a metadata of 0, so setting that bit made it a mundane potion.
Also add missing break statements to the read item NBT switch, which would otherwise break items with custom names and also cause incorrect "Unimplemented NBT data when parsing!" logging.
* Copy Protocol18x as Protocol19x
Aditionally, method and class names have been swapped to clean up other diffs. This commit is only added to make the following diffs more readable; it doesn't make any other changes (beyond class names).
* Make thrown potions use the correct appearence
This was caused by potions now using metadata.
* Add missing api doc for cSplashPotionEntity::GetItem
* Fix compile error in SplashPotionEntity.cpp
* Fix fix of cSplashPotionEntity API doc
* Temporarilly disable fall damage particles
These were causing issues in 1.9 due to the changed effect ID.
* Properly send a kick packet when connecting with an invalid version
This means that the client no longer waits on the server screen with no indication whatsoever. However, right now the server list ping isn't implemented for unknown versions, so it'll only load "Old" on the ping.
I also added a GetVarIntSize method to cByteBuffer. This helps clean up part of the code here (and I think it could clean up other parts), but it may make sense for it to be moved elsewhere (or declared in a different way).
* Handle server list pings from unrecognized versions
This isn't the cleanest way of writing it (it feels odd to use ProtocolRecognizer to send packets, and the addition of m_InPingForUnrecognizedVersion feels like the wrong technique), but it works and I can't think of a better way (apart from creating a full separate protocol class to handle only the ping... which would be worse).
* Use cPacketizer for the disconnect packet
This also should fix clang build errors.
* Add 1.9.3 / 1.9.4 support
* Fix incorrect indentation in APIDesc
2016-05-14 15:12:42 -04:00
|
|
|
|
2020-07-17 13:46:50 -04:00
|
|
|
// Send the packet's payload:
|
|
|
|
AString PacketData;
|
|
|
|
a_OutPacketBuffer.ReadAll(PacketData);
|
|
|
|
a_OutPacketBuffer.CommitRead();
|
|
|
|
a_Client.SendData(PacketData.data(), PacketData.size());
|
1.9 / 1.9.2 / 1.9.3 / 1.9.4 protocol support (#3135)
* Semistable update to 15w31a
I'm going through snapshots in a sequential order since it should make things easier, and since protocol version history is written.
* Update to 15w34b protocol
Also, fix an issue with the Entity Equipment packet from the past version. Clients are able to connect and do stuff!
* Partially update to 15w35e
Chunk data doesn't work, but the client joins. I'm waiting to do chunk data because chunk data has an incomplete format until 15w36d.
* Add '/blk' debug command
This command lets one see what block they are looking at, and makes figuring out what's supposed to be where in a highly broken chunk possible.
* Fix CRLF normalization in CheckBasicStyle.lua
Normally, this doesn't cause an issue, but when running from cygwin, it detects the CR as whitespace and creates thousands of violations for every single line. Lua, when run on windows, will normalize automatically, but when run via cygwin, it won't.
The bug was simply that gsub was returning a replaced version, but not changing the parameter, so the replaced version was ignored.
* Update to 15w40b
This includes chunk serialization. Fully functional chunk serialization for 1.9.
I'm not completely happy with the chunk serialization as-is (correct use of palettes would be great), but cuberite also doesn't skip sending empty chunks so this performance optimization should probably come later. The creation of a full buffer is suboptimal, but it's the easiest way to implement this code.
* Write long-by-long rather than creating a buffer
This is a bit faster and should be equivalent. However, the code still doesn't look too good.
* Update to 15w41a protocol
This includes the new set passengers packet, which works off of the ridden entity, not the rider. That means, among other things, that information about the previously ridden vehicle is needed when detaching. So a new method with that info was added.
* Update to 15w45a
* 15w51b protocol
* Update to 1.9.0 protocol
Closes #3067. There are still a few things that need to be worked out (picking up items, effects, particles, and most importantly inventory), but in general this should work. I'll make a few more changes tomorrow to get the rest of the protocol set up, along with 1.9.1/1.9.2 (which did make a few changes). Chunks, however, _are_ working, along with most other parts of the game (placing/breaking blocks).
* Fix item pickup packet not working
That was a silly mistake, but at least it was an easy one.
* 1.9.2 protocol support
* Fix version info found in server list ping
Thus, the client reports that it can connect rather than saying that the server is out of date. This required creating separate classes for 1.9.1 and 1.9.2, unfortunately.
* Fix build errors generated by clang
These didn't happen in MSVC.
* Add protocol19x.cpp and protocol19x.h to CMakeLists
* Ignore warnings in protocol19x that are ignored in protocol18x
* Document BLOCK_FACE and DIG_STATUS constants
* Fix BLOCK_FACE links and add separate section for DIG_STATUS
* Fix bat animation and object spawning
The causes of both of these are explained in #3135, but the gist is that both were typos.
* Implement Use Item packet
This means that buckets, bows, fishing rods, and several other similar items now work when not looking at a block.
* Handle DIG_STATUS_SWAP_ITEM_IN_HAND
* Add support for spawn eggs and potions
The items are transformed from the 1.9 version to the 1.8 version when reading and transformed back when sending.
* Remove spammy potion debug logging
* Fix wolf collar color metadata
The wrong type was being used, causing several clientside issues (including the screen going black).
* Fix 1.9 chunk sending in the nether
The nether and the end don't send skylight.
* Fix clang build errors
* Fix water bottles becoming mundane potions
This happened because the can become splash potion bit got set incorrectly. Water bottles and mundane potions are only differentiated by the fact that water bottles have a metadata of 0, so setting that bit made it a mundane potion.
Also add missing break statements to the read item NBT switch, which would otherwise break items with custom names and also cause incorrect "Unimplemented NBT data when parsing!" logging.
* Copy Protocol18x as Protocol19x
Aditionally, method and class names have been swapped to clean up other diffs. This commit is only added to make the following diffs more readable; it doesn't make any other changes (beyond class names).
* Make thrown potions use the correct appearence
This was caused by potions now using metadata.
* Add missing api doc for cSplashPotionEntity::GetItem
* Fix compile error in SplashPotionEntity.cpp
* Fix fix of cSplashPotionEntity API doc
* Temporarilly disable fall damage particles
These were causing issues in 1.9 due to the changed effect ID.
* Properly send a kick packet when connecting with an invalid version
This means that the client no longer waits on the server screen with no indication whatsoever. However, right now the server list ping isn't implemented for unknown versions, so it'll only load "Old" on the ping.
I also added a GetVarIntSize method to cByteBuffer. This helps clean up part of the code here (and I think it could clean up other parts), but it may make sense for it to be moved elsewhere (or declared in a different way).
* Handle server list pings from unrecognized versions
This isn't the cleanest way of writing it (it feels odd to use ProtocolRecognizer to send packets, and the addition of m_InPingForUnrecognizedVersion feels like the wrong technique), but it works and I can't think of a better way (apart from creating a full separate protocol class to handle only the ping... which would be worse).
* Use cPacketizer for the disconnect packet
This also should fix clang build errors.
* Add 1.9.3 / 1.9.4 support
* Fix incorrect indentation in APIDesc
2016-05-14 15:12:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-07-17 13:46:50 -04:00
|
|
|
UInt32 cMultiVersionProtocol::GetPacketID(cProtocol::ePacketType a_PacketType)
|
2019-09-09 12:22:37 -04:00
|
|
|
{
|
|
|
|
switch (a_PacketType)
|
|
|
|
{
|
2020-07-17 13:46:50 -04:00
|
|
|
case cProtocol::ePacketType::pktDisconnectDuringLogin: return 0x00;
|
|
|
|
case cProtocol::ePacketType::pktStatusResponse: return 0x00;
|
|
|
|
case cProtocol::ePacketType::pktPingResponse: return 0x01;
|
2019-09-09 12:22:37 -04:00
|
|
|
default:
|
|
|
|
{
|
2020-07-17 13:46:50 -04:00
|
|
|
ASSERT(!"GetPacketID() called for an unhandled packet");
|
2019-09-09 12:22:37 -04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-07-17 13:46:50 -04:00
|
|
|
void cMultiVersionProtocol::HandlePacketStatusRequest(cClientHandle & a_Client, cByteBuffer & a_Out)
|
1.9 / 1.9.2 / 1.9.3 / 1.9.4 protocol support (#3135)
* Semistable update to 15w31a
I'm going through snapshots in a sequential order since it should make things easier, and since protocol version history is written.
* Update to 15w34b protocol
Also, fix an issue with the Entity Equipment packet from the past version. Clients are able to connect and do stuff!
* Partially update to 15w35e
Chunk data doesn't work, but the client joins. I'm waiting to do chunk data because chunk data has an incomplete format until 15w36d.
* Add '/blk' debug command
This command lets one see what block they are looking at, and makes figuring out what's supposed to be where in a highly broken chunk possible.
* Fix CRLF normalization in CheckBasicStyle.lua
Normally, this doesn't cause an issue, but when running from cygwin, it detects the CR as whitespace and creates thousands of violations for every single line. Lua, when run on windows, will normalize automatically, but when run via cygwin, it won't.
The bug was simply that gsub was returning a replaced version, but not changing the parameter, so the replaced version was ignored.
* Update to 15w40b
This includes chunk serialization. Fully functional chunk serialization for 1.9.
I'm not completely happy with the chunk serialization as-is (correct use of palettes would be great), but cuberite also doesn't skip sending empty chunks so this performance optimization should probably come later. The creation of a full buffer is suboptimal, but it's the easiest way to implement this code.
* Write long-by-long rather than creating a buffer
This is a bit faster and should be equivalent. However, the code still doesn't look too good.
* Update to 15w41a protocol
This includes the new set passengers packet, which works off of the ridden entity, not the rider. That means, among other things, that information about the previously ridden vehicle is needed when detaching. So a new method with that info was added.
* Update to 15w45a
* 15w51b protocol
* Update to 1.9.0 protocol
Closes #3067. There are still a few things that need to be worked out (picking up items, effects, particles, and most importantly inventory), but in general this should work. I'll make a few more changes tomorrow to get the rest of the protocol set up, along with 1.9.1/1.9.2 (which did make a few changes). Chunks, however, _are_ working, along with most other parts of the game (placing/breaking blocks).
* Fix item pickup packet not working
That was a silly mistake, but at least it was an easy one.
* 1.9.2 protocol support
* Fix version info found in server list ping
Thus, the client reports that it can connect rather than saying that the server is out of date. This required creating separate classes for 1.9.1 and 1.9.2, unfortunately.
* Fix build errors generated by clang
These didn't happen in MSVC.
* Add protocol19x.cpp and protocol19x.h to CMakeLists
* Ignore warnings in protocol19x that are ignored in protocol18x
* Document BLOCK_FACE and DIG_STATUS constants
* Fix BLOCK_FACE links and add separate section for DIG_STATUS
* Fix bat animation and object spawning
The causes of both of these are explained in #3135, but the gist is that both were typos.
* Implement Use Item packet
This means that buckets, bows, fishing rods, and several other similar items now work when not looking at a block.
* Handle DIG_STATUS_SWAP_ITEM_IN_HAND
* Add support for spawn eggs and potions
The items are transformed from the 1.9 version to the 1.8 version when reading and transformed back when sending.
* Remove spammy potion debug logging
* Fix wolf collar color metadata
The wrong type was being used, causing several clientside issues (including the screen going black).
* Fix 1.9 chunk sending in the nether
The nether and the end don't send skylight.
* Fix clang build errors
* Fix water bottles becoming mundane potions
This happened because the can become splash potion bit got set incorrectly. Water bottles and mundane potions are only differentiated by the fact that water bottles have a metadata of 0, so setting that bit made it a mundane potion.
Also add missing break statements to the read item NBT switch, which would otherwise break items with custom names and also cause incorrect "Unimplemented NBT data when parsing!" logging.
* Copy Protocol18x as Protocol19x
Aditionally, method and class names have been swapped to clean up other diffs. This commit is only added to make the following diffs more readable; it doesn't make any other changes (beyond class names).
* Make thrown potions use the correct appearence
This was caused by potions now using metadata.
* Add missing api doc for cSplashPotionEntity::GetItem
* Fix compile error in SplashPotionEntity.cpp
* Fix fix of cSplashPotionEntity API doc
* Temporarilly disable fall damage particles
These were causing issues in 1.9 due to the changed effect ID.
* Properly send a kick packet when connecting with an invalid version
This means that the client no longer waits on the server screen with no indication whatsoever. However, right now the server list ping isn't implemented for unknown versions, so it'll only load "Old" on the ping.
I also added a GetVarIntSize method to cByteBuffer. This helps clean up part of the code here (and I think it could clean up other parts), but it may make sense for it to be moved elsewhere (or declared in a different way).
* Handle server list pings from unrecognized versions
This isn't the cleanest way of writing it (it feels odd to use ProtocolRecognizer to send packets, and the addition of m_InPingForUnrecognizedVersion feels like the wrong technique), but it works and I can't think of a better way (apart from creating a full separate protocol class to handle only the ping... which would be worse).
* Use cPacketizer for the disconnect packet
This also should fix clang build errors.
* Add 1.9.3 / 1.9.4 support
* Fix incorrect indentation in APIDesc
2016-05-14 15:12:42 -04:00
|
|
|
{
|
|
|
|
cServer * Server = cRoot::Get()->GetServer();
|
|
|
|
AString ServerDescription = Server->GetDescription();
|
2017-07-28 12:54:40 -04:00
|
|
|
auto NumPlayers = static_cast<signed>(Server->GetNumPlayers());
|
|
|
|
auto MaxPlayers = static_cast<signed>(Server->GetMaxPlayers());
|
1.9 / 1.9.2 / 1.9.3 / 1.9.4 protocol support (#3135)
* Semistable update to 15w31a
I'm going through snapshots in a sequential order since it should make things easier, and since protocol version history is written.
* Update to 15w34b protocol
Also, fix an issue with the Entity Equipment packet from the past version. Clients are able to connect and do stuff!
* Partially update to 15w35e
Chunk data doesn't work, but the client joins. I'm waiting to do chunk data because chunk data has an incomplete format until 15w36d.
* Add '/blk' debug command
This command lets one see what block they are looking at, and makes figuring out what's supposed to be where in a highly broken chunk possible.
* Fix CRLF normalization in CheckBasicStyle.lua
Normally, this doesn't cause an issue, but when running from cygwin, it detects the CR as whitespace and creates thousands of violations for every single line. Lua, when run on windows, will normalize automatically, but when run via cygwin, it won't.
The bug was simply that gsub was returning a replaced version, but not changing the parameter, so the replaced version was ignored.
* Update to 15w40b
This includes chunk serialization. Fully functional chunk serialization for 1.9.
I'm not completely happy with the chunk serialization as-is (correct use of palettes would be great), but cuberite also doesn't skip sending empty chunks so this performance optimization should probably come later. The creation of a full buffer is suboptimal, but it's the easiest way to implement this code.
* Write long-by-long rather than creating a buffer
This is a bit faster and should be equivalent. However, the code still doesn't look too good.
* Update to 15w41a protocol
This includes the new set passengers packet, which works off of the ridden entity, not the rider. That means, among other things, that information about the previously ridden vehicle is needed when detaching. So a new method with that info was added.
* Update to 15w45a
* 15w51b protocol
* Update to 1.9.0 protocol
Closes #3067. There are still a few things that need to be worked out (picking up items, effects, particles, and most importantly inventory), but in general this should work. I'll make a few more changes tomorrow to get the rest of the protocol set up, along with 1.9.1/1.9.2 (which did make a few changes). Chunks, however, _are_ working, along with most other parts of the game (placing/breaking blocks).
* Fix item pickup packet not working
That was a silly mistake, but at least it was an easy one.
* 1.9.2 protocol support
* Fix version info found in server list ping
Thus, the client reports that it can connect rather than saying that the server is out of date. This required creating separate classes for 1.9.1 and 1.9.2, unfortunately.
* Fix build errors generated by clang
These didn't happen in MSVC.
* Add protocol19x.cpp and protocol19x.h to CMakeLists
* Ignore warnings in protocol19x that are ignored in protocol18x
* Document BLOCK_FACE and DIG_STATUS constants
* Fix BLOCK_FACE links and add separate section for DIG_STATUS
* Fix bat animation and object spawning
The causes of both of these are explained in #3135, but the gist is that both were typos.
* Implement Use Item packet
This means that buckets, bows, fishing rods, and several other similar items now work when not looking at a block.
* Handle DIG_STATUS_SWAP_ITEM_IN_HAND
* Add support for spawn eggs and potions
The items are transformed from the 1.9 version to the 1.8 version when reading and transformed back when sending.
* Remove spammy potion debug logging
* Fix wolf collar color metadata
The wrong type was being used, causing several clientside issues (including the screen going black).
* Fix 1.9 chunk sending in the nether
The nether and the end don't send skylight.
* Fix clang build errors
* Fix water bottles becoming mundane potions
This happened because the can become splash potion bit got set incorrectly. Water bottles and mundane potions are only differentiated by the fact that water bottles have a metadata of 0, so setting that bit made it a mundane potion.
Also add missing break statements to the read item NBT switch, which would otherwise break items with custom names and also cause incorrect "Unimplemented NBT data when parsing!" logging.
* Copy Protocol18x as Protocol19x
Aditionally, method and class names have been swapped to clean up other diffs. This commit is only added to make the following diffs more readable; it doesn't make any other changes (beyond class names).
* Make thrown potions use the correct appearence
This was caused by potions now using metadata.
* Add missing api doc for cSplashPotionEntity::GetItem
* Fix compile error in SplashPotionEntity.cpp
* Fix fix of cSplashPotionEntity API doc
* Temporarilly disable fall damage particles
These were causing issues in 1.9 due to the changed effect ID.
* Properly send a kick packet when connecting with an invalid version
This means that the client no longer waits on the server screen with no indication whatsoever. However, right now the server list ping isn't implemented for unknown versions, so it'll only load "Old" on the ping.
I also added a GetVarIntSize method to cByteBuffer. This helps clean up part of the code here (and I think it could clean up other parts), but it may make sense for it to be moved elsewhere (or declared in a different way).
* Handle server list pings from unrecognized versions
This isn't the cleanest way of writing it (it feels odd to use ProtocolRecognizer to send packets, and the addition of m_InPingForUnrecognizedVersion feels like the wrong technique), but it works and I can't think of a better way (apart from creating a full separate protocol class to handle only the ping... which would be worse).
* Use cPacketizer for the disconnect packet
This also should fix clang build errors.
* Add 1.9.3 / 1.9.4 support
* Fix incorrect indentation in APIDesc
2016-05-14 15:12:42 -04:00
|
|
|
AString Favicon = Server->GetFaviconData();
|
2020-07-17 13:46:50 -04:00
|
|
|
cRoot::Get()->GetPluginManager()->CallHookServerPing(a_Client, ServerDescription, NumPlayers, MaxPlayers, Favicon);
|
1.9 / 1.9.2 / 1.9.3 / 1.9.4 protocol support (#3135)
* Semistable update to 15w31a
I'm going through snapshots in a sequential order since it should make things easier, and since protocol version history is written.
* Update to 15w34b protocol
Also, fix an issue with the Entity Equipment packet from the past version. Clients are able to connect and do stuff!
* Partially update to 15w35e
Chunk data doesn't work, but the client joins. I'm waiting to do chunk data because chunk data has an incomplete format until 15w36d.
* Add '/blk' debug command
This command lets one see what block they are looking at, and makes figuring out what's supposed to be where in a highly broken chunk possible.
* Fix CRLF normalization in CheckBasicStyle.lua
Normally, this doesn't cause an issue, but when running from cygwin, it detects the CR as whitespace and creates thousands of violations for every single line. Lua, when run on windows, will normalize automatically, but when run via cygwin, it won't.
The bug was simply that gsub was returning a replaced version, but not changing the parameter, so the replaced version was ignored.
* Update to 15w40b
This includes chunk serialization. Fully functional chunk serialization for 1.9.
I'm not completely happy with the chunk serialization as-is (correct use of palettes would be great), but cuberite also doesn't skip sending empty chunks so this performance optimization should probably come later. The creation of a full buffer is suboptimal, but it's the easiest way to implement this code.
* Write long-by-long rather than creating a buffer
This is a bit faster and should be equivalent. However, the code still doesn't look too good.
* Update to 15w41a protocol
This includes the new set passengers packet, which works off of the ridden entity, not the rider. That means, among other things, that information about the previously ridden vehicle is needed when detaching. So a new method with that info was added.
* Update to 15w45a
* 15w51b protocol
* Update to 1.9.0 protocol
Closes #3067. There are still a few things that need to be worked out (picking up items, effects, particles, and most importantly inventory), but in general this should work. I'll make a few more changes tomorrow to get the rest of the protocol set up, along with 1.9.1/1.9.2 (which did make a few changes). Chunks, however, _are_ working, along with most other parts of the game (placing/breaking blocks).
* Fix item pickup packet not working
That was a silly mistake, but at least it was an easy one.
* 1.9.2 protocol support
* Fix version info found in server list ping
Thus, the client reports that it can connect rather than saying that the server is out of date. This required creating separate classes for 1.9.1 and 1.9.2, unfortunately.
* Fix build errors generated by clang
These didn't happen in MSVC.
* Add protocol19x.cpp and protocol19x.h to CMakeLists
* Ignore warnings in protocol19x that are ignored in protocol18x
* Document BLOCK_FACE and DIG_STATUS constants
* Fix BLOCK_FACE links and add separate section for DIG_STATUS
* Fix bat animation and object spawning
The causes of both of these are explained in #3135, but the gist is that both were typos.
* Implement Use Item packet
This means that buckets, bows, fishing rods, and several other similar items now work when not looking at a block.
* Handle DIG_STATUS_SWAP_ITEM_IN_HAND
* Add support for spawn eggs and potions
The items are transformed from the 1.9 version to the 1.8 version when reading and transformed back when sending.
* Remove spammy potion debug logging
* Fix wolf collar color metadata
The wrong type was being used, causing several clientside issues (including the screen going black).
* Fix 1.9 chunk sending in the nether
The nether and the end don't send skylight.
* Fix clang build errors
* Fix water bottles becoming mundane potions
This happened because the can become splash potion bit got set incorrectly. Water bottles and mundane potions are only differentiated by the fact that water bottles have a metadata of 0, so setting that bit made it a mundane potion.
Also add missing break statements to the read item NBT switch, which would otherwise break items with custom names and also cause incorrect "Unimplemented NBT data when parsing!" logging.
* Copy Protocol18x as Protocol19x
Aditionally, method and class names have been swapped to clean up other diffs. This commit is only added to make the following diffs more readable; it doesn't make any other changes (beyond class names).
* Make thrown potions use the correct appearence
This was caused by potions now using metadata.
* Add missing api doc for cSplashPotionEntity::GetItem
* Fix compile error in SplashPotionEntity.cpp
* Fix fix of cSplashPotionEntity API doc
* Temporarilly disable fall damage particles
These were causing issues in 1.9 due to the changed effect ID.
* Properly send a kick packet when connecting with an invalid version
This means that the client no longer waits on the server screen with no indication whatsoever. However, right now the server list ping isn't implemented for unknown versions, so it'll only load "Old" on the ping.
I also added a GetVarIntSize method to cByteBuffer. This helps clean up part of the code here (and I think it could clean up other parts), but it may make sense for it to be moved elsewhere (or declared in a different way).
* Handle server list pings from unrecognized versions
This isn't the cleanest way of writing it (it feels odd to use ProtocolRecognizer to send packets, and the addition of m_InPingForUnrecognizedVersion feels like the wrong technique), but it works and I can't think of a better way (apart from creating a full separate protocol class to handle only the ping... which would be worse).
* Use cPacketizer for the disconnect packet
This also should fix clang build errors.
* Add 1.9.3 / 1.9.4 support
* Fix incorrect indentation in APIDesc
2016-05-14 15:12:42 -04:00
|
|
|
|
|
|
|
// Version:
|
|
|
|
Json::Value Version;
|
|
|
|
Version["name"] = "Cuberite " MCS_CLIENT_VERSIONS;
|
2017-05-13 06:08:40 -04:00
|
|
|
Version["protocol"] = MCS_LATEST_PROTOCOL_VERSION;
|
1.9 / 1.9.2 / 1.9.3 / 1.9.4 protocol support (#3135)
* Semistable update to 15w31a
I'm going through snapshots in a sequential order since it should make things easier, and since protocol version history is written.
* Update to 15w34b protocol
Also, fix an issue with the Entity Equipment packet from the past version. Clients are able to connect and do stuff!
* Partially update to 15w35e
Chunk data doesn't work, but the client joins. I'm waiting to do chunk data because chunk data has an incomplete format until 15w36d.
* Add '/blk' debug command
This command lets one see what block they are looking at, and makes figuring out what's supposed to be where in a highly broken chunk possible.
* Fix CRLF normalization in CheckBasicStyle.lua
Normally, this doesn't cause an issue, but when running from cygwin, it detects the CR as whitespace and creates thousands of violations for every single line. Lua, when run on windows, will normalize automatically, but when run via cygwin, it won't.
The bug was simply that gsub was returning a replaced version, but not changing the parameter, so the replaced version was ignored.
* Update to 15w40b
This includes chunk serialization. Fully functional chunk serialization for 1.9.
I'm not completely happy with the chunk serialization as-is (correct use of palettes would be great), but cuberite also doesn't skip sending empty chunks so this performance optimization should probably come later. The creation of a full buffer is suboptimal, but it's the easiest way to implement this code.
* Write long-by-long rather than creating a buffer
This is a bit faster and should be equivalent. However, the code still doesn't look too good.
* Update to 15w41a protocol
This includes the new set passengers packet, which works off of the ridden entity, not the rider. That means, among other things, that information about the previously ridden vehicle is needed when detaching. So a new method with that info was added.
* Update to 15w45a
* 15w51b protocol
* Update to 1.9.0 protocol
Closes #3067. There are still a few things that need to be worked out (picking up items, effects, particles, and most importantly inventory), but in general this should work. I'll make a few more changes tomorrow to get the rest of the protocol set up, along with 1.9.1/1.9.2 (which did make a few changes). Chunks, however, _are_ working, along with most other parts of the game (placing/breaking blocks).
* Fix item pickup packet not working
That was a silly mistake, but at least it was an easy one.
* 1.9.2 protocol support
* Fix version info found in server list ping
Thus, the client reports that it can connect rather than saying that the server is out of date. This required creating separate classes for 1.9.1 and 1.9.2, unfortunately.
* Fix build errors generated by clang
These didn't happen in MSVC.
* Add protocol19x.cpp and protocol19x.h to CMakeLists
* Ignore warnings in protocol19x that are ignored in protocol18x
* Document BLOCK_FACE and DIG_STATUS constants
* Fix BLOCK_FACE links and add separate section for DIG_STATUS
* Fix bat animation and object spawning
The causes of both of these are explained in #3135, but the gist is that both were typos.
* Implement Use Item packet
This means that buckets, bows, fishing rods, and several other similar items now work when not looking at a block.
* Handle DIG_STATUS_SWAP_ITEM_IN_HAND
* Add support for spawn eggs and potions
The items are transformed from the 1.9 version to the 1.8 version when reading and transformed back when sending.
* Remove spammy potion debug logging
* Fix wolf collar color metadata
The wrong type was being used, causing several clientside issues (including the screen going black).
* Fix 1.9 chunk sending in the nether
The nether and the end don't send skylight.
* Fix clang build errors
* Fix water bottles becoming mundane potions
This happened because the can become splash potion bit got set incorrectly. Water bottles and mundane potions are only differentiated by the fact that water bottles have a metadata of 0, so setting that bit made it a mundane potion.
Also add missing break statements to the read item NBT switch, which would otherwise break items with custom names and also cause incorrect "Unimplemented NBT data when parsing!" logging.
* Copy Protocol18x as Protocol19x
Aditionally, method and class names have been swapped to clean up other diffs. This commit is only added to make the following diffs more readable; it doesn't make any other changes (beyond class names).
* Make thrown potions use the correct appearence
This was caused by potions now using metadata.
* Add missing api doc for cSplashPotionEntity::GetItem
* Fix compile error in SplashPotionEntity.cpp
* Fix fix of cSplashPotionEntity API doc
* Temporarilly disable fall damage particles
These were causing issues in 1.9 due to the changed effect ID.
* Properly send a kick packet when connecting with an invalid version
This means that the client no longer waits on the server screen with no indication whatsoever. However, right now the server list ping isn't implemented for unknown versions, so it'll only load "Old" on the ping.
I also added a GetVarIntSize method to cByteBuffer. This helps clean up part of the code here (and I think it could clean up other parts), but it may make sense for it to be moved elsewhere (or declared in a different way).
* Handle server list pings from unrecognized versions
This isn't the cleanest way of writing it (it feels odd to use ProtocolRecognizer to send packets, and the addition of m_InPingForUnrecognizedVersion feels like the wrong technique), but it works and I can't think of a better way (apart from creating a full separate protocol class to handle only the ping... which would be worse).
* Use cPacketizer for the disconnect packet
This also should fix clang build errors.
* Add 1.9.3 / 1.9.4 support
* Fix incorrect indentation in APIDesc
2016-05-14 15:12:42 -04:00
|
|
|
|
|
|
|
// Players:
|
|
|
|
Json::Value Players;
|
|
|
|
Players["online"] = NumPlayers;
|
|
|
|
Players["max"] = MaxPlayers;
|
|
|
|
// TODO: Add "sample"
|
|
|
|
|
|
|
|
// Description:
|
|
|
|
Json::Value Description;
|
|
|
|
Description["text"] = ServerDescription.c_str();
|
|
|
|
|
|
|
|
// Create the response:
|
|
|
|
Json::Value ResponseValue;
|
|
|
|
ResponseValue["version"] = Version;
|
|
|
|
ResponseValue["players"] = Players;
|
|
|
|
ResponseValue["description"] = Description;
|
|
|
|
if (!Favicon.empty())
|
|
|
|
{
|
|
|
|
ResponseValue["favicon"] = Printf("data:image/png;base64,%s", Favicon.c_str());
|
|
|
|
}
|
|
|
|
|
2020-05-09 10:51:15 -04:00
|
|
|
AString Response = JsonUtils::WriteFastString(ResponseValue);
|
1.9 / 1.9.2 / 1.9.3 / 1.9.4 protocol support (#3135)
* Semistable update to 15w31a
I'm going through snapshots in a sequential order since it should make things easier, and since protocol version history is written.
* Update to 15w34b protocol
Also, fix an issue with the Entity Equipment packet from the past version. Clients are able to connect and do stuff!
* Partially update to 15w35e
Chunk data doesn't work, but the client joins. I'm waiting to do chunk data because chunk data has an incomplete format until 15w36d.
* Add '/blk' debug command
This command lets one see what block they are looking at, and makes figuring out what's supposed to be where in a highly broken chunk possible.
* Fix CRLF normalization in CheckBasicStyle.lua
Normally, this doesn't cause an issue, but when running from cygwin, it detects the CR as whitespace and creates thousands of violations for every single line. Lua, when run on windows, will normalize automatically, but when run via cygwin, it won't.
The bug was simply that gsub was returning a replaced version, but not changing the parameter, so the replaced version was ignored.
* Update to 15w40b
This includes chunk serialization. Fully functional chunk serialization for 1.9.
I'm not completely happy with the chunk serialization as-is (correct use of palettes would be great), but cuberite also doesn't skip sending empty chunks so this performance optimization should probably come later. The creation of a full buffer is suboptimal, but it's the easiest way to implement this code.
* Write long-by-long rather than creating a buffer
This is a bit faster and should be equivalent. However, the code still doesn't look too good.
* Update to 15w41a protocol
This includes the new set passengers packet, which works off of the ridden entity, not the rider. That means, among other things, that information about the previously ridden vehicle is needed when detaching. So a new method with that info was added.
* Update to 15w45a
* 15w51b protocol
* Update to 1.9.0 protocol
Closes #3067. There are still a few things that need to be worked out (picking up items, effects, particles, and most importantly inventory), but in general this should work. I'll make a few more changes tomorrow to get the rest of the protocol set up, along with 1.9.1/1.9.2 (which did make a few changes). Chunks, however, _are_ working, along with most other parts of the game (placing/breaking blocks).
* Fix item pickup packet not working
That was a silly mistake, but at least it was an easy one.
* 1.9.2 protocol support
* Fix version info found in server list ping
Thus, the client reports that it can connect rather than saying that the server is out of date. This required creating separate classes for 1.9.1 and 1.9.2, unfortunately.
* Fix build errors generated by clang
These didn't happen in MSVC.
* Add protocol19x.cpp and protocol19x.h to CMakeLists
* Ignore warnings in protocol19x that are ignored in protocol18x
* Document BLOCK_FACE and DIG_STATUS constants
* Fix BLOCK_FACE links and add separate section for DIG_STATUS
* Fix bat animation and object spawning
The causes of both of these are explained in #3135, but the gist is that both were typos.
* Implement Use Item packet
This means that buckets, bows, fishing rods, and several other similar items now work when not looking at a block.
* Handle DIG_STATUS_SWAP_ITEM_IN_HAND
* Add support for spawn eggs and potions
The items are transformed from the 1.9 version to the 1.8 version when reading and transformed back when sending.
* Remove spammy potion debug logging
* Fix wolf collar color metadata
The wrong type was being used, causing several clientside issues (including the screen going black).
* Fix 1.9 chunk sending in the nether
The nether and the end don't send skylight.
* Fix clang build errors
* Fix water bottles becoming mundane potions
This happened because the can become splash potion bit got set incorrectly. Water bottles and mundane potions are only differentiated by the fact that water bottles have a metadata of 0, so setting that bit made it a mundane potion.
Also add missing break statements to the read item NBT switch, which would otherwise break items with custom names and also cause incorrect "Unimplemented NBT data when parsing!" logging.
* Copy Protocol18x as Protocol19x
Aditionally, method and class names have been swapped to clean up other diffs. This commit is only added to make the following diffs more readable; it doesn't make any other changes (beyond class names).
* Make thrown potions use the correct appearence
This was caused by potions now using metadata.
* Add missing api doc for cSplashPotionEntity::GetItem
* Fix compile error in SplashPotionEntity.cpp
* Fix fix of cSplashPotionEntity API doc
* Temporarilly disable fall damage particles
These were causing issues in 1.9 due to the changed effect ID.
* Properly send a kick packet when connecting with an invalid version
This means that the client no longer waits on the server screen with no indication whatsoever. However, right now the server list ping isn't implemented for unknown versions, so it'll only load "Old" on the ping.
I also added a GetVarIntSize method to cByteBuffer. This helps clean up part of the code here (and I think it could clean up other parts), but it may make sense for it to be moved elsewhere (or declared in a different way).
* Handle server list pings from unrecognized versions
This isn't the cleanest way of writing it (it feels odd to use ProtocolRecognizer to send packets, and the addition of m_InPingForUnrecognizedVersion feels like the wrong technique), but it works and I can't think of a better way (apart from creating a full separate protocol class to handle only the ping... which would be worse).
* Use cPacketizer for the disconnect packet
This also should fix clang build errors.
* Add 1.9.3 / 1.9.4 support
* Fix incorrect indentation in APIDesc
2016-05-14 15:12:42 -04:00
|
|
|
|
2020-07-17 13:46:50 -04:00
|
|
|
VERIFY(a_Out.WriteVarInt32(GetPacketID(cProtocol::ePacketType::pktStatusResponse)));
|
|
|
|
VERIFY(a_Out.WriteVarUTF8String(Response));
|
2015-03-22 14:46:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-07-17 13:46:50 -04:00
|
|
|
void cMultiVersionProtocol::HandlePacketStatusPing(cClientHandle & a_Client, cByteBuffer & a_Out)
|
2017-07-16 19:19:09 -04:00
|
|
|
{
|
|
|
|
Int64 Timestamp;
|
|
|
|
if (!m_Buffer.ReadBEInt64(Timestamp))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-07-17 13:46:50 -04:00
|
|
|
VERIFY(a_Out.WriteVarInt32(GetPacketID(cProtocol::ePacketType::pktPingResponse)));
|
|
|
|
VERIFY(a_Out.WriteBEInt64(Timestamp));
|
2017-07-16 19:19:09 -04:00
|
|
|
}
|