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

5.5 KiB

🔄 Phase 7 Legacy Singleton Call Migration Plan

Executive Summary

Total Legacy Calls Found: 320+ Managers Affected: 22 Phase 7 managers Critical Files: 15 high-priority files requiring migration


Priority Classification

🔴 CRITICAL (Runtime Crash Risk)

Files that will crash on first bot creation:

  1. UnifiedQuestManager.cpp - 200+ calls

    • DynamicQuestSystem (45 calls)
    • QuestCompletion (36 calls)
    • QuestPickup (20 calls)
    • QuestTurnIn (59 calls)
    • QuestValidation (48 calls)
  2. UnifiedLootManager.cpp - 13 calls

    • LootDistribution (all methods)
  3. ProfessionAuctionBridge.cpp - 2 calls

    • AuctionHouse::instance()
  4. AI/Strategy/QuestStrategy.cpp - 9 calls

    • ObjectiveTracker (all methods)
  5. Dungeon/DungeonBehavior.cpp - 8 calls

    • InstanceCoordination (all instance methods)
  6. LFG/LFGBotManager.cpp - 3 calls

    • LFGBotSelector::instance()

🟡 HIGH (Functionality Broken)

  1. ServiceRegistration.h - 22 DI registrations
    • All Phase 7 managers still registered as singletons

🟢 MEDIUM (Documentation/Cleanup)

  1. Various .md documentation files
  2. Backup files (.backup)

Migration Strategy

Pattern 1: Facade Pattern (UnifiedQuestManager, UnifiedLootManager)

These are facade classes that delegate to underlying managers.

OLD Pattern:

// UnifiedQuestManager.cpp
return DynamicQuestSystem::instance()->DiscoverAvailableQuests(bot);

NEW Pattern:

// UnifiedQuestManager.cpp - needs BotAI* reference
BotAI* botAI = GET_BOT_AI(bot); // Need helper
return botAI->GetGameSystems()->GetDynamicQuestSystem()->DiscoverAvailableQuests();

Challenge: Facades only have Player*, need to get BotAI*

Solution: Add helper method to get BotAI from Player


Pattern 2: Strategy Classes

OLD Pattern:

// QuestStrategy.cpp
ObjectiveTracker::instance()->UpdateBotTracking(bot, diff);

NEW Pattern:

BotAI* botAI = dynamic_cast<BotAI*>(bot->GetPlayerbotAI());
botAI->GetGameSystems()->GetObjectiveTracker()->UpdateBotTracking(diff);

Pattern 3: Behavior Classes

OLD Pattern:

// DungeonBehavior.cpp
InstanceCoordination::instance()->InitializeInstanceCoordination(group, instance);

NEW Pattern:

// Need per-bot access - must iterate group members
for (auto member : group->GetMembers())
{
    if (BotAI* botAI = GetBotAI(member))
        botAI->GetGameSystems()->GetInstanceCoordination()->InitializeInstanceCoordination(...);
}

Note: Coordination methods may need refactoring to work per-bot


Pattern 4: ServiceRegistration.h

OLD Pattern:

container.RegisterInstance<IArenaAI>(
    std::shared_ptr<IArenaAI>(ArenaAI::instance(), [](IArenaAI*) {})
);

NEW Pattern:

// REMOVE ENTIRELY - Already done in Phase 7 commits
// But code still exists physically in file

Execution Plan

Phase A: Infrastructure (Hours 1-2)

  1. ✅ Complete legacy call audit (DONE)
  2. Create helper functions:
    • BotAI* GetBotAI(Player* player)
    • GameSystemsManager* GetGameSystems(Player* player)
  3. Add to Player or utility header

Phase B: Critical Facades (Hours 2-4)

  1. Migrate UnifiedQuestManager.cpp (200+ calls)

    • Create systematic sed/awk scripts
    • Test each manager migration
    • Handle Player* → BotAI* conversion
  2. Migrate UnifiedLootManager.cpp (13 calls)

    • Similar pattern to quest manager

Phase C: Strategies & Behaviors (Hours 4-6)

  1. Migrate QuestStrategy.cpp (9 calls)
  2. Migrate DungeonBehavior.cpp (8 calls)
  3. Migrate LFG files (LFGBotManager, LFGBotSelector, LFGGroupCoordinator)

Phase D: Remaining Files (Hours 6-7)

  1. Migrate ProfessionAuctionBridge.cpp
  2. Clean up ServiceRegistration.h (physical removal)

Phase E: Verification (Hours 7-8)

  1. Grep verification - ensure 0 instance() calls
  2. Build attempt (if environment permits)
  3. Code review
  4. Documentation update

Implementation Scripts

Script 1: Helper Functions

// Add to BotAI.h or utility header
inline BotAI* GetBotAI(Player* player)
{
    if (!player)
        return nullptr;
    return dynamic_cast<BotAI*>(player->GetPlayerbotAI());
}

inline GameSystemsManager* GetGameSystems(Player* player)
{
    BotAI* botAI = GetBotAI(player);
    return botAI ? botAI->GetGameSystems() : nullptr;
}

Script 2: UnifiedQuestManager Migration Template

# For each singleton call in UnifiedQuestManager.cpp:
# OLD: DynamicQuestSystem::instance()->Method(bot, ...)
# NEW:
if (!bot) return [default];
BotAI* botAI = GetBotAI(bot);
if (!botAI || !botAI->GetGameSystems()) return [default];
return botAI->GetGameSystems()->GetDynamicQuestSystem()->Method(...);

Risk Assessment

High Risk Areas:

  1. Group coordination methods - May need architectural changes
  2. Facade pattern - Adds BotAI dependency
  3. Performance - Additional pointer indirection

Mitigation:

  1. Add null checks everywhere
  2. Return sensible defaults on failure
  3. Log warnings for failed lookups
  4. Incremental testing

Success Criteria

✅ Zero instance() calls to Phase 7 managers ✅ All facades migrated to per-bot access ✅ ServiceRegistration.h cleaned up ✅ Code compiles (if build environment available) ✅ Comprehensive testing plan documented ✅ Migration documented in commits


Estimated Total Time: 8-10 hours Token Budget: 50k-70k tokens

Status: Ready for execution