Merge branch 'master' into portals
Conflicts: src/ClientHandle.cpp src/Entities/Player.cpp src/Entities/Player.h src/Protocol/Protocol125.cpp src/Protocol/Protocol17x.cpp
This commit is contained in:
@@ -133,7 +133,8 @@ typedef unsigned char Byte;
|
||||
|
||||
cProtocol125::cProtocol125(cClientHandle * a_Client) :
|
||||
super(a_Client),
|
||||
m_ReceivedData(32 KiB)
|
||||
m_ReceivedData(32 KiB),
|
||||
m_LastSentDimension(dimNotSet)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -591,6 +592,7 @@ void cProtocol125::SendLogin(const cPlayer & a_Player, const cWorld & a_World)
|
||||
WriteByte (0); // Unused
|
||||
WriteByte (60); // Client list width or something
|
||||
Flush();
|
||||
m_LastSentDimension = a_World.GetDimension();
|
||||
}
|
||||
|
||||
|
||||
@@ -834,6 +836,11 @@ void cProtocol125::SendRemoveEntityEffect(const cEntity & a_Entity, int a_Effect
|
||||
void cProtocol125::SendRespawn(const cWorld & a_World)
|
||||
{
|
||||
cCSLock Lock(m_CSPacket);
|
||||
if (m_LastSentDimension == a_World.GetDimension())
|
||||
{
|
||||
// Must not send a respawn for the world with the same dimension, the client goes cuckoo if we do
|
||||
return;
|
||||
}
|
||||
cPlayer * Player = m_Client->GetPlayer();
|
||||
WriteByte (PACKET_RESPAWN);
|
||||
WriteInt ((int)(a_World.GetDimension()));
|
||||
@@ -841,6 +848,8 @@ void cProtocol125::SendRespawn(const cWorld & a_World)
|
||||
WriteChar ((char)Player->GetGameMode());
|
||||
WriteShort (256); // Current world height
|
||||
WriteString("default");
|
||||
Flush();
|
||||
m_LastSentDimension = a_World.GetDimension();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -113,6 +113,10 @@ protected:
|
||||
cByteBuffer m_ReceivedData; ///< Buffer for the received data
|
||||
|
||||
AString m_Username; ///< Stored in ParseHandshake(), compared to Login username
|
||||
|
||||
/** The dimension that was last sent to a player in a Respawn or Login packet.
|
||||
Used to avoid Respawning into the same dimension, which confuses the client. */
|
||||
eDimension m_LastSentDimension;
|
||||
|
||||
virtual void SendData(const char * a_Data, size_t a_Size) override;
|
||||
|
||||
|
||||
@@ -253,7 +253,7 @@ void cProtocol132::SendLogin(const cPlayer & a_Player, const cWorld & a_World)
|
||||
WriteByte (0); // Unused, used to be world height
|
||||
WriteByte (8); // Client list width or something
|
||||
Flush();
|
||||
|
||||
m_LastSentDimension = a_World.GetDimension();
|
||||
SendCompass(a_World);
|
||||
}
|
||||
|
||||
|
||||
@@ -92,7 +92,8 @@ cProtocol172::cProtocol172(cClientHandle * a_Client, const AString & a_ServerAdd
|
||||
m_ReceivedData(32 KiB),
|
||||
m_OutPacketBuffer(64 KiB),
|
||||
m_OutPacketLenBuffer(20), // 20 bytes is more than enough for one VarInt
|
||||
m_IsEncrypted(false)
|
||||
m_IsEncrypted(false),
|
||||
m_LastSentDimension(dimNotSet)
|
||||
{
|
||||
// Create the comm log file, if so requested:
|
||||
if (g_ShouldLogCommIn || g_ShouldLogCommOut)
|
||||
@@ -656,6 +657,7 @@ void cProtocol172::SendLogin(const cPlayer & a_Player, const cWorld & a_World)
|
||||
Pkt.WriteByte(std::min(Server->GetMaxPlayers(), 60));
|
||||
Pkt.WriteString("default"); // Level type - wtf?
|
||||
}
|
||||
m_LastSentDimension = a_World.GetDimension();
|
||||
|
||||
// Send the spawn position:
|
||||
{
|
||||
@@ -986,12 +988,19 @@ void cProtocol172::SendRemoveEntityEffect(const cEntity & a_Entity, int a_Effect
|
||||
|
||||
void cProtocol172::SendRespawn(const cWorld & a_World)
|
||||
{
|
||||
if (m_LastSentDimension == a_World.GetDimension())
|
||||
{
|
||||
// Must not send a respawn for the world with the same dimension, the client goes cuckoo if we do
|
||||
return;
|
||||
}
|
||||
|
||||
cPacketizer Pkt(*this, 0x07); // Respawn packet
|
||||
cPlayer * Player = m_Client->GetPlayer();
|
||||
Pkt.WriteInt((int)a_World.GetDimension());
|
||||
Pkt.WriteByte(2); // TODO: Difficulty (set to Normal)
|
||||
Pkt.WriteByte((Byte)Player->GetEffectiveGameMode());
|
||||
Pkt.WriteString("default");
|
||||
m_LastSentDimension = a_World.GetDimension();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -244,6 +244,10 @@ protected:
|
||||
/** The logfile where the comm is logged, when g_ShouldLogComm is true */
|
||||
cFile m_CommLogFile;
|
||||
|
||||
/** The dimension that was last sent to a player in a Respawn or Login packet.
|
||||
Used to avoid Respawning into the same dimension, which confuses the client. */
|
||||
eDimension m_LastSentDimension;
|
||||
|
||||
|
||||
/** Adds the received (unencrypted) data to m_ReceivedData, parses complete packets */
|
||||
void AddReceivedData(const char * a_Data, size_t a_Size);
|
||||
|
||||
Reference in New Issue
Block a user