fix(teleport): prevent recursive teleport loops - #3818
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
adfacc8 to
454ed06
Compare
454ed06 to
81bb4b6
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/game/game.cpp`:
- Around line 2930-2951: Remove the duplicate recursion check by deleting the
initial if (teleportStack.contains(teleportThing)) block and rely solely on the
insert() result: call teleportStack.insert(teleportThing) and check the inserted
flag (it->second / inserted) to detect recursion; if insertion fails, log the
same detailed messages using thing->getCreature(), thing->getItem(), g_logger()
and __FUNCTION__ and return RETURNVALUE_NOTPOSSIBLE. Ensure teleportThing,
teleportStack and the existing logging branches remain unchanged so behavior and
messages are identical when recursion is detected.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/game/game.cpp`:
- Around line 2935-2951: The code has a duplicate declaration of
teleportStackGuard which causes a build error; remove the second declaration and
keep a single unique_ptr named teleportStackGuard constructed with teleportThing
and the InternalGame::TeleportStackCleaner deleter (references:
teleportStackGuard, teleportThing, InternalGame::TeleportStackCleaner) so only
one guard instance exists in the scope.
9052ef1 to
d72291e
Compare
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/game/game.cpp`:
- Around line 2934-2944: The current teleport recursion guard
(InternalGame::tryInsertTeleportStack) only blocks re-entrancy in the same stack
but allows infinite loops via event-scheduled teleports; add a per-Thing
cooldown or rate-limiter (for example a lastTeleportTime map keyed by Thing
pointer/id handled in InternalGame or Game class) and check/update it at the
start of the teleport routine (before calling tryInsertTeleportStack) to reject
teleports that occur inside the cooldown window, and remove the duplicate
teleportStackGuard declaration (the redundant teleportStackGuard symbol present
near the teleport logic) so only the single intended guard remains; ensure you
reference and update the same Thing identity used by getCreature()/getItem()
checks when applying cooldown.
5491a39 to
7d2f20a
Compare
|
✅ Updated vcpkg baseline to 2026.01.16 ( |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
✅ Updated vcpkg baseline to 2026.01.16 ( |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@vcpkg.json`:
- Line 35: The "builtin-baseline" value currently set to commit hash
23dc124705fcac41cf35c33dd9541f5094a9c19f is invalid; update the vcpkg baseline
by replacing the "builtin-baseline" value with a valid commit hash from the
official microsoft/vcpkg repository (e.g., pick a known good upstream commit SHA
or the recommended baseline for your vcpkg version), ensuring the key
"builtin-baseline" in vcpkg.json is updated to that valid commit so dependency
resolution succeeds.
|
✅ Updated vcpkg baseline to 2026.01.16 ( |
|
|
This PR is stale because it has been open 45 days with no activity. |
|
Merges 4 upstream commits from main: - fix(container) opentibiabr#3995: page-index bounds clamp in sendBatchUpdateContainer, isNearDepotBox() → const, shouldCloseContainer depot proximity fix - fix(teleport) opentibiabr#3818: anti-recursive teleport guard in InternalGame namespace - feat: release workflow + MyAAC client 1501→1511 - chore: release metadata 3.5.0→3.6.0 SOLID boundary preserved: - Page-index fix ported to PlayerStashComponent::sendBatchUpdateContainer (not re-inlined in player.cpp) - isNearDepotBox() const propagated through PlayerStashComponent - Teleport guard added to Game::internalTeleport facade; actual teleport logic stays in MovementService::internalTeleport - 3 regression tests added (isNearDepotBox const, sendBatchUpdate null guard) Tests: 579/579 passing Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Applies SOLID/Hexagonal to the anti-recursive teleport fix (main opentibiabr#3818). Before: ~200 lines of recursion stack + rate limiter + state tracking embedded as free functions in InternalGame namespace inside game.cpp. After: TeleportGuard class in src/game/movement/teleport_guard.{hpp,cpp} with a clear public API: - tryEnterStack() — RAII recursion guard (thread_local stack) - shouldBlockRate() — per-entity burst/sustained rate limiter - recordBlock() — exponential-backoff log snapshot - logBlock() — structured error output - reset() — test isolation hook Game::internalTeleport keeps the guard pre-check at the facade layer and delegates actual teleport logic to MovementService (unchanged). 12 TDD unit tests cover: recursion detection, RAII cleanup, burst limit, rate-window reset, per-key isolation, log suppression and re-emission. Tests: 591/591 passing Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>







Resolves #3585
Summary by CodeRabbit
Bug Fixes
Chores
✏️ Tip: You can customize this high-level summary in your review settings.
TalkAction for tests: