eqemu-server/zone/guild.cpp
Mitch Freeman 91f5932c6d
[Feature] Add RoF2 Guild features (#3699)
* [Feature] Add additional Guild Features

This adds the following guild features and design pattern
- the existing guild system was used
- guild features are based on RoF2 within source with translaters used to converted between client differences
- backward compatible with Ti and UF, and allows for mixed client servers
- Guild Back for Ti and UF is based on RoF2 Permissions for banking if Guild Leader does not use Ti/UF
- Guild Ranks and Permissions are enabled.
- Guild Tributes are enabled.
- Event logging via rules for donating tribute items and plat
- Rules to limit Guild Tributes based on max level of server
- Rewrote guild communications to client using specific opcodes
-- Server no longer sends a guild member list on each zone
-- Guild window is updated when a member levels, rank changes, zone changes, banker/alt status using individual opcodes
-- When a member is removed or added to a guild, a single opcode is sent to each guild member
-- This reduces network traffic considerably

Known issues:
- Visual bug only. Guild Tributes window will display a 0 for level if tribute is above max level rule setting.
- Visual bug only. Guild Mgmt Window will not display an online member if the player has 'show offline' unchecked and a guild member zones within the Notes/Tribute tab.  This is resolved by selecting and de-selecting the 'Show Offline' checkbox.

* Updated RoF2 Guild Comms

Updated RoF2 Guild Comms
Update RoF2 Opcodes
Rewrote RoF2 Guild Communications using specific opcodes.
Added database changes - they are irreversible

* Formatting

* Update base_guild_members_repository.h

* Format GuildInfo

* Format GuildAction enum

* Formatting in clientlist

* quantity vs quantity

* desc vs description

* Format structs

* Inline struct values

* Formatting

* Formatting

* Formatting fixes

* Formatting items

* Formatting

* Formatting

* struct formatting updates

* Updated formatting

* Updated
- std:string items
- naming conventions
- magic numbers

* Repo refactors
Other formatting updates

* Remove test guild commands

* Updated #guild info command

* Add new repo methods for Neckolla ReplaceOne and ReplaceMany

* Fix guild_tributes repo

* Update database_update_manifest.cpp

* Phase 1 of final testing with RoF2 -> RoF2.
Next phase will be inter compatibility review

* Remove #guild testing commands

* Fix uf translator error
Rewrite LoadGuilds

* Use extended repository

* FIx guild window on member add

* LoadGuild Changes

* Update guild_base.cpp

* Few small fixes for display issue with UF

* Update guild_base.cpp

* Update guild_members_repository.h

* Update zoneserver.cpp

* Update guild.cpp

* Update entity.h

* Switch formatting

* Formatting

* Update worldserver.cpp

* Switch formatting

* Formatting switch statement

* Update guild.cpp

* Formatting in guild_base

* We don't need to validate m_db everywhere

* More formatting / spacing issues

* Switch format

* Update guild_base.cpp

* Fix an UF issue displaying incorrect guildtag as <>

* Updated several constants, fixed a few issues with Ti/UF and guild tributes not being removed or sent when a member is removed/disbands from a guild.

* Formatting and logging updates

* Fix for Loadguilds and permissions after repo updates.

* Cleanup unnecessary m_db checks

* Updated logging to use player_event_logs

* Updated to use the single opcodes for guild traffic for Ti/UF/RoF2.  Several enhancements for guild functionality for more reusable code and readability.

* Update to fix Demote Self and guild invites declining when option set to not accept guild invites

* Potential fix for guild notes/tribute display issues when client has 'Show Offline' unchecked.

* Updates to fox recent master changes

Updates to fix recent master changes

* Updates in response to comments

* Further Updates in response to comments

* Comment updates and refactor for SendAppearance functions

* Comment updates

* Update client spawn process for show guild name

Add show guild tag to default spawn process

* Update to use zone spawn packets for RoF2
Removed several unused functions as a result
Updated MemberRankUpdate to properly update guild_show on rank change.
Updated OP_GuildURLAndChannel opcode for UF/RoF2

* Cleanup of world changes
Created function for repetitive zonelist sendpackets to only booted zones
Re-Inserted accidental delete of scanclosemobs

* Fixes

* Further world cleanup

* Fix a few test guild bank cases for backward compat
Removed a duplicate db call
Fixed a fallthrough issue

* Update guild_mgr.cpp

* Cleanup

---------

Co-authored-by: Akkadius <akkadius1@gmail.com>
2024-02-10 03:27:58 -06:00

867 lines
24 KiB
C++

/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2003 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "../common/database.h"
#include "../common/guilds.h"
#include "../common/strings.h"
#include "guild_mgr.h"
#include "worldserver.h"
extern WorldServer worldserver;
void Client::SendGuildMOTD(bool GetGuildMOTDReply) {
auto outapp = new EQApplicationPacket(OP_GuildMOTD, sizeof(GuildMOTD_Struct));
// When the Client gets an OP_GuildMOTD, it compares the text to the version it has previously stored.
// If the text in the OP_GuildMOTD packet is the same, it does nothing. If not the same, it displays
// the new MOTD and then stores the new text.
//
// When the Client receives an OP_GetGuildMOTDReply, it displays the text in the packet.
//
// So OP_GuildMOTD should be sent on zone entry and when an Officer changes the MOTD, and OP_GetGuildMOTDReply
// should be sent when the client issues the /getguildmotd command.
//
if(GetGuildMOTDReply)
outapp->SetOpcode(OP_GetGuildMOTDReply);
GuildMOTD_Struct *motd = (GuildMOTD_Struct *) outapp->pBuffer;
motd->unknown0 = 0;
strn0cpy(motd->name, m_pp.name, 64);
if(IsInAGuild()) {
if(!guild_mgr.GetGuildMOTD(GuildID(), motd->motd, motd->setby_name)) {
motd->setby_name[0] = '\0';
strcpy(motd->motd, "ERROR GETTING MOTD!");
}
} else {
//we have to send them an empty MOTD anywyas.
motd->motd[0] = '\0'; //just to be sure
motd->setby_name[0] = '\0'; //just to be sure
}
LogGuilds("Sending OP_GuildMOTD of length [{}]", outapp->size);
FastQueuePacket(&outapp);
}
void Client::SendGuildURL()
{
if (ClientVersion() < EQ::versions::ClientVersion::SoF)
return;
if(IsInAGuild())
{
auto outapp =
new EQApplicationPacket(OP_GuildUpdate, sizeof(GuildUpdateURLAndChannel_Struct));
GuildUpdateURLAndChannel_Struct *guuacs = (GuildUpdateURLAndChannel_Struct*) outapp->pBuffer;
if(guild_mgr.GetGuildURL(GuildID(), guuacs->Text))
{
guuacs->Action = GuildUpdateURL;
FastQueuePacket(&outapp);
}
else
safe_delete(outapp);
}
}
void Client::SendGuildChannel()
{
if (ClientVersion() < EQ::versions::ClientVersion::SoF)
return;
if(IsInAGuild())
{
auto outapp =
new EQApplicationPacket(OP_GuildUpdate, sizeof(GuildUpdateURLAndChannel_Struct));
GuildUpdateURLAndChannel_Struct *guuacs = (GuildUpdateURLAndChannel_Struct*) outapp->pBuffer;
if(guild_mgr.GetGuildChannel(GuildID(), guuacs->Text))
{
guuacs->Action = GuildUpdateChannel;
FastQueuePacket(&outapp);
}
else
safe_delete(outapp);
}
}
void Client::SendGuildRanks()
{
if (ClientVersion() < EQ::versions::ClientVersion::RoF)
return;
int permissions = GUILD_MAX_FUNCTIONS + 1; //Static number of permissions in all EQ clients as of May 2014
int ranks = GUILD_RECRUIT + 1; // Static number of RoF+ ranks as of May 2014
int j = 1;
int i = 1;
if(IsInAGuild())
{
while(j < ranks)
{
while(i < permissions)
{
auto outapp = new EQApplicationPacket(OP_GuildUpdate,
sizeof(GuildUpdateRanks_Struct));
GuildUpdateRanks_Struct* guuacs = (GuildUpdateRanks_Struct*)outapp->pBuffer;
strncpy(guuacs->Unknown0012, GetCleanName(), 64);
guuacs->Action = GuildUpdatePermissions;
guuacs->RankID = j;
guuacs->GuildID = GuildID();
guuacs->PermissionID = i;
guuacs->PermissionVal = guild_mgr.CheckPermission(GuildID(), j, (GuildAction)i);
guuacs->Unknown0089[0] = 0x2c;
guuacs->Unknown0089[1] = 0x01;
guuacs->Unknown0089[2] = 0x00;
FastQueuePacket(&outapp);
i++;
}
j++;
i = 1;
}
}
}
void Client::SendGuildRankNames()
{
if (IsInAGuild() && (ClientVersion() >= EQ::versions::ClientVersion::RoF)) {
auto guild = guild_mgr.GetGuildByGuildID(GuildID());
for (int i = 1; i <= GUILD_MAX_RANK; i++) {
auto outapp = new EQApplicationPacket(OP_GuildUpdate, sizeof(GuildUpdateUCPStruct));
GuildUpdateUCPStruct *gucp = (GuildUpdateUCPStruct *) outapp->pBuffer;
gucp->payload.rank_name.rank = i;
strn0cpy(
gucp->payload.rank_name.rank_name,
guild->rank_names[i].c_str(),
sizeof(gucp->payload.rank_name.rank_name)
);
gucp->action = GuildUpdateRanks;
QueuePacket(outapp);
safe_delete(outapp);
}
}
}
void Client::SendGuildSpawnAppearance() {
if (!IsInAGuild()) {
// clear guildtag
SendAppearancePacket(AppearanceType::GuildID, GUILD_NONE);
LogGuilds("Sending spawn appearance for no guild tag");
} else {
uint8 rank = guild_mgr.GetDisplayedRank(GuildID(), GuildRank(), CharacterID());
uint32 display = guild_mgr.CheckPermission(GuildID(), GuildRank(), GUILD_ACTION_DISPLAY_GUILD_NAME) ? 1 : 0;
LogGuilds("Sending spawn appearance for guild [{}] at rank [{}]", GuildID(), rank);
SendAppearancePacket(AppearanceType::GuildID, GuildID(), true);
SendAppearancePacket(AppearanceType::GuildRank, rank, true);
SendAppearancePacket(AppearanceType::GuildShow, display, true);
}
UpdateWho();
}
void Client::SendGuildList() {
EQApplicationPacket *outapp;
// outapp = new EQApplicationPacket(OP_ZoneGuildList);
outapp = new EQApplicationPacket(OP_GuildsList);
//ask the guild manager to build us a nice guild list packet
outapp->pBuffer = guild_mgr.MakeGuildList(/*GetName()*/"", outapp->size);
if(outapp->pBuffer == nullptr) {
LogGuilds("Unable to make guild list!");
safe_delete(outapp);
return;
}
LogGuilds("Sending OP_ZoneGuildList of length [{}]", outapp->size);
FastQueuePacket(&outapp);
}
void Client::SendGuildMembers() {
uint32 len;
uint8 *data = guild_mgr.MakeGuildMembers(GuildID(), GetName(), len);
if(data == nullptr)
return; //invalid guild, shouldent happen.
auto outapp = new EQApplicationPacket(OP_GuildMemberList);
outapp->size = len;
outapp->pBuffer = data;
data = nullptr;
LogGuilds("Sending OP_GuildMemberList of length [{}]", outapp->size);
FastQueuePacket(&outapp);
auto pack =
new ServerPacket(ServerOP_RequestOnlineGuildMembers, sizeof(ServerRequestOnlineGuildMembers_Struct));
ServerRequestOnlineGuildMembers_Struct *srogms = (ServerRequestOnlineGuildMembers_Struct*)pack->pBuffer;
srogms->FromID = CharacterID();
srogms->GuildID = GuildID();
worldserver.SendPacket(pack);
safe_delete(pack);
// We need to send the Guild URL and Channel name again, as sending OP_GuildMemberList appears to clear this information out.
SendGuildURL();
SendGuildChannel();
}
void Client::RefreshGuildInfo()
{
uint32 OldGuildID = guild_id;
guildrank = GUILD_RANK_NONE;
guild_id = GUILD_NONE;
bool WasBanker = GuildBanker;
CharGuildInfo info;
if(!guild_mgr.GetCharInfo(CharacterID(), info)) {
LogGuilds("Unable to obtain guild char info for [{}] ([{}])", GetName(), CharacterID());
return;
}
guildrank = info.rank;
guild_id = info.guild_id;
GuildBanker = info.banker ||
guild_mgr.IsGuildLeader(GuildID(), CharacterID()) ||
guild_mgr.GetBankerFlag(CharacterID()) ||
ClientVersion() >= EQ::versions::ClientVersion::RoF ? true : false;
if(zone->GetZoneID() == Zones::GUILDHALL)
{
if(WasBanker != GuildBanker)
{
auto outapp = new EQApplicationPacket(OP_SetGuildRank, sizeof(GuildSetRank_Struct));
GuildSetRank_Struct *gsrs = (GuildSetRank_Struct*)outapp->pBuffer;
gsrs->rank = guildrank;
strn0cpy(gsrs->member_name, GetName(), sizeof(gsrs->member_name));
gsrs->banker = GuildBanker;
FastQueuePacket(&outapp);
}
if((guild_id != OldGuildID) && GuildBanks)
{
// Unsure about this for RoF+ ... But they don't have that action anymore so fuck it
if (ClientVersion() < EQ::versions::ClientVersion::RoF)
ClearGuildBank();
if (guild_id != GUILD_NONE)
GuildBanks->SendGuildBank(this);
}
}
SendGuildSpawnAppearance();
}
void EntityList::SendGuildMOTD(uint32 guild_id)
{
if (guild_id == GUILD_NONE) {
return;
}
for (auto const &c: client_list) {
if (c.second->GuildID() == guild_id) {
c.second->SendGuildMOTD();
}
}
}
void EntityList::SendGuildChannel(uint32 guild_id)
{
if (guild_id == GUILD_NONE) {
return;
}
for (auto const &c: client_list) {
if (c.second->GuildID() == guild_id) {
c.second->SendGuildChannel();
}
}
}
void EntityList::SendGuildURL(uint32 guild_id)
{
if (guild_id == GUILD_NONE) {
return;
}
for (auto const &c: client_list) {
if (c.second->GuildID() == guild_id) {
c.second->SendGuildURL();
}
}
}
void EntityList::SendGuildSpawnAppearance(uint32 guild_id)
{
if (guild_id == GUILD_NONE) {
return;
}
auto it = client_list.begin();
while (it != client_list.end()) {
Client *client = it->second;
if (client->GuildID() == guild_id) {
client->SendGuildSpawnAppearance();
}
++it;
}
}
void EntityList::RefreshAllGuildInfo(uint32 guild_id)
{
if (guild_id == GUILD_NONE) {
return;
}
auto it = client_list.begin();
while (it != client_list.end()) {
Client *client = it->second;
if (client->GuildID() == guild_id) {
client->RefreshGuildInfo();
}
++it;
}
}
void EntityList::SendGuildMembers(uint32 guild_id)
{
if (guild_id == GUILD_NONE) {
return;
}
//this could be optimized a bit to only build the member's packet once
//and then keep swapping out the name in the packet on each send.
auto it = client_list.begin();
while (it != client_list.end()) {
Client *client = it->second;
if (client->GuildID() == guild_id) {
//client->SendGuildMembers();
}
++it;
}
}
void EntityList::SendGuildList()
{
for (auto const& c : client_list) {
c.second->SendGuildList();
}
}
void Client::SendGuildJoin(GuildJoin_Struct *gj)
{
auto outapp = new EQApplicationPacket(OP_GuildManageAdd, sizeof(GuildJoin_Struct));
auto outgj = (GuildJoin_Struct *) outapp->pBuffer;
outgj->class_ = gj->class_;
outgj->guild_id = gj->guild_id;
outgj->level = gj->level;
outgj->rank = gj->rank;
outgj->zoneid = gj->zoneid;
strcpy(outgj->name, gj->name);
LogGuilds("Sending OP_GuildManageAdd for join of length [{}]", outapp->size);
FastQueuePacket(&outapp);
}
void EntityList::GuildSetPreRoFBankerFlag(uint32 guild_id, uint32 guild_rank, bool bank_status)
{
auto guild_members = [&]() -> std::vector<Client *> {
std::vector<Client *> members = {};
for (auto const &c: entity_list.GetClientList()) {
if (c.second->GuildID() == guild_id && c.second->GuildRank() == guild_rank) {
members.push_back(c.second);
}
}
return members;
};
for (auto const &c: guild_members()) {
auto outapp = new ServerPacket(
ServerOP_GuildRankUpdate,
sizeof(ServerGuildRankUpdate_Struct)
);
guild_mgr.UpdateDbBankerFlag(c->CharacterID(), bank_status);
c->SetGuildBanker(bank_status);
CharGuildInfo cgi;
guild_mgr.GetCharInfo(c->CharacterID(), cgi);
auto *sgrus = (ServerGuildRankUpdate_Struct *) outapp->pBuffer;
sgrus->guild_id = guild_id;
sgrus->rank = guild_rank;
sgrus->banker = (bank_status ? 1 : 0) + (cgi.alt ? 2 : 0);
sgrus->no_update = true;
strn0cpy(sgrus->member_name, c->GetCleanName(), sizeof(sgrus->member_name));
worldserver.SendPacket(outapp);
safe_delete(outapp);
}
}
void Client::SetGuildRank(uint32 rank)
{
guildrank = rank;
}
void Client::SetGuildTributeOptIn(bool state)
{
guild_tribute_opt_in = state;
}
void Client::SetGuildID(uint32 g_id)
{
guild_id = g_id;
}
void EntityList::UpdateGuildTributes(uint32 guild_id)
{
for (auto const &c: entity_list.GetClientList()) {
if (c.second->GuildID() == guild_id) {
c.second->DoGuildTributeUpdate();
}
}
}
/*
void EntityList::SendGuildJoin(GuildJoin_Struct* gj){
LinkedListIterator<Client*> iterator(client_list);
iterator.Reset();
while(iterator.MoreElements())
{
Client* client = iterator.GetData()->CastToClient();
if (client->IsInGuild(gj->guild_id))
client->SendGuildJoin(gj);
iterator.Advance();
}
}*/
/*bool Client::SetGuild(uint32 in_guild_id, uint8 in_rank) {
if (in_guild_id == 0) {
// update DB
if (!guild_mgr.SetGuild(character_id, 0, GUILD_MEMBER))
return false;
// clear guildtag
guild_id = GUILD_NONE;
SendAppearancePacket(AppearanceType::GuildID, GUILD_NONE);
SendAppearancePacket(AppearanceType::GuildRank, GUILD_RANK_NONE);
UpdateWho();
return true;
} else {
if (!guild_mgr.SetGuild(character_id, in_guild_id, in_rank))
return false;
guildrank = in_rank;
if (guild_id != in_guild_id) {
guild_id = in_guild_id;
SendAppearancePacket(AppearanceType::GuildID, in_guild_id);
}
SendAppearancePacket(AppearanceType::GuildRank, in_rank);
UpdateWho();
return true;
}
UpdateWho();
return false;
}*/
/*
void Client::GuildChangeRank(uint32 guild_id, uint32 oldrank, uint32 newrank){
GuildChangeRank(GetName(), guild_id, oldrank, newrank);
}
void Client::GuildChangeRank(const char* name, uint32 guild_id, uint32 oldrank, uint32 newrank) {
EQApplicationPacket* outapp = new EQApplicationPacket(OP_GuildManageStatus, sizeof(GuildManageStatus_Struct));
GuildManageStatus_Struct* gms = (GuildManageStatus_Struct*) outapp->pBuffer;
gms->guild_id = guild_id;
strcpy(gms->name, name);
gms->newrank = newrank;
gms->oldrank = oldrank;
entity_list.QueueClientsGuild(this, outapp, false, guild_id);
safe_delete(outapp);
SendGuildMembers(guild_id, true);
}*/
void Client::SendGuildMembersList()
{
auto guild_name = guild_mgr.GetGuildName(GuildID());
uint32 len;
uint8 *data = guild_mgr.MakeGuildMembers(GuildID(), guild_name, len);
if (data == nullptr) {
return;
}
auto outapp = new EQApplicationPacket(OP_GuildMemberList);
outapp->size = len;
outapp->pBuffer = data;
data = nullptr;
LogGuilds("Sending OP_GuildMemberList of length [{}]", outapp->size);
FastQueuePacket(&outapp);
SendGuildMOTD();
SendGuildChannel();
SendGuildURL();
SetGuildListDirty(false);
}
void Client::SendGuildMemberAdd(
uint32 guild_id,
uint32 level,
uint32 class_,
uint32 rank_,
uint32 guild_show,
uint32 zone_id,
std::string player_name
)
{
if (GetGuildListDirty()) {
SendGuildMembersList();
return;
}
auto outapp = new EQApplicationPacket(OP_GuildMemberAdd, sizeof(GuildMemberAdd_Struct));
auto out = (GuildMemberAdd_Struct *) outapp->pBuffer;
out->guild_id = guild_id;
out->last_on = time(nullptr);
out->level = level;
out->zone_id = zone_id;
out->rank_ = rank_;
out->guild_show = guild_show;
out->class_ = class_;
strn0cpy(out->player_name, player_name.c_str(), sizeof(out->player_name));
QueuePacket(outapp);
safe_delete(outapp);
}
void Client::SendGuildMemberRename(uint32 guild_id, std::string player_name, std::string new_player_name)
{
auto outapp = new EQApplicationPacket(OP_GuildMemberRename, sizeof(GuildRenameMember_Struct));
auto *out = (GuildRenameMember_Struct *) outapp->pBuffer;
out->guild_id = guild_id;
strn0cpy(out->player_name, player_name.c_str(), sizeof(out->player_name));
strn0cpy(out->new_player_name, new_player_name.c_str(), sizeof(out->new_player_name));
QueuePacket(outapp);
safe_delete(outapp);
}
void Client::SendGuildMemberDelete(uint32 guild_id, std::string player_name)
{
auto outapp = new EQApplicationPacket(OP_GuildMemberDelete, sizeof(GuildMemberDelete_Struct));
auto out = (GuildMemberDelete_Struct *) outapp->pBuffer;
out->guild_id = guild_id;
strn0cpy(out->player_name, player_name.c_str(), sizeof(out->player_name));
QueuePacket(outapp);
safe_delete(outapp);
SetGuildListDirty(true);
}
void Client::SendGuildMemberLevel(uint32 guild_id, uint32 level, std::string player_name)
{
auto outapp = new EQApplicationPacket(OP_GuildMemberLevel, sizeof(GuildMemberLevel_Struct));
auto out = (GuildMemberLevel_Struct *) outapp->pBuffer;
out->guild_id = guild_id;
out->level = level;
strn0cpy(out->player_name, player_name.c_str(), sizeof(out->player_name));
QueuePacket(outapp);
safe_delete(outapp);
}
void Client::SendGuildMemberRankAltBanker(uint32 guild_id, uint32 rank, std::string player_name, bool alt, bool banker)
{
auto outapp = new EQApplicationPacket(OP_GuildMemberRankAltBanker, sizeof(GuildMemberRank_Struct));
auto out = (GuildMemberRank_Struct *) outapp->pBuffer;
out->guild_id = guild_id;
out->rank_ = rank;
out->alt_banker = (alt << 1) | banker;
strn0cpy(out->player_name, player_name.c_str(), sizeof(out->player_name));
QueuePacket(outapp);
safe_delete(outapp);
}
void Client::SendGuildMemberPublicNote(uint32 guild_id, std::string player_name, std::string public_note)
{
auto outapp = new EQApplicationPacket(OP_GuildMemberPublicNote, sizeof(GuildMemberPublicNote_Struct));
auto out = (GuildMemberPublicNote_Struct *) outapp->pBuffer;
out->guild_id = guild_id;
strn0cpy(out->player_name, player_name.c_str(), sizeof(out->player_name));
strn0cpy(out->public_note, public_note.c_str(), sizeof(out->public_note));
QueuePacket(outapp);
safe_delete(outapp);
}
void Client::SendGuildMemberDetails(uint32 guild_id, uint32 zone_id, uint32 offline_mode, std::string player_name)
{
auto outapp = new EQApplicationPacket(OP_GuildMemberDetails, sizeof(GuildMemberDetails_Struct));
auto out = (GuildMemberDetails_Struct *) outapp->pBuffer;
out->guild_id = guild_id;
out->zone_id = zone_id;
out->last_on = time(nullptr);
out->offline_mode = offline_mode;
strn0cpy(out->player_name, player_name.c_str(), sizeof(out->player_name));
QueuePacket(outapp);
safe_delete(outapp);
}
void Client::SendGuildRenameGuild(uint32 guild_id, std::string new_guild_name)
{
auto outapp = new EQApplicationPacket(OP_GuildRenameGuild, sizeof(GuildRenameGuild_Struct));
auto out = (GuildRenameGuild_Struct *) outapp->pBuffer;
out->guild_id = guild_id;
strn0cpy(out->new_guild_name, new_guild_name.c_str(), sizeof(out->new_guild_name));
QueuePacket(outapp);
safe_delete(outapp);
}
void EntityList::SendGuildMembersList(uint32 guild_id)
{
for (auto const& c : client_list) {
if (c.second->GuildID() == guild_id) {
c.second->SendGuildMembersList();
c.second->SetGuildListDirty(false);
}
}
}
void EntityList::SendGuildMemberAdd(
uint32 guild_id,
uint32 level,
uint32 class_,
uint32 rank_,
uint32 spirit,
uint32 zone_id,
std::string player_name
)
{
for (auto &c: client_list) {
if (c.second->GuildID() == guild_id) {
c.second->SendGuildMemberAdd(guild_id, level, class_, rank_, 0, zone_id, player_name);
}
if (player_name.compare(c.second->GetCleanName()) == 0) {
c.second->SetGuildID(guild_id);
c.second->SetGuildRank(rank_);
c.second->SendGuildList();
c.second->SetGuildTributeOptIn(false);
c.second->SendGuildMembersList();
if (c.second->ClientVersion() >= EQ::versions::ClientVersion::RoF) {
c.second->SendGuildRanks();
c.second->SendGuildRankNames();
}
if (zone->GetZoneID() == Zones::GUILDHALL && GuildBanks) {
GuildBanks->SendGuildBank(c.second);
}
c.second->SendGuildActiveTributes(guild_id);
c.second->SendAppearancePacket(AppearanceType::GuildID, guild_id, true, false, c.second);
c.second->SendAppearancePacket(AppearanceType::GuildRank, rank_, true, false, c.second);
c.second->SendAppearancePacket(AppearanceType::GuildShow, guild_mgr.CheckPermission(guild_id, rank_, GUILD_ACTION_DISPLAY_GUILD_NAME) ? 1 : 0);
c.second->DoGuildTributeUpdate();
}
}
}
void EntityList::SendGuildMemberRename(uint32 guild_id, std::string player_name, std::string new_player_name)
{
for (auto const &c: client_list) {
if (c.second->GuildID() == guild_id) {
auto outapp = new EQApplicationPacket(OP_GuildMemberRename, sizeof(GuildRenameMember_Struct));
auto out = (GuildRenameMember_Struct *) outapp->pBuffer;
out->guild_id = guild_id;
strn0cpy(out->player_name, player_name.c_str(), sizeof(out->player_name));
strn0cpy(out->new_player_name, new_player_name.c_str(), sizeof(out->new_player_name));
c.second->QueuePacket(outapp);
safe_delete(outapp);
}
}
}
void EntityList::SendGuildMemberRemove(uint32 guild_id, std::string player_name)
{
for (auto &c: client_list) {
if (c.second->GuildID() == guild_id) {
auto outapp = new EQApplicationPacket(OP_GuildMemberDelete, sizeof(GuildMemberDelete_Struct));
auto out = (GuildMemberDelete_Struct *) outapp->pBuffer;
out->guild_id = guild_id;
strn0cpy(out->player_name, player_name.c_str(), sizeof(out->player_name));
c.second->QueuePacket(outapp);
safe_delete(outapp);
c.second->SetGuildListDirty(true);
if (player_name.compare(c.second->GetCleanName()) == 0) {
c.second->SetGuildID(GUILD_NONE);
c.second->SetGuildRank(GUILD_RANK_NONE);
c.second->SetGuildTributeOptIn(false);
c.second->SendGuildActiveTributes(0);
c.second->SetGuildListDirty(false);
c.second->SendGuildList();
c.second->SendAppearancePacket(AppearanceType::GuildID, GUILD_NONE, true);
c.second->SendAppearancePacket(AppearanceType::GuildRank, GUILD_RANK_NONE, true);
}
}
}
}
void EntityList::SendGuildMemberLevel(uint32 guild_id, uint32 level, std::string player_name)
{
for (auto const &c: client_list) {
if (c.second->GuildID() == guild_id) {
auto outapp = new EQApplicationPacket(OP_GuildMemberLevel, sizeof(GuildMemberLevel_Struct));
GuildMemberLevel_Struct *out = (GuildMemberLevel_Struct *) outapp->pBuffer;
out->guild_id = guild_id;
out->level = level;
strn0cpy(out->player_name, player_name.c_str(), sizeof(out->player_name));
c.second->QueuePacket(outapp);
safe_delete(outapp);
}
}
}
void EntityList::SendGuildMemberRankAltBanker(uint32 guild_id, uint32 rank_, std::string player_name, bool alt, bool banker)
{
for (auto const &c: client_list) {
if (c.second->GuildID() == guild_id) {
auto outapp = new EQApplicationPacket(OP_GuildMemberRankAltBanker, sizeof(GuildMemberRank_Struct));
auto out = (GuildMemberRank_Struct *) outapp->pBuffer;
out->guild_id = guild_id;
out->rank_ = rank_;
out->alt_banker = (alt << 1) | banker;
strn0cpy(out->player_name, player_name.c_str(), sizeof(out->player_name));
c.second->QueuePacket(outapp);
safe_delete(outapp);
}
if (player_name.compare(c.second->GetName()) == 0) {
c.second->SetGuildRank(rank_);
c.second->SendAppearancePacket(AppearanceType::GuildRank, rank_, false);
c.second->SendAppearancePacket(AppearanceType::GuildShow,
guild_mgr.CheckPermission(c.second->GuildID(), c.second->GuildRank(), GUILD_ACTION_DISPLAY_GUILD_NAME) ? 1 : 0,
true);
}
}
}
void EntityList::SendGuildMemberPublicNote(uint32 guild_id, std::string player_name, std::string public_note)
{
for (auto const &c: client_list) {
if (c.second->GuildID() == guild_id) {
auto outapp = new EQApplicationPacket(OP_GuildMemberPublicNote, sizeof(GuildMemberPublicNote_Struct));
auto out = (GuildMemberPublicNote_Struct *) outapp->pBuffer;
out->guild_id = guild_id;
strn0cpy(out->player_name, player_name.c_str(), sizeof(out->player_name));
strn0cpy(out->public_note, public_note.c_str(), sizeof(out->public_note));
c.second->QueuePacket(outapp);
safe_delete(outapp);
}
}
}
void EntityList::SendGuildMemberDetails(uint32 guild_id, uint32 zone_id, uint32 offline_mode, std::string player_name)
{
for (auto const &c: client_list) {
if (c.second->GuildID() == guild_id) {
auto outapp = new EQApplicationPacket(OP_GuildMemberDetails, sizeof(GuildMemberDetails_Struct));
auto out = (GuildMemberDetails_Struct *) outapp->pBuffer;
out->guild_id = guild_id;
out->zone_id = zone_id;
out->last_on = time(nullptr);
out->offline_mode = offline_mode;
strn0cpy(out->player_name, player_name.c_str(), sizeof(out->player_name));
c.second->QueuePacket(outapp);
safe_delete(outapp);
}
}
}
void EntityList::SendGuildRenameGuild(uint32 guild_id, std::string new_guild_name)
{
for (auto const &c: client_list) {
if (c.second->GuildID() == guild_id) {
auto outapp = new EQApplicationPacket(OP_GuildRenameGuild, sizeof(GuildRenameGuild_Struct));
auto out = (GuildRenameGuild_Struct *) outapp->pBuffer;
out->guild_id = guild_id;
strn0cpy(out->new_guild_name, new_guild_name.c_str(), sizeof(out->new_guild_name));
c.second->QueuePacket(outapp);
safe_delete(outapp);
}
}
}
void Client::SendGuildDeletePacket(uint32 guild_id)
{
auto outapp = new EQApplicationPacket(OP_GuildDeleteGuild, sizeof(GuildDelete_Struct));
auto data = (GuildDelete_Struct*)outapp->pBuffer;
data->guild_id = guild_id;
FastQueuePacket(&outapp);
}