Use id not name in dz makeleader world msg

This commit is contained in:
hg 2020-11-06 20:36:40 -05:00
parent e5916c5c03
commit 738fd48163
5 changed files with 8 additions and 9 deletions

View File

@ -2110,9 +2110,9 @@ struct ServerDzCommand_Struct {
struct ServerDzCommandMakeLeader_Struct {
uint32 expedition_id;
uint32 requester_id;
uint8 is_online; // set by world, 0: new leader name offline, 1: online
uint8 is_success; // set by world, 0: makeleader failed, 1: success (is online member)
char requester_name[64];
char new_leader_name[64];
};

View File

@ -156,7 +156,7 @@ void ExpeditionMessage::MakeLeader(ServerPacket* pack)
}
// if old and new leader are in the same zone only send one message
ClientListEntry* requester_cle = client_list.FindCharacter(buf->requester_name);
ClientListEntry* requester_cle = client_list.FindCLEByCharacterID(buf->requester_id);
if (requester_cle && requester_cle->Server() && requester_cle->Server() != new_leader_zs)
{
requester_cle->Server()->SendPacket(pack);

View File

@ -6986,7 +6986,7 @@ void command_dz(Client* c, const Seperator* sep)
{
auto char_name = FormatName(sep->arg[3]);
c->Message(Chat::White, fmt::format("Setting expedition [{}] leader to [{}]", expedition_id, char_name).c_str());
expedition->SendWorldMakeLeaderRequest(c->GetName(), char_name);
expedition->SendWorldMakeLeaderRequest(c->CharacterID(), char_name);
}
else
{

View File

@ -1022,7 +1022,7 @@ void Expedition::DzMakeLeader(Client* requester, std::string new_leader_name)
}
// leader can only be changed by world
SendWorldMakeLeaderRequest(requester->GetName(), FormatName(new_leader_name));
SendWorldMakeLeaderRequest(requester->CharacterID(), FormatName(new_leader_name));
}
void Expedition::DzRemovePlayer(Client* requester, std::string char_name)
@ -1584,14 +1584,13 @@ void Expedition::SendWorldLockoutUpdate(
worldserver.SendPacket(pack.get());
}
void Expedition::SendWorldMakeLeaderRequest(
const std::string& requester_name, const std::string& new_leader_name)
void Expedition::SendWorldMakeLeaderRequest(uint32_t requester_id, const std::string& new_leader_name)
{
uint32_t pack_size = sizeof(ServerDzCommandMakeLeader_Struct);
auto pack = std::unique_ptr<ServerPacket>(new ServerPacket(ServerOP_ExpeditionDzMakeLeader, pack_size));
auto buf = reinterpret_cast<ServerDzCommandMakeLeader_Struct*>(pack->pBuffer);
buf->expedition_id = GetID();
strn0cpy(buf->requester_name, requester_name.c_str(), sizeof(buf->requester_name));
buf->requester_id = requester_id;
strn0cpy(buf->new_leader_name, new_leader_name.c_str(), sizeof(buf->new_leader_name));
worldserver.SendPacket(pack.get());
}
@ -1993,7 +1992,7 @@ void Expedition::HandleWorldMessage(ServerPacket* pack)
auto expedition = Expedition::FindCachedExpeditionByID(buf->expedition_id);
if (expedition)
{
auto old_leader_client = entity_list.GetClientByName(buf->requester_name);
auto old_leader_client = entity_list.GetClientByCharID(buf->requester_id);
auto new_leader_client = entity_list.GetClientByName(buf->new_leader_name);
expedition->ProcessMakeLeader(old_leader_client, new_leader_client,
buf->new_leader_name, buf->is_success, buf->is_online);

View File

@ -145,7 +145,7 @@ public:
void SetLootEventBySpawnID(uint32_t spawn_id, const std::string& event_name);
void SendClientExpeditionInfo(Client* client);
void SendWorldMakeLeaderRequest(const std::string& requester_name, const std::string& new_leader_name);
void SendWorldMakeLeaderRequest(uint32_t requester_id, const std::string& new_leader_name);
void SendWorldPendingInvite(const ExpeditionInvite& invite, const std::string& add_name);
void DzAddPlayer(Client* requester, const std::string& add_char_name, const std::string& swap_remove_name = {});