From 3fd1bdbaaffc6582943e3c9b3c28c20976fcb2ad Mon Sep 17 00:00:00 2001 From: fusion32 Date: Sat, 1 Aug 2026 12:54:04 -0300 Subject: one last adjustment to `CloseContainer` (hopefully?) I've also reverted the search range of `NotifyTrades` to (12, 10), because it's just not related to `CloseContainer`. It is called before objects are moved, and on the case the object is split, it is called on the remaining part. --- src/operate.cc | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/operate.cc b/src/operate.cc index 5e2c964..93cdeee 100644 --- a/src/operate.cc +++ b/src/operate.cc @@ -998,7 +998,7 @@ void NotifyTrades(Object Obj){ return; } - TFindCreatures Search(16, 14, Obj, FIND_PLAYERS); + TFindCreatures Search(12, 10, Obj, FIND_PLAYERS); while(true){ uint32 CharacterID = Search.getNext(); if(CharacterID == 0){ @@ -1065,7 +1065,18 @@ void CloseContainer(Object Con, bool Force){ return; } - TFindCreatures Search(16, 14, Con, FIND_PLAYERS); + // IMPORTANT(fusion): The original search range was (12, 10), but it caused + // containers to remain open when a player moved them beyond it. The new range + // is the sum of: + // (7, 7) - max Z offset + // (7, 5) - max terminal distance + // (6, 4) - max walk to object distance + // (2, 2) - max distance to another player close to the container + // Considering that `CMoveObject` does a visibility check to limit the "walk + // to object distance", this should be a permanent fix. It may not be the best + // solution, but I don't want to diverge too much from the original. See `Move` + // for a complementary comment about this. + TFindCreatures Search(22, 18, Con, FIND_PLAYERS); while(true){ uint32 CharacterID = Search.getNext(); if(CharacterID == 0){ @@ -1386,7 +1397,7 @@ void Move(uint32 CreatureID, Object Obj, Object Con, int Count, bool NoMerge, Ob NotifyDepot(CreatureID, Obj, CountObjects(Obj)); } - // NOTE(fusion): `CloseContainer` checks a small region around the object, + // IMPORTANT(fusion): `CloseContainer` checks a fixed region around the object, // related to the terminal width/height, so calling it once at the end should // be enough when the movement is done by a creature (CreatureID != 0). // The other case (when the movement is done by a script, spell, etc...) can -- cgit v1.2.3