mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 21:01:29 +00:00
* [Quest API] Add Instance Methods to Perl/Lua. # Perl - Add `quest::GetInstanceIDs(zone_name)`. - Add `quest::GetInstanceIDsByCharID(zone_name, character_id)`. - Add `quest::GetInstanceVersionByID(instance_id)`. - Add `quest::GetInstanceZoneIDByID(instance_id)`. # Lua - Add `eq.get_instance_ids(zone_name)`. - Add `eq.get_instance_ids_by_char_id(zone_name, character_id)`. - Add `eq.get_instance_version_by_id(instance_id)`. - Add `eq.get_instance_zone_id_by_id(instance_id)`. # Notes - The instance IDs methods return arrays of IDs for looping so you can check on mass the instances a player has for a zone. - Keeps operators from having to guess which possible versions of a zone a player has an instance for or loop through them all to find out. - Cleanup `common/database_instances.cpp` to mostly use repositories where possible. * Update database.h * Update character_corpses_repository.h
71 lines
1.4 KiB
C++
71 lines
1.4 KiB
C++
#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.GetInstanceZoneID(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.CheckInstanceByCharID(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.",
|
|
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;
|
|
auto zone_mode = sep->IsNumber(2) ? ZoneSolicited : ZoneToSafeCoords;
|
|
|
|
c->MovePC(
|
|
zone_id,
|
|
instance_id,
|
|
x,
|
|
y,
|
|
z,
|
|
0.0f,
|
|
0,
|
|
zone_mode
|
|
);
|
|
}
|