mirror of
https://github.com/EQEmu/Server.git
synced 2026-04-08 10:02:26 +00:00
[Commands] Cleanup #zonelock Command. (#1711)
* [Commands] Cleanup #zonelock Command. - Add support for Zone IDs. - Cleanup messages and display. - Fix dangling pointer in ZoneLongName() helper method so name is displayed properly. * Add account status enum. * Typo. * Typo. * Convert list to constants. * Cleanup. * Update command.cpp * Fix compile.
This commit is contained in:
parent
27f8ae3999
commit
90bcc5f03c
@ -230,6 +230,31 @@ namespace EQ
|
|||||||
const int STANCE_TYPE_LAST = stanceBurnAE;
|
const int STANCE_TYPE_LAST = stanceBurnAE;
|
||||||
const int STANCE_TYPE_COUNT = stanceBurnAE;
|
const int STANCE_TYPE_COUNT = stanceBurnAE;
|
||||||
|
|
||||||
|
enum ServerLockType : int {
|
||||||
|
List,
|
||||||
|
Lock,
|
||||||
|
Unlock
|
||||||
|
};
|
||||||
|
|
||||||
|
enum AccountStatus : uint8 {
|
||||||
|
Player = 0,
|
||||||
|
Steward = 10,
|
||||||
|
ApprenticeGuide = 20,
|
||||||
|
Guide = 50,
|
||||||
|
QuestTroupe = 80,
|
||||||
|
SeniorGuide = 81,
|
||||||
|
GMTester = 85,
|
||||||
|
EQSupport = 90,
|
||||||
|
GMStaff = 95,
|
||||||
|
GMAdmin = 100,
|
||||||
|
GMLeadAdmin = 150,
|
||||||
|
QuestMaster = 160,
|
||||||
|
GMAreas = 170,
|
||||||
|
GMCoder = 180,
|
||||||
|
GMMgmt = 200,
|
||||||
|
GMImpossible = 250,
|
||||||
|
Max = 255
|
||||||
|
};
|
||||||
} /*constants*/
|
} /*constants*/
|
||||||
|
|
||||||
namespace profile {
|
namespace profile {
|
||||||
|
|||||||
@ -85,6 +85,26 @@ std::string WorldStore::GetZoneName(uint32 zone_id)
|
|||||||
return std::string();
|
return std::string();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param zone_id
|
||||||
|
* @param error_unknown
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
const char *WorldStore::GetZoneLongName(uint32 zone_id, bool error_unknown)
|
||||||
|
{
|
||||||
|
for (auto &z: zones) {
|
||||||
|
if (z.zoneidnumber == zone_id) {
|
||||||
|
return z.long_name.c_str();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (error_unknown) {
|
||||||
|
return "UNKNOWN";
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param zone_id
|
* @param zone_id
|
||||||
* @return
|
* @return
|
||||||
|
|||||||
@ -40,7 +40,7 @@ public:
|
|||||||
std::string GetZoneName(uint32 zone_id);
|
std::string GetZoneName(uint32 zone_id);
|
||||||
std::string GetZoneLongName(uint32 zone_id);
|
std::string GetZoneLongName(uint32 zone_id);
|
||||||
const char *GetZoneName(uint32 zone_id, bool error_unknown = false);
|
const char *GetZoneName(uint32 zone_id, bool error_unknown = false);
|
||||||
|
const char *GetZoneLongName(uint32 zone_id, bool error_unknown = false);
|
||||||
};
|
};
|
||||||
|
|
||||||
extern WorldStore world_store;
|
extern WorldStore world_store;
|
||||||
@ -57,7 +57,13 @@ inline const char *ZoneName(uint32 zone_id, bool error_unknown = false)
|
|||||||
error_unknown
|
error_unknown
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
inline const char *ZoneLongName(uint32 zone_id) { return world_store.GetZoneLongName(zone_id).c_str(); }
|
inline const char *ZoneLongName(uint32 zone_id, bool error_unknown = false)
|
||||||
|
{
|
||||||
|
return world_store.GetZoneLongName(
|
||||||
|
zone_id,
|
||||||
|
error_unknown
|
||||||
|
);
|
||||||
|
}
|
||||||
inline ZoneRepository::Zone GetZone(uint32 zone_id, int version = 0) { return world_store.GetZone(zone_id, version); };
|
inline ZoneRepository::Zone GetZone(uint32 zone_id, int version = 0) { return world_store.GetZone(zone_id, version); };
|
||||||
inline ZoneRepository::Zone GetZone(const char *in_zone_name) { return world_store.GetZone(in_zone_name); };
|
inline ZoneRepository::Zone GetZone(const char *in_zone_name) { return world_store.GetZone(in_zone_name); };
|
||||||
|
|
||||||
|
|||||||
@ -270,14 +270,39 @@ bool ZSList::IsZoneLocked(uint16 iZoneID) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ZSList::ListLockedZones(const char* to, WorldTCPConnection* connection) {
|
void ZSList::ListLockedZones(const char* to, WorldTCPConnection* connection) {
|
||||||
int x = 0;
|
int zone_count = 0;
|
||||||
for (auto &zone : pLockedZones) {
|
for (const auto& zone_id : pLockedZones) {
|
||||||
if (zone) {
|
if (zone_id) {
|
||||||
connection->SendEmoteMessageRaw(to, 0, 0, 0, ZoneName(zone, true));
|
int zone_number = (zone_count + 1);
|
||||||
x++;
|
connection->SendEmoteMessageRaw(
|
||||||
|
to,
|
||||||
|
0,
|
||||||
|
EQ::constants::AccountStatus::Player,
|
||||||
|
Chat::White,
|
||||||
|
fmt::format(
|
||||||
|
"Zone {} | Name: {} ({}) ID: {}",
|
||||||
|
zone_number,
|
||||||
|
ZoneLongName(zone_id),
|
||||||
|
ZoneName(zone_id),
|
||||||
|
zone_id
|
||||||
|
).c_str()
|
||||||
|
);
|
||||||
|
zone_count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
connection->SendEmoteMessage(to, 0, 0, 0, "%i zones locked.", x);
|
|
||||||
|
std::string zone_message = (
|
||||||
|
zone_count ?
|
||||||
|
fmt::format("{} Zones are locked.", zone_count) :
|
||||||
|
"There are no zones locked."
|
||||||
|
);
|
||||||
|
connection->SendEmoteMessage(
|
||||||
|
to,
|
||||||
|
0,
|
||||||
|
EQ::constants::AccountStatus::Player,
|
||||||
|
Chat::White,
|
||||||
|
zone_message.c_str()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZSList::SendZoneStatus(const char* to, int16 admin, WorldTCPConnection* connection) {
|
void ZSList::SendZoneStatus(const char* to, int16 admin, WorldTCPConnection* connection) {
|
||||||
|
|||||||
@ -1022,22 +1022,44 @@ void ZoneServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) {
|
|||||||
LogInfo("Wrong size on ServerOP_LockZone. Got: [{}], Expected: [{}]", pack->size, sizeof(ServerLockZone_Struct));
|
LogInfo("Wrong size on ServerOP_LockZone. Got: [{}], Expected: [{}]", pack->size, sizeof(ServerLockZone_Struct));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ServerLockZone_Struct* s = (ServerLockZone_Struct*)pack->pBuffer;
|
|
||||||
switch (s->op) {
|
ServerLockZone_Struct* lock_zone = (ServerLockZone_Struct*) pack->pBuffer;
|
||||||
case 0:
|
if (lock_zone->op == EQ::constants::ServerLockType::List) {
|
||||||
zoneserver_list.ListLockedZones(s->adminname, this);
|
zoneserver_list.ListLockedZones(lock_zone->adminname, this);
|
||||||
break;
|
break;
|
||||||
case 1:
|
} else if (
|
||||||
if (zoneserver_list.SetLockedZone(s->zoneID, true))
|
lock_zone->op == EQ::constants::ServerLockType::Lock ||
|
||||||
zoneserver_list.SendEmoteMessage(0, 0, 80, 15, "Zone locked: %s", ZoneName(s->zoneID));
|
lock_zone->op == EQ::constants::ServerLockType::Unlock
|
||||||
else
|
) {
|
||||||
this->SendEmoteMessageRaw(s->adminname, 0, 0, 0, "Failed to change lock");
|
if (zoneserver_list.SetLockedZone(lock_zone->zoneID, lock_zone->op == EQ::constants::ServerLockType::Lock)) {
|
||||||
break;
|
zoneserver_list.SendEmoteMessage(
|
||||||
case 2:
|
0,
|
||||||
if (zoneserver_list.SetLockedZone(s->zoneID, false))
|
0,
|
||||||
zoneserver_list.SendEmoteMessage(0, 0, 80, 15, "Zone unlocked: %s", ZoneName(s->zoneID));
|
EQ::constants::AccountStatus::QuestTroupe,
|
||||||
else
|
Chat::White,
|
||||||
this->SendEmoteMessageRaw(s->adminname, 0, 0, 0, "Failed to change lock");
|
fmt::format(
|
||||||
|
"Zone {} | Name: {} ({}) ID: {}",
|
||||||
|
lock_zone->op == EQ::constants::ServerLockType::Lock ? "Locked" : "Unlocked",
|
||||||
|
ZoneLongName(lock_zone->zoneID),
|
||||||
|
ZoneName(lock_zone->zoneID),
|
||||||
|
lock_zone->zoneID
|
||||||
|
).c_str()
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
SendEmoteMessageRaw(
|
||||||
|
lock_zone->adminname,
|
||||||
|
0,
|
||||||
|
EQ::constants::AccountStatus::Player,
|
||||||
|
Chat::White,
|
||||||
|
fmt::format(
|
||||||
|
"Zone Failed to {} | Name: {} ({}) ID: {}",
|
||||||
|
lock_zone->op == EQ::constants::ServerLockType::Lock ? "Lock" : "Unlock",
|
||||||
|
ZoneLongName(lock_zone->zoneID),
|
||||||
|
ZoneName(lock_zone->zoneID),
|
||||||
|
lock_zone->zoneID
|
||||||
|
).c_str()
|
||||||
|
);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -22,6 +22,7 @@
|
|||||||
#include "../common/net/servertalk_server.h"
|
#include "../common/net/servertalk_server.h"
|
||||||
#include "../common/event/timer.h"
|
#include "../common/event/timer.h"
|
||||||
#include "../common/timer.h"
|
#include "../common/timer.h"
|
||||||
|
#include "../common/emu_constants.h"
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -29,7 +30,6 @@
|
|||||||
class Client;
|
class Client;
|
||||||
class ServerPacket;
|
class ServerPacket;
|
||||||
|
|
||||||
|
|
||||||
class ZoneServer : public WorldTCPConnection {
|
class ZoneServer : public WorldTCPConnection {
|
||||||
public:
|
public:
|
||||||
ZoneServer(std::shared_ptr<EQ::Net::ServertalkServerConnection> connection, EQ::Net::ConsoleServer *console);
|
ZoneServer(std::shared_ptr<EQ::Net::ServertalkServerConnection> connection, EQ::Net::ConsoleServer *console);
|
||||||
|
|||||||
@ -455,7 +455,7 @@ int command_init(void)
|
|||||||
command_add("zone", "[zonename] [x] [y] [z] - Go to specified zone (coords optional)", 50, command_zone) ||
|
command_add("zone", "[zonename] [x] [y] [z] - Go to specified zone (coords optional)", 50, command_zone) ||
|
||||||
command_add("zonebootup", "[ZoneServerID] [shortname] - Make a zone server boot a specific zone", 150, command_zonebootup) ||
|
command_add("zonebootup", "[ZoneServerID] [shortname] - Make a zone server boot a specific zone", 150, command_zonebootup) ||
|
||||||
command_add("zoneinstance", "[instanceid] [x] [y] [z] - Go to specified instance zone (coords optional)", 50, command_zone_instance) ||
|
command_add("zoneinstance", "[instanceid] [x] [y] [z] - Go to specified instance zone (coords optional)", 50, command_zone_instance) ||
|
||||||
command_add("zonelock", "[list/lock/unlock] - Set/query lock flag for zoneservers", 100, command_zonelock) ||
|
command_add("zonelock", "[List|Lock|Unlock] [Zone ID|Zone Short Name] - Set or get lock status of a Zone by ID or Short Name", 100, command_zonelock) ||
|
||||||
command_add("zoneshutdown", "[shortname] - Shut down a zone server", 150, command_zoneshutdown) ||
|
command_add("zoneshutdown", "[shortname] - Shut down a zone server", 150, command_zoneshutdown) ||
|
||||||
command_add("zonespawn", "- Not implemented", 250, command_zonespawn) ||
|
command_add("zonespawn", "- Not implemented", 250, command_zonespawn) ||
|
||||||
command_add("zonestatus", "- Show connected zoneservers, synonymous with /servers", 150, command_zonestatus) ||
|
command_add("zonestatus", "- Show connected zoneservers, synonymous with /servers", 150, command_zonestatus) ||
|
||||||
@ -5757,40 +5757,56 @@ void command_equipitem(Client *c, const Seperator *sep)
|
|||||||
|
|
||||||
void command_zonelock(Client *c, const Seperator *sep)
|
void command_zonelock(Client *c, const Seperator *sep)
|
||||||
{
|
{
|
||||||
|
int arguments = sep->argnum;
|
||||||
|
if (!arguments) {
|
||||||
|
c->Message(Chat::White, "Usage: #zonelock list - Lists Locked Zones");
|
||||||
|
if (c->Admin() >= commandLockZones) {
|
||||||
|
c->Message(Chat::White, "Usage: #zonelock lock [Zone ID] or #zonelock lock [Zone Short Name] - Locks a Zone by ID or Short Name");
|
||||||
|
c->Message(Chat::White, "Usage: #zonelock unlock [Zone ID] or #zonelock unlock [Zone Short Name] - Unlocks a Zone by ID or Short Name");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string lock_type = str_tolower(sep->arg[1]);
|
||||||
|
bool is_list = lock_type.find("list") != std::string::npos;
|
||||||
|
bool is_lock = lock_type.find("lock") != std::string::npos;
|
||||||
|
bool is_unlock = lock_type.find("unlock") != std::string::npos;
|
||||||
|
if (!is_list && !is_lock && !is_unlock) {
|
||||||
|
c->Message(Chat::White, "Usage: #zonelock list - Lists Locked Zones");
|
||||||
|
if (c->Admin() >= commandLockZones) {
|
||||||
|
c->Message(Chat::White, "Usage: #zonelock lock [Zone ID] or #zonelock lock [Zone Short Name] - Locks a Zone by ID or Short Name");
|
||||||
|
c->Message(Chat::White, "Usage: #zonelock unlock [Zone ID] or #zonelock unlock [Zone Short Name] - Unlocks a Zone by ID or Short Name");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto pack = new ServerPacket(ServerOP_LockZone, sizeof(ServerLockZone_Struct));
|
auto pack = new ServerPacket(ServerOP_LockZone, sizeof(ServerLockZone_Struct));
|
||||||
ServerLockZone_Struct* s = (ServerLockZone_Struct*) pack->pBuffer;
|
ServerLockZone_Struct* lock_zone = (ServerLockZone_Struct*) pack->pBuffer;
|
||||||
strn0cpy(s->adminname, c->GetName(), sizeof(s->adminname));
|
strn0cpy(lock_zone->adminname, c->GetName(), sizeof(lock_zone->adminname));
|
||||||
if (strcasecmp(sep->arg[1], "list") == 0) {
|
|
||||||
s->op = 0;
|
if (is_list) {
|
||||||
|
lock_zone->op = EQ::constants::ServerLockType::List;
|
||||||
worldserver.SendPacket(pack);
|
worldserver.SendPacket(pack);
|
||||||
}
|
} else if (!is_list && c->Admin() >= commandLockZones) {
|
||||||
else if (strcasecmp(sep->arg[1], "lock") == 0 && c->Admin() >= commandLockZones) {
|
auto zone_id = (
|
||||||
uint16 tmp = ZoneID(sep->arg[2]);
|
sep->IsNumber(2) ?
|
||||||
if (tmp) {
|
static_cast<uint16>(std::stoul(sep->arg[2])) :
|
||||||
s->op = 1;
|
static_cast<uint16>(ZoneID(sep->arg[2]))
|
||||||
s->zoneID = tmp;
|
);
|
||||||
|
std::string zone_short_name = str_tolower(ZoneName(zone_id, true));
|
||||||
|
bool is_unknown_zone = zone_short_name.find("unknown") != std::string::npos;
|
||||||
|
if (zone_id && !is_unknown_zone) {
|
||||||
|
lock_zone->op = is_lock ? EQ::constants::ServerLockType::Lock : EQ::constants::ServerLockType::Unlock;
|
||||||
|
lock_zone->zoneID = zone_id;
|
||||||
worldserver.SendPacket(pack);
|
worldserver.SendPacket(pack);
|
||||||
}
|
} else {
|
||||||
else
|
c->Message(
|
||||||
c->Message(Chat::White, "Usage: #zonelock lock [zonename]");
|
Chat::White,
|
||||||
}
|
fmt::format(
|
||||||
else if (strcasecmp(sep->arg[1], "unlock") == 0 && c->Admin() >= commandLockZones) {
|
"Usage: #zonelock {} [Zone ID] or #zonelock {} [Zone Short Name]",
|
||||||
uint16 tmp = ZoneID(sep->arg[2]);
|
is_lock ? "lock" : "unlock"
|
||||||
if (tmp) {
|
).c_str()
|
||||||
s->op = 2;
|
);
|
||||||
s->zoneID = tmp;
|
|
||||||
worldserver.SendPacket(pack);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
c->Message(Chat::White, "Usage: #zonelock unlock [zonename]");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
c->Message(Chat::White, "#zonelock sub-commands");
|
|
||||||
c->Message(Chat::White, " list");
|
|
||||||
if(c->Admin() >= commandLockZones)
|
|
||||||
{
|
|
||||||
c->Message(Chat::White, " lock [zonename]");
|
|
||||||
c->Message(Chat::White, " unlock [zonename]");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
safe_delete(pack);
|
safe_delete(pack);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user