# HG changeset patch # User James D. Callahan III # Date 1348737414 18000 # Node ID aa48190cb5eb7ad5cfeaca57de8ba9931b255361 # Parent 87177ba1f6f78695205bc41133d7436ef8e3a565 Handle race-condition case when a player releases a captured pet - also, use the BATTLE_PET_BREED_QUALITY constants instead of the ITEM_QUALITY constant for rarity. diff -r 87177ba1f6f7 -r aa48190cb5eb Main.lua --- a/Main.lua Wed Sep 26 13:39:11 2012 -0500 +++ b/Main.lua Thu Sep 27 04:16:54 2012 -0500 @@ -1432,17 +1432,20 @@ if is_owned then local health, max_health, attack, speed, rarity = _G.C_PetJournal.GetPetStats(pet_id) - local rarity_name = _G["ITEM_QUALITY" .. rarity - 1 .. "_DESC"] - local npc = NPCEntry(npc_id) - npc.wild_pet = is_wild or nil - npc.battle_pet_data = npc.battle_pet_data or {} - npc.battle_pet_data[rarity_name] = npc.battle_pet_data[rarity_name] or {} - npc.battle_pet_data[rarity_name]["level_" .. level] = npc.battle_pet_data[rarity_name]["level_" .. level] or {} - local data = npc.battle_pet_data[rarity_name]["level_" .. level] - data.max_health = max_health - data.attack = attack - data.speed = speed + if rarity then + local rarity_name = _G["BATTLE_PET_BREED_QUALITY" .. rarity] + local npc = NPCEntry(npc_id) + npc.wild_pet = is_wild or nil + npc.battle_pet_data = npc.battle_pet_data or {} + npc.battle_pet_data[rarity_name] = npc.battle_pet_data[rarity_name] or {} + npc.battle_pet_data[rarity_name]["level_" .. level] = npc.battle_pet_data[rarity_name]["level_" .. level] or {} + + local data = npc.battle_pet_data[rarity_name]["level_" .. level] + data.max_health = max_health + data.attack = attack + data.speed = speed + end end end end