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:
-
UnifiedQuestManager.cpp - 200+ calls
- DynamicQuestSystem (45 calls)
- QuestCompletion (36 calls)
- QuestPickup (20 calls)
- QuestTurnIn (59 calls)
- QuestValidation (48 calls)
-
UnifiedLootManager.cpp - 13 calls
- LootDistribution (all methods)
-
ProfessionAuctionBridge.cpp - 2 calls
- AuctionHouse::instance()
-
AI/Strategy/QuestStrategy.cpp - 9 calls
- ObjectiveTracker (all methods)
-
Dungeon/DungeonBehavior.cpp - 8 calls
- InstanceCoordination (all instance methods)
-
LFG/LFGBotManager.cpp - 3 calls
- LFGBotSelector::instance()
🟡 HIGH (Functionality Broken)
- ServiceRegistration.h - 22 DI registrations
- All Phase 7 managers still registered as singletons
🟢 MEDIUM (Documentation/Cleanup)
- Various .md documentation files
- 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)
- ✅ Complete legacy call audit (DONE)
- Create helper functions:
BotAI* GetBotAI(Player* player)GameSystemsManager* GetGameSystems(Player* player)
- Add to Player or utility header
Phase B: Critical Facades (Hours 2-4)
-
Migrate UnifiedQuestManager.cpp (200+ calls)
- Create systematic sed/awk scripts
- Test each manager migration
- Handle Player* → BotAI* conversion
-
Migrate UnifiedLootManager.cpp (13 calls)
- Similar pattern to quest manager
Phase C: Strategies & Behaviors (Hours 4-6)
- Migrate QuestStrategy.cpp (9 calls)
- Migrate DungeonBehavior.cpp (8 calls)
- Migrate LFG files (LFGBotManager, LFGBotSelector, LFGGroupCoordinator)
Phase D: Remaining Files (Hours 6-7)
- Migrate ProfessionAuctionBridge.cpp
- Clean up ServiceRegistration.h (physical removal)
Phase E: Verification (Hours 7-8)
- Grep verification - ensure 0 instance() calls
- Build attempt (if environment permits)
- Code review
- 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:
- Group coordination methods - May need architectural changes
- Facade pattern - Adds BotAI dependency
- Performance - Additional pointer indirection
Mitigation:
- Add null checks everywhere
- Return sensible defaults on failure
- Log warnings for failed lookups
- 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