Mercurial > wow > wowdb-profiler
comparison Main.lua @ 24:7cc6ca206c00
Store race and class of the player on quest details. Store the current map area id alongside the zone name.
| author | James D. Callahan III <jcallahan@curse.com> | 
|---|---|
| date | Mon, 14 May 2012 17:13:32 -0500 | 
| parents | 2ff0171bddae | 
| children | e681130c2144 | 
   comparison
  equal
  deleted
  inserted
  replaced
| 23:2ff0171bddae | 24:7cc6ca206c00 | 
|---|---|
| 117 end | 117 end | 
| 118 | 118 | 
| 119 if _G.DungeonUsesTerrainMap() then | 119 if _G.DungeonUsesTerrainMap() then | 
| 120 map_level = map_level - 1 | 120 map_level = map_level - 1 | 
| 121 end | 121 end | 
| 122 return _G.GetRealZoneText(), ("%.2f"):format(x * 100), ("%.2f"):format(y * 100), map_level or 0, InstanceDifficultyToken() | 122 return _G.GetRealZoneText(), _G.GetCurrentMapAreaID(), ("%.2f"):format(x * 100), ("%.2f"):format(y * 100), map_level, InstanceDifficultyToken() | 
| 123 end | 123 end | 
| 124 | 124 | 
| 125 | 125 | 
| 126 local function ItemLinkToID(item_link) | 126 local function ItemLinkToID(item_link) | 
| 127 if not item_link then | 127 if not item_link then | 
| 152 | 152 | 
| 153 local function UpdateObjectLocation(identifier) | 153 local function UpdateObjectLocation(identifier) | 
| 154 if not identifier then | 154 if not identifier then | 
| 155 return | 155 return | 
| 156 end | 156 end | 
| 157 local zone_name, x, y, map_level, instance_token = CurrentLocationData() | 157 local zone_name, area_id, x, y, map_level, instance_token = CurrentLocationData() | 
| 158 local object = DBEntry("objects", identifier) | 158 local object = DBEntry("objects", identifier) | 
| 159 object.locations = object.locations or {} | 159 object.locations = object.locations or {} | 
| 160 | 160 | 
| 161 if not object.locations[zone_name] then | 161 local location_token = ("%s:%d"):format(zone_name, area_id) | 
| 162 object.locations[zone_name] = {} | 162 | 
| 163 end | 163 if not object.locations[location_token] then | 
| 164 object.locations[zone_name][("%s:%s:%s:%s"):format(instance_token, map_level, x, y)] = true | 164 object.locations[location_token] = {} | 
| 165 end | |
| 166 object.locations[location_token][("%s:%s:%s:%s"):format(instance_token, map_level, x, y)] = true | |
| 165 end | 167 end | 
| 166 | 168 | 
| 167 | 169 | 
| 168 local function HandleItemUse(item_link, bag_index, slot_index) | 170 local function HandleItemUse(item_link, bag_index, slot_index) | 
| 169 if not item_link then | 171 if not item_link then | 
| 321 local unit_type, unit_idnum = self:ParseGUID(target_guid) | 323 local unit_type, unit_idnum = self:ParseGUID(target_guid) | 
| 322 | 324 | 
| 323 if unit_type ~= private.UNIT_TYPES.NPC or not unit_idnum then | 325 if unit_type ~= private.UNIT_TYPES.NPC or not unit_idnum then | 
| 324 return | 326 return | 
| 325 end | 327 end | 
| 326 local zone_name, x, y, map_level, instance_token = CurrentLocationData() | 328 local zone_name, area_id, x, y, map_level, instance_token = CurrentLocationData() | 
| 327 local npc_data = DBEntry("npcs", unit_idnum).encounter_data[("level_%d"):format(_G.UnitLevel("target"))] | 329 local npc_data = DBEntry("npcs", unit_idnum).encounter_data[("level_%d"):format(_G.UnitLevel("target"))] | 
| 328 npc_data.locations = npc_data.locations or {} | 330 npc_data.locations = npc_data.locations or {} | 
| 329 | 331 | 
| 330 if not npc_data.locations[zone_name] then | 332 local location_token = ("%s:%d"):format(zone_name, area_id) | 
| 331 npc_data.locations[zone_name] = {} | 333 | 
| 334 if not npc_data.locations[location_token] then | |
| 335 npc_data.locations[location_token] = {} | |
| 332 end | 336 end | 
| 333 | 337 | 
| 334 -- Only record corpse location if there is no entry for this GUID. | 338 -- Only record corpse location if there is no entry for this GUID. | 
| 335 if is_dead and npc_data.locations[zone_name][target_guid] then | 339 if is_dead and npc_data.locations[location_token][target_guid] then | 
| 336 return | 340 return | 
| 337 end | 341 end | 
| 338 npc_data.locations[zone_name][target_guid] = ("%s:%s:%s:%s"):format(instance_token, map_level, x, y) | 342 npc_data.locations[location_token][target_guid] = ("%s:%s:%s:%s"):format(instance_token, map_level, x, y) | 
| 339 end | 343 end | 
| 340 | 344 | 
| 341 | 345 | 
| 342 ----------------------------------------------------------------------- | 346 ----------------------------------------------------------------------- | 
| 343 -- Event handlers. | 347 -- Event handlers. | 
| 756 UpdateObjectLocation(unit_id) | 760 UpdateObjectLocation(unit_id) | 
| 757 end | 761 end | 
| 758 local quest = DBEntry("quests", _G.GetQuestID()) | 762 local quest = DBEntry("quests", _G.GetQuestID()) | 
| 759 quest[point] = quest[point] or {} | 763 quest[point] = quest[point] or {} | 
| 760 quest[point][("%s:%d"):format(private.UNIT_TYPE_NAMES[unit_type + 1], unit_id)] = true | 764 quest[point][("%s:%d"):format(private.UNIT_TYPE_NAMES[unit_type + 1], unit_id)] = true | 
| 765 | |
| 766 return quest | |
| 761 end | 767 end | 
| 762 | 768 | 
| 763 | 769 | 
| 764 function WDP:QUEST_COMPLETE() | 770 function WDP:QUEST_COMPLETE() | 
| 765 UpdateQuestJuncture("end") | 771 UpdateQuestJuncture("end") | 
| 766 end | 772 end | 
| 767 | 773 | 
| 768 | 774 | 
| 769 function WDP:QUEST_DETAIL() | 775 function WDP:QUEST_DETAIL() | 
| 770 UpdateQuestJuncture("begin") | 776 local quest = UpdateQuestJuncture("begin") | 
| 777 | |
| 778 local _, class = _G.UnitClass("player") | |
| 779 quest.classes = quest.classes or {} | |
| 780 quest.classes[class] = true | |
| 781 | |
| 782 local _, race = _G.UnitRace("player") | |
| 783 quest.races = quest.races or {} | |
| 784 quest.races[race] = true | |
| 771 end | 785 end | 
| 772 end -- do-block | 786 end -- do-block | 
| 773 | 787 | 
| 774 | 788 | 
| 775 function WDP:QUEST_LOG_UPDATE() | 789 function WDP:QUEST_LOG_UPDATE() | 
| 822 elseif target_name and target_name ~= "" then | 836 elseif target_name and target_name ~= "" then | 
| 823 local _, target_item_link = _G.GetItemInfo(target_name) | 837 local _, target_item_link = _G.GetItemInfo(target_name) | 
| 824 action_data.item_id = ItemLinkToID(target_item_link) | 838 action_data.item_id = ItemLinkToID(target_item_link) | 
| 825 end | 839 end | 
| 826 elseif not tt_item_name and not tt_unit_name then | 840 elseif not tt_item_name and not tt_unit_name then | 
| 827 local zone_name, x, y, map_level, instance_token = CurrentLocationData() | 841 local zone_name, area_id, x, y, map_level, instance_token = CurrentLocationData() | 
| 828 | 842 | 
| 829 action_data.instance_token = instance_token | 843 action_data.instance_token = instance_token | 
| 830 action_data.map_level = map_level | 844 action_data.map_level = map_level | 
| 831 action_data.name = target_name | 845 action_data.name = target_name | 
| 832 action_data.x = x | 846 action_data.x = x | 
| 833 action_data.y = y | 847 action_data.y = y | 
| 834 action_data.zone = zone_name | 848 action_data.zone = ("%s:%d"):format(zone_name, area_id) | 
| 835 | 849 | 
| 836 if bit.band(spell_flags, AF.OBJECT) == AF.OBJECT then | 850 if bit.band(spell_flags, AF.OBJECT) == AF.OBJECT then | 
| 837 if target_name == "" then | 851 if target_name == "" then | 
| 838 return | 852 return | 
| 839 end | 853 end | 
