# Template Parameter and Resource Type Fixes - Summary ## Overview Fixed compilation errors in Feral Druid and Protection Paladin refactored specializations related to: 1. Missing template parameters 2. Resource type redefinition conflicts 3. Method override conflicts 4. 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 `` - **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) override` doesn't match base - **Base Expectation**: `TauntTarget(::Unit* target)` is the virtual method in `TankSpecialization` - **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()` declared `final` in base template - **Error**: Cannot override final method - **Fix**: Removed override entirely - base `TankSpecialization` provides `final` 5.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)` - **Fix**: Standardized all calls to use base ClassAI signature: `CastSpell(target, spellId)` - **Locations Fixed**: - Line 267: `SHIELD_OF_THE_RIGHTEOUS` on self - Line 317: `CONSECRATION` on self - Line 326: `BLESSED_HAMMER` on self - Line 348: `SHIELD_OF_THE_RIGHTEOUS` on self (AoE rotation) - Line 365: `CONSECRATION` on self (AoE rotation) - **Result**: Consistent API usage throughout, matches TrinityCore ClassAI interface ## Technical Details ### Template Parameter Requirements The template-based architecture requires explicit template parameters when inheriting: ```cpp // WRONG - Missing template parameter class FeralDruidRefactored : public MeleeDpsSpecialization, public DruidSpecialization // CORRECT - Explicit template parameter class FeralDruidRefactored : public MeleeDpsSpecialization, public DruidSpecialization ``` ### Resource Type Design Pattern Complex resource types must: 1. Define `available` member (bool) 2. Implement `Consume(uint32)` returning bool 3. Implement `Regenerate(uint32)` 4. Implement `GetAvailable()` returning uint32 5. Implement `GetMax()` returning uint32 6. Implement `Initialize(Player* bot)` ### Method Override Hierarchy ``` CombatSpecializationTemplate └─ TankSpecialization └─ 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**: ```cpp // 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 1. **Compile Test**: Full rebuild of Playerbot module 2. **Runtime Test**: - Create Feral Druid bot, verify combat rotation - Create Protection Paladin bot, verify tanking behavior - Verify threat generation and defensive cooldown usage 3. **Resource Test**: - Monitor energy/combo point tracking for Feral - Monitor mana/holy power tracking for Protection 4. **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: 1. The value is role-specific, not class-specific 2. All tanks need exactly 5.0f range 3. Prevents inconsistent behavior across specializations 4. Enforces architectural consistency ### Why Remove Redundant Methods? The template architecture provides common functionality at the base level. Redefining methods like `GetEnemiesInRange()` in derived classes: 1. Defeats the purpose of the template system 2. Increases maintenance burden 3. May cause subtle behavioral differences 4. Reduces code reusability ## Related Files The fixes depend on these architectural components: 1. **CombatSpecializationTemplates.h** - Base template definitions 2. **ResourceTypes.h** - Resource type definitions 3. **ClassAI.h** - Original ClassAI interface 4. **DruidSpecialization.h** - Druid-specific base class 5. **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: 1. `CastSpell(::Unit* target, uint32 spellId)` - ClassAI base 2. `CastSpell(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: 1. Proper template parameter usage 2. Include guard protection for shared types 3. Correct method override patterns 4. API consistency enforcement The fixes maintain architectural integrity while eliminating technical debt.