diff --git a/dNet/WorldPackets.cpp b/dNet/WorldPackets.cpp index 53dbf062..ae8f71a4 100644 --- a/dNet/WorldPackets.cpp +++ b/dNet/WorldPackets.cpp @@ -12,6 +12,7 @@ #include "LDFFormat.h" #include "dServer.h" #include "dZoneManager.h" +#include "CharacterComponent.h" #include "ZCompression.h" void WorldPackets::SendLoadStaticZone(const SystemAddress& sysAddr, float x, float y, float z, uint32_t checksum) { @@ -126,20 +127,26 @@ void WorldPackets::SendServerState ( const SystemAddress& sysAddr ) { SEND_PACKET } -void WorldPackets::SendCreateCharacter(const SystemAddress& sysAddr, const LWOOBJID& objectID, const std::string& xmlData, const std::u16string& username, int32_t gm) { +void WorldPackets::SendCreateCharacter(const SystemAddress& sysAddr, Entity* entity, const std::string& xmlData, const std::u16string& username, int32_t gm) { RakNet::BitStream bitStream; PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_CREATE_CHARACTER); RakNet::BitStream data; data.Write(7); //LDF key count - LDFData* objid = new LDFData(u"objid", objectID); + auto character = entity->GetComponent(); + if (!character) { + Game::logger->Log("WorldPackets", "Entity is not a character?? what??"); + return; + } + + LDFData* objid = new LDFData(u"objid", entity->GetObjectID()); LDFData* lot = new LDFData(u"template", 1); LDFData * xmlConfigData = new LDFData(u"xmlData", xmlData); LDFData* name = new LDFData(u"name", username); LDFData* gmlevel = new LDFData(u"gmlevel", gm); LDFData* chatmode = new LDFData(u"chatmode", gm); - LDFData* reputation = new LDFData(u"reputation", 400); + LDFData* reputation = new LDFData(u"reputation", character->GetReputation()); objid->WriteToPacket(&data); lot->WriteToPacket(&data); @@ -178,7 +185,7 @@ void WorldPackets::SendCreateCharacter(const SystemAddress& sysAddr, const LWOOB PacketUtils::SavePacket("chardata.bin", (const char *)bitStream.GetData(), static_cast(bitStream.GetNumberOfBytesUsed())); SEND_PACKET - Game::logger->Log("WorldPackets", "Sent CreateCharacter for ID: %llu\n", objectID); + Game::logger->Log("WorldPackets", "Sent CreateCharacter for ID: %llu\n", entity->GetObjectID()); } void WorldPackets::SendChatModerationResponse(const SystemAddress& sysAddr, bool requestAccepted, uint32_t requestID, const std::string& receiver, std::unordered_map unacceptedItems) { diff --git a/dNet/WorldPackets.h b/dNet/WorldPackets.h index ff51a7f6..3508d6f0 100644 --- a/dNet/WorldPackets.h +++ b/dNet/WorldPackets.h @@ -4,6 +4,7 @@ #include "dCommonVars.h" #include #include +#include "Entity.h" class User; struct SystemAddress; @@ -16,7 +17,7 @@ namespace WorldPackets { void SendCharacterDeleteResponse(const SystemAddress& sysAddr, bool response); void SendTransferToWorld(const SystemAddress& sysAddr, const std::string& serverIP, uint32_t serverPort, bool mythranShift); void SendServerState(const SystemAddress& sysAddr); - void SendCreateCharacter(const SystemAddress& sysAddr, const LWOOBJID& objectID, const std::string& xmlData, const std::u16string& username, int32_t gm); + void SendCreateCharacter(const SystemAddress& sysAddr, Entity* entity, const std::string& xmlData, const std::u16string& username, int32_t gm); void SendChatModerationResponse(const SystemAddress& sysAddr, bool requestAccepted, uint32_t requestID, const std::string& receiver, std::unordered_map unacceptedItems); void SendGMLevelChange(const SystemAddress& sysAddr, bool success, uint8_t highestLevel, uint8_t prevLevel, uint8_t newLevel); }