Mercurial > wow > wowdb-profiler
comparison Main.lua @ 298:841eeb16dcf7
Update group pets on GROUP_ROSTER_UPDATE as well as on UNIT_PET since pets may exist before groups are formed.
| author | James D. Callahan III <jcallahan@curse.com> |
|---|---|
| date | Tue, 18 Jun 2013 14:18:44 -0500 |
| parents | 57cb63fe5ba8 |
| children | 0946f1091810 |
comparison
equal
deleted
inserted
replaced
| 297:57cb63fe5ba8 | 298:841eeb16dcf7 |
|---|---|
| 1047 end | 1047 end |
| 1048 end | 1048 end |
| 1049 end | 1049 end |
| 1050 | 1050 |
| 1051 | 1051 |
| 1052 function WDP:GROUP_ROSTER_UPDATE() | 1052 local function UpdateUnitPet(unit_guid, unit_id) |
| 1053 local is_raid = _G.IsInRaid() | |
| 1054 local unit_type = is_raid and "raid" or "party" | |
| 1055 local group_size = is_raid and _G.GetNumGroupMembers() or _G.GetNumSubgroupMembers() | |
| 1056 | |
| 1057 table.wipe(group_member_uids) | |
| 1058 | |
| 1059 Debug("GROUP_ROSTER_UPDATE: %s group - %d members.", unit_type, group_size) | |
| 1060 | |
| 1061 for index = 1, group_size do | |
| 1062 local group_unit = unit_type .. index | |
| 1063 local unit_guid = _G.UnitGUID(group_unit) | |
| 1064 | |
| 1065 Debug("%s (%s) added as GUID %s", group_unit, _G.UnitName(group_unit), unit_guid) | |
| 1066 group_member_uids[unit_guid] = true | |
| 1067 end | |
| 1068 group_member_uids[_G.UnitGUID("player")] = true | |
| 1069 end | |
| 1070 | |
| 1071 | |
| 1072 function WDP:UNIT_PET(event_name, unit_id) | |
| 1073 local unit_guid = _G.UnitGUID(unit_id) | |
| 1074 local current_pet_guid = group_owner_guids_to_pet_guids[unit_guid] | 1053 local current_pet_guid = group_owner_guids_to_pet_guids[unit_guid] |
| 1075 | 1054 |
| 1076 if current_pet_guid then | 1055 if current_pet_guid then |
| 1077 Debug("Removing existing pet GUID for %s", _G.UnitName(unit_id)) | 1056 Debug("Removing existing pet GUID for %s", _G.UnitName(unit_id)) |
| 1078 group_owner_guids_to_pet_guids[unit_guid] = nil | 1057 group_owner_guids_to_pet_guids[unit_guid] = nil |
| 1083 if pet_guid then | 1062 if pet_guid then |
| 1084 Debug("Adding new pet GUID for %s.", _G.UnitName(unit_id)) | 1063 Debug("Adding new pet GUID for %s.", _G.UnitName(unit_id)) |
| 1085 group_owner_guids_to_pet_guids[unit_guid] = pet_guid | 1064 group_owner_guids_to_pet_guids[unit_guid] = pet_guid |
| 1086 group_pet_guids[pet_guid] = true | 1065 group_pet_guids[pet_guid] = true |
| 1087 end | 1066 end |
| 1067 end | |
| 1068 | |
| 1069 | |
| 1070 function WDP:GROUP_ROSTER_UPDATE(event_name) | |
| 1071 local is_raid = _G.IsInRaid() | |
| 1072 local unit_type = is_raid and "raid" or "party" | |
| 1073 local group_size = is_raid and _G.GetNumGroupMembers() or _G.GetNumSubgroupMembers() | |
| 1074 | |
| 1075 table.wipe(group_member_uids) | |
| 1076 | |
| 1077 Debug("GROUP_ROSTER_UPDATE: %s group - %d members.", unit_type, group_size) | |
| 1078 | |
| 1079 for index = 1, group_size do | |
| 1080 local unit_id = unit_type .. index | |
| 1081 local unit_guid = _G.UnitGUID(unit_id) | |
| 1082 | |
| 1083 group_member_uids[unit_guid] = true | |
| 1084 Debug("%s (%s) added as GUID %s", unit_id, _G.UnitName(unit_id), unit_guid) | |
| 1085 UpdateUnitPet(unit_guid, unit_id) | |
| 1086 end | |
| 1087 group_member_uids[_G.UnitGUID("player")] = true | |
| 1088 end | |
| 1089 | |
| 1090 | |
| 1091 function WDP:UNIT_PET(event_name, unit_id) | |
| 1092 UpdateUnitPet(_G.UnitGUID(unit_id), unit_id) | |
| 1088 end | 1093 end |
| 1089 | 1094 |
| 1090 | 1095 |
| 1091 function WDP:SHOW_LOOT_TOAST(event_name, loot_type, item_link, quantity) | 1096 function WDP:SHOW_LOOT_TOAST(event_name, loot_type, item_link, quantity) |
| 1092 if loot_type ~= "item" then | 1097 if loot_type ~= "item" then |
