From 0da6391be319af6d4b20a13c88edce6ff03b85b9 Mon Sep 17 00:00:00 2001 From: Chris Miles Date: Mon, 6 Feb 2023 17:23:40 -0600 Subject: [PATCH] [Doors] Remove door dev tools spam on client controlled doors (#2824) * [Doors] Remove door dev tools spam on client controlled doors * Update client_packet.cpp * Update client_packet.cpp * Update ruletypes.h --- common/ruletypes.h | 1 + zone/client_packet.cpp | 35 +++++++++++++++++++++++++++-------- zone/doors.cpp | 6 +++++- 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/common/ruletypes.h b/common/ruletypes.h index 8ee53cc5a..9070d78ee 100644 --- a/common/ruletypes.h +++ b/common/ruletypes.h @@ -583,6 +583,7 @@ RULE_INT(Range, SongMessages, 75, "The packet range in which song messages are s RULE_INT(Range, ClientPositionUpdates, 300, "Distance in which the own changed position is communicated to other clients") RULE_INT(Range, CriticalDamage, 80, "The packet range in which critical hit messages are sent") RULE_INT(Range, MobCloseScanDistance, 600, "Close scan distance") +RULE_INT(Range, MaxDistanceToClickDoors, 100, "Max distance that a client can click a door from (Client says 'You can't reach that' at roughly 25-50 for most doors)") RULE_CATEGORY_END() RULE_CATEGORY(Bots) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index e4ca1a55d..f08c38303 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -4385,27 +4385,46 @@ void Client::Handle_OP_ClickDoor(const EQApplicationPacket *app) return; } - // set door selected - if (IsDevToolsEnabled()) { + float distance = DistanceNoZ(GetPosition(), currentdoor->GetPosition()); + + LogDoors( + "Door [{}] client handle, client distance from door [{:.2f}]", + currentdoor->GetDoorID(), + distance + ); + + bool within_distance = distance < RuleI(Range, MaxDistanceToClickDoors); + + // distance gate this because some doors are client controlled and the client + // will spam door click even across the zone to force a door back into desired state + if (IsDevToolsEnabled() && within_distance) { SetDoorToolEntityId(currentdoor->GetEntityID()); DoorManipulation::CommandHeader(this); Message( Chat::White, fmt::format( "Door ({}) [{}]", - currentdoor->GetEntityID(), + currentdoor->GetDoorID(), Saylink::Silent("#door edit") ).c_str() ); } - std::string export_string = fmt::format("{}", cd->doorid); - std::vector args; - args.push_back(currentdoor); - if (parse->EventPlayer(EVENT_CLICK_DOOR, this, export_string, 0, &args) == 0) - { + // don't spam scripts with client controlled doors if not within distance + if (within_distance) { + std::string export_string = fmt::format("{}", cd->doorid); + std::vector args; + args.push_back(currentdoor); + if (parse->EventPlayer(EVENT_CLICK_DOOR, this, export_string, 0, &args) == 0) { + currentdoor->HandleClick(this, 0); + } + } + else { + // we let this pass because client controlled doors require this to force the linked doors + // back into state currentdoor->HandleClick(this, 0); } + } void Client::Handle_OP_ClickObject(const EQApplicationPacket *app) diff --git a/zone/doors.cpp b/zone/doors.cpp index 550b3964a..2a4b25022 100644 --- a/zone/doors.cpp +++ b/zone/doors.cpp @@ -121,6 +121,7 @@ Doors::~Doors() bool Doors::Process() { if (m_close_timer.Enabled() && m_close_timer.Check() && IsDoorOpen()) { + LogDoorsDetail("door open and timer triggered door_id [{}] open_type [{}]", GetDoorID(), m_open_type); if (m_open_type == 40 || GetTriggerType() == 1) { auto outapp = new EQApplicationPacket(OP_MoveDoor, sizeof(MoveDoor_Struct)); MoveDoor_Struct *md = (MoveDoor_Struct *) outapp->pBuffer; @@ -627,11 +628,13 @@ void Doors::ForceOpen(Mob *sender, bool alt_mode) if (!alt_mode) { // original function if (!m_is_open) { if (!m_disable_timer) { + LogDoorsDetail("door_id [{}] starting timer", md->doorid); m_close_timer.Start(); } m_is_open = true; } else { + LogDoorsDetail("door_id [{}] disable timer", md->doorid); m_close_timer.Disable(); if (!m_disable_timer) { m_is_open = false; @@ -640,6 +643,7 @@ void Doors::ForceOpen(Mob *sender, bool alt_mode) } else { // alternative function if (!m_disable_timer) { + LogDoorsDetail("door_id [{}] alt starting timer", md->doorid); m_close_timer.Start(); } m_is_open = true; @@ -840,7 +844,7 @@ void Doors::CreateDatabaseEntry() return; } - + auto e = DoorsRepository::NewEntity(); e.id = GetDoorDBID();