Mercurial > wow > wowdb-profiler
comparison Main.lua @ 468:0997fb63abeb
Fixed bugs caused by attempting mathematical operations on 'nil' results from HereBeDragons.
author | Caleb Atherton <catherton@curse.com> |
---|---|
date | Sun, 19 Jun 2016 20:46:23 -0400 |
parents | eb87dbc295b3 |
children | fd48b8d72f13 |
comparison
equal
deleted
inserted
replaced
467:a463db95c1b6 | 468:0997fb63abeb |
---|---|
373 end | 373 end |
374 | 374 |
375 | 375 |
376 local function CurrentLocationData() | 376 local function CurrentLocationData() |
377 local x, y, current_area_id, map_level = HereBeDragons:GetPlayerZonePosition(true) | 377 local x, y, current_area_id, map_level = HereBeDragons:GetPlayerZonePosition(true) |
378 local zone_name = _G.GetRealZoneText() | |
378 | 379 |
379 -- Put coordinates into expected format (as integers, they don't get a billion decimals output in the SavedVariables) | 380 -- Put coordinates into expected format (as integers, they don't get a billion decimals output in the SavedVariables) |
380 local x_int = _G.floor(x * 1000) | 381 local x_int = nil |
381 local y_int = _G.floor(y * 1000) | 382 if (x and type(x) == "number") then |
382 if x_int % 2 ~= 0 then | 383 x_int = _G.floor(x * 1000) |
383 x_int = x_int + 1 | 384 if x_int % 2 ~= 0 then |
384 end | 385 x_int = x_int + 1 |
385 if y_int % 2 ~= 0 then | 386 end |
386 y_int = y_int + 1 | 387 end |
387 end | 388 local y_int = nil |
388 | 389 if (y and type(y) == "number") then |
389 return _G.GetRealZoneText(), current_area_id, x_int, y_int, map_level, InstanceDifficultyToken() | 390 y_int = _G.floor(y * 1000) |
391 if y_int % 2 ~= 0 then | |
392 y_int = y_int + 1 | |
393 end | |
394 end | |
395 | |
396 return zone_name, current_area_id, x_int, y_int, map_level, InstanceDifficultyToken() | |
390 end | 397 end |
391 | 398 |
392 | 399 |
393 local function DBEntry(data_type, unit_id) | 400 local function DBEntry(data_type, unit_id) |
394 if not data_type or not unit_id then | 401 if not data_type or not unit_id then |
451 if not identifier then | 458 if not identifier then |
452 return | 459 return |
453 end | 460 end |
454 local zone_name, area_id, x, y, map_level, difficulty_token = CurrentLocationData() | 461 local zone_name, area_id, x, y, map_level, difficulty_token = CurrentLocationData() |
455 if not (zone_name and area_id and x and y and map_level) then | 462 if not (zone_name and area_id and x and y and map_level) then |
456 Debug("UpdateDBEntryLocation: Missing current location data - %s, %d, %d, %d, %d.", zone_name, area_id, x, y, map_level) | 463 Debug("UpdateDBEntryLocation: Missing current location data - %s, %s, %s, %s, %s.", tostring(zone_name), tostring(area_id), tostring(x), tostring(y), tostring(map_level)) |
457 return | 464 return |
458 end | 465 end |
459 local entry = DBEntry(entry_type, identifier) | 466 local entry = DBEntry(entry_type, identifier) |
460 entry[difficulty_token] = entry[difficulty_token] or {} | 467 entry[difficulty_token] = entry[difficulty_token] or {} |
461 entry[difficulty_token].locations = entry[difficulty_token].locations or {} | 468 entry[difficulty_token].locations = entry[difficulty_token].locations or {} |
1146 if not npc then | 1153 if not npc then |
1147 return | 1154 return |
1148 end | 1155 end |
1149 local zone_name, area_id, x, y, map_level, difficulty_token = CurrentLocationData() | 1156 local zone_name, area_id, x, y, map_level, difficulty_token = CurrentLocationData() |
1150 if not (zone_name and area_id and x and y and map_level) then | 1157 if not (zone_name and area_id and x and y and map_level) then |
1151 Debug("UpdateTargetLocation: Missing current location data - %s, %d, %d, %d, %d.", zone_name, area_id, x, y, map_level) | 1158 Debug("UpdateTargetLocation: Missing current location data - %s, %s, %s, %s, %s.", tostring(zone_name), tostring(area_id), tostring(x), tostring(y), tostring(map_level)) |
1152 return | 1159 return |
1153 end | 1160 end |
1154 local npc_data = npc:EncounterData(difficulty_token).stats[("level_%d"):format(_G.UnitLevel("target"))] | 1161 local npc_data = npc:EncounterData(difficulty_token).stats[("level_%d"):format(_G.UnitLevel("target"))] |
1155 local zone_token = ("%s:%d"):format(zone_name, area_id) | 1162 local zone_token = ("%s:%d"):format(zone_name, area_id) |
1156 npc_data.locations = npc_data.locations or {} -- TODO: Fix this. It is broken. Possibly something to do with the timed updates. | 1163 npc_data.locations = npc_data.locations or {} -- TODO: Fix this. It is broken. Possibly something to do with the timed updates. |
2026 | 2033 |
2027 if _G.IsFishingLoot() then | 2034 if _G.IsFishingLoot() then |
2028 -- Set up a proper 'fishing' current_action table | 2035 -- Set up a proper 'fishing' current_action table |
2029 local zone_name, area_id, x, y, map_level, instance_token = CurrentLocationData() | 2036 local zone_name, area_id, x, y, map_level, instance_token = CurrentLocationData() |
2030 if not (zone_name and area_id and x and y and map_level) then | 2037 if not (zone_name and area_id and x and y and map_level) then |
2031 Debug("%s: Missing current location data - %s, %d, %d, %d, %d.", log_source, zone_name, area_id, x, y, map_level) | 2038 Debug("%s: Missing current location data - %s, %s, %s, %s, %s.", log_source, tostring(zone_name), tostring(area_id), tostring(x), tostring(y), tostring(map_level)) |
2032 return | 2039 return |
2033 end | 2040 end |
2034 current_action.instance_token = instance_token | 2041 current_action.instance_token = instance_token |
2035 current_action.map_level = map_level | 2042 current_action.map_level = map_level |
2036 current_action.x = x | 2043 current_action.x = x |
2693 unit_id = "target" | 2700 unit_id = "target" |
2694 end | 2701 end |
2695 local spell_flags = private.SPELL_FLAGS_BY_LABEL[spell_label] | 2702 local spell_flags = private.SPELL_FLAGS_BY_LABEL[spell_label] |
2696 local zone_name, area_id, x, y, map_level, instance_token = CurrentLocationData() | 2703 local zone_name, area_id, x, y, map_level, instance_token = CurrentLocationData() |
2697 if not (zone_name and area_id and x and y and map_level) then | 2704 if not (zone_name and area_id and x and y and map_level) then |
2698 Debug("%s: Missing current location data - %s, %d, %d, %d, %d.", event_name, zone_name, area_id, x, y, map_level) | 2705 Debug("%s: Missing current location data - %s, %s, %s, %s, %s.", event_name, tostring(zone_name), tostring(area_id), tostring(x), tostring(y), tostring(map_level)) |
2699 return | 2706 return |
2700 end | 2707 end |
2701 | 2708 |
2702 table.wipe(current_action) | 2709 table.wipe(current_action) |
2703 current_action.instance_token = instance_token | 2710 current_action.instance_token = instance_token |