refactor(12.0): Update Difficulty enum type from uint8 to int16

TrinityCore 12.0 changed the core Difficulty enum from uint8 to int16.
This commit updates all Playerbot module enums and function signatures
to match:

- InstanceFarmingManager.h: InstanceDifficulty enum
- RaidState.h: RaidDifficulty enum
- DungeonState.h: DungeonDifficulty enum
- GroupEvents.h/cpp: DifficultyChanged() parameter
- PlayerbotGroupScript.h: GroupStateSnapshot difficulty fields
- PlayerbotGroupScript.cpp: Difficulty casts
- PlayerBotHooks.cpp: GroupEvent difficulty cast

Also adds comprehensive WOW_12_0_MIGRATION_ANALYSIS.md documenting:
- Critical API changes (Stats, Difficulty, Items, Spells)
- Files requiring updates
- Migration task plan

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Signed-off-by: luis <[email protected]>
This commit is contained in:
agatho
2026-02-04 20:25:58 -03:00
committed by luis
co-authored by Claude Opus 4.5
parent 38c85f0a05
commit 318c198b66
9 changed files with 380 additions and 15 deletions
+362
View File
@@ -0,0 +1,362 @@
# WoW 12.0 Migration Analysis - Playerbot Module
**Date**: 2026-02-03
**TrinityCore Commit**: b0a596908d5c1b5b09f90e97b17a7fc785e5366f
**Migration Status**: IN PROGRESS
## Executive Summary
The TrinityCore project has been updated to WoW 12.0 (The War Within Season 2+). This document analyzes all changes affecting the Playerbot module and provides a systematic migration plan.
---
## Critical API Changes in 12.0
### 1. Stats System Changes
**BREAKING CHANGE**: `STAT_SPIRIT` re-added, `MAX_STATS` increased from 4 to 5
```cpp
// OLD (11.x)
enum Stats : uint16
{
STAT_STRENGTH = 0,
STAT_AGILITY = 1,
STAT_STAMINA = 2,
STAT_INTELLECT = 3,
};
#define MAX_STATS 4
// NEW (12.0)
enum Stats : uint16
{
STAT_STRENGTH = 0,
STAT_AGILITY = 1,
STAT_STAMINA = 2,
STAT_INTELLECT = 3,
STAT_SPIRIT = 4, // RE-ADDED
};
#define MAX_STATS 5
```
**Playerbot Impact**:
- Stats array iterations must loop to `MAX_STATS` (5 now)
- Healer/caster calculations may use Spirit for mana regen
- Already partially implemented in:
- `LFGRoleDetector.cpp:265` - Spirit used in healer score
- `DoubleBufferedSpatialGrid.cpp:704` - Spirit snapshot
- `RoleAssignment.cpp:670` - Spirit in stat calculation
### 2. Difficulty Type Change
**BREAKING CHANGE**: `Difficulty` enum type changed from `uint8` to `int16`
```cpp
// OLD (11.x)
enum Difficulty : uint8
// NEW (12.0)
enum Difficulty : int16
```
**Playerbot Impact**:
- `InstanceDifficulty` enum needs update to `int16`
- `RaidDifficulty` enum needs update to `int16`
- `DungeonDifficulty` enum needs update to `int16`
- `GroupEvent::DifficultyChanged()` parameter type change
- All casts to `uint8` for difficulty need review
**Files Affected**:
- `src/modules/Playerbot/Dungeon/InstanceFarmingManager.h:61`
- `src/modules/Playerbot/AI/Coordination/Raid/RaidState.h:81`
- `src/modules/Playerbot/AI/Coordination/Dungeon/DungeonState.h:42`
- `src/modules/Playerbot/Group/GroupEvents.h:140`
- `src/modules/Playerbot/Group/GroupEvents.cpp:196`
- `src/modules/Playerbot/Group/PlayerbotGroupScript.cpp:400-402`
### 3. Spell System Changes
**NEW**: `SpellAttr16` attribute set added
```cpp
// NEW (12.0)
enum SpellAttr16 : uint32
{
SPELL_ATTR16_UNK0 = 0x00000001,
// ... 32 flags
SPELL_ATTR16_UNK31 = 0x80000000
};
// SpellInfo now has:
uint32 AttributesEx16 = 0;
bool HasAttribute(SpellAttr16 attribute) const;
```
**NEW**: `SpellModOp::MaxTargets = 40`, `MAX_SPELLMOD` increased to 41
**NEW**: `SpellPvpModifier` enum for PvP spell modifications
**Playerbot Impact**:
- Spell validation code may need updates
- PvP spell handling for BG bots should use new modifiers
- Combat calculations should check AttributesEx16
### 4. Item Level System Changes
**CRITICAL**: Item Squish Era system added for cross-expansion item level normalization
```cpp
// BonusData changes
struct BonusData {
uint32 ItemSquishEraID; // NEW
bool IgnoreSquish; // NEW
// ...
};
// ItemTemplate changes
uint32 GetItemSquishEraId() const;
// NEW bonus type
ITEM_BONUS_ITEM_BONUS_LIST = 50
```
**Playerbot Impact**:
- GearScore calculations must account for squish eras
- Item level comparisons need era-aware logic
- Bot equipment decisions need squish awareness
- Template repository item levels need validation
**Files Requiring Updates** (70 files use item level):
- `Equipment/EquipmentManager.cpp` - Core gear management
- `Equipment/BotGearFactory.cpp` - Gear creation
- `Lifecycle/Instance/BotTemplateRepository.cpp` - Template item levels
- `LFG/LFGBotSelector.cpp` - LFG matching by item level
- `Group/RoleAssignment.cpp` - Role-based gear checks
### 5. UpdateFields Changes
**CRITICAL**: Stats array size in UnitData changed from 4 to 5
```cpp
// OLD (11.x)
UpdateFieldArray<int32, 4, 185, 186> Stats;
UpdateFieldArray<int32, 4, 185, 190> StatPosBuff;
UpdateFieldArray<int32, 4, 185, 194> StatNegBuff;
UpdateFieldArray<int32, 4, 185, 198> StatSupportBuff;
// NEW (12.0)
UpdateFieldArray<int32, 5, 185, 186> Stats;
UpdateFieldArray<int32, 5, 185, 191> StatPosBuff;
UpdateFieldArray<int32, 5, 185, 196> StatNegBuff;
UpdateFieldArray<int32, 5, 185, 201> StatSupportBuff;
```
**NEW**: `VisibleItem` has 2 new bool fields
**NEW**: `LeaverInfo` structure changes:
- `LeaverStatus` → `Flags`
- `IsLeaver` bool added
### 6. Map Type Changes
**NEW**: 3 new map types added
```cpp
// NEW (12.0)
MAP_WOWLABS = 6, // Plunderstorm/WoW Labs
MAP_HOUSE_INTERIOR = 7, // Player housing interior
MAP_HOUSE_NEIGHBORHOOD = 8 // Player housing neighborhood
```
**Playerbot Impact**:
- Bot teleportation/map checks need updates
- Housing maps should be excluded from bot spawning
- IsValidBotMap() checks need new map types
### 7. New Criteria Types
**CriteriaType::Count** increased from 279 to 283 (4 new criteria added)
### 8. New GameRules
```cpp
// NEW (12.0)
EjJourneysDisabled = 156,
PvPInitialRatingOverride = 190,
```
### 9. New GlobalCurves for Housing
```cpp
// NEW (12.0)
HouseLevelFavorForLevel = 37,
HouseInteriorDecorBudget = 38,
HouseExteriorDecorBudget = 39,
HouseRoomPlacementBudget = 40,
HouseFixtureBudget = 41,
TransmogCost = 43,
MaxHouseSizeForLevel = 46,
```
### 10. New Spell Effects
```cpp
// NEW (12.0)
SPELL_EFFECT_CREATE_AREATRIGGER_2 = 353,
SPELL_EFFECT_SET_NEIGHBORHOOD_INITIATIVE = 354,
```
### 11. New SpellCastResult
```cpp
// NEW (12.0)
SPELL_FAILED_TRANSMOG_OUTFIT_ALREADY_KNOWN = 323,
SPELL_FAILED_UNKNOWN = 324, // Shifted from 323
```
---
## Documentation Updates Required
### Files Referencing "11.x" That Need Version Updates
1. **AUTOMATED_WORLD_POPULATION_DESIGN.md** - Multiple 11.2 references
2. **WoW112CharacterCreation.h** - Entire file named for 11.2
3. **docs/TROUBLESHOOTING_FAQ.md** - Version references
4. **docs/DEPLOYMENT_GUIDE.md** - Version references
5. **docs/CONFIGURATION_REFERENCE.md** - Version references
6. **docs/ARCHITECTURE_OVERVIEW.md** - Version references
7. **Chat/BotChatCommandHandler.cpp:240** - Comment reference
8. **Banking/BankingManager.cpp:842,847** - Comment references
9. **Achievements/AchievementManager.cpp:99** - Comment reference
10. **CMakeLists.txt:787** - Comment reference
11. **Character/ZoneLevelHelper.h:27** - Comment reference
---
## Migration Tasks
### Phase 1: Critical Breaking Changes (IMMEDIATE)
| Task | Priority | Files | Complexity |
|------|----------|-------|------------|
| Update Difficulty enum type to int16 | HIGH | 6 files | LOW |
| Update Stats array handling (MAX_STATS=5) | HIGH | ~10 files | MEDIUM |
| Validate item level squish handling | HIGH | 70 files | HIGH |
### Phase 2: Feature Parity Updates
| Task | Priority | Files | Complexity |
|------|----------|-------|------------|
| Add SpellAttr16 support in spell checks | MEDIUM | 5-10 files | LOW |
| Update map type validations | MEDIUM | 3-5 files | LOW |
| Add new SpellModOp::MaxTargets handling | LOW | 2-3 files | LOW |
### Phase 3: Documentation Updates
| Task | Priority | Files | Complexity |
|------|----------|-------|------------|
| Rename WoW112*.h → WoW120*.h | HIGH | 2 files | LOW |
| Update all "11.x" references to "12.0" | MEDIUM | 15+ files | LOW |
| Update version numbers in configs | LOW | 3 files | LOW |
---
## Code Audit Checklist
### Stats System
- [ ] All `MAX_STATS` iterations include index 4 (Spirit)
- [ ] Healer/caster stat calculations use Spirit
- [ ] Stat snapshot code captures Spirit
- [ ] No hardcoded "4" for stats array size
### Difficulty System
- [ ] All custom Difficulty enums use `int16`
- [ ] All difficulty casts use `static_cast<int16>`
- [ ] GroupEvent difficulty parameter updated
- [ ] No truncation warnings
### Item Level System
- [ ] GearScore accounts for ItemSquishEraID
- [ ] Item comparisons are era-aware
- [ ] Bot equipment manager handles squish
- [ ] Template item levels validated for 12.0
### Spell System
- [ ] AttributesEx16 checks where appropriate
- [ ] SpellPvpModifier usage for PvP bots
- [ ] New spell effects handled gracefully
### Map System
- [ ] Housing maps excluded from bot spawning
- [ ] WowLabs maps handled appropriately
- [ ] Map type checks include new types
---
## Testing Requirements
### Unit Tests
- [ ] Stats iteration tests with Spirit
- [ ] Item level squish calculation tests
- [ ] Difficulty type conversion tests
- [ ] Map type validation tests
### Integration Tests
- [ ] Bot spawning on all map types
- [ ] Item equipping with squish-era items
- [ ] Group difficulty changes
- [ ] PvP combat with new modifiers
### Regression Tests
- [ ] Existing bot behavior unchanged
- [ ] Performance metrics maintained
- [ ] No new crashes or errors
---
## Implementation Order
1. **Difficulty Type Migration** (LOW RISK)
- Update enums to int16
- Update function signatures
- Update casts
- Compile and test
2. **Stats System Update** (MEDIUM RISK)
- Audit all MAX_STATS usage
- Update iterations
- Verify Spirit handling
- Test stat calculations
3. **Item Level Squish** (HIGH RISK)
- Research squish curve behavior
- Update GearScore calculations
- Update item comparisons
- Extensive testing required
4. **Documentation Updates** (NO RISK)
- Rename files
- Update version references
- Update comments
---
## Rollback Plan
If migration causes issues:
1. Revert Playerbot module changes
2. Core TrinityCore 12.0 is compatible with 11.x Playerbot data
3. Document incompatibilities for future fix
---
## References
- TrinityCore 12.0 Commit: `b0a596908d5c1b5b09f90e97b17a7fc785e5366f`
- Files Changed: 92 files, +8452/-5638 lines
- Key Files:
- `src/server/game/DataStores/DBCEnums.h`
- `src/server/game/Miscellaneous/SharedDefines.h`
- `src/server/game/Entities/Item/Item.cpp`
- `src/server/game/Entities/Object/Updates/UpdateFields.h`
@@ -38,8 +38,9 @@ enum class DungeonState : uint8
/**
* @enum DungeonDifficulty
* @brief Dungeon difficulty modes
* @note WoW 12.0: Changed from uint8 to int16 to match core Difficulty type
*/
enum class DungeonDifficulty : uint8
enum class DungeonDifficulty : int16
{
NORMAL = 0,
HEROIC = 1,
@@ -77,8 +77,9 @@ enum class HealerAssignment : uint8
/**
* @enum RaidDifficulty
* @brief Raid instance difficulty
* @note WoW 12.0: Changed from uint8 to int16 to match core Difficulty type
*/
enum class RaidDifficulty : uint8
enum class RaidDifficulty : int16
{
NORMAL = 0,
HEROIC = 1,
@@ -415,8 +415,8 @@ void PlayerBotHooks::RegisterHooks()
IncrementHookCall("OnDifficultyChanged");
// Publish difficulty change event
GroupEvent event = GroupEvent::DifficultyChanged(group->GetGUID(), static_cast<uint8>(difficulty));
// Publish difficulty change event (WoW 12.0: Difficulty is int16)
GroupEvent event = GroupEvent::DifficultyChanged(group->GetGUID(), static_cast<int16>(difficulty));
GroupEventBus::instance()->PublishEvent(event);
TC_LOG_DEBUG("module.playerbot.hooks", "Hook: Group {} difficulty changed to {}",
@@ -57,8 +57,9 @@ enum class FarmingContentType : uint8
/**
* @enum InstanceDifficulty
* @brief Instance difficulty settings
* @note WoW 12.0: Changed from uint8 to int16 to match core Difficulty type
*/
enum class InstanceDifficulty : uint8
enum class InstanceDifficulty : int16
{
NORMAL = 0,
HEROIC,
+1 -1
View File
@@ -193,7 +193,7 @@ GroupEvent GroupEvent::LootMethodChanged(ObjectGuid groupGuid, uint8 lootMethod)
return event;
}
GroupEvent GroupEvent::DifficultyChanged(ObjectGuid groupGuid, uint8 difficulty)
GroupEvent GroupEvent::DifficultyChanged(ObjectGuid groupGuid, int16 difficulty)
{
GroupEvent event;
event.type = GroupEventType::DIFFICULTY_CHANGED;
+1 -1
View File
@@ -137,7 +137,7 @@ struct GroupEvent
static GroupEvent TargetIconChanged(ObjectGuid groupGuid, uint8 icon, ObjectGuid targetGuid);
static GroupEvent RaidMarkerChanged(ObjectGuid groupGuid, uint32 markerId, Position const& position);
static GroupEvent LootMethodChanged(ObjectGuid groupGuid, uint8 lootMethod);
static GroupEvent DifficultyChanged(ObjectGuid groupGuid, uint8 difficulty);
static GroupEvent DifficultyChanged(ObjectGuid groupGuid, int16 difficulty); // WoW 12.0: Difficulty is int16
};
} // namespace Playerbot
@@ -396,10 +396,10 @@ void PlayerbotGroupScript::InitializeGroupState(Group* group, GroupState& state)
// NOTE: Target icon initialization removed - Group::GetTargetIcon() is not accessible
// Initialize difficulty
state.dungeonDifficulty = static_cast<uint8>(group->GetDungeonDifficultyID());
state.raidDifficulty = static_cast<uint8>(group->GetRaidDifficultyID());
state.legacyRaidDifficulty = static_cast<uint8>(group->GetLegacyRaidDifficultyID());
// Initialize difficulty (WoW 12.0: Difficulty is int16)
state.dungeonDifficulty = static_cast<int16>(group->GetDungeonDifficultyID());
state.raidDifficulty = static_cast<int16>(group->GetRaidDifficultyID());
state.legacyRaidDifficulty = static_cast<int16>(group->GetLegacyRaidDifficultyID());
// Initialize raid status
state.isRaid = group->isRaidGroup();
@@ -149,10 +149,10 @@ private:
// Target icons (8 raid markers)
::std::array<ObjectGuid, 8> targetIcons;
// Difficulty settings
uint8 dungeonDifficulty{0};
uint8 raidDifficulty{0};
uint8 legacyRaidDifficulty{0};
// Difficulty settings (WoW 12.0: Changed from uint8 to int16)
int16 dungeonDifficulty{0};
int16 raidDifficulty{0};
int16 legacyRaidDifficulty{0};
// Ready check
bool readyCheckActive{false};