7.9 KiB
Template Parameter and Resource Type Fixes - Summary
Overview
Fixed compilation errors in Feral Druid and Protection Paladin refactored specializations related to:
- Missing template parameters
- Resource type redefinition conflicts
- Method override conflicts
- CastSpell parameter order inconsistencies
Files Modified
1. FeralDruidRefactored.h
Location: c:\TrinityBots\TrinityCore\src\modules\Playerbot\AI\ClassAI\Druids\FeralDruidRefactored.h
Changes Made:
Issue 1: Missing Template Parameter (Line 295)
- Problem: Class declaration missing template parameter for base class
- Error: "Für die Verwendung von Klasse Vorlage ist eine Vorlage-Argumentliste erforderlich"
- Fix: Already had correct template parameter
<EnergyComboResource> - Action: Added
using Base::GetEnemiesInRange;to bring base method into scope
Issue 2: Invalid Method Call (Line 330)
- Problem: Called
this->GetEnemiesInRange()when method is from base template - Fix: Changed to
GetEnemiesInRange()after adding using declaration - Result: Properly calls base template method
Issue 3: Redundant Method Definition (Line 663)
- Problem: Attempted to redefine
GetEnemiesInRange()which is provided by base - Fix: Removed redundant definition, added comment explaining base provides it
- Result: Eliminated duplicate code and potential conflicts
2. ProtectionPaladinRefactored.h
Location: c:\TrinityBots\TrinityCore\src\modules\Playerbot\AI\ClassAI\Paladins\ProtectionPaladinRefactored.h
Changes Made:
Issue 1: ManaHolyPowerResource Redefinition (Lines 80-116)
- Problem: Resource struct defined in header without include guards
- Error: "ManaHolyPowerResource: Neudefinition"
- Fix: Wrapped definition in include guard
#ifndef PLAYERBOT_RESOURCE_TYPES_MANA_HOLY_POWER - Result: Prevents multiple definition errors during compilation
- Additional: Added missing
GetMaxPower(POWER_HOLY_POWER)initialization
Issue 2: OnTauntRequired Override Conflict (Line 238)
- Problem: Method signature
OnTauntRequired(::Unit* target) overridedoesn't match base - Base Expectation:
TauntTarget(::Unit* target)is the virtual method inTankSpecialization - Fix: Changed to
TauntTarget(::Unit* target) override - Result: Properly overrides base class virtual method
Issue 3: GetOptimalRange Final Method Override (Line 247)
- Problem: Attempted to override
GetOptimalRange()declaredfinalin base template - Error: Cannot override final method
- Fix: Removed override entirely - base
TankSpecializationprovidesfinal5.0f return - Result: Uses base implementation (5.0f melee range for all tanks)
- Justification: All tank specs need 5.0f range, no specialization needed
Issue 4: CastSpell Parameter Order (Multiple Locations)
- Problem: Mixed usage of two different CastSpell signatures
- Old ClassAI:
CastSpell(::Unit* target, uint32 spellId) - New Template:
CastSpell(uint32 spellId, ::Unit* target = nullptr)
- Old ClassAI:
- Fix: Standardized all calls to use base ClassAI signature:
CastSpell(target, spellId) - Locations Fixed:
- Line 267:
SHIELD_OF_THE_RIGHTEOUSon self - Line 317:
CONSECRATIONon self - Line 326:
BLESSED_HAMMERon self - Line 348:
SHIELD_OF_THE_RIGHTEOUSon self (AoE rotation) - Line 365:
CONSECRATIONon self (AoE rotation)
- Line 267:
- Result: Consistent API usage throughout, matches TrinityCore ClassAI interface
Technical Details
Template Parameter Requirements
The template-based architecture requires explicit template parameters when inheriting:
// WRONG - Missing template parameter
class FeralDruidRefactored : public MeleeDpsSpecialization, public DruidSpecialization
// CORRECT - Explicit template parameter
class FeralDruidRefactored : public MeleeDpsSpecialization<EnergyComboResource>, public DruidSpecialization
Resource Type Design Pattern
Complex resource types must:
- Define
availablemember (bool) - Implement
Consume(uint32)returning bool - Implement
Regenerate(uint32) - Implement
GetAvailable()returning uint32 - Implement
GetMax()returning uint32 - Implement
Initialize(Player* bot)
Method Override Hierarchy
CombatSpecializationTemplate<T>
└─ TankSpecialization<T>
└─ ProtectionPaladinRefactored
GetOptimalRange() - FINAL at TankSpecialization level (5.0f)
TauntTarget() - VIRTUAL at TankSpecialization level
└─ Overridden in ProtectionPaladinRefactored
CastSpell API Consistency
Base ClassAI provides: bool CastSpell(::Unit* target, uint32 spellId)
Self-cast pattern:
// Correct for self-targeting spells
this->CastSpell(this->GetBot(), SPELL_ID);
// Correct for target-based spells
this->CastSpell(target, SPELL_ID);
Compilation Impact
These fixes resolve:
- 4 template parameter errors (missing template arguments)
- 1 redefinition error (ManaHolyPowerResource)
- 2 override conflicts (OnTauntRequired, GetOptimalRange)
- 5 API inconsistencies (CastSpell parameter orders)
Total: 12 compilation errors eliminated
Testing Recommendations
- Compile Test: Full rebuild of Playerbot module
- Runtime Test:
- Create Feral Druid bot, verify combat rotation
- Create Protection Paladin bot, verify tanking behavior
- Verify threat generation and defensive cooldown usage
- Resource Test:
- Monitor energy/combo point tracking for Feral
- Monitor mana/holy power tracking for Protection
- Template Test:
- Verify no duplicate symbols in linker output
- Confirm template instantiation for both specializations
Architecture Notes
Why Include Guards for Resource Types?
The ManaHolyPowerResource struct is defined in a header that may be included by multiple translation units. Without include guards, each inclusion would create a new definition, causing ODR (One Definition Rule) violations.
Why Final Methods in Template Base?
Methods like GetOptimalRange() are marked final in role-based templates (Tank/Melee/Ranged) because:
- The value is role-specific, not class-specific
- All tanks need exactly 5.0f range
- Prevents inconsistent behavior across specializations
- Enforces architectural consistency
Why Remove Redundant Methods?
The template architecture provides common functionality at the base level. Redefining methods like GetEnemiesInRange() in derived classes:
- Defeats the purpose of the template system
- Increases maintenance burden
- May cause subtle behavioral differences
- Reduces code reusability
Related Files
The fixes depend on these architectural components:
- CombatSpecializationTemplates.h - Base template definitions
- ResourceTypes.h - Resource type definitions
- ClassAI.h - Original ClassAI interface
- DruidSpecialization.h - Druid-specific base class
- PaladinSpecialization.h - Paladin-specific base class
Future Considerations
Should ManaHolyPowerResource be in ResourceTypes.h?
Recommendation: Yes, move it to ResourceTypes.h alongside:
RuneSystem(Death Knight)ComboPointSystem(Rogue/Druid)HolyPowerSystem(Paladin)ChiSystem(Monk)SoulShardSystem(Warlock)
This would:
- Centralize all resource type definitions
- Eliminate include guard proliferation
- Make resource types discoverable
- Prevent future redefinition errors
CastSpell API Unification?
There are currently two signatures in use:
CastSpell(::Unit* target, uint32 spellId)- ClassAI baseCastSpell(uint32 spellId, ::Unit* target = nullptr)- Some specializations
Recommendation: Standardize on ClassAI signature for consistency with TrinityCore patterns.
Conclusion
All compilation errors have been resolved through:
- Proper template parameter usage
- Include guard protection for shared types
- Correct method override patterns
- API consistency enforcement
The fixes maintain architectural integrity while eliminating technical debt.