From d0edb93d62ac23f811493f3721e7139f39bacef0 Mon Sep 17 00:00:00 2001 From: Alex King <89047260+Kinglykrab@users.noreply.github.com> Date: Sun, 22 Jan 2023 12:56:42 -0500 Subject: [PATCH] [Commands] Remove #guildapprove, #guildcreate, and #guildlist Commands (#2775) # Notes - Removes `#guildapprove`, `#guildcreate`, and `#guildlist`. - Removes associated functions, classes, etc. that were only used in these commands. - These commands are unused and/or covered by the general `#guild` command. - Approvals don't really seem to be a thing anymore and the variable itself doesn't exist in stock PEQ database anyway. --- zone/command.cpp | 6 - zone/command.h | 3 - zone/gm_commands/guildapprove.cpp | 8 -- zone/gm_commands/guildcreate.cpp | 13 -- zone/gm_commands/guildlist.cpp | 14 -- zone/guild_mgr.cpp | 219 ------------------------------ zone/guild_mgr.h | 28 ---- 7 files changed, 291 deletions(-) delete mode 100755 zone/gm_commands/guildapprove.cpp delete mode 100755 zone/gm_commands/guildcreate.cpp delete mode 100755 zone/gm_commands/guildlist.cpp diff --git a/zone/command.cpp b/zone/command.cpp index 95783216f..e44e590d6 100644 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -176,9 +176,6 @@ int command_init(void) command_add("goto", "[playername] or [x y z] [h] - Teleport to the provided coordinates or to your target", AccountStatus::Steward, command_goto) || command_add("grid", "[add/delete] [grid_num] [wandertype] [pausetype] - Create/delete a wandering grid", AccountStatus::GMAreas, command_grid) || command_add("guild", "Guild manipulation commands. Use argument help for more info.", AccountStatus::Steward, command_guild) || - command_add("guildapprove", "[guildapproveid] - Approve a guild with specified ID (guild creator receives the id)", AccountStatus::Player, command_guildapprove) || - command_add("guildcreate", "[guildname] - Creates an approval setup for guild name specified", AccountStatus::Player, command_guildcreate) || - command_add("guildlist", "[guildapproveid] - Lists character names who have approved the guild specified by the approve id", AccountStatus::Player, command_guildlist) || command_add("haste", "[percentage] - Set your haste percentage", AccountStatus::GMAdmin, command_haste) || command_add("hatelist", "Display hate list for NPC.", AccountStatus::QuestTroupe, command_hatelist) || command_add("heal", "Completely heal your target", AccountStatus::Steward, command_heal) || @@ -1014,9 +1011,6 @@ void command_bot(Client *c, const Seperator *sep) #include "gm_commands/goto.cpp" #include "gm_commands/grid.cpp" #include "gm_commands/guild.cpp" -#include "gm_commands/guildapprove.cpp" -#include "gm_commands/guildcreate.cpp" -#include "gm_commands/guildlist.cpp" #include "gm_commands/haste.cpp" #include "gm_commands/hatelist.cpp" #include "gm_commands/heal.cpp" diff --git a/zone/command.h b/zone/command.h index 492027fe8..452579ffa 100644 --- a/zone/command.h +++ b/zone/command.h @@ -122,9 +122,6 @@ void command_godmode(Client* c, const Seperator *sep); void command_goto(Client *c, const Seperator *sep); void command_grid(Client *c, const Seperator *sep); void command_guild(Client *c, const Seperator *sep); -void command_guildapprove(Client *c, const Seperator *sep); -void command_guildcreate(Client *c, const Seperator *sep); -void command_guildlist(Client *c, const Seperator *sep); void command_haste(Client *c, const Seperator *sep); void command_hatelist(Client *c, const Seperator *sep); void command_heal(Client *c, const Seperator *sep); diff --git a/zone/gm_commands/guildapprove.cpp b/zone/gm_commands/guildapprove.cpp deleted file mode 100755 index 5c7805224..000000000 --- a/zone/gm_commands/guildapprove.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "../client.h" -#include "../guild_mgr.h" - -void command_guildapprove(Client *c, const Seperator *sep) -{ - guild_mgr.AddMemberApproval(atoi(sep->arg[1]), c); -} - diff --git a/zone/gm_commands/guildcreate.cpp b/zone/gm_commands/guildcreate.cpp deleted file mode 100755 index 48e90d3ef..000000000 --- a/zone/gm_commands/guildcreate.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "../client.h" -#include "../guild_mgr.h" - -void command_guildcreate(Client *c, const Seperator *sep) -{ - if (strlen(sep->argplus[1]) > 4 && strlen(sep->argplus[1]) < 16) { - guild_mgr.AddGuildApproval(sep->argplus[1], c); - } - else { - c->Message(Chat::White, "Guild name must be more than 4 characters and less than 16."); - } -} - diff --git a/zone/gm_commands/guildlist.cpp b/zone/gm_commands/guildlist.cpp deleted file mode 100755 index 3ec40ef02..000000000 --- a/zone/gm_commands/guildlist.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "../client.h" -#include "../guild_mgr.h" - -void command_guildlist(Client *c, const Seperator *sep) -{ - GuildApproval *tmp = guild_mgr.FindGuildByIDApproval(atoi(sep->arg[1])); - if (tmp) { - tmp->ApprovedMembers(c); - } - else { - c->Message(Chat::White, "Could not find reference id."); - } -} - diff --git a/zone/guild_mgr.cpp b/zone/guild_mgr.cpp index e778647e3..812fe2785 100644 --- a/zone/guild_mgr.cpp +++ b/zone/guild_mgr.cpp @@ -652,79 +652,11 @@ void ZoneGuildManager::RequestOnlineGuildMembers(uint32 FromID, uint32 GuildID) safe_delete(pack); } -void ZoneGuildManager::ProcessApproval() -{ - LinkedListIterator iterator(list); - - iterator.Reset(); - while(iterator.MoreElements()) - { - if(!iterator.GetData()->ProcessApproval()) - iterator.RemoveCurrent(); - iterator.Advance(); - } -} - -void ZoneGuildManager::AddGuildApproval(const char* guildname,Client* owner) -{ - auto tmp = new GuildApproval(guildname, owner, GetFreeID()); - list.Insert(tmp); -} - -void ZoneGuildManager::AddMemberApproval(uint32 refid,Client* name) -{ - GuildApproval* tmp = FindGuildByIDApproval(refid); - if(tmp != 0) - { - if(!tmp->AddMemberApproval(name)) - name->Message(Chat::White,"Unable to add to list."); - else - { - name->Message(Chat::White,"Added to list."); - } - } - else - name->Message(Chat::White,"Unable to find guild reference id."); -} - ZoneGuildManager::~ZoneGuildManager() { ClearGuilds(); } -void ZoneGuildManager::ClearGuildsApproval() -{ - list.Clear(); -} - -GuildApproval* ZoneGuildManager::FindGuildByIDApproval(uint32 refid) -{ - LinkedListIterator iterator(list); - - iterator.Reset(); - while(iterator.MoreElements()) - { - if(iterator.GetData()->GetID() == refid) - return iterator.GetData(); - iterator.Advance(); - } - return 0; -} - -GuildApproval* ZoneGuildManager::FindGuildByOwnerApproval(Client* owner) -{ - LinkedListIterator iterator(list); - - iterator.Reset(); - while(iterator.MoreElements()) - { - if(iterator.GetData()->GetOwner() == owner) - return iterator.GetData(); - iterator.Advance(); - } - return 0; -} - GuildBankManager::~GuildBankManager() { auto Iterator = Banks.begin(); @@ -1524,154 +1456,3 @@ bool GuildBankManager::AllowedToWithdraw(uint32 GuildID, uint16 Area, uint16 Slo return false; } - -/*================== GUILD APPROVAL ========================*/ - -bool GuildApproval::ProcessApproval() -{ - if(owner && owner->GuildID() != 0) - { - owner->Message(Chat::NPCQuestSay,"You are already in a guild! Guild request deleted."); - return false; - } - if(deletion_timer->Check() || !owner) - { - if(owner) - owner->Message(Chat::White,"You took too long! Your guild request has been deleted."); - return false; - } - - return true; -} - -GuildApproval::GuildApproval(const char* guildname, Client* owner,uint32 id) -{ - std::string founders; - database.GetVariable("GuildCreation", founders); - uint8 tmp = atoi(founders.c_str()); - deletion_timer = new Timer(1800000); - strcpy(guild,guildname); - owner = owner; - refid = id; - if(owner) - owner->Message(Chat::White,"You can now start getting your guild approved, tell your %i members to #guildapprove %i, you have 30 minutes to create your guild.",tmp,GetID()); - for(int i=0;iMessage(Chat::White,"%i: %s",i,members[i]->GetName()); - } -} - -void GuildApproval::GuildApproved() -{ - char petitext[PBUFFER] = "A new guild was founded! Guildname: "; - char gmembers[MBUFFER] = " "; - - if(!owner) - return; - std::string founders; - database.GetVariable("GuildCreation", founders); - uint8 tmp = atoi(founders.c_str()); - uint32 tmpeq = guild_mgr.CreateGuild(guild, owner->CharacterID()); - guild_mgr.SetGuild(owner->CharacterID(),tmpeq,2); - owner->SendAppearancePacket(AT_GuildID,true,false); - for(int i=0;iMessage(Chat::White, "%s",members[i]->GetName()); - owner->Message(Chat::White, "%i",members[i]->CharacterID()); - guild_mgr.SetGuild(members[i]->CharacterID(),tmpeq,0); - size_t len = MBUFFER - strlen(gmembers)+1; - strncat(gmembers," ",len); - strncat(gmembers,members[i]->GetName(),len); - } - } - size_t len = PBUFFER - strlen(petitext)+1; - strncat(petitext,guild,len); - strncat(petitext," Leader: ",len); - strncat(petitext,owner->CastToClient()->GetName(),len); - strncat(petitext," Members:",len); - strncat(petitext,gmembers,len); - auto pet = new Petition(owner->CastToClient()->CharacterID()); - pet->SetAName(owner->CastToClient()->AccountName()); - pet->SetClass(owner->CastToClient()->GetClass()); - pet->SetLevel(owner->CastToClient()->GetLevel()); - pet->SetCName(owner->CastToClient()->GetName()); - pet->SetRace(owner->CastToClient()->GetRace()); - pet->SetLastGM(""); - pet->SetCName(owner->CastToClient()->GetName()); //aza77 is this really 2 times needed ?? - pet->SetPetitionText(petitext); - pet->SetZone(zone->GetZoneID()); - pet->SetUrgency(0); - petition_list.AddPetition(pet); - database.InsertPetitionToDB(pet); - petition_list.UpdateGMQueue(); - petition_list.UpdateZoneListQueue(); - worldserver.SendEmoteMessage( - 0, - 0, - AccountStatus::QuestTroupe, - Chat::Yellow, - fmt::format( - "{} has made a petition. ID: {}", - owner->CastToClient()->GetName(), - pet->GetID() - ).c_str() - ); - auto pack = new ServerPacket; - pack->opcode = ServerOP_RefreshGuild; - pack->size = tmp; - pack->pBuffer = new uchar[pack->size]; - memcpy(pack->pBuffer, &tmpeq, 4); - worldserver.SendPacket(pack); - safe_delete(pack); - owner->Message(Chat::White, "Your guild was created."); - owner = 0; -} - diff --git a/zone/guild_mgr.h b/zone/guild_mgr.h index 2e6a12de1..ae21c55c3 100644 --- a/zone/guild_mgr.h +++ b/zone/guild_mgr.h @@ -47,36 +47,10 @@ enum { GuildBankDepositArea = 0, GuildBankMainArea = 1 }; enum { GuildBankBankerOnly = 0, GuildBankSingleMember = 1, GuildBankPublicIfUsable = 2, GuildBankPublic = 3 }; -class GuildApproval -{ -public: - GuildApproval(const char* guildname,Client* owner,uint32 id); - ~GuildApproval(); - bool ProcessApproval(); - bool AddMemberApproval(Client* addition); - uint32 GetID() { return refid; } - Client* GetOwner() { return owner; } - void GuildApproved(); - void ApprovedMembers(Client* requestee); -private: - Timer* deletion_timer; - char guild[16]; - Client* owner; - Client* members[6]; - uint32 refid; -}; - class ZoneGuildManager : public BaseGuildManager { public: ~ZoneGuildManager(void); - void AddGuildApproval(const char* guildname, Client* owner); - void AddMemberApproval(uint32 refid,Client* name); - void ClearGuildsApproval(); - GuildApproval* FindGuildByIDApproval(uint32 refid); - GuildApproval* FindGuildByOwnerApproval(Client* owner); - void ProcessApproval(); - uint32 GetFreeID() { return id+1; } //called by worldserver when it receives a message from world. void ProcessWorldPacket(ServerPacket *pack); @@ -103,9 +77,7 @@ protected: std::map > m_inviteQueue; //map from char ID to guild,rank private: - LinkedList list; uint32 id; - };