mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 16:51:29 +00:00
[Commands] Cleanup #zone and #zoneinstance Commands. (#2202)
* [Commands] Cleanup #zone and #zoneinstance Commands. - Cleanup messages and logic. - Broke these commands out in to their own files. * Update database.cpp * Update database.cpp * Update database.cpp
This commit is contained in:
parent
7072b5721b
commit
275995a374
@ -50,6 +50,8 @@
|
||||
#include "http/httplib.h"
|
||||
#include "http/uri.h"
|
||||
|
||||
#include "repositories/zone_repository.h"
|
||||
|
||||
extern Client client;
|
||||
|
||||
Database::Database () {
|
||||
@ -2496,3 +2498,16 @@ void Database::SourceDatabaseTableFromUrl(std::string table_name, std::string ur
|
||||
}
|
||||
}
|
||||
|
||||
uint8 Database::GetMinStatus(uint32 zone_id, uint32 instance_version)
|
||||
{
|
||||
auto zones = ZoneRepository::GetWhere(
|
||||
*this,
|
||||
fmt::format(
|
||||
"zoneidnumber = {} AND (version = {} OR version = 0) ORDER BY version DESC LIMIT 1",
|
||||
zone_id,
|
||||
instance_version
|
||||
)
|
||||
);
|
||||
|
||||
return !zones.empty() ? zones[0].min_status : 0;
|
||||
}
|
||||
|
||||
@ -252,6 +252,7 @@ public:
|
||||
bool LoadPTimers(uint32 charid, PTimerList &into);
|
||||
|
||||
uint8 GetPEQZone(uint32 zone_id, uint32 version);
|
||||
uint8 GetMinStatus(uint32 zone_id, uint32 instance_version);
|
||||
uint8 GetRaceSkill(uint8 skillid, uint8 in_race);
|
||||
uint8 GetServerType();
|
||||
uint8 GetSkillCap(uint8 skillid, uint8 in_race, uint8 in_class, uint16 in_level);
|
||||
|
||||
117
zone/command.cpp
117
zone/command.cpp
@ -378,9 +378,9 @@ int command_init(void)
|
||||
command_add("zclip", "[Minimum Clip] [Maximum Clip] [Fog Minimum Clip] [Fog Maximum Clip] [Permanent (0 = False, 1 = True)] - Change zone clipping", AccountStatus::QuestTroupe, command_zclip) ||
|
||||
command_add("zcolor", "[Red] [Green] [Blue] [Permanent (0 = False, 1 = True)] - Change sky color", AccountStatus::QuestTroupe, command_zcolor) ||
|
||||
command_add("zheader", "[Zone ID|Zone Short Name] [Version] - Load a zone header from the database", AccountStatus::QuestTroupe, command_zheader) ||
|
||||
command_add("zone", "[zonename] [x] [y] [z] - Go to specified zone (coords optional)", AccountStatus::Guide, command_zone) ||
|
||||
command_add("zone", "[Zone ID|Zone Short Name] [X] [Y] [Z] - Teleport to specified Zone by ID or Short Name (coordinates are optional)", AccountStatus::Guide, command_zone) ||
|
||||
command_add("zonebootup", "[ZoneServerID] [shortname] - Make a zone server boot a specific zone", AccountStatus::GMLeadAdmin, command_zonebootup) ||
|
||||
command_add("zoneinstance", "[instanceid] [x] [y] [z] - Go to specified instance zone (coords optional)", AccountStatus::Guide, command_zone_instance) ||
|
||||
command_add("zoneinstance", "[Instance ID] [X] [Y] [Z] - Teleport to specified Instance by ID (coordinates are optional)", AccountStatus::Guide, command_zone_instance) ||
|
||||
command_add("zonelock", "[List|Lock|Unlock] [Zone ID|Zone Short Name] - Set or get lock status of a Zone by ID or Short Name", AccountStatus::GMAdmin, command_zonelock) ||
|
||||
command_add("zoneshutdown", "[shortname] - Shut down a zone server", AccountStatus::GMLeadAdmin, command_zoneshutdown) ||
|
||||
command_add("zonestatus", "- Show connected zoneservers, synonymous with /servers", AccountStatus::GMLeadAdmin, command_zonestatus) ||
|
||||
@ -635,117 +635,6 @@ void command_help(Client *c, const Seperator *sep)
|
||||
|
||||
}
|
||||
|
||||
void command_zone(Client *c, const Seperator *sep)
|
||||
{
|
||||
if(c->Admin() < commandZoneToCoords &&
|
||||
(sep->IsNumber(2) || sep->IsNumber(3) || sep->IsNumber(4))) {
|
||||
c->Message(Chat::White, "Your status is not high enough to zone to specific coordinates.");
|
||||
return;
|
||||
}
|
||||
|
||||
uint16 zoneid = 0;
|
||||
|
||||
if (sep->IsNumber(1))
|
||||
{
|
||||
if(atoi(sep->arg[1])==26 && (c->Admin() < commandZoneToSpecials)){ //cshome
|
||||
c->Message(Chat::White, "Only Guides and above can goto that zone.");
|
||||
return;
|
||||
}
|
||||
zoneid = atoi(sep->arg[1]);
|
||||
}
|
||||
else if (sep->arg[1][0] == 0)
|
||||
{
|
||||
c->Message(Chat::White, "Usage: #zone [zonename]");
|
||||
c->Message(Chat::White, "Optional Usage: #zone [zonename] y x z");
|
||||
return;
|
||||
}
|
||||
else if (zone->GetZoneID() == 184 && c->Admin() < commandZoneToSpecials) { // Zone: 'Load'
|
||||
c->Message(Chat::White, "The Gods brought you here, only they can send you away.");
|
||||
return;
|
||||
} else {
|
||||
if((strcasecmp(sep->arg[1], "cshome")==0) && (c->Admin() < commandZoneToSpecials)){
|
||||
c->Message(Chat::White, "Only Guides and above can goto that zone.");
|
||||
return;
|
||||
}
|
||||
|
||||
zoneid = ZoneID(sep->arg[1]);
|
||||
if(zoneid == 0) {
|
||||
c->Message(Chat::White, "Unable to locate zone '%s'", sep->arg[1]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef BOTS
|
||||
// This block is necessary to clean up any bot objects owned by a Client
|
||||
if(zoneid != c->GetZoneID())
|
||||
Bot::ProcessClientZoneChange(c);
|
||||
#endif
|
||||
|
||||
if (sep->IsNumber(2) || sep->IsNumber(3) || sep->IsNumber(4)){
|
||||
//zone to specific coords
|
||||
c->MovePC(zoneid, (float)atof(sep->arg[2]), atof(sep->arg[3]), atof(sep->arg[4]), 0.0f, 0);
|
||||
}
|
||||
else
|
||||
//zone to safe coords
|
||||
c->MovePC(zoneid, 0.0f, 0.0f, 0.0f, 0.0f, 0, ZoneToSafeCoords);
|
||||
}
|
||||
|
||||
//todo: fix this so it checks if you're in the instance set
|
||||
void command_zone_instance(Client *c, const Seperator *sep)
|
||||
{
|
||||
if(c->Admin() < commandZoneToCoords &&
|
||||
(sep->IsNumber(2) || sep->IsNumber(3) || sep->IsNumber(4))) {
|
||||
c->Message(Chat::White, "Your status is not high enough to zone to specific coordinates.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (sep->arg[1][0] == 0)
|
||||
{
|
||||
c->Message(Chat::White, "Usage: #zoneinstance [instance id]");
|
||||
c->Message(Chat::White, "Optional Usage: #zoneinstance [instance id] y x z");
|
||||
return;
|
||||
}
|
||||
|
||||
uint16 zoneid = 0;
|
||||
uint16 instanceid = 0;
|
||||
|
||||
if(sep->IsNumber(1))
|
||||
{
|
||||
instanceid = atoi(sep->arg[1]);
|
||||
if(!instanceid)
|
||||
{
|
||||
c->Message(Chat::White, "Must enter a valid instance id.");
|
||||
return;
|
||||
}
|
||||
|
||||
zoneid = database.ZoneIDFromInstanceID(instanceid);
|
||||
if(!zoneid)
|
||||
{
|
||||
c->Message(Chat::White, "Instance not found or zone is set to null.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
c->Message(Chat::White, "Must enter a valid instance id.");
|
||||
return;
|
||||
}
|
||||
|
||||
if(!database.VerifyInstanceAlive(instanceid, c->CharacterID()))
|
||||
{
|
||||
c->Message(Chat::White, "Instance ID expiried or you are not apart of this instance.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (sep->IsNumber(2) || sep->IsNumber(3) || sep->IsNumber(4)){
|
||||
//zone to specific coords
|
||||
c->MovePC(zoneid, instanceid, atof(sep->arg[2]), atof(sep->arg[3]), atof(sep->arg[4]), 0.0f, 0);
|
||||
}
|
||||
else{
|
||||
c->MovePC(zoneid, instanceid, 0.0f, 0.0f, 0.0f, 0.0f, 0, ZoneToSafeCoords);
|
||||
}
|
||||
}
|
||||
|
||||
void command_spawneditmass(Client *c, const Seperator *sep)
|
||||
{
|
||||
std::string query = fmt::format(
|
||||
@ -1355,10 +1244,12 @@ void command_bot(Client *c, const Seperator *sep)
|
||||
#include "gm_commands/zclip.cpp"
|
||||
#include "gm_commands/zcolor.cpp"
|
||||
#include "gm_commands/zheader.cpp"
|
||||
#include "gm_commands/zone.cpp"
|
||||
#include "gm_commands/zonebootup.cpp"
|
||||
#include "gm_commands/zonelock.cpp"
|
||||
#include "gm_commands/zoneshutdown.cpp"
|
||||
#include "gm_commands/zonestatus.cpp"
|
||||
#include "gm_commands/zone_instance.cpp"
|
||||
#include "gm_commands/zopp.cpp"
|
||||
#include "gm_commands/zsafecoords.cpp"
|
||||
#include "gm_commands/zsave.cpp"
|
||||
|
||||
56
zone/gm_commands/zone.cpp
Normal file
56
zone/gm_commands/zone.cpp
Normal file
@ -0,0 +1,56 @@
|
||||
#include "../client.h"
|
||||
|
||||
void command_zone(Client *c, const Seperator *sep)
|
||||
{
|
||||
int arguments = sep->argnum;
|
||||
if (!arguments) {
|
||||
c->Message(Chat::White, "Usage: #zone [Zone ID|Zone Short Name] [X] [Y] [Z]");
|
||||
return;
|
||||
}
|
||||
|
||||
auto zone_id = (
|
||||
sep->IsNumber(1) ?
|
||||
std::stoul(sep->arg[1]) :
|
||||
ZoneID(sep->arg[1])
|
||||
);
|
||||
auto zone_short_name = ZoneName(zone_id);
|
||||
if (
|
||||
!zone_id ||
|
||||
!zone_short_name
|
||||
) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"No zones were found matching '{}'.",
|
||||
sep->arg[1]
|
||||
).c_str()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
auto min_status = database.GetMinStatus(zone_id, 0);
|
||||
if (c->Admin() < min_status) {
|
||||
c->Message(Chat::White, "Your status is not high enough to go to this zone.");
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef BOTS
|
||||
// This block is necessary to clean up any bot objects owned by a Client
|
||||
if (zone_id != c->GetZoneID()) {
|
||||
Bot::ProcessClientZoneChange(c);
|
||||
}
|
||||
#endif
|
||||
|
||||
auto x = sep->IsNumber(2) ? std::stof(sep->arg[2]) : 0.0f;
|
||||
auto y = sep->IsNumber(3) ? std::stof(sep->arg[3]) : 0.0f;
|
||||
auto z = sep->IsNumber(4) ? std::stof(sep->arg[4]) : 0.0f;
|
||||
|
||||
c->MovePC(
|
||||
zone_id,
|
||||
x,
|
||||
y,
|
||||
z,
|
||||
0.0f,
|
||||
sep->IsNumber(2) ? 0 : ZoneToSafeCoords
|
||||
);
|
||||
}
|
||||
70
zone/gm_commands/zone_instance.cpp
Normal file
70
zone/gm_commands/zone_instance.cpp
Normal file
@ -0,0 +1,70 @@
|
||||
#include "../client.h"
|
||||
|
||||
void command_zone_instance(Client *c, const Seperator *sep)
|
||||
{
|
||||
int arguments = sep->argnum;
|
||||
if (!arguments || !sep->IsNumber(1)) {
|
||||
c->Message(Chat::White, "Usage: #zoneinstance [Instance ID] [X] [Y] [Z]");
|
||||
return;
|
||||
}
|
||||
|
||||
auto instance_id = std::stoul(sep->arg[1]);
|
||||
if (!instance_id) {
|
||||
c->Message(Chat::White, "You must enter a valid instance id.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!database.CheckInstanceExists(instance_id)) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Instance ID {} does not exist.",
|
||||
instance_id
|
||||
).c_str()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
auto zone_id = database.ZoneIDFromInstanceID(instance_id);
|
||||
if (!zone_id) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Instance ID {} not found or zone is set to null.",
|
||||
instance_id
|
||||
).c_str()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (database.CharacterInInstanceGroup(instance_id, c->CharacterID())) {
|
||||
c->Message(Chat::White, "You are already a part of this instance, sending you there.");
|
||||
c->MoveZoneInstance(instance_id);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!database.VerifyInstanceAlive(instance_id, c->CharacterID())) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Instance ID {} expired or you are not apart of this instance.",
|
||||
instance_id
|
||||
).c_str()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
auto x = sep->IsNumber(2) ? std::stof(sep->arg[2]) : 0.0f;
|
||||
auto y = sep->IsNumber(3) ? std::stof(sep->arg[3]) : 0.0f;
|
||||
auto z = sep->IsNumber(4) ? std::stof(sep->arg[4]) : 0.0f;
|
||||
|
||||
c->MovePC(
|
||||
zone_id,
|
||||
instance_id,
|
||||
x,
|
||||
y,
|
||||
z,
|
||||
0.0f,
|
||||
sep->IsNumber(2) ? 0 : ZoneToSafeCoords
|
||||
);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user