Files
ThordekkCore/MOVEMENT_USAGE_ANALYSIS.md
T
2026-01-20 21:33:16 -03:00

5.1 KiB

MovementManager Usage Analysis - Refined Decision

Date: 2025-10-07 Context: During Option A cleanup, discovered MovementManager IS used by Quest system


Usage Summary

Total MovementManager Calls: 5 active + 2 dead

Active Files (In CMakeLists.txt)

  1. Quest/QuestCompletion.cpp - 4 calls:

    • Line 567: MoveToUnit(bot, npc, range) - Move to quest giver NPC
    • Line 657: MoveTo(bot, gameObject->GetPosition()) - Move to quest object
    • Line 814: MoveToUnit(bot, escortTarget, 5.0f) - Follow escort NPC
    • Line 851: MoveTo(bot, targetPos) - Move to quest objective
  2. Quest/QuestTurnIn.cpp - 1 call:

    • Line 456: MoveTo(bot, position) - Navigate to quest turn-in location

Dead Code (NOT in CMakeLists.txt)

  1. Integration/Phase3SystemIntegration.cpp - 2 calls:
    • Line 58: MovementManager initialization
    • NOT compiled - file not in build system

Movement Architecture Map

Current State

Quest System (ACTIVE)
   ↓
MovementManager::Instance()
   ↓
MovementManager (31KB implementation)
   ↓
MotionMaster (TrinityCore)

Strategy System (ACTIVE)
   ↓
BotMovementUtil (deduplication wrapper)
   ↓
MotionMaster (TrinityCore)

Problem: TWO movement paths exist - quest uses MovementManager, strategies use BotMovementUtil


Refined Options

Option A.1: Keep MovementManager for Quest System (HYBRID)

Keep:

  • Movement/Core/MovementManager.h (289 lines)
  • Movement/Core/MovementManager.cpp (877 lines)
  • Movement/Core/MovementGenerator.h (base class)
  • Movement/Core/MovementGenerator.cpp (base class)

Delete:

  • Movement/Generators/ConcreteMovementGenerators.h (722 lines - unused generators)
  • Integration/Phase3SystemIntegration.cpp (dead code)

Changes Needed:

  • ZERO refactoring
  • Delete 1 file
  • Update CMakeLists.txt

Pros:

  • ✅ Quest movement continues working
  • ✅ No refactoring risk
  • ✅ Clean separation (quests = manager, strategies = util)
  • ✅ ~700 lines deleted

Cons:

  • ⚠️ Two movement systems remain
  • ⚠️ Architectural inconsistency
  • ⚠️ MovementManager kept for only 5 calls

Option A.2: Refactor Quest System to BotMovementUtil (COMPLETE CLEANUP)

Delete:

  • Movement/Core/MovementManager.h (289 lines)
  • Movement/Core/MovementManager.cpp (877 lines)
  • Movement/Core/MovementGenerator.h
  • Movement/Core/MovementGenerator.cpp
  • Movement/Generators/ConcreteMovementGenerators.h (722 lines)
  • Integration/Phase3SystemIntegration.cpp (dead code)

Refactor (5 changes):

// OLD (QuestCompletion.cpp:567)
MovementManager::Instance()->MoveToUnit(bot, npc, QUEST_GIVER_INTERACTION_RANGE - 1.0f);

// NEW
BotMovementUtil::MoveToUnit(bot, npc, QUEST_GIVER_INTERACTION_RANGE - 1.0f);

// Similar for all 5 calls

Changes Needed:

  • Replace 5 MovementManager calls with BotMovementUtil
  • Add MoveToUnit() method to BotMovementUtil (if missing)
  • Delete 6 files
  • Update CMakeLists.txt
  • Test quest navigation

Pros:

  • ✅ Single movement architecture (BotMovementUtil only)
  • ✅ ~1,500 lines deleted
  • ✅ Architectural consistency
  • ✅ Eliminates confusion

Cons:

  • ⚠️ Requires BotMovementUtil extension (MoveToUnit method)
  • ⚠️ 5 quest methods need testing
  • ⚠️ Small refactoring risk

BotMovementUtil Current Capabilities

Let me check what BotMovementUtil currently provides:

File: Movement/BotMovementUtil.h (needs verification)

Required Methods for Quest refactoring:

  1. MoveTo(Player*, Position) - ✅ Likely exists
  2. MoveToUnit(Player*, Unit*, float distance) - ❓ Need to verify

If MoveToUnit doesn't exist, we need to add it (~10 lines).


Recommendation

Choose Option A.2: Complete Cleanup ⭐

Rationale:

  1. Single source of truth - One movement path (BotMovementUtil → MotionMaster)
  2. Eliminates architectural debt - No "system used by only 5 calls"
  3. Low risk - Only 5 call sites to change
  4. Clear ownership - BotMovementUtil owns ALL movement
  5. Follows DRY - Don't maintain two movement systems

Implementation Steps:

  1. Check if BotMovementUtil has MoveToUnit() - if not, add it
  2. Replace 5 MovementManager calls with BotMovementUtil
  3. Delete MovementManager files
  4. Delete ConcreteMovementGenerators.h
  5. Update CMakeLists.txt
  6. Compile and test quest navigation

Estimated Time: 2-3 hours (low complexity)


Alternative: Option A.1 (If Conservative Approach Preferred)

If we want ZERO refactoring risk:

  • Keep MovementManager for quest system
  • Delete only ConcreteMovementGenerators.h
  • Accept architectural inconsistency
  • ~700 lines deleted instead of ~1,500

Trade-off: Faster (30 minutes) but leaves technical debt


Next Steps (Awaiting Confirmation)

Which option do you prefer?

  1. Option A.2 (Recommended) - Refactor quest system, delete all MovementManager (~2-3 hours)
  2. Option A.1 (Conservative) - Keep MovementManager for quests, delete generators only (~30 minutes)

My strong recommendation: Option A.2 - eliminate the architectural inconsistency now rather than later.


Status: ⏳ AWAITING DECISION