* Add some more transactioncontrol to pet database handling + adjust character_aura keys to avoid duplicates

--HG--
branch : trunk
This commit is contained in:
click
2010-04-21 20:34:04 +02:00
parent aaf3a62395
commit 123d40dcfe
3 changed files with 7 additions and 1 deletions

View File

@@ -531,7 +531,7 @@ CREATE TABLE `character_aura` (
`maxduration` int(11) NOT NULL default '0',
`remaintime` int(11) NOT NULL default '0',
`remaincharges` tinyint(3) unsigned NOT NULL default '0',
PRIMARY KEY (`guid`,`spell`,`effect_mask`)
PRIMARY KEY (`guid`,`caster_guid`,`spell`,`effect_mask`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Player System';
/*!40101 SET character_set_client = @saved_cs_client */;

View File

@@ -0,0 +1,2 @@
ALTER TABLE `character_aura` DROP PRIMARY KEY ,
ADD PRIMARY KEY ( `guid` , `caster_guid` , `spell`, `effect_mask` )

View File

@@ -378,6 +378,7 @@ void Pet::SavePetToDB(PetSaveMode mode)
uint32 curhealth = GetHealth();
uint32 curmana = GetPower(POWER_MANA);
CharacterDatabase.BeginTransaction();
// save auras before possibly removing them
_SaveAuras();
@@ -389,6 +390,7 @@ void Pet::SavePetToDB(PetSaveMode mode)
_SaveSpells();
_SaveSpellCooldowns();
CharacterDatabase.CommitTransaction();
// current/stable/not_in_slot
if (mode >= PET_SAVE_AS_CURRENT)
@@ -453,11 +455,13 @@ void Pet::SavePetToDB(PetSaveMode mode)
void Pet::DeleteFromDB(uint32 guidlow)
{
CharacterDatabase.BeginTransaction();
CharacterDatabase.PExecute("DELETE FROM character_pet WHERE id = '%u'", guidlow);
CharacterDatabase.PExecute("DELETE FROM character_pet_declinedname WHERE id = '%u'", guidlow);
CharacterDatabase.PExecute("DELETE FROM pet_aura WHERE guid = '%u'", guidlow);
CharacterDatabase.PExecute("DELETE FROM pet_spell WHERE guid = '%u'", guidlow);
CharacterDatabase.PExecute("DELETE FROM pet_spell_cooldown WHERE guid = '%u'", guidlow);
CharacterDatabase.CommitTransaction();
}
void Pet::setDeathState(DeathState s) // overwrite virtual Creature::setDeathState and Unit::setDeathState