Pet Battles: Fix BattlePetAbilityEffect column names and DisplayID repair
Rename misnamed SQL columns to match WoWDBDefs 12.0: - Aura → BattlePetEffectPropertiesID - BattlePetEffectPropertiesID → AuraBattlePetAbilityID - VisualID → BattlePetVisualID Add migration script for existing databases, update SELECT query. Also add DisplayID=0 repair in LoadPlayerTeam and a log warning in SelectPetDisplay when creature_template is missing.
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
--
|
||||
-- Rename misnamed columns in battle_pet_ability_effect to match WoWDBDefs 12.0
|
||||
-- Old names were swapped: Aura was actually BattlePetEffectPropertiesID,
|
||||
-- BattlePetEffectPropertiesID was actually AuraBattlePetAbilityID,
|
||||
-- VisualID was actually BattlePetVisualID
|
||||
--
|
||||
|
||||
-- Two-step rename to avoid name collision (Aura->BattlePetEffectPropertiesID conflicts with existing column)
|
||||
-- Step 1: Rename the conflicting column out of the way first
|
||||
ALTER TABLE `battle_pet_ability_effect`
|
||||
CHANGE COLUMN `BattlePetEffectPropertiesID` `AuraBattlePetAbilityID` smallint unsigned NOT NULL DEFAULT '0',
|
||||
CHANGE COLUMN `Aura` `BattlePetEffectPropertiesID` smallint unsigned NOT NULL DEFAULT '0',
|
||||
CHANGE COLUMN `VisualID` `BattlePetVisualID` smallint unsigned NOT NULL DEFAULT '0';
|
||||
@@ -2252,7 +2252,7 @@ void HotfixDatabaseConnection::DoPrepareStatements()
|
||||
|
||||
//BATTLEPET
|
||||
// BattlePetAbilityEffect.db2
|
||||
PrepareStatement(HOTFIX_SEL_BATTLE_PET_ABILITY_EFFECT, "SELECT ID, BattlePetAbilityTurnID, OrderIndex, Aura, BattlePetEffectPropertiesID, VisualID, "
|
||||
PrepareStatement(HOTFIX_SEL_BATTLE_PET_ABILITY_EFFECT, "SELECT ID, BattlePetAbilityTurnID, OrderIndex, BattlePetEffectPropertiesID, AuraBattlePetAbilityID, BattlePetVisualID, "
|
||||
"Param1, Param2, Param3, Param4, Param5, Param6 FROM battle_pet_ability_effect WHERE (`VerifiedBuild` > 0) = ?", CONNECTION_SYNCH);
|
||||
PREPARE_MAX_ID_STMT(HOTFIX_SEL_BATTLE_PET_ABILITY_EFFECT, "SELECT MAX(ID) + 1 FROM battle_pet_ability_effect", CONNECTION_SYNCH);
|
||||
|
||||
|
||||
@@ -253,9 +253,15 @@ namespace BattlePets
|
||||
uint32 BattlePetMgr::SelectPetDisplay(BattlePetSpeciesEntry const* speciesEntry)
|
||||
{
|
||||
if (CreatureTemplate const* creatureTemplate = sObjectMgr->GetCreatureTemplate(speciesEntry->CreatureID))
|
||||
{
|
||||
if (!speciesEntry->GetFlags().HasFlag(BattlePetSpeciesFlags::RandomDisplay))
|
||||
if (CreatureModel const* creatureModel = creatureTemplate->GetRandomValidModel())
|
||||
return creatureModel->CreatureDisplayID;
|
||||
}
|
||||
else
|
||||
TC_LOG_ERROR("misc", "BattlePetMgr::SelectPetDisplay: creature_template entry {} not found for species {}. "
|
||||
"Battle pet will have DisplayID=0. Add the creature_template and creature_template_model entries.",
|
||||
speciesEntry->CreatureID, speciesEntry->ID);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -67,6 +67,20 @@ namespace PetBattles
|
||||
battlePet.Species = pet->PacketInfo.Species;
|
||||
battlePet.CreatureID = pet->PacketInfo.CreatureID;
|
||||
battlePet.DisplayID = pet->PacketInfo.DisplayID;
|
||||
|
||||
// Repair DisplayID if it was stored as 0 (missing creature_template at pet creation time)
|
||||
if (battlePet.DisplayID == 0 && battlePet.CreatureID != 0)
|
||||
{
|
||||
if (CreatureTemplate const* ct = sObjectMgr->GetCreatureTemplate(battlePet.CreatureID))
|
||||
if (CreatureModel const* model = ct->GetRandomValidModel())
|
||||
{
|
||||
battlePet.DisplayID = model->CreatureDisplayID;
|
||||
pet->PacketInfo.DisplayID = battlePet.DisplayID;
|
||||
TC_LOG_DEBUG("server.loading", "PetBattle: Repaired DisplayID for species {} (creature {}) -> {}",
|
||||
battlePet.Species, battlePet.CreatureID, battlePet.DisplayID);
|
||||
}
|
||||
}
|
||||
|
||||
battlePet.Breed = pet->PacketInfo.Breed;
|
||||
battlePet.Level = pet->PacketInfo.Level;
|
||||
battlePet.Xp = pet->PacketInfo.Exp;
|
||||
|
||||
Reference in New Issue
Block a user