From 992e4ac59e0cb243c3d951fa1417b70ef3d06961 Mon Sep 17 00:00:00 2001 From: Kinglykrab <89047260+Kinglykrab@users.noreply.github.com> Date: Sun, 22 May 2022 22:30:56 -0400 Subject: [PATCH] [Commands] Consolidate #lock and #unlock Commands into #serverlock. (#2193) - Convert the two commands into one command. - Cleanup struct naming. --- common/servertalk.h | 4 ++-- world/zoneserver.cpp | 16 ++++++++-------- zone/command.cpp | 6 ++---- zone/command.h | 2 +- zone/gm_commands/lock.cpp | 15 --------------- zone/gm_commands/serverlock.cpp | 22 ++++++++++++++++++++++ zone/gm_commands/unlock.cpp | 15 --------------- 7 files changed, 35 insertions(+), 45 deletions(-) delete mode 100755 zone/gm_commands/lock.cpp create mode 100644 zone/gm_commands/serverlock.cpp delete mode 100755 zone/gm_commands/unlock.cpp diff --git a/common/servertalk.h b/common/servertalk.h index bcc4d739f..b780175cb 100644 --- a/common/servertalk.h +++ b/common/servertalk.h @@ -740,8 +740,8 @@ struct ServerMultiLineMsg_Struct { }; struct ServerLock_Struct { - char myname[64]; // User that did it - uint8 mode; // 0 = Unlocked ; 1 = Locked + char character_name[64]; + bool is_locked; }; struct ServerMotd_Struct { diff --git a/world/zoneserver.cpp b/world/zoneserver.cpp index 88e3dfcf0..83a00572f 100644 --- a/world/zoneserver.cpp +++ b/world/zoneserver.cpp @@ -972,8 +972,8 @@ void ZoneServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) { break; } - auto slock = (ServerLock_Struct*) pack->pBuffer; - if (slock->mode >= 1) { + auto l = (ServerLock_Struct*) pack->pBuffer; + if (l->is_locked) { WorldConfig::LockWorld(); } else { WorldConfig::UnlockWorld(); @@ -982,24 +982,24 @@ void ZoneServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) { if (loginserverlist.Connected()) { loginserverlist.SendStatus(); SendEmoteMessage( - slock->myname, + l->character_name, 0, AccountStatus::Player, - Chat::Red, + Chat::Yellow, fmt::format( "World {}.", - slock->mode ? "locked" : "unlocked" + l->is_locked ? "locked" : "unlocked" ).c_str() ); } else { SendEmoteMessage( - slock->myname, + l->character_name, 0, AccountStatus::Player, - Chat::Red, + Chat::Yellow, fmt::format( "World {}, but login server not connected.", - slock->mode ? "locked" : "unlocked" + l->is_locked ? "locked" : "unlocked" ).c_str() ); } diff --git a/zone/command.cpp b/zone/command.cpp index 43e755a7c..d5873fe23 100755 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -229,7 +229,6 @@ int command_init(void) command_add("listpetition", "- List petitions", AccountStatus::Guide, command_listpetition) || command_add("load_shared_memory", "[shared_memory_name] - Reloads shared memory and uses the input as output", AccountStatus::GMImpossible, command_load_shared_memory) || command_add("loc", "- Print out your or your target's current location and heading", AccountStatus::Player, command_loc) || - command_add("lock", "- Lock the worldserver", AccountStatus::GMLeadAdmin, command_lock) || command_add("logs", "Manage anything to do with logs", AccountStatus::GMImpossible, command_logs) || command_add("makepet", "[Pet Name] - Make a pet", AccountStatus::Guide, command_makepet) || command_add("mana", "- Fill your or your target's mana", AccountStatus::Guide, command_mana) || @@ -299,6 +298,7 @@ int command_init(void) command_add("sendzonespawns", "- Refresh spawn list for all clients in zone", AccountStatus::GMLeadAdmin, command_sendzonespawns) || command_add("sensetrap", "Analog for ldon sense trap for the newer clients since we still don't have it working.", AccountStatus::Player, command_sensetrap) || command_add("serverinfo", "- Get CPU, Operating System, and Process Information about the server", AccountStatus::GMMgmt, command_serverinfo) || + command_add("serverlock", "[0|1] - Lock or Unlock the World Server (0 = Unlocked, 1 = Locked)", AccountStatus::GMLeadAdmin, command_serverlock) || command_add("serverrules", "- Read this server's rules", AccountStatus::Player, command_serverrules) || command_add("setaapts", "[AA|Group|Raid] [AA Amount] - Set your or your player target's Available AA Points by Type", AccountStatus::GMAdmin, command_setaapts) || command_add("setaaxp", "[AA|Group|Raid] [AA Experience] - Set your or your player target's AA Experience by Type", AccountStatus::GMAdmin, command_setaaxp) || @@ -355,7 +355,6 @@ int command_init(void) command_add("undye", "- Remove dye from all of your or your target's armor slots", AccountStatus::GMAdmin, command_undye) || command_add("undyeme", "- Remove dye from all of your armor slots", AccountStatus::Player, command_undyeme) || command_add("unfreeze", "- Unfreeze your target", AccountStatus::QuestTroupe, command_unfreeze) || - command_add("unlock", "- Unlock the worldserver", AccountStatus::GMLeadAdmin, command_unlock) || command_add("unmemspell", "[Spell ID] - Unmemorize a Spell by ID for you or your target", AccountStatus::Guide, command_unmemspell) || command_add("unmemspells", " - Unmemorize all spells for you or your target", AccountStatus::Guide, command_unmemspells) || command_add("unscribespell", "[Spell ID] - Unscribe a spell from your or your target's spell book by Spell ID", AccountStatus::GMCoder, command_unscribespell) || @@ -1242,7 +1241,6 @@ void command_bot(Client *c, const Seperator *sep) #include "gm_commands/list.cpp" #include "gm_commands/listpetition.cpp" #include "gm_commands/loc.cpp" -#include "gm_commands/lock.cpp" #include "gm_commands/logcommand.cpp" #include "gm_commands/logs.cpp" #include "gm_commands/makepet.cpp" @@ -1314,6 +1312,7 @@ void command_bot(Client *c, const Seperator *sep) #include "gm_commands/sendzonespawns.cpp" #include "gm_commands/sensetrap.cpp" #include "gm_commands/serverinfo.cpp" +#include "gm_commands/serverlock.cpp" #include "gm_commands/serverrules.cpp" #include "gm_commands/set_adventure_points.cpp" #include "gm_commands/setaapts.cpp" @@ -1368,7 +1367,6 @@ void command_bot(Client *c, const Seperator *sep) #include "gm_commands/undye.cpp" #include "gm_commands/undyeme.cpp" #include "gm_commands/unfreeze.cpp" -#include "gm_commands/unlock.cpp" #include "gm_commands/unmemspell.cpp" #include "gm_commands/unmemspells.cpp" #include "gm_commands/unscribespell.cpp" diff --git a/zone/command.h b/zone/command.h index ab25202ba..b6d766d70 100644 --- a/zone/command.h +++ b/zone/command.h @@ -139,7 +139,6 @@ void command_list(Client *c, const Seperator *sep); void command_listpetition(Client *c, const Seperator *sep); void command_load_shared_memory(Client *c, const Seperator *sep); void command_loc(Client *c, const Seperator *sep); -void command_lock(Client *c, const Seperator *sep); void command_logs(Client *c, const Seperator *sep); void command_makepet(Client *c, const Seperator *sep); void command_mana(Client *c, const Seperator *sep); @@ -214,6 +213,7 @@ void command_revoke(Client *c, const Seperator *sep); void command_roambox(Client *c, const Seperator *sep); void command_rules(Client *c, const Seperator *sep); void command_save(Client *c, const Seperator *sep); +void command_serverlock(Client *c, const Seperator *sep); void command_scale(Client *c, const Seperator *sep); void command_scribespell(Client *c, const Seperator *sep); void command_scribespells(Client *c, const Seperator *sep); diff --git a/zone/gm_commands/lock.cpp b/zone/gm_commands/lock.cpp deleted file mode 100755 index 1fda53841..000000000 --- a/zone/gm_commands/lock.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include "../client.h" -#include "../worldserver.h" - -extern WorldServer worldserver; - -void command_lock(Client *c, const Seperator *sep) -{ - auto outpack = new ServerPacket(ServerOP_Lock, sizeof(ServerLock_Struct)); - ServerLock_Struct *lss = (ServerLock_Struct *) outpack->pBuffer; - strcpy(lss->myname, c->GetName()); - lss->mode = 1; - worldserver.SendPacket(outpack); - safe_delete(outpack); -} - diff --git a/zone/gm_commands/serverlock.cpp b/zone/gm_commands/serverlock.cpp new file mode 100644 index 000000000..59a43f912 --- /dev/null +++ b/zone/gm_commands/serverlock.cpp @@ -0,0 +1,22 @@ +#include "../client.h" +#include "../worldserver.h" + +extern WorldServer worldserver; + +void command_serverlock(Client *c, const Seperator *sep) +{ + if (!sep->IsNumber(1)) { + c->Message(Chat::White, "Usage: #serverlock [0|1] - Lock or Unlock the World Server (0 = Unlocked, 1 = Locked)"); + return; + } + + auto is_locked = std::stoi(sep->arg[1]) ? true : false; + + auto pack = new ServerPacket(ServerOP_Lock, sizeof(ServerLock_Struct)); + auto l = (ServerLock_Struct *) pack->pBuffer; + strn0cpy(l->character_name, c->GetCleanName(), sizeof(l->character_name)); + l->is_locked = is_locked; + worldserver.SendPacket(pack); + safe_delete(pack); +} + diff --git a/zone/gm_commands/unlock.cpp b/zone/gm_commands/unlock.cpp deleted file mode 100755 index 2d35220e6..000000000 --- a/zone/gm_commands/unlock.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include "../client.h" -#include "../worldserver.h" - -extern WorldServer worldserver; - -void command_unlock(Client *c, const Seperator *sep) -{ - auto outpack = new ServerPacket(ServerOP_Lock, sizeof(ServerLock_Struct)); - ServerLock_Struct *lss = (ServerLock_Struct *) outpack->pBuffer; - strcpy(lss->myname, c->GetName()); - lss->mode = 0; - worldserver.SendPacket(outpack); - safe_delete(outpack); -} -