[Zone] Implement zone player count sharding (#4536)

* [Zone] Implement zone player count sharding

* Update client.cpp

* Update database_instances.cpp

* You must request a shard change from the zone you are currently in.

* // zone sharding

* You cannot request a shard change while in combat.

* Query adjustment

* Use safe coords

* Changes

* Fixes to instance query

* Push

* Push

* Final push

* Update client.cpp

* Update eq_packet_structs.h

* Remove pick menu

* Comment

* Update character_data_repository.h

* Update zoning.cpp

---------

Co-authored-by: Kinglykrab <kinglykrab@gmail.com>
This commit is contained in:
Chris Miles
2025-01-08 17:41:16 -06:00
committed by GitHub
parent 15684567cf
commit c82f1b9afc
22 changed files with 443 additions and 22 deletions
+56 -8
View File
@@ -13037,19 +13037,19 @@ void Client::ClientToNpcAggroProcess()
const std::vector<int16>& Client::GetInventorySlots()
{
static const std::vector<std::pair<int16, int16>> slots = {
{ EQ::invslot::POSSESSIONS_BEGIN, EQ::invslot::POSSESSIONS_END },
{ EQ::invbag::GENERAL_BAGS_BEGIN, EQ::invbag::GENERAL_BAGS_END },
{ EQ::invbag::CURSOR_BAG_BEGIN, EQ::invbag::CURSOR_BAG_END },
{ EQ::invslot::BANK_BEGIN, EQ::invslot::BANK_END },
{ EQ::invbag::BANK_BAGS_BEGIN, EQ::invbag::BANK_BAGS_END },
{ EQ::invslot::SHARED_BANK_BEGIN, EQ::invslot::SHARED_BANK_END },
{ EQ::invbag::SHARED_BANK_BAGS_BEGIN, EQ::invbag::SHARED_BANK_BAGS_END },
{EQ::invslot::POSSESSIONS_BEGIN, EQ::invslot::POSSESSIONS_END},
{EQ::invbag::GENERAL_BAGS_BEGIN, EQ::invbag::GENERAL_BAGS_END},
{EQ::invbag::CURSOR_BAG_BEGIN, EQ::invbag::CURSOR_BAG_END},
{EQ::invslot::BANK_BEGIN, EQ::invslot::BANK_END},
{EQ::invbag::BANK_BAGS_BEGIN, EQ::invbag::BANK_BAGS_END},
{EQ::invslot::SHARED_BANK_BEGIN, EQ::invslot::SHARED_BANK_END},
{EQ::invbag::SHARED_BANK_BAGS_BEGIN, EQ::invbag::SHARED_BANK_BAGS_END},
};
static std::vector<int16> slot_ids;
if (slot_ids.empty()) {
for (const auto& [begin, end] : slots) {
for (const auto &[begin, end]: slots) {
for (int16 slot_id = begin; slot_id <= end; ++slot_id) {
slot_ids.emplace_back(slot_id);
}
@@ -13058,3 +13058,51 @@ const std::vector<int16>& Client::GetInventorySlots()
return slot_ids;
}
void Client::ShowZoneShardMenu()
{
auto z = GetZone(GetZoneID());
if (z && !z->shard_at_player_count) {
return;
}
auto results = CharacterDataRepository::GetInstanceZonePlayerCounts(database, GetZoneID());
LogZoning("Zone sharding results count [{}]", results.size());
if (results.empty()) {
Message(Chat::White, "No zone shards found.");
return;
}
if (!results.empty()) {
Message(Chat::White, "Available Zone Shards:");
}
int number = 1;
for (auto &e: results) {
std::string teleport_link = Saylink::Silent(
fmt::format("#zoneshard {} {}", e.zone_id, (e.instance_id == 0 ? -1 : e.instance_id)),
"Teleport"
);
std::string yours;
if (e.zone_id == GetZoneID() && e.instance_id == GetInstanceID()) {
teleport_link = "Teleport";
yours = " (Yours)";
}
Message(
Chat::White, fmt::format(
" --> [{}] #{} {} ({}) [{}/{}] players {}",
teleport_link,
number,
z->long_name,
e.instance_id,
e.player_count,
z->shard_at_player_count,
yours
).c_str()
);
number++;
}
}