Mercurial > wow > wowdb-profiler
comparison Main.lua @ 328:3487529df8e5
Fixed several nil errors, including at least four with zone_data, and spell detection now ignores Chi Wave.
| author | MMOSimca <MMOSimca@gmail.com> | 
|---|---|
| date | Wed, 06 Aug 2014 04:31:49 -0400 | 
| parents | 66b136635f6b | 
| children | 84817627cb22 | 
   comparison
  equal
  deleted
  inserted
  replaced
| 327:c191c8a521fb | 328:3487529df8e5 | 
|---|---|
| 45 local PLAYER_FACTION = _G.UnitFactionGroup("player") | 45 local PLAYER_FACTION = _G.UnitFactionGroup("player") | 
| 46 local PLAYER_GUID | 46 local PLAYER_GUID | 
| 47 local PLAYER_NAME = _G.UnitName("player") | 47 local PLAYER_NAME = _G.UnitName("player") | 
| 48 local PLAYER_RACE = _G.select(2, _G.UnitRace("player")) | 48 local PLAYER_RACE = _G.select(2, _G.UnitRace("player")) | 
| 49 | 49 | 
| 50 local SPELL_ID_CHI_WAVE = 132464 | |
| 50 local SPELL_ID_DISGUISE = 121308 | 51 local SPELL_ID_DISGUISE = 121308 | 
| 51 | 52 | 
| 52 local ALLOWED_LOCALES = { | 53 local ALLOWED_LOCALES = { | 
| 53 enUS = true, | 54 enUS = true, | 
| 54 enGB = true, | 55 enGB = true, | 
| 513 function UpdateDBEntryLocation(entry_type, identifier) | 514 function UpdateDBEntryLocation(entry_type, identifier) | 
| 514 if not identifier then | 515 if not identifier then | 
| 515 return | 516 return | 
| 516 end | 517 end | 
| 517 local zone_name, area_id, x, y, map_level, difficulty_token = CurrentLocationData() | 518 local zone_name, area_id, x, y, map_level, difficulty_token = CurrentLocationData() | 
| 519 if not (zone_name and area_id and x and y and map_level) then | |
| 520 Debug("UpdateDBEntryLocation: Missing current location data - %s, %d, %d, %d, %d.", zone_name, area_id, x, y, map_level) | |
| 521 return | |
| 522 end | |
| 518 local entry = DBEntry(entry_type, identifier) | 523 local entry = DBEntry(entry_type, identifier) | 
| 519 entry[difficulty_token] = entry[difficulty_token] or {} | 524 entry[difficulty_token] = entry[difficulty_token] or {} | 
| 520 entry[difficulty_token].locations = entry[difficulty_token].locations or {} | 525 entry[difficulty_token].locations = entry[difficulty_token].locations or {} | 
| 521 | 526 | 
| 522 local zone_token = ("%s:%d"):format(zone_name, area_id) | 527 local zone_token = ("%s:%d"):format(zone_name, area_id) | 
| 666 local source_id | 671 local source_id | 
| 667 | 672 | 
| 668 if current_loot.target_type == AF.ITEM then | 673 if current_loot.target_type == AF.ITEM then | 
| 669 -- Items return the player as the source, so we need to use the item's ID (disenchant, milling, etc) | 674 -- Items return the player as the source, so we need to use the item's ID (disenchant, milling, etc) | 
| 670 source_id = current_loot.identifier | 675 source_id = current_loot.identifier | 
| 671 elseif current_loot.target_type == AF.OBJECT then | |
| 672 source_id = ("%s:%s"):format(current_loot.spell_label, select(2, ParseGUID(source_guid))) | |
| 673 else | 676 else | 
| 674 source_id = select(2, ParseGUID(source_guid)) | 677 local unit_ID = select(2, ParseGUID(source_guid)) | 
| 678 if unit_ID then | |
| 679 if current_loot.target_type == AF.OBJECT then | |
| 680 source_id = ("%s:%s"):format(current_loot.spell_label, unit_ID) | |
| 681 else | |
| 682 source_id = unit_ID | |
| 683 end | |
| 684 end | |
| 675 end | 685 end | 
| 676 local entry = DBEntry(data_type, source_id) | 686 local entry = DBEntry(data_type, source_id) | 
| 677 | 687 | 
| 678 if entry then | 688 if entry then | 
| 679 local loot_table = LootTable(entry, loot_type, top_field) | 689 local loot_table = LootTable(entry, loot_type, top_field) | 
| 1112 | 1122 | 
| 1113 if not npc then | 1123 if not npc then | 
| 1114 return | 1124 return | 
| 1115 end | 1125 end | 
| 1116 local zone_name, area_id, x, y, map_level, difficulty_token = CurrentLocationData() | 1126 local zone_name, area_id, x, y, map_level, difficulty_token = CurrentLocationData() | 
| 1127 if not (zone_name and area_id and x and y and map_level) then | |
| 1128 Debug("UpdateTargetLocation: Missing current location data - %s, %d, %d, %d, %d.", zone_name, area_id, x, y, map_level) | |
| 1129 return | |
| 1130 end | |
| 1117 local npc_data = npc:EncounterData(difficulty_token).stats[("level_%d"):format(_G.UnitLevel("target"))] | 1131 local npc_data = npc:EncounterData(difficulty_token).stats[("level_%d"):format(_G.UnitLevel("target"))] | 
| 1118 local zone_token = ("%s:%d"):format(zone_name, area_id) | 1132 local zone_token = ("%s:%d"):format(zone_name, area_id) | 
| 1119 npc_data.locations = npc_data.locations or {} -- TODO: Fix this. It is broken. Possibly something to do with the timed updates. | 1133 npc_data.locations = npc_data.locations or {} -- TODO: Fix this. It is broken. Possibly something to do with the timed updates. | 
| 1120 | 1134 | 
| 1121 local zone_data = npc_data.locations[zone_token] | 1135 local zone_data = npc_data.locations[zone_token] | 
| 1432 do -- do-block | 1446 do -- do-block | 
| 1433 local FLAGS_NPC = bit.bor(_G.COMBATLOG_OBJECT_TYPE_GUARDIAN, _G.COMBATLOG_OBJECT_CONTROL_NPC) | 1447 local FLAGS_NPC = bit.bor(_G.COMBATLOG_OBJECT_TYPE_GUARDIAN, _G.COMBATLOG_OBJECT_CONTROL_NPC) | 
| 1434 local FLAGS_NPC_CONTROL = bit.bor(_G.COMBATLOG_OBJECT_AFFILIATION_OUTSIDER, _G.COMBATLOG_OBJECT_CONTROL_NPC) | 1448 local FLAGS_NPC_CONTROL = bit.bor(_G.COMBATLOG_OBJECT_AFFILIATION_OUTSIDER, _G.COMBATLOG_OBJECT_CONTROL_NPC) | 
| 1435 | 1449 | 
| 1436 local function RecordNPCSpell(sub_event, source_guid, source_name, source_flags, dest_guid, dest_name, dest_flags, spell_id, spell_name) | 1450 local function RecordNPCSpell(sub_event, source_guid, source_name, source_flags, dest_guid, dest_name, dest_flags, spell_id, spell_name) | 
| 1437 if not spell_id or spell_id == SPELL_ID_DISGUISE then | 1451 if not spell_id or spell_id == SPELL_ID_CHI_WAVE or spell_id == SPELL_ID_DISGUISE then | 
| 1438 return | 1452 return | 
| 1439 end | 1453 end | 
| 1440 local source_type, source_id = ParseGUID(source_guid) | 1454 local source_type, source_id = ParseGUID(source_guid) | 
| 1441 | 1455 | 
| 1442 if not source_id or not UnitTypeIsNPC(source_type) then | 1456 if not source_id or not UnitTypeIsNPC(source_type) then | 
| 1746 end, | 1760 end, | 
| 1747 [AF.OBJECT] = function() | 1761 [AF.OBJECT] = function() | 
| 1748 GenericLootUpdate("objects", InstanceDifficultyToken()) | 1762 GenericLootUpdate("objects", InstanceDifficultyToken()) | 
| 1749 end, | 1763 end, | 
| 1750 [AF.ZONE] = function() | 1764 [AF.ZONE] = function() | 
| 1765 if not (current_loot.map_level and current_loot.x and current_loot.y and current_loot.zone_data) then | |
| 1766 return | |
| 1767 end | |
| 1751 local location_token = ("%d:%d:%d"):format(current_loot.map_level, current_loot.x, current_loot.y) | 1768 local location_token = ("%d:%d:%d"):format(current_loot.map_level, current_loot.x, current_loot.y) | 
| 1752 | 1769 | 
| 1753 -- This will start life as a boolean true. | 1770 -- This will start life as a boolean true. | 
| 1754 if _G.type(current_loot.zone_data[location_token]) ~= "table" then | 1771 if _G.type(current_loot.zone_data[location_token]) ~= "table" then | 
| 1755 current_loot.zone_data[location_token] = { | 1772 current_loot.zone_data[location_token] = { | 
| 2046 DatamineTT:SetMerchantItem(item_index) | 2063 DatamineTT:SetMerchantItem(item_index) | 
| 2047 | 2064 | 
| 2048 if not item_id then | 2065 if not item_id then | 
| 2049 local item_name, item_link = DatamineTT:GetItem() | 2066 local item_name, item_link = DatamineTT:GetItem() | 
| 2050 item_id = ItemLinkToID(item_link) | 2067 item_id = ItemLinkToID(item_link) | 
| 2051 Debug("%s: GetMerchantItemLink() still ocassionally fails, apparently. Failed item's ID - %s", event_name, item_id) | 2068 if item_id then | 
| 2069 Debug("%s: GetMerchantItemLink() still ocassionally fails, apparently. Failed item's ID - %s", event_name, item_id) | |
| 2070 else | |
| 2071 Debug("%s: GetMerchantItemLink() still ocassionally fails, apparently. Failed item's ID - nil", event_name) | |
| 2072 end | |
| 2052 end | 2073 end | 
| 2053 | 2074 | 
| 2054 if item_id and item_id > 0 then | 2075 if item_id and item_id > 0 then | 
| 2055 local price_string = ActualCopperCost(copper_price, merchant_standing) | 2076 local price_string = ActualCopperCost(copper_price, merchant_standing) | 
| 2056 | 2077 | 
| 2415 unit_name = target_name | 2436 unit_name = target_name | 
| 2416 unit_id = "target" | 2437 unit_id = "target" | 
| 2417 end | 2438 end | 
| 2418 local spell_flags = private.SPELL_FLAGS_BY_LABEL[spell_label] | 2439 local spell_flags = private.SPELL_FLAGS_BY_LABEL[spell_label] | 
| 2419 local zone_name, area_id, x, y, map_level, instance_token = CurrentLocationData() | 2440 local zone_name, area_id, x, y, map_level, instance_token = CurrentLocationData() | 
| 2441 if not (zone_name and area_id and x and y and map_level) then | |
| 2442 Debug("%s: Missing current location data - %s, %d, %d, %d, %d.", event_name, zone_name, area_id, x, y, map_level) | |
| 2443 return | |
| 2444 end | |
| 2420 | 2445 | 
| 2421 table.wipe(current_action) | 2446 table.wipe(current_action) | 
| 2422 current_action.instance_token = instance_token | 2447 current_action.instance_token = instance_token | 
| 2423 current_action.map_level = map_level | 2448 current_action.map_level = map_level | 
| 2424 current_action.x = x | 2449 current_action.x = x | 
