diff --git a/src/Client/Realm/RealmSocket.cpp b/src/Client/Realm/RealmSocket.cpp index 3800931..6102428 100644 --- a/src/Client/Realm/RealmSocket.cpp +++ b/src/Client/Realm/RealmSocket.cpp @@ -210,7 +210,15 @@ void RealmSocket::OnRead(void) { log("RealmSocket: Got unknown packet, cmd=%u",cmd); } - ibuf.Remove(ibuf.GetLength()); // if we have data crap left on the buf, delete it + if(ibuf.GetLength()) + { + uint32 len = ibuf.GetLength(); + char *data = new char[len]; + ibuf.Read(data,len); // if we have data crap left on the buf, delete it + logdebug("Data left on RealmSocket, Hexdump:"); + logdebug(toHexDump((uint8*)data,len).c_str()); + delete [] data; + } } @@ -258,6 +266,17 @@ PseuInstance *RealmSocket::GetInstance(void) void RealmSocket::_HandleLogonChallenge(void) { logdebug("RealmSocket: Got AUTH_LOGON_CHALLENGE [%u of %u bytes]",ibuf.GetLength(),sizeof(sAuthLogonChallenge_S)); + if(ibuf.GetLength() < sizeof(sAuthLogonChallenge_S)) + { + logerror("AUTH_LOGON_CHALLENGE: Recieved incorrect/unknown packet. Hexdump:"); + uint32 len = ibuf.GetLength(); + char* data = new char[len]; + ibuf.Read(data,len); + logerror(toHexDump((uint8*)data,len).c_str()); + delete [] data; + return; + } + sAuthLogonChallenge_S lc; ibuf.Read((char*)&lc, sizeof(sAuthLogonChallenge_S)); @@ -332,7 +351,7 @@ void RealmSocket::_HandleLogonChallenge(void) S2hash.UpdateData((const uint8*)S2,16); S2hash.Finalize(); // Re-combine them - char S_hash[40]; // 2*Sha1Len+1 for \0 + char S_hash[40]; for(i=0;i<20;i++){ S_hash[i*2]=S1hash.GetDigest()[i]; S_hash[i*2+1]=S2hash.GetDigest()[i]; @@ -368,15 +387,17 @@ void RealmSocket::_HandleLogonChallenge(void) M2hash.UpdateData((const uint8*)S_hash,40); M2hash.Finalize(); - - //logdebug("--> M1=");printchex((char*)M1hash.GetDigest(),20,true); - //logdebug("--> M2=");printchex((char*)M2hash.GetDigest(),20,true); + logdebug("== Common Hashes =="); + logdebug("--> M1=%s",toHexDump(M1hash.GetDigest(),M1hash.GetLength(),false).c_str()); + logdebug("--> M2=%s",toHexDump(M2hash.GetDigest(),M2hash.GetLength(),false).c_str()); // Calc CRC & CRC_hash // i don't know yet how to calc it, so set it to zero char crc_hash[20]; memset(crc_hash,0,20); + logdebug("--> CRC=%s",toHexDump((uint8*)crc_hash,20,false).c_str()); + // now lets prepare the packet ByteBuffer packet; @@ -397,7 +418,7 @@ void RealmSocket::_HandleLogonChallenge(void) break; default: - log("Unknown realm server response! opcode=0x%x\n",(unsigned char)lc.error); + logerror("Unknown realm server response! opcode=0x%x\n",(unsigned char)lc.error); break; } } @@ -406,6 +427,16 @@ void RealmSocket::_HandleLogonChallenge(void) void RealmSocket::_HandleLogonProof(void) { logdetail("RealmSocket: Got AUTH_LOGON_PROOF [%u of %u bytes]\n",ibuf.GetLength(),26); + if(ibuf.GetLength() < 26) + { + logerror("AUTH_LOGON_PROOF: Recieved incorrect/unknown packet. Hexdump:"); + uint32 len = ibuf.GetLength(); + char* data = new char[len]; + ibuf.Read(data,len); + logerror(toHexDump((uint8*)data,len).c_str()); + delete [] data; + return; + } sAuthLogonProof_S lp; ibuf.Read((char*)&lp, 26); // the compiler didnt like 'sizeof(sAuthLogonProof_S)', said it was 28 //printchex((char*)&lp, sizeof(sAuthLogonProof_S),true); @@ -434,6 +465,6 @@ void RealmSocket::OnConnect() void RealmSocket::OnConnectFailed(void) { - log("Connecting to Realm failed!"); + logerror("Connecting to Realm failed!"); } diff --git a/src/Client/World/WorldSession.cpp b/src/Client/World/WorldSession.cpp index ce36c1d..2d6ac21 100644 --- a/src/Client/World/WorldSession.cpp +++ b/src/Client/World/WorldSession.cpp @@ -588,21 +588,14 @@ void WorldSession::_HandleMovementOpcode(WorldPacket& recvPacket) std::string plrname; guid = recvPacket.GetPackedGuid(); recvPacket >> flags >> time >> x >> y >> z >> o; - if(guid){ + /*if(guid){ plrname=plrNameCache.GetName(guid); if(plrname.empty()) { SendQueryPlayerName(guid); plrname="Unknown Entity"; } - } - // for follow: - //if(_followGUID==guid){ - // ByteBuffer bb; - // bb << time << flags << x << y << z << o; - // SendWorldPacket(opcode,&bb); - //} - // more to come + }*/ } void WorldSession::_HandleTelePortAckOpcode(WorldPacket& recvPacket) @@ -616,7 +609,7 @@ void WorldSession::_HandleTelePortAckOpcode(WorldPacket& recvPacket) recvPacket >> unk >> guid >> unk3 >> unk1 >> unk2 >> o >> x >> y >> z >> ang >> unk4; - logdetail("Got teleported, data: x: %f, y: %f, z: %f, o: %f, guid: %d\n", x, y, z, o, guid); + logdetail("Got teleported, data: x: %f, y: %f, z: %f, o: %f, guid: "I64FMT, x, y, z, o, guid); WorldPacket response; response.SetOpcode(MSG_MOVE_FALL_LAND); diff --git a/src/Client/World/WorldSocket.cpp b/src/Client/World/WorldSocket.cpp index 285ebd6..5c4b758 100644 --- a/src/Client/World/WorldSocket.cpp +++ b/src/Client/World/WorldSocket.cpp @@ -12,17 +12,17 @@ WorldSocket::WorldSocket(SocketHandler &h, WorldSession *s) : TcpSocket(h) void WorldSocket::OnConnect() { - printf("Connected to world server.\r\n"); + log("Connected to world server.\r\n"); } void WorldSocket::OnConnectFailed() { - printf("WorldSocket::OnConnectFailed()\n"); + logerror("WorldSocket::OnConnectFailed()\n"); } void WorldSocket::OnDelete() { - printf("Connection to world server has been closed.\n"); + log("Connection to world server has been closed.\n"); if(_session) _session->SetSocket(NULL); } diff --git a/src/shared/tools.cpp b/src/shared/tools.cpp index d5af563..9dc4d91 100644 --- a/src/shared/tools.cpp +++ b/src/shared/tools.cpp @@ -70,3 +70,17 @@ uint64 toInt(std::string str) return strtoul(str.c_str(),NULL,10); } +std::string toHexDump(uint8* array,uint32 size,bool spaces) +{ + std::stringstream ss; + char buf[5]; + for(uint32 i=0;i