diff options
Diffstat (limited to 'Tools/ProtoProxy')
-rw-r--r-- | Tools/ProtoProxy/Connection.cpp | 45 | ||||
-rw-r--r-- | Tools/ProtoProxy/Connection.h | 2 |
2 files changed, 43 insertions, 4 deletions
diff --git a/Tools/ProtoProxy/Connection.cpp b/Tools/ProtoProxy/Connection.cpp index f02b503f1..b21d2ae59 100644 --- a/Tools/ProtoProxy/Connection.cpp +++ b/Tools/ProtoProxy/Connection.cpp @@ -387,6 +387,8 @@ bool cConnection::RelayFromServer(void) return CLIENTSEND(Buffer, res); } } + ASSERT(!"Unhandled server state while relaying from server"); + return false; } @@ -423,6 +425,8 @@ bool cConnection::RelayFromClient(void) return SERVERSEND(Buffer, res); } } + ASSERT(!"Unhandled server state while relaying from client"); + return false; } @@ -438,11 +442,11 @@ double cConnection::GetRelativeTime(void) -bool cConnection::SendData(SOCKET a_Socket, const char * a_Data, int a_Size, const char * a_Peer) +bool cConnection::SendData(SOCKET a_Socket, const char * a_Data, size_t a_Size, const char * a_Peer) { - DataLog(a_Data, a_Size, "Sending data to %s, %d bytes", a_Peer, a_Size); + DataLog(a_Data, a_Size, "Sending data to %s, %u bytes", a_Peer, (unsigned)a_Size); - int res = send(a_Socket, a_Data, a_Size, 0); + int res = send(a_Socket, a_Data, (int)a_Size, 0); if (res <= 0) { Log("%s closed the socket: %d, %d; aborting connection", a_Peer, res, SocketError); @@ -2193,11 +2197,39 @@ bool cConnection::HandleServerSpawnMob(void) +struct sSpawnData +{ + AString m_Name; + AString m_Value; + AString m_Signature; + sSpawnData(const AString & a_Name, const AString & a_Value, const AString & a_Signature) : + m_Name(a_Name), + m_Value(a_Value), + m_Signature(a_Signature) + { + } +}; + +typedef std::vector<sSpawnData> sSpawnDatas; + + + + + bool cConnection::HandleServerSpawnNamedEntity(void) { HANDLE_SERVER_PACKET_READ(ReadVarInt, UInt32, EntityID); HANDLE_SERVER_PACKET_READ(ReadVarUTF8String, AString, EntityUUID); HANDLE_SERVER_PACKET_READ(ReadVarUTF8String, AString, EntityName); + HANDLE_SERVER_PACKET_READ(ReadVarInt, UInt32, DataCount); + sSpawnDatas Data; + for (UInt32 i = 0; i < DataCount; i++) + { + HANDLE_SERVER_PACKET_READ(ReadVarUTF8String, AString, Name) + HANDLE_SERVER_PACKET_READ(ReadVarUTF8String, AString, Value) + HANDLE_SERVER_PACKET_READ(ReadVarUTF8String, AString, Signature) + Data.push_back(sSpawnData(Name, Value, Signature)); + } HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosX); HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosY); HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosZ); @@ -2215,6 +2247,13 @@ bool cConnection::HandleServerSpawnNamedEntity(void) Log(" EntityID = %u (0x%x)", EntityID, EntityID); Log(" UUID = \"%s\"", EntityUUID.c_str()); Log(" Name = \"%s\"", EntityName.c_str()); + Log(" NumData = %u", DataCount); + for (sSpawnDatas::const_iterator itr = Data.begin(), end = Data.end(); itr != end; ++itr) + { + Log(" Name = \"%s\", Value = \"%s\", Signature = \"%s\"", + itr->m_Name.c_str(), itr->m_Value.c_str(), itr->m_Signature.c_str() + ); + } // for itr - Data[] Log(" Pos = %s", PrintableAbsIntTriplet(PosX, PosY, PosZ).c_str()); Log(" Rotation = <yaw %d, pitch %d>", Yaw, Pitch); Log(" CurrentItem = %d", CurrentItem); diff --git a/Tools/ProtoProxy/Connection.h b/Tools/ProtoProxy/Connection.h index 70b759d0f..9e04994b7 100644 --- a/Tools/ProtoProxy/Connection.h +++ b/Tools/ProtoProxy/Connection.h @@ -103,7 +103,7 @@ protected: double GetRelativeTime(void); /// Sends data to the specified socket. If sending fails, prints a fail message using a_Peer and returns false. - bool SendData(SOCKET a_Socket, const char * a_Data, int a_Size, const char * a_Peer); + bool SendData(SOCKET a_Socket, const char * a_Data, size_t a_Size, const char * a_Peer); /// Sends data to the specified socket. If sending fails, prints a fail message using a_Peer and returns false. bool SendData(SOCKET a_Socket, cByteBuffer & a_Data, const char * a_Peer); |