[Bug Fix] Fix MovePC in #zone and #zoneinstance Commands. (#2236)

* [Bug Fix] Fix MovePC in #zone and #zoneinstance COmmands.

* #zone 0 Optional Functionality.
This commit is contained in:
Kinglykrab 2022-06-01 17:05:43 -04:00 committed by GitHub
parent 57ac46d090
commit 38da37755d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 18 deletions

View File

@ -8,21 +8,34 @@ void command_zone(Client *c, const Seperator *sep)
return;
}
std::string zone_identifier = sep->arg[1];
if (StringIsNumber(zone_identifier) && zone_identifier == "0") {
c->Message(Chat::White, "Sending you to the safe coordinates of this zone.");
c->MovePC(
0.0f,
0.0f,
0.0f,
0.0f,
0,
ZoneToSafeCoords
);
return;
}
auto zone_id = (
sep->IsNumber(1) ?
std::stoul(sep->arg[1]) :
ZoneID(sep->arg[1])
std::stoul(zone_identifier) :
ZoneID(zone_identifier)
);
auto zone_short_name = ZoneName(zone_id);
if (
!zone_id ||
!zone_short_name
) {
if (!zone_id || !zone_short_name) {
c->Message(
Chat::White,
fmt::format(
"No zones were found matching '{}'.",
sep->arg[1]
zone_identifier
).c_str()
);
return;
@ -44,6 +57,7 @@ void command_zone(Client *c, const Seperator *sep)
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;
auto zone_mode = sep->IsNumber(2) ? ZoneSolicited : ZoneToSafeCoords;
c->MovePC(
zone_id,
@ -51,6 +65,7 @@ void command_zone(Client *c, const Seperator *sep)
y,
z,
0.0f,
sep->IsNumber(2) ? 0 : ZoneToSafeCoords
0,
zone_mode
);
}
}

View File

@ -10,7 +10,7 @@ void command_zone_instance(Client *c, const Seperator *sep)
auto instance_id = std::stoul(sep->arg[1]);
if (!instance_id) {
c->Message(Chat::White, "You must enter a valid instance id.");
c->Message(Chat::White, "You must enter a valid Instance ID.");
return;
}
@ -36,18 +36,16 @@ void command_zone_instance(Client *c, const Seperator *sep)
);
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.CharacterInInstanceGroup(instance_id, c->CharacterID())) {
database.AddClientToInstance(instance_id, c->CharacterID());
}
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 {} expired.",
instance_id
).c_str()
);
@ -57,6 +55,7 @@ void command_zone_instance(Client *c, const Seperator *sep)
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;
auto zone_mode = sep->IsNumber(2) ? ZoneSolicited : ZoneToSafeCoords;
c->MovePC(
zone_id,
@ -65,6 +64,7 @@ void command_zone_instance(Client *c, const Seperator *sep)
y,
z,
0.0f,
sep->IsNumber(2) ? 0 : ZoneToSafeCoords
0,
zone_mode
);
}