3.3 KiB
3.3 KiB
QuestManager BehaviorManager Integration Fix
Summary
Fixed QuestManager.cpp to properly inherit from BehaviorManager base class according to Phase 2.4 refactoring plan.
Issues Fixed
1. Removed Duplicate/Conflicting Methods
- REMOVED:
Update(uint32 diff)- BehaviorManager provides this - REMOVED:
Reset()- Not part of BehaviorManager pattern - REMOVED:
Shutdown()- BehaviorManager handles cleanup - REMOVED:
Initialize()- Replaced with OnInitialize()
2. Removed Duplicate Member Variables
- REMOVED:
m_ai- BehaviorManager provides GetAI() - REMOVED:
m_enabled- BehaviorManager provides IsEnabled()/SetEnabled() - REMOVED:
m_timeSinceLastUpdate- BehaviorManager handles timing - REMOVED:
m_updateInterval- BehaviorManager handles this - REMOVED:
m_totalUpdateTime- Not needed - REMOVED:
m_updateCount- BehaviorManager provides m_updateCount - REMOVED:
m_cpuUsage- BehaviorManager handles performance
3. Removed Undefined Performance Methods
- REMOVED:
StartPerformanceTimer()- BehaviorManager handles this - REMOVED:
EndPerformanceTimer()- BehaviorManager handles this - REMOVED:
UpdatePerformanceMetrics()- BehaviorManager handles this
4. Implemented BehaviorManager Virtual Methods
- ADDED:
OnInitialize()- Returns true on successful init - CHANGED:
Update()toOnUpdate(uint32 elapsed)- Called by base class - CHANGED:
Shutdown()toOnShutdown()- Called by base class
5. Added Missing Method Implementation
- ADDED:
HasActiveQuest(uint32 questId)- Was declared but not implemented
BehaviorManager Pattern Implementation
class QuestManager : public BehaviorManager {
public:
QuestManager(Player* bot, BotAI* ai)
: BehaviorManager(bot, ai, 2000, "QuestManager") // 2 second update interval
// ... initialize QuestManager-specific members
protected:
// Called once at startup
bool OnInitialize() override {
// One-time initialization
return true;
}
// Called every 2 seconds (throttled by BehaviorManager)
void OnUpdate(uint32 elapsed) override {
// Regular quest updates
}
// Called at shutdown
void OnShutdown() override {
// Cleanup
}
};
Key Changes in Constructor
- Properly calls BehaviorManager constructor with all 4 parameters
- Removed initialization of duplicate member variables
- Kept only QuestManager-specific members
Benefits
- Consistent API: All managers use same base class pattern
- Automatic Throttling: Updates only run every 2 seconds
- Performance Monitoring: Built-in slow update detection
- Thread Safety: Atomic state flags for lock-free queries
- Reduced Code Duplication: Base class handles common functionality
Testing Required
- Compile playerbot module
- Verify QuestManager initializes correctly
- Verify quest scanning works
- Verify quest acceptance/completion works
- Check performance metrics
Related Files
src/modules/Playerbot/Game/QuestManager.h- Header file (already correct)src/modules/Playerbot/Game/QuestManager.cpp- Implementation (FIXED)src/modules/Playerbot/AI/BehaviorManager.h- Base class definitionPHASE_2_4_MANAGER_REFACTOR.md- Refactoring plan documentation