From 8be57ce9ebacee2ca2e36bbc796afabd4c2bb552 Mon Sep 17 00:00:00 2001 From: Emagi Date: Wed, 18 Jun 2025 18:28:39 -0400 Subject: [PATCH] #35 world peering limit client to one character active, only recover linkdead --- source/WorldServer/Web/PeerManager.h | 2 +- source/WorldServer/World.cpp | 7 ++++--- source/WorldServer/World.h | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/source/WorldServer/Web/PeerManager.h b/source/WorldServer/Web/PeerManager.h index 8600976..aa603cb 100644 --- a/source/WorldServer/Web/PeerManager.h +++ b/source/WorldServer/Web/PeerManager.h @@ -176,7 +176,7 @@ public: void setZonePeerDataSelf(ZoneChangeDetails* opt_details, std::string zoneFileName, std::string zoneName, int32 zoneId, int32 instanceId, float safeX, float safeY, float safeZ, float safeHeading, bool lockState, sint16 minStatus, int16 minLevel, int16 maxLevel, int16 minVersion, int32 defaultLockoutTime, int32 defaultReenterTime, int8 instanceType, int32 numPlayers, bool isCityZone, void* zonePtr = nullptr); - bool IsClientConnectedPeer(int32 account_id); + bool IsClientConnectedPeer(int32 account_id, int32 char_id); std::string GetCharacterPeerId(std::string charName); void SendPeersChannelMessage(int32 group_id, std::string fromName, std::string message, int16 channel, int32 language_id = 0, int8 custom_type = 0); void SendPeersGuildChannelMessage(int32 guild_id, std::string fromName, std::string message, int16 channel, int32 language_id = 0, int8 custom_type = 0); diff --git a/source/WorldServer/World.cpp b/source/WorldServer/World.cpp index e2bdbc3..7e76c66 100644 --- a/source/WorldServer/World.cpp +++ b/source/WorldServer/World.cpp @@ -911,7 +911,7 @@ bool ZoneList::GetZoneByInstance(ZoneChangeDetails* zone_details, int32 instance return (tmp != nullptr) ? true : false; } -bool PeerManager::IsClientConnectedPeer(int32 account_id) { +bool PeerManager::IsClientConnectedPeer(int32 account_id, int32 char_id) { for (auto& [peerId, peer] : peers) { if(peer->healthCheck.status != HealthStatus::OK) continue; @@ -920,6 +920,7 @@ bool PeerManager::IsClientConnectedPeer(int32 account_id) { for (const auto& zone : peer->client_tree->get_child("Clients")) { // Access each field within the current zone int32 client_acct_id = zone.second.get("account_id"); + int32 in_character_id = zone.second.get("character_id"); bool is_linkdead = zone.second.get("is_linkdead"); bool is_zoning = zone.second.get("is_zoning"); bool in_zone = zone.second.get("in_zone"); @@ -927,7 +928,7 @@ bool PeerManager::IsClientConnectedPeer(int32 account_id) { if(client_acct_id == account_id) { if(is_zoning) return true; - else if(is_linkdead) + else if(is_linkdead && in_character_id == char_id) return false; else if(in_zone) return true; @@ -1306,7 +1307,7 @@ bool ZoneList::ClientConnected(int32 account_id, int32 char_id){ } } if(!ret) { - ret = peer_manager.IsClientConnectedPeer(account_id); + ret = peer_manager.IsClientConnectedPeer(account_id, char_id); } MClientList.unlock(); return ret; diff --git a/source/WorldServer/World.h b/source/WorldServer/World.h index 707e3b1..3f1986b 100644 --- a/source/WorldServer/World.h +++ b/source/WorldServer/World.h @@ -455,7 +455,7 @@ class ZoneList { bool GetZone(ZoneChangeDetails* zone_details, int32 opt_zone_id, std::string opt_zone_name = "", bool loadZone = true, bool skip_existing_zones = false, bool increment_zone = true, bool check_peers = true, bool check_instances = false, bool only_always_loaded = false, bool skip_self = false, bool duplicated_zone = false, int32 minLevel = 0, int32 maxLevel = 0, int32 avgLevel = 0, int32 firstLevel = 0); bool GetZoneByInstance(ZoneChangeDetails* zone_details, int32 instance_id, int32 zone_id = 0, bool loadZone = true, bool skip_existing_zones = false, bool increment_zone = true, bool check_peers = true, int32 minLevel = 0, int32 maxLevel = 0, int32 avgLevel = 0, int32 firstLevel = 0); - bool IsClientConnectedPeer(int32 account_id); + bool IsClientConnectedPeer(int32 account_id, int32 char_id); //ZoneServer* Get(int32 id, bool loadZone = true, bool skip_existing_zones = false, bool increment_zone = true); //ZoneServer* Get(const char* zone_name, bool loadZone=true, bool skip_existing_zones = false, bool increment_zone = true); //ZoneServer* GetByInstanceID(int32 id, int32 zone_id=0, bool skip_existing_zones = false, bool increment_zone = true);