mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-25 23:17:28 +00:00
fix: use team data in packets where applicaable
This commit is contained in:
parent
35ce8771e5
commit
938bcd258d
@ -709,7 +709,9 @@ void ChatPacketHandler::SendTeamInvite(const PlayerData& receiver, const PlayerD
|
|||||||
SEND_PACKET;
|
SEND_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatPacketHandler::SendTeamInviteConfirm(const PlayerData& receiver, bool bLeaderIsFreeTrial, LWOOBJID i64LeaderID, LWOZONEID i64LeaderZoneID, uint8_t ucLootFlag, uint8_t ucNumOfOtherPlayers, uint8_t ucResponseCode, std::u16string wsLeaderName) {
|
void ChatPacketHandler::SendTeamInviteConfirm(const PlayerData& receiver, TeamData* team, uint8_t responseCode) {
|
||||||
|
if(!team) return;
|
||||||
|
|
||||||
CBITSTREAM;
|
CBITSTREAM;
|
||||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
||||||
bitStream.Write(receiver.playerID);
|
bitStream.Write(receiver.playerID);
|
||||||
@ -720,25 +722,35 @@ void ChatPacketHandler::SendTeamInviteConfirm(const PlayerData& receiver, bool b
|
|||||||
bitStream.Write(receiver.playerID);
|
bitStream.Write(receiver.playerID);
|
||||||
bitStream.Write(eGameMessageType::TEAM_INVITE_CONFIRM);
|
bitStream.Write(eGameMessageType::TEAM_INVITE_CONFIRM);
|
||||||
|
|
||||||
bitStream.Write(bLeaderIsFreeTrial);
|
bitStream.Write(false); // bLeaderIsFreeTrial
|
||||||
bitStream.Write(i64LeaderID);
|
bitStream.Write(team->leaderID);
|
||||||
bitStream.Write(i64LeaderZoneID);
|
const auto& leader = Game::playerContainer.GetPlayerData(team->leaderID);
|
||||||
bitStream.Write<uint32_t>(0); // BinaryBuffe, no clue what's in here
|
|
||||||
bitStream.Write(ucLootFlag);
|
bitStream.Write(leader.zoneID);
|
||||||
bitStream.Write(ucNumOfOtherPlayers);
|
bitStream.Write<uint32_t>((team->memberIDs.size() - 1) * ((sizeof(int16_t) * 33) + sizeof(LWOOBJID) + sizeof(LWOZONEID)));
|
||||||
bitStream.Write(ucResponseCode);
|
for (const auto memberid: team->memberIDs){
|
||||||
bitStream.Write<uint32_t>(wsLeaderName.size());
|
if (memberid == team->leaderID) continue;
|
||||||
for (const auto character : wsLeaderName) {
|
const auto& member = Game::playerContainer.GetPlayerData(memberid);
|
||||||
bitStream.Write(character);
|
bitStream.Write(LUWString(member.playerName));
|
||||||
|
bitStream.Write(memberid);
|
||||||
|
bitStream.Write(member.zoneID);
|
||||||
}
|
}
|
||||||
|
bitStream.Write(team->lootFlag);
|
||||||
|
bitStream.Write(team->memberIDs.size());
|
||||||
|
bitStream.Write<uint8_t>(0); // ucResponseCode
|
||||||
|
const std::u16string wsLeaderName = GeneralUtils::UTF8ToUTF16(leader.playerName);
|
||||||
|
bitStream.Write<uint32_t>(wsLeaderName.size());
|
||||||
|
bitStream.Write(wsLeaderName);
|
||||||
|
|
||||||
SystemAddress sysAddr = receiver.sysAddr;
|
SystemAddress sysAddr = receiver.sysAddr;
|
||||||
SEND_PACKET;
|
SEND_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatPacketHandler::SendTeamStatus(const PlayerData& receiver, LWOOBJID i64LeaderID, LWOZONEID i64LeaderZoneID, uint8_t ucLootFlag, uint8_t ucNumOfOtherPlayers, std::u16string wsLeaderName) {
|
void ChatPacketHandler::SendTeamStatus(const PlayerData& receiver, TeamData* team) {
|
||||||
|
if(!team) return;
|
||||||
|
|
||||||
CBITSTREAM;
|
CBITSTREAM;
|
||||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER);
|
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::WORLD_ROUTE_PACKET);
|
||||||
bitStream.Write(receiver.playerID);
|
bitStream.Write(receiver.playerID);
|
||||||
|
|
||||||
//portion that will get routed:
|
//portion that will get routed:
|
||||||
@ -747,16 +759,23 @@ void ChatPacketHandler::SendTeamStatus(const PlayerData& receiver, LWOOBJID i64L
|
|||||||
bitStream.Write(receiver.playerID);
|
bitStream.Write(receiver.playerID);
|
||||||
bitStream.Write(eGameMessageType::TEAM_GET_STATUS_RESPONSE);
|
bitStream.Write(eGameMessageType::TEAM_GET_STATUS_RESPONSE);
|
||||||
|
|
||||||
bitStream.Write(i64LeaderID);
|
bitStream.Write(team->leaderID);
|
||||||
bitStream.Write(i64LeaderZoneID);
|
const auto& leader = Game::playerContainer.GetPlayerData(team->leaderID);
|
||||||
bitStream.Write<uint32_t>(0); // BinaryBuffe, no clue what's in here
|
|
||||||
bitStream.Write(ucLootFlag);
|
|
||||||
bitStream.Write(ucNumOfOtherPlayers);
|
|
||||||
bitStream.Write<uint32_t>(wsLeaderName.size());
|
|
||||||
for (const auto character : wsLeaderName) {
|
|
||||||
bitStream.Write(character);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
bitStream.Write(leader.zoneID);
|
||||||
|
bitStream.Write<uint32_t>((team->memberIDs.size() - 1) * ((sizeof(int16_t) * 33) + sizeof(LWOOBJID) + sizeof(LWOZONEID)));
|
||||||
|
for (const auto memberid: team->memberIDs){
|
||||||
|
if (memberid == team->leaderID) continue;
|
||||||
|
const auto& member = Game::playerContainer.GetPlayerData(memberid);
|
||||||
|
bitStream.Write(LUWString(member.playerName));
|
||||||
|
bitStream.Write(memberid);
|
||||||
|
bitStream.Write(member.zoneID);
|
||||||
|
}
|
||||||
|
bitStream.Write(team->lootFlag);
|
||||||
|
bitStream.Write(team->memberIDs.size());
|
||||||
|
const std::u16string wsLeaderName = GeneralUtils::UTF8ToUTF16(leader.playerName);
|
||||||
|
bitStream.Write<uint32_t>(wsLeaderName.size());
|
||||||
|
bitStream.Write(wsLeaderName);
|
||||||
SystemAddress sysAddr = receiver.sysAddr;
|
SystemAddress sysAddr = receiver.sysAddr;
|
||||||
SEND_PACKET;
|
SEND_PACKET;
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "BitStream.h"
|
#include "BitStream.h"
|
||||||
|
|
||||||
struct PlayerData;
|
struct PlayerData;
|
||||||
|
struct TeamData;
|
||||||
|
|
||||||
enum class eAddFriendResponseType : uint8_t;
|
enum class eAddFriendResponseType : uint8_t;
|
||||||
|
|
||||||
@ -64,8 +65,8 @@ namespace ChatPacketHandler {
|
|||||||
void HandleTeamStatusRequest(Packet* packet);
|
void HandleTeamStatusRequest(Packet* packet);
|
||||||
|
|
||||||
void SendTeamInvite(const PlayerData& receiver, const PlayerData& sender);
|
void SendTeamInvite(const PlayerData& receiver, const PlayerData& sender);
|
||||||
void SendTeamInviteConfirm(const PlayerData& receiver, bool bLeaderIsFreeTrial, LWOOBJID i64LeaderID, LWOZONEID i64LeaderZoneID, uint8_t ucLootFlag, uint8_t ucNumOfOtherPlayers, uint8_t ucResponseCode, std::u16string wsLeaderName);
|
void SendTeamInviteConfirm(const PlayerData& receiver, TeamData* team, uint8_t responseCode);
|
||||||
void SendTeamStatus(const PlayerData& receiver, LWOOBJID i64LeaderID, LWOZONEID i64LeaderZoneID, uint8_t ucLootFlag, uint8_t ucNumOfOtherPlayers, std::u16string wsLeaderName);
|
void SendTeamStatus(const PlayerData& receiver, TeamData* team);
|
||||||
void SendTeamSetLeader(const PlayerData& receiver, LWOOBJID i64PlayerID);
|
void SendTeamSetLeader(const PlayerData& receiver, LWOOBJID i64PlayerID);
|
||||||
void SendTeamAddPlayer(const PlayerData& receiver, bool bIsFreeTrial, bool bLocal, bool bNoLootOnDeath, LWOOBJID i64PlayerID, std::u16string wsPlayerName, LWOZONEID zoneID);
|
void SendTeamAddPlayer(const PlayerData& receiver, bool bIsFreeTrial, bool bLocal, bool bNoLootOnDeath, LWOOBJID i64PlayerID, std::u16string wsPlayerName, LWOZONEID zoneID);
|
||||||
void SendTeamRemovePlayer(const PlayerData& receiver, bool bDisband, bool bIsKicked, bool bIsLeaving, bool bLocal, LWOOBJID i64LeaderID, LWOOBJID i64PlayerID, std::u16string wsPlayerName);
|
void SendTeamRemovePlayer(const PlayerData& receiver, bool bDisband, bool bIsKicked, bool bIsLeaving, bool bLocal, LWOOBJID i64LeaderID, LWOOBJID i64PlayerID, std::u16string wsPlayerName);
|
||||||
|
@ -228,7 +228,7 @@ void PlayerContainer::AddMember(TeamData* team, LWOOBJID playerID) {
|
|||||||
const auto leaderName = GeneralUtils::UTF8ToUTF16(leader.playerName);
|
const auto leaderName = GeneralUtils::UTF8ToUTF16(leader.playerName);
|
||||||
const auto memberName = GeneralUtils::UTF8ToUTF16(member.playerName);
|
const auto memberName = GeneralUtils::UTF8ToUTF16(member.playerName);
|
||||||
|
|
||||||
ChatPacketHandler::SendTeamInviteConfirm(member, false, leader.playerID, leader.zoneID, team->lootFlag, 0, 0, leaderName);
|
ChatPacketHandler::SendTeamInviteConfirm(member, team, 0);
|
||||||
|
|
||||||
if (!team->local) {
|
if (!team->local) {
|
||||||
ChatPacketHandler::SendTeamSetLeader(member, leader.playerID);
|
ChatPacketHandler::SendTeamSetLeader(member, leader.playerID);
|
||||||
@ -343,7 +343,7 @@ void PlayerContainer::TeamStatusUpdate(TeamData* team) {
|
|||||||
if (!otherMember) continue;
|
if (!otherMember) continue;
|
||||||
|
|
||||||
if (!team->local) {
|
if (!team->local) {
|
||||||
ChatPacketHandler::SendTeamStatus(otherMember, team->leaderID, leader.zoneID, team->lootFlag, 0, leaderName);
|
ChatPacketHandler::SendTeamStatus(otherMember, team);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user