mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-16 22:58:34 +00:00
[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>
This commit is contained in:
+242
-57
@@ -19,6 +19,10 @@
|
||||
#include "../common/global_define.h"
|
||||
#include "../common/eq_packet_structs.h"
|
||||
#include "../common/features.h"
|
||||
#include "../common/repositories/guild_tributes_repository.h"
|
||||
#include "../common/guild_base.h"
|
||||
#include "guild_mgr.h"
|
||||
#include "worldserver.h"
|
||||
|
||||
#include "client.h"
|
||||
|
||||
@@ -43,19 +47,7 @@ The server periodicly sends tribute timer updates to the client on live,
|
||||
but I dont see a point to that right now, so I dont do it.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
class TributeData {
|
||||
public:
|
||||
//this level data stored in regular byte order and must be flipped before sending
|
||||
TributeLevel_Struct tiers[MAX_TRIBUTE_TIERS];
|
||||
uint8 tier_count;
|
||||
uint32 unknown;
|
||||
std::string name;
|
||||
std::string description;
|
||||
bool is_guild; //is a guild tribute item
|
||||
};
|
||||
|
||||
extern WorldServer worldserver;
|
||||
std::map<uint32, TributeData> tribute_list;
|
||||
|
||||
void Client::ToggleTribute(bool enabled) {
|
||||
@@ -229,8 +221,8 @@ void Client::SendTributeDetails(uint32 client_id, uint32 tribute_id) {
|
||||
|
||||
t->client_id = client_id;
|
||||
t->tribute_id = tribute_id;
|
||||
memcpy(t->desc, td.description.c_str(), len);
|
||||
t->desc[len] = '\0';
|
||||
memcpy(t->description, td.description.c_str(), len);
|
||||
t->description[len] = '\0';
|
||||
|
||||
QueuePacket(&outapp);
|
||||
}
|
||||
@@ -334,47 +326,6 @@ void Client::SendTributes() {
|
||||
}
|
||||
}
|
||||
|
||||
void Client::SendGuildTributes() {
|
||||
|
||||
std::map<uint32, TributeData>::iterator cur,end;
|
||||
cur = tribute_list.begin();
|
||||
end = tribute_list.end();
|
||||
|
||||
for(; cur != end; ++cur) {
|
||||
if(!cur->second.is_guild)
|
||||
continue; //skip guild tributes here
|
||||
int len = cur->second.name.length();
|
||||
|
||||
//guild tribute has an unknown uint32 at its begining, guild ID?
|
||||
EQApplicationPacket outapp(OP_TributeInfo, sizeof(TributeAbility_Struct) + len + 1 + 4);
|
||||
uint32 *unknown = (uint32 *) outapp.pBuffer;
|
||||
TributeAbility_Struct* tas = (TributeAbility_Struct*) (outapp.pBuffer+4);
|
||||
|
||||
//this is prolly wrong in general, prolly for one specific guild
|
||||
*unknown = 0x8A110000;
|
||||
|
||||
tas->tribute_id = htonl(cur->first);
|
||||
tas->tier_count = htonl(cur->second.unknown);
|
||||
|
||||
//gotta copy over the data from tiers, and flip all the
|
||||
//byte orders, no idea why its flipped here
|
||||
uint32 r, c;
|
||||
c = cur->second.tier_count;
|
||||
TributeLevel_Struct *dest = tas->tiers;
|
||||
TributeLevel_Struct *src = cur->second.tiers;
|
||||
for(r = 0; r < c; r++, dest++, src++) {
|
||||
dest->cost = htonl(src->cost);
|
||||
dest->level = htonl(src->level);
|
||||
dest->tribute_item_id = htonl(src->tribute_item_id);
|
||||
}
|
||||
|
||||
memcpy(tas->name, cur->second.name.c_str(), len);
|
||||
tas->name[len] = '\0';
|
||||
|
||||
QueuePacket(&outapp);
|
||||
}
|
||||
}
|
||||
|
||||
bool ZoneDatabase::LoadTributes() {
|
||||
|
||||
TributeData tributeData;
|
||||
@@ -435,9 +386,243 @@ bool ZoneDatabase::LoadTributes() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void Client::SendGuildTributes()
|
||||
{
|
||||
for (auto const& t : tribute_list) {
|
||||
if (!t.second.is_guild)
|
||||
continue; //skip non guild tributes here
|
||||
|
||||
//guild tribute has an unknown uint32 at its begining, guild ID?
|
||||
int len = t.second.name.length() + 1;
|
||||
|
||||
EQApplicationPacket* outapp = new EQApplicationPacket(OP_SendGuildTributes, sizeof(GuildTributeAbility_Struct) + len);
|
||||
GuildTributeAbility_Struct* gtas = (GuildTributeAbility_Struct*)outapp->pBuffer;
|
||||
|
||||
auto tier_count = t.second.tier_count;
|
||||
for (int ti = 0; ti < t.second.tier_count; ti++) {
|
||||
if (RuleB(Guild, UseCharacterMaxLevelForGuildTributes) && t.second.tiers[ti].level > RuleI(Character, MaxLevel)) {
|
||||
tier_count -= 1;
|
||||
continue;
|
||||
}
|
||||
gtas->guild_id = GuildID();
|
||||
gtas->ability.tier_count = htonl(tier_count);
|
||||
gtas->ability.tribute_id = htonl(t.first);
|
||||
gtas->ability.tiers[ti].cost = htonl(t.second.tiers[ti].cost);
|
||||
gtas->ability.tiers[ti].tribute_item_id = htonl(t.second.tiers[ti].tribute_item_id);
|
||||
gtas->ability.tiers[ti].level = htonl(t.second.tiers[ti].level);
|
||||
}
|
||||
strcpy(gtas->ability.name, t.second.name.data());
|
||||
FastQueuePacket(&outapp);
|
||||
}
|
||||
}
|
||||
|
||||
void Client::SendGuildTributeDetails(uint32 tribute_id, uint32 tier)
|
||||
{
|
||||
if (tribute_list.count(tribute_id) != 1) {
|
||||
LogGuilds("Details request for invalid tribute [{}]", tribute_id);
|
||||
return;
|
||||
}
|
||||
|
||||
TributeData& td = tribute_list[tribute_id];
|
||||
|
||||
int len = td.description.length();
|
||||
EQApplicationPacket* outapp = new EQApplicationPacket(OP_GuildSelectTribute, sizeof(GuildTributeSelectReply_Struct) + len + 1);
|
||||
GuildTributeSelectReply_Struct* t = (GuildTributeSelectReply_Struct*)outapp->pBuffer;
|
||||
|
||||
t->tribute_id = tribute_id;
|
||||
t->tier = tier;
|
||||
t->tribute_id2 = tribute_id;
|
||||
strncpy(&t->description, td.description.c_str(), len);
|
||||
|
||||
QueuePacket(outapp);
|
||||
safe_delete(outapp);
|
||||
}
|
||||
|
||||
void Client::DoGuildTributeUpdate()
|
||||
{
|
||||
LogTribute("DoGuildTributeUpdate");
|
||||
auto guild = guild_mgr.GetGuildByGuildID(GuildID());
|
||||
|
||||
if (guild && guild->tribute.enabled && GuildTributeOptIn()) {
|
||||
TributeData& d1 = tribute_list[guild->tribute.id_1];
|
||||
uint32 item_id1 = d1.tiers[guild->tribute.id_1_tier].tribute_item_id;
|
||||
TributeData& d2 = tribute_list[guild->tribute.id_2];
|
||||
uint32 item_id2 = d2.tiers[guild->tribute.id_2_tier].tribute_item_id;
|
||||
|
||||
if (item_id1) {
|
||||
LogGuilds("Guild Tribute Item 1 is {}", item_id1);
|
||||
const EQ::ItemInstance* inst = database.CreateItem(item_id1, 1);
|
||||
if (!inst) {
|
||||
LogGuilds("Guild Tribute Item 1 was not found. {}", item_id1);
|
||||
return;
|
||||
}
|
||||
auto inst_level = d1.tiers[guild->tribute.id_1_tier].level;
|
||||
if (m_inv[EQ::invslot::GUILD_TRIBUTE_BEGIN]) {
|
||||
LogGuilds("Guild Tribute DELETE Item in Slot 450");
|
||||
DeleteItemInInventory(EQ::invslot::GUILD_TRIBUTE_BEGIN);
|
||||
}
|
||||
|
||||
if ((RuleB(Guild,UseCharacterMaxLevelForGuildTributes) && RuleI(Character, MaxLevel) >= inst_level && GetLevel() >= inst_level) ||
|
||||
!RuleB(Guild, UseCharacterMaxLevelForGuildTributes)) {
|
||||
PutItemInInventory(EQ::invslot::GUILD_TRIBUTE_BEGIN, *inst);
|
||||
SendItemPacket(EQ::invslot::GUILD_TRIBUTE_BEGIN, inst, ItemPacketGuildTribute);
|
||||
}
|
||||
|
||||
safe_delete(inst);
|
||||
}
|
||||
|
||||
if (item_id2) {
|
||||
LogInfo("Guild Tribute Item 2 is {}", item_id2);
|
||||
const EQ::ItemInstance* inst = database.CreateItem(item_id2, 1);
|
||||
if (!inst) {
|
||||
LogGuilds("Guild Tribute Item 1 was not found. {}", item_id2);
|
||||
return;
|
||||
}
|
||||
auto inst_level = d2.tiers[guild->tribute.id_2_tier].level;
|
||||
if (m_inv[EQ::invslot::GUILD_TRIBUTE_BEGIN + 1]) {
|
||||
DeleteItemInInventory(EQ::invslot::GUILD_TRIBUTE_BEGIN + 1);
|
||||
LogGuilds("Guild Tribute DELETE Item in Slot 451");
|
||||
}
|
||||
|
||||
if ((RuleB(Guild, UseCharacterMaxLevelForGuildTributes) && RuleI(Character, MaxLevel) >= inst_level && GetLevel() >= inst_level) ||
|
||||
!RuleB(Guild, UseCharacterMaxLevelForGuildTributes)) {
|
||||
PutItemInInventory(EQ::invslot::GUILD_TRIBUTE_BEGIN + 1, *inst);
|
||||
SendItemPacket(EQ::invslot::GUILD_TRIBUTE_BEGIN + 1, inst, ItemPacketGuildTribute);
|
||||
}
|
||||
|
||||
safe_delete(inst);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (m_inv[EQ::invslot::GUILD_TRIBUTE_BEGIN]) {
|
||||
DeleteItemInInventory(EQ::invslot::GUILD_TRIBUTE_BEGIN);
|
||||
}
|
||||
if (m_inv[EQ::invslot::GUILD_TRIBUTE_BEGIN + 1]) {
|
||||
DeleteItemInInventory(EQ::invslot::GUILD_TRIBUTE_BEGIN + 1);
|
||||
}
|
||||
}
|
||||
CalcBonuses();
|
||||
}
|
||||
|
||||
void Client::SendGuildActiveTributes(uint32 guild_id)
|
||||
{
|
||||
auto guild = guild_mgr.GetGuildByGuildID(guild_id);
|
||||
|
||||
auto outapp = new EQApplicationPacket(OP_GuildSendActiveTributes, sizeof(GuildTributeSendActive_Struct));
|
||||
auto gtsa = (GuildTributeSendActive_Struct *) outapp->pBuffer;
|
||||
|
||||
if (guild) {
|
||||
gtsa->guild_favor = guild->tribute.favor;
|
||||
gtsa->tribute_timer = guild->tribute.time_remaining;
|
||||
gtsa->tribute_enabled = guild->tribute.enabled;
|
||||
gtsa->tribute_id_1 = guild->tribute.id_1;
|
||||
gtsa->tribute_id_1_tier = guild->tribute.id_1_tier;
|
||||
gtsa->tribute_id_2 = guild->tribute.id_2;
|
||||
gtsa->tribute_id_2_tier = guild->tribute.id_2_tier;
|
||||
}
|
||||
else {
|
||||
gtsa->guild_favor = 0;
|
||||
gtsa->tribute_timer = 0;
|
||||
gtsa->tribute_enabled = 0;
|
||||
gtsa->tribute_id_1 = 0xffffffff;
|
||||
gtsa->tribute_id_1_tier = 0;
|
||||
gtsa->tribute_id_2 = 0xffffffff;
|
||||
gtsa->tribute_id_2_tier = 0;
|
||||
}
|
||||
|
||||
QueuePacket(outapp);
|
||||
safe_delete(outapp)
|
||||
}
|
||||
|
||||
void Client::SendGuildFavorAndTimer(uint32 guild_id)
|
||||
{
|
||||
auto guild = guild_mgr.GetGuildByGuildID(guild_id);
|
||||
|
||||
if (guild) {
|
||||
auto outapp = new EQApplicationPacket(OP_GuildTributeFavorAndTimer, sizeof(GuildTributeFavorTimer_Struct));
|
||||
auto gtsa = (GuildTributeFavorTimer_Struct *) outapp->pBuffer;
|
||||
|
||||
gtsa->guild_favor = guild->tribute.favor;
|
||||
gtsa->tribute_timer = guild->tribute.time_remaining;
|
||||
gtsa->trophy_timer = 0; //not yet implemented
|
||||
|
||||
QueuePacket(outapp);
|
||||
safe_delete(outapp);
|
||||
}
|
||||
}
|
||||
|
||||
void Client::SendGuildTributeOptInToggle(const GuildTributeMemberToggle* in)
|
||||
{
|
||||
EQApplicationPacket* outapp = new EQApplicationPacket(OP_GuildOptInOut, sizeof(GuildTributeOptInOutReply_Struct));
|
||||
GuildTributeOptInOutReply_Struct* data = (GuildTributeOptInOutReply_Struct*)outapp->pBuffer;
|
||||
|
||||
strncpy(data->player_name, in->player_name, 64);
|
||||
data->guild_id = in->guild_id;
|
||||
data->no_donations = in->no_donations;
|
||||
data->tribute_toggle = in->tribute_toggle;
|
||||
data->tribute_trophy_toggle = 0; //not yet implemented
|
||||
data->time = time(nullptr);
|
||||
data->command = in->command;
|
||||
|
||||
QueuePacket(outapp);
|
||||
safe_delete(outapp);
|
||||
}
|
||||
|
||||
void Client::RequestGuildActiveTributes(uint32 guild_id)
|
||||
{
|
||||
auto sp = new ServerPacket(ServerOP_RequestGuildActiveTributes, sizeof(GuildTributeUpdate));
|
||||
auto data = (GuildTributeUpdate *) sp->pBuffer;
|
||||
|
||||
data->guild_id = GuildID();
|
||||
|
||||
worldserver.SendPacket(sp);
|
||||
safe_delete(sp);
|
||||
}
|
||||
|
||||
void Client::RequestGuildFavorAndTimer(uint32 guild_id)
|
||||
{
|
||||
auto sp = new ServerPacket(ServerOP_RequestGuildFavorAndTimer, sizeof(GuildTributeUpdate));
|
||||
auto data = (GuildTributeUpdate *) sp->pBuffer;
|
||||
|
||||
data->guild_id = GuildID();
|
||||
|
||||
worldserver.SendPacket(sp);
|
||||
safe_delete(sp);
|
||||
}
|
||||
|
||||
void Client::SendGuildTributeDonateItemReply(GuildTributeDonateItemRequest_Struct* in, uint32 favor) {
|
||||
|
||||
auto outapp = new EQApplicationPacket(OP_GuildTributeDonateItem, sizeof(GuildTributeDonateItemReply_Struct));
|
||||
auto out = (GuildTributeDonateItemReply_Struct*)outapp->pBuffer;
|
||||
|
||||
out->type = in->type;
|
||||
out->slot = in->slot;
|
||||
out->aug_index = in->aug_index;
|
||||
out->sub_index = in->sub_index;
|
||||
out->quantity = in->quantity;
|
||||
out->unknown10 = in->unknown10;
|
||||
out->unknown20 = in->unknown20;
|
||||
out->favor = favor;
|
||||
|
||||
QueuePacket(outapp);
|
||||
safe_delete(outapp);
|
||||
|
||||
}
|
||||
|
||||
void Client::SendGuildTributeDonatePlatReply(GuildTributeDonatePlatRequest_Struct* in, uint32 favor) {
|
||||
|
||||
auto outapp = new EQApplicationPacket(OP_GuildTributeDonatePlat, sizeof(GuildTributeDonatePlatReply_Struct));
|
||||
auto out = (GuildTributeDonatePlatReply_Struct*)outapp->pBuffer;
|
||||
|
||||
out->favor = favor;
|
||||
out->quantity = in->quantity;
|
||||
|
||||
QueuePacket(outapp);
|
||||
safe_delete(outapp)
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
64.37.149.6:1353 == server
|
||||
66.90.221.245:3173 == client
|
||||
|
||||
|
||||
Reference in New Issue
Block a user