From 9ac11f281d9b72a51c81e85bf18c7b80857accb8 Mon Sep 17 00:00:00 2001 From: Aaron Kimbre Date: Tue, 20 Dec 2022 18:19:21 -0600 Subject: [PATCH] better WIP --- dChatServer/ChatPacketHandler.cpp | 8 ++++++++ dChatServer/ChatPacketHandler.h | 2 ++ dChatServer/ChatServer.cpp | 23 ++++++++++++++++++----- dGame/dGameMessages/GameMessages.cpp | 11 +---------- dGame/dGameMessages/GameMessages.h | 1 - dNet/ClientPackets.cpp | 18 ++++++++++++++---- dNet/ClientPackets.h | 2 ++ dWorldServer/WorldServer.cpp | 1 + 8 files changed, 46 insertions(+), 20 deletions(-) diff --git a/dChatServer/ChatPacketHandler.cpp b/dChatServer/ChatPacketHandler.cpp index 119083ee..621cd4d2 100644 --- a/dChatServer/ChatPacketHandler.cpp +++ b/dChatServer/ChatPacketHandler.cpp @@ -714,6 +714,14 @@ void ChatPacketHandler::HandleTeamStatusRequest(Packet* packet) { } } +void ChatPacketHandler::HandleGuildLeave(Packet* packet){ + CINSTREAM; + LWOOBJID playerID = LWOOBJID_EMPTY; + inStream.Read(playerID); + inStream.Read(playerID); + Game::logger->Log("ChatPacketHandler", "HandleGuildLeave %llu", playerID); +} + void ChatPacketHandler::SendTeamInvite(PlayerData* receiver, PlayerData* sender) { CBITSTREAM; PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER); diff --git a/dChatServer/ChatPacketHandler.h b/dChatServer/ChatPacketHandler.h index fffd1ca4..b8c53826 100644 --- a/dChatServer/ChatPacketHandler.h +++ b/dChatServer/ChatPacketHandler.h @@ -23,6 +23,8 @@ namespace ChatPacketHandler { void HandleTeamLootOption(Packet* packet); void HandleTeamStatusRequest(Packet* packet); + void HandleGuildLeave(Packet* packet); + void SendTeamInvite(PlayerData* receiver, PlayerData* sender); void SendTeamInviteConfirm(PlayerData* receiver, bool bLeaderIsFreeTrial, LWOOBJID i64LeaderID, LWOZONEID i64LeaderZoneID, uint8_t ucLootFlag, uint8_t ucNumOfOtherPlayers, uint8_t ucResponseCode, std::u16string wsLeaderName); void SendTeamStatus(PlayerData* receiver, LWOOBJID i64LeaderID, LWOZONEID i64LeaderZoneID, uint8_t ucLootFlag, uint8_t ucNumOfOtherPlayers, std::u16string wsLeaderName); diff --git a/dChatServer/ChatServer.cpp b/dChatServer/ChatServer.cpp index 8c3543fa..2f0186d9 100644 --- a/dChatServer/ChatServer.cpp +++ b/dChatServer/ChatServer.cpp @@ -289,20 +289,33 @@ void HandlePacket(Packet* packet) { break; // Guild messages + case MSG_CHAT_GUILD_CREATE: - Game::logger->Log("ChatPackets", "GuildCreate"); + Game::logger->Log("ChatServer", "GUILD_CREATE"); break; - case MSG_CHAT_GUILD_GET_ALL: - Game::logger->Log("ChatPackets", "GuildGetAll"); + case MSG_CHAT_GUILD_INVITE_RESPONSE: + Game::logger->Log("ChatServer", "GUILD_INVITE_RESPONSE"); + break; + + case MSG_CHAT_GUILD_LEAVE: + ChatPacketHandler::HandleGuildLeave(packet); + break; + + case MSG_CHAT_GUILD_KICK: + Game::logger->Log("ChatServer", "GUILD_KICK"); break; case MSG_CHAT_GUILD_GET_STATUS: - Game::logger->Log("ChatPackets", "GuildGetStatus"); + Game::logger->Log("ChatServer", "GUILD_GET_STATUS"); + break; + + case MSG_CHAT_GUILD_GET_ALL: + Game::logger->Log("ChatServer", "GUILD_GET_ALL"); break; default: - Game::logger->Log("ChatServer", "Unknown CHAT id: %i", int(packet->data[3])); + Game::logger->Log("ChatServer", "Unknown MSG_CHAT id: %i", int(packet->data[3])); } } diff --git a/dGame/dGameMessages/GameMessages.cpp b/dGame/dGameMessages/GameMessages.cpp index 3984f736..0c0f5a4c 100644 --- a/dGame/dGameMessages/GameMessages.cpp +++ b/dGame/dGameMessages/GameMessages.cpp @@ -4545,22 +4545,13 @@ void GameMessages::SendDisplayGuildCreateBox(const LWOOBJID& objectID, bool bSho CBITSTREAM; CMSGHEADER; - bitStream.Write((unsigned short)GAME_MSG_DISPLAY_GUILD_CREATE_BOX); + bitStream.Write(GAME_MSG_DISPLAY_GUILD_CREATE_BOX); bitStream.Write(objectID); bitStream.Write((unsigned char)bShow); SEND_PACKET; } -void GameMessages::SendGuildCreateResponse(const SystemAddress& sysAddr, eGuildCreationResponse guildResponse, LWOOBJID guildID, std::u16string& guildName) { - CBITSTREAM; - CMSGHEADER; - bitStream.Write(MSG_CLIENT_GUILD_CREATE_RESPONSE); - bitStream.Write(guildResponse); - bitStream.Write(guildID); - PacketUtils::WriteWString(bitStream, guildName, 33); - SEND_PACKET; -} //----------------------------------------------------------------------------------------------------------------------------------------------- //------------------------------------------------------------------- Handlers ------------------------------------------------------------------ diff --git a/dGame/dGameMessages/GameMessages.h b/dGame/dGameMessages/GameMessages.h index bacbc53d..e234b82d 100644 --- a/dGame/dGameMessages/GameMessages.h +++ b/dGame/dGameMessages/GameMessages.h @@ -540,7 +540,6 @@ namespace GameMessages { //Guild messages: void SendDisplayGuildCreateBox(const LWOOBJID& objectID, bool bShow, const SystemAddress& sysAddr); - void SendGuildCreateResponse(const SystemAddress& sysAddr, eGuildCreationResponse guildResponse, LWOOBJID guildID, std::u16string& guildName); //Handlers: diff --git a/dNet/ClientPackets.cpp b/dNet/ClientPackets.cpp index 6696435d..41507ed8 100644 --- a/dNet/ClientPackets.cpp +++ b/dNet/ClientPackets.cpp @@ -391,7 +391,7 @@ void ClientPackets::HandleGuildCreation(const SystemAddress& sysAddr, Packet* pa if (res->rowsCount() > 0) { Game::logger->Log("ClientPackets", "But a guild already exists with that name!"); auto usedName = GeneralUtils::UTF8ToUTF16(guildName); - GameMessages::SendGuildCreateResponse(sysAddr, eGuildCreationResponse::REJECTED_EXISTS, LWOOBJID_EMPTY, usedName); + SendGuildCreateResponse(sysAddr, eGuildCreationResponse::REJECTED_EXISTS, LWOOBJID_EMPTY, usedName); return; } @@ -401,7 +401,7 @@ void ClientPackets::HandleGuildCreation(const SystemAddress& sysAddr, Packet* pa // if (!Game::chatFilter->IsSentenceOkay(guildName, 1).empty()) { // Game::logger->Log("ClientPackets", "But they used bad words!"); // auto usedName = GeneralUtils::UTF8ToUTF16(guildName); - // GameMessages::SendGuildCreateResponse(sysAddr, eGuildCreationResponse::REJECTED_BAD_NAME, LWOOBJID_EMPTY, usedName); + // SendGuildCreateResponse(sysAddr, eGuildCreationResponse::REJECTED_BAD_NAME, LWOOBJID_EMPTY, usedName); // return; // } @@ -444,7 +444,7 @@ void ClientPackets::HandleGuildCreation(const SystemAddress& sysAddr, Packet* pa if (guildId == LWOOBJID_EMPTY){ Game::logger->Log("ClientPackets", "Unknown error ocurred while creating a guild!"); auto usedName = GeneralUtils::UTF8ToUTF16(guildName); - GameMessages::SendGuildCreateResponse(sysAddr, eGuildCreationResponse::UNKNOWN_ERROR, LWOOBJID_EMPTY, usedName); + SendGuildCreateResponse(sysAddr, eGuildCreationResponse::UNKNOWN_ERROR, LWOOBJID_EMPTY, usedName); return; } @@ -457,7 +457,17 @@ void ClientPackets::HandleGuildCreation(const SystemAddress& sysAddr, Packet* pa delete insertOwner; //Send the guild create response: - GameMessages::SendGuildCreateResponse(sysAddr, eGuildCreationResponse::CREATED, guildId, name); + SendGuildCreateResponse(sysAddr, eGuildCreationResponse::CREATED, guildId, name); + // GameMessages::SendDisplayGuildCreateBox(, true, sysAddr) } +void ClientPackets::SendGuildCreateResponse(const SystemAddress& sysAddr, eGuildCreationResponse guildResponse, LWOOBJID guildID, std::u16string& guildName) { + CBITSTREAM; + CMSGHEADER; + bitStream.Write(MSG_CLIENT_GUILD_CREATE_RESPONSE); + bitStream.Write(guildResponse); + bitStream.Write(guildID); + PacketUtils::WriteWString(bitStream, guildName, 33); + SEND_PACKET; +} diff --git a/dNet/ClientPackets.h b/dNet/ClientPackets.h index 95201cb8..e4b16cc9 100644 --- a/dNet/ClientPackets.h +++ b/dNet/ClientPackets.h @@ -8,6 +8,7 @@ #include "RakNetTypes.h" #include "eGuildCreationResponse.h" +#include "dCommonVars.h" namespace ClientPackets { void HandleChatMessage(const SystemAddress& sysAddr, Packet* packet); @@ -16,6 +17,7 @@ namespace ClientPackets { // Guild stuff void HandleGuildCreation(const SystemAddress& sysAddr, Packet* packet); + void SendGuildCreateResponse(const SystemAddress& sysAddr, eGuildCreationResponse guildResponse, LWOOBJID guildID, std::u16string& guildName); }; #endif // CLIENTPACKETS_H diff --git a/dWorldServer/WorldServer.cpp b/dWorldServer/WorldServer.cpp index efd109fc..9f539095 100644 --- a/dWorldServer/WorldServer.cpp +++ b/dWorldServer/WorldServer.cpp @@ -1242,6 +1242,7 @@ void HandlePacket(Packet* packet) { case MSG_WORLD_CLIENT_TMP_GUILD_CREATE: { Game::logger->Log("WorldServer", "create a guild"); ClientPackets::HandleGuildCreation(packet->systemAddress, packet); + break; } default: