eqemu-server/zone/gm_commands/show/show_spawn_status.cpp
Alex c84df0d5ba
Some checks are pending
Build / Linux (push) Waiting to run
Build / Windows (push) Waiting to run
Build Improvements (#5033)
* Start rewrite, add vcpkg

* Simple vcpkg manifest, will almost certainly need tweaking

* Remove cmake ext we wont be using anymore

* Update vcpkg to no longer be from 2022, update cmake lists (wip)

* Add finds to the toplevel cmakelists

* WIP, luabind and perlbind build.  Common only partially builds.

* Fix common build.

* shared_memory compiles

* client files compile

* Tests and more cmake version updates

* World, had to swap out zlib-ng for now because it wasn't playing nicely along side the zlib install.  May revisit.

* UCS compiles now too!

* queryserv and eqlaunch

* loginserver works

* Zone works but is messy, tomorrow futher cleanup!

* Cleanup main file

* remove old zlibng, remove perlwrap, remove hc

* More cleanup

* vcpkg baseline set for CI

* Remove pkg-config, it's the suggested way to use luajit with vcpkg but it causes issues with CI and might be a pain point for windows users

* Actually add file

* Set perlbind include dir

* Perl link got lost

* PERL_SET_INTERP causes an issue on newer versions of perl on windows because a symbol is not properly exported in their API, change the lines so it's basically what it used to be

* Remove static unix linking, we dont do automated released anymore and this was tightly coupled to that.  Can explore this again if we decide to change that.

* Remove unused submodules, set cmake policy for boost

* Fix some cereal includes

* Improve some boilerplate, I'd still like to do better about getting linker stuff set.

* Going through and cleaning up the build.

* Fix world, separate out data_buckets.

* add fixes for other servers

* fix zone

* Fix client files, loginserver and tests

* Newer versions of libmariadb default to tls forced on, return to the default of not forcing that.
auto_login were breaking on linux builds
loginserver wasn't setting proper openssl compile flag

* Move set out of a giant cpp file include.

* Convert show

* convert find

* Add uuid to unix builds

* Remove some cpp includes.

* Restructure to remove more things.

* change db update manifest to header
change build yml

* Move world CLI include cpps to cmake.

* Move zone cli out of source and into cmake

* Sidecar stuff wont directly include cpp files now too.

* Fix uuid-dev missing on linux runner

* Reorg common cmake file

* Some cleanup

* Fix libsodium support (oops). Fix perl support (more oops)

* Change doc

---------

Co-authored-by: KimLS <KimLS@peqtgc.com>
2025-12-13 19:56:37 -08:00

148 lines
3.3 KiB
C++

#include "../../client.h"
void ShowSpawnStatus(Client *c, const Seperator *sep)
{
const auto arguments = sep->argnum;
if (arguments < 2) {
c->Message(Chat::White, "Usage: #show spawn_status all - Show all spawn statuses for your current zone");
c->Message(Chat::White, "Usage: #show spawn_status disabled - Show all disabled spawn statuses for your current zone");
c->Message(Chat::White, "Usage: #show spawn_status enabled - Show all enabled spawn statuses for your current zone");
c->Message(Chat::White, "Usage: #show spawn_status [Spawn ID] - Show spawn status by ID for your current zone");
return;
}
const bool is_all = !strcasecmp(sep->arg[2], "all");
const bool is_disabled = !strcasecmp(sep->arg[2], "disabled");
const bool is_enabled = !strcasecmp(sep->arg[2], "enabled");
const bool is_search = sep->IsNumber(2);
if (
!is_all &&
!is_disabled &&
!is_enabled &&
!is_search
) {
c->Message(Chat::White, "Usage: #show spawn_status all - Show all spawn statuses for your current zone");
c->Message(Chat::White, "Usage: #show spawn_status disabled - Show all disabled spawn statuses for your current zone");
c->Message(Chat::White, "Usage: #show spawn_status enabled - Show all enabled spawn statuses for your current zone");
c->Message(Chat::White, "Usage: #show spawn_status [Spawn ID] - Show spawn status by ID for your current zone");
return;
}
std::string filter_type;
if (is_disabled) {
filter_type = "Disabled";
} else if (is_enabled) {
filter_type = "Enabled";
}
const uint32 spawn_id = (
is_search ?
Strings::ToUnsignedInt(sep->arg[2]) :
0
);
LinkedListIterator<Spawn2*> iterator(zone->spawn2_list);
iterator.Reset();
uint32 filtered_count = 0;
uint32 spawn_count = 0;
uint32 spawn_number = 1;
while (iterator.MoreElements()) {
const auto& e = iterator.GetData();
const uint32 time_remaining = e->GetTimer().GetRemainingTime();
if (
is_all ||
(
is_disabled &&
time_remaining == UINT32_MAX
) ||
(
is_enabled &&
time_remaining != UINT32_MAX
) ||
(
is_search &&
e->GetID() == spawn_id
)
) {
c->Message(
Chat::White,
fmt::format(
"Spawn {} | ID: {} Coordinates: {:.2f}, {:.2f}, {:.2f}, {:.2f}",
spawn_number,
e->GetID(),
e->GetX(),
e->GetY(),
e->GetZ(),
e->GetHeading()
).c_str()
);
if (time_remaining != UINT32_MAX) {
const uint32 seconds_remaining = (time_remaining / 1000);
c->Message(
Chat::White,
fmt::format(
"Spawn {} | Respawn: {}",
spawn_number,
Strings::SecondsToTime(seconds_remaining)
).c_str()
);
}
filtered_count++;
spawn_number++;
}
spawn_count++;
iterator.Advance();
}
if (!spawn_count) {
c->Message(Chat::White, "No spawns were found.");
return;
}
if (
(is_disabled || is_enabled) &&
!filtered_count
) {
c->Message(
Chat::White,
fmt::format(
"No {} spawns were found.",
filter_type
).c_str()
);
return;
}
if (is_all) {
c->Message(
Chat::White,
fmt::format(
"{} Spawn{} found.",
spawn_count,
spawn_count != 1 ? "s" : ""
).c_str()
);
return;
}
c->Message(
Chat::White,
fmt::format(
"{} of {} spawn{} found.",
filtered_count,
spawn_count,
spawn_count != 1 ? "s" : ""
).c_str()
);
}