Mercurial > wow > wowdb-profiler
comparison Main.lua @ 441:7e0ef2127b49
Replaced LibMapData-1.0 usage with standard WoW 5.X map functions. They even perform better (LibMapData-1.0 was returning 0,0 for new content).
author | MMOSimca <MMOSimca@gmail.com> |
---|---|
date | Sat, 28 Feb 2015 23:59:07 -0500 |
parents | a4256abd13b7 |
children | 2151f136ca5c |
comparison
equal
deleted
inserted
replaced
440:a4256abd13b7 | 441:7e0ef2127b49 |
---|---|
24 local LibStub = _G.LibStub | 24 local LibStub = _G.LibStub |
25 local WDP = LibStub("AceAddon-3.0"):NewAddon(ADDON_NAME, "AceConsole-3.0", "AceEvent-3.0") | 25 local WDP = LibStub("AceAddon-3.0"):NewAddon(ADDON_NAME, "AceConsole-3.0", "AceEvent-3.0") |
26 | 26 |
27 local deformat = LibStub("LibDeformat-3.0") | 27 local deformat = LibStub("LibDeformat-3.0") |
28 local LPJ = LibStub("LibPetJournal-2.0") | 28 local LPJ = LibStub("LibPetJournal-2.0") |
29 local MapData = LibStub("LibMapData-1.0") | |
30 | 29 |
31 local DatamineTT = _G.CreateFrame("GameTooltip", "WDPDatamineTT", _G.UIParent, "GameTooltipTemplate") | 30 local DatamineTT = _G.CreateFrame("GameTooltip", "WDPDatamineTT", _G.UIParent, "GameTooltipTemplate") |
32 DatamineTT:SetOwner(_G.WorldFrame, "ANCHOR_NONE") | 31 DatamineTT:SetOwner(_G.WorldFrame, "ANCHOR_NONE") |
33 | 32 |
34 | 33 |
361 end | 360 end |
362 return "NONE:0:false" | 361 return "NONE:0:false" |
363 end | 362 end |
364 | 363 |
365 | 364 |
365 local function CurrentLocationData() | |
366 if _G.GetCurrentMapAreaID() ~= current_area_id then | |
367 return _G.GetRealZoneText(), current_area_id, 0, 0, 0, InstanceDifficultyToken() | |
368 end | |
369 local map_level = _G.GetCurrentMapDungeonLevel() or 0 | |
370 local x, y = _G.GetPlayerMapPosition("player") | |
371 | |
372 x = x or 0 | |
373 y = y or 0 | |
374 | |
375 if x == 0 and y == 0 then | |
376 for level_index = 1, _G.GetNumDungeonMapLevels() do | |
377 _G.SetDungeonMapLevel(level_index) | |
378 x, y = _G.GetPlayerMapPosition("player") | |
379 | |
380 if x and y and (x > 0 or y > 0) then | |
381 _G.SetDungeonMapLevel(map_level) | |
382 map_level = level_index | |
383 break | |
384 end | |
385 end | |
386 end | |
387 | |
388 if _G.DungeonUsesTerrainMap() then | |
389 map_level = map_level - 1 | |
390 end | |
391 local x = _G.floor(x * 1000) | |
392 local y = _G.floor(y * 1000) | |
393 | |
394 if x % 2 ~= 0 then | |
395 x = x + 1 | |
396 end | |
397 | |
398 if y % 2 ~= 0 then | |
399 y = y + 1 | |
400 end | |
401 return _G.GetRealZoneText(), current_area_id, x, y, map_level, InstanceDifficultyToken() | |
402 end | |
403 | |
404 | |
366 local function DBEntry(data_type, unit_id) | 405 local function DBEntry(data_type, unit_id) |
367 if not data_type or not unit_id then | 406 if not data_type or not unit_id then |
368 return | 407 return |
369 end | 408 end |
370 local category = global_db[data_type] | 409 local category = global_db[data_type] |
404 return self.encounter_data[difficulty_token] | 443 return self.encounter_data[difficulty_token] |
405 end | 444 end |
406 end | 445 end |
407 | 446 |
408 | 447 |
409 local function CurrentLocationData() | |
410 if _G.GetCurrentMapAreaID() ~= current_area_id then | |
411 return _G.GetRealZoneText(), current_area_id, 0, 0, 0, InstanceDifficultyToken() | |
412 end | |
413 local map_level = _G.GetCurrentMapDungeonLevel() or 0 | |
414 local x, y = _G.GetPlayerMapPosition("player") | |
415 | |
416 x = x or 0 | |
417 y = y or 0 | |
418 | |
419 if x == 0 and y == 0 then | |
420 for level_index = 1, _G.GetNumDungeonMapLevels() do | |
421 _G.SetDungeonMapLevel(level_index) | |
422 x, y = _G.GetPlayerMapPosition("player") | |
423 | |
424 if x and y and (x > 0 or y > 0) then | |
425 _G.SetDungeonMapLevel(map_level) | |
426 map_level = level_index | |
427 break | |
428 end | |
429 end | |
430 end | |
431 | |
432 if _G.DungeonUsesTerrainMap() then | |
433 map_level = map_level - 1 | |
434 end | |
435 local x = _G.floor(x * 1000) | |
436 local y = _G.floor(y * 1000) | |
437 | |
438 if x % 2 ~= 0 then | |
439 x = x + 1 | |
440 end | |
441 | |
442 if y % 2 ~= 0 then | |
443 y = y + 1 | |
444 end | |
445 return _G.GetRealZoneText(), current_area_id, x, y, map_level, InstanceDifficultyToken() | |
446 end | |
447 | |
448 | |
449 local function CurrencyLinkToTexture(currency_link) | |
450 if not currency_link then | |
451 return | |
452 end | |
453 local _, _, texture_path = _G.GetCurrencyInfo(tonumber(currency_link:match("currency:(%d+)"))) | |
454 return texture_path:match("[^\\]+$"):lower() | |
455 end | |
456 | |
457 | |
458 local function ItemLinkToID(item_link) | |
459 if not item_link then | |
460 return | |
461 end | |
462 return tonumber(tostring(item_link):match("item:(%d+)")) | |
463 end | |
464 | |
465 private.ItemLinkToID = ItemLinkToID | |
466 | |
467 local function UnitTypeIsNPC(unit_type) | |
468 return unit_type == private.UNIT_TYPES.NPC or unit_type == private.UNIT_TYPES.VEHICLE | |
469 end | |
470 | |
471 | |
472 local ParseGUID | |
473 do | |
474 local UNIT_TYPES = private.UNIT_TYPES | |
475 | |
476 local NPC_ID_MAPPING = { | |
477 [62164] = 63191, -- Garalon | |
478 } | |
479 | |
480 | |
481 local function MatchUnitTypes(unit_type_name) | |
482 if not unit_type_name then | |
483 return UNIT_TYPES.UNKNOWN | |
484 end | |
485 | |
486 for def, text in next, UNIT_TYPES do | |
487 if unit_type_name == text then | |
488 return UNIT_TYPES[def] | |
489 end | |
490 end | |
491 return UNIT_TYPES.UNKNOWN | |
492 end | |
493 | |
494 | |
495 function ParseGUID(guid) | |
496 if not guid then | |
497 return | |
498 end | |
499 | |
500 -- We might want to use some of this new information later, but leaving the returns alone for now | |
501 local unit_type_name, unk_id1, server_id, instance_id, unk_id2, unit_idnum, spawn_id = ("-"):split(guid) | |
502 | |
503 local unit_type = MatchUnitTypes(unit_type_name) | |
504 if unit_type ~= UNIT_TYPES.PLAYER and unit_type ~= UNIT_TYPES.PET and unit_type ~= UNIT_TYPES.ITEM then | |
505 | |
506 local id_mapping = NPC_ID_MAPPING[unit_idnum] | |
507 | |
508 if id_mapping and UnitTypeIsNPC(unit_type) then | |
509 unit_idnum = id_mapping | |
510 end | |
511 return unit_type, unit_idnum | |
512 end | |
513 return unit_type | |
514 end | |
515 | |
516 private.ParseGUID = ParseGUID | |
517 end -- do-block | |
518 | |
519 | |
520 local UpdateDBEntryLocation | 448 local UpdateDBEntryLocation |
521 do | 449 do |
522 -- Fishing node coordinate code based on code in GatherMate2 with permission from Kagaro. | 450 -- Fishing node coordinate code based on code in GatherMate2 with permission from Kagaro. |
523 local function FishingCoordinates(x, y, yard_width, yard_height) | 451 local function FishingCoordinates(x, y, yard_width, yard_height) |
524 local facing = _G.GetPlayerFacing() | 452 local facing = _G.GetPlayerFacing() |
552 entry[difficulty_token].locations[zone_token] = zone_data | 480 entry[difficulty_token].locations[zone_token] = zone_data |
553 end | 481 end |
554 | 482 |
555 -- Special case for Fishing. | 483 -- Special case for Fishing. |
556 if current_action.spell_label == "FISHING" then | 484 if current_action.spell_label == "FISHING" then |
557 local yard_width, yard_height = MapData:MapArea(area_id, map_level) | 485 local _, qx, qy = _G.GetWorldLocFromMapPos(0, 0) |
486 local _, wx, wy = _G.GetWorldLocFromMapPos(1, 1) | |
487 local yard_width, yard_height = qy - wy, qx - wx | |
558 | 488 |
559 if yard_width > 0 and yard_height > 0 then | 489 if yard_width > 0 and yard_height > 0 then |
560 x, y = FishingCoordinates(x, y, yard_width, yard_height) | 490 x, y = FishingCoordinates(x, y, yard_width, yard_height) |
561 current_action.x = x | 491 current_action.x = x |
562 current_action.y = y | 492 current_action.y = y |
565 local location_token = ("%d:%d:%d"):format(map_level, x, y) | 495 local location_token = ("%d:%d:%d"):format(map_level, x, y) |
566 | 496 |
567 zone_data[location_token] = zone_data[location_token] or true | 497 zone_data[location_token] = zone_data[location_token] or true |
568 return zone_data | 498 return zone_data |
569 end | 499 end |
500 end -- do-block | |
501 | |
502 | |
503 local function CurrencyLinkToTexture(currency_link) | |
504 if not currency_link then | |
505 return | |
506 end | |
507 local _, _, texture_path = _G.GetCurrencyInfo(tonumber(currency_link:match("currency:(%d+)"))) | |
508 return texture_path:match("[^\\]+$"):lower() | |
509 end | |
510 | |
511 | |
512 local function ItemLinkToID(item_link) | |
513 if not item_link then | |
514 return | |
515 end | |
516 return tonumber(tostring(item_link):match("item:(%d+)")) | |
517 end | |
518 | |
519 private.ItemLinkToID = ItemLinkToID | |
520 | |
521 local function UnitTypeIsNPC(unit_type) | |
522 return unit_type == private.UNIT_TYPES.NPC or unit_type == private.UNIT_TYPES.VEHICLE | |
523 end | |
524 | |
525 | |
526 local ParseGUID | |
527 do | |
528 local UNIT_TYPES = private.UNIT_TYPES | |
529 | |
530 local NPC_ID_MAPPING = { | |
531 [62164] = 63191, -- Garalon | |
532 } | |
533 | |
534 | |
535 local function MatchUnitTypes(unit_type_name) | |
536 if not unit_type_name then | |
537 return UNIT_TYPES.UNKNOWN | |
538 end | |
539 | |
540 for def, text in next, UNIT_TYPES do | |
541 if unit_type_name == text then | |
542 return UNIT_TYPES[def] | |
543 end | |
544 end | |
545 return UNIT_TYPES.UNKNOWN | |
546 end | |
547 | |
548 | |
549 function ParseGUID(guid) | |
550 if not guid then | |
551 return | |
552 end | |
553 | |
554 -- We might want to use some of this new information later, but leaving the returns alone for now | |
555 local unit_type_name, unk_id1, server_id, instance_id, unk_id2, unit_idnum, spawn_id = ("-"):split(guid) | |
556 | |
557 local unit_type = MatchUnitTypes(unit_type_name) | |
558 if unit_type ~= UNIT_TYPES.PLAYER and unit_type ~= UNIT_TYPES.PET and unit_type ~= UNIT_TYPES.ITEM then | |
559 | |
560 local id_mapping = NPC_ID_MAPPING[unit_idnum] | |
561 | |
562 if id_mapping and UnitTypeIsNPC(unit_type) then | |
563 unit_idnum = id_mapping | |
564 end | |
565 return unit_type, unit_idnum | |
566 end | |
567 return unit_type | |
568 end | |
569 | |
570 private.ParseGUID = ParseGUID | |
570 end -- do-block | 571 end -- do-block |
571 | 572 |
572 | 573 |
573 local function HandleItemUse(item_link, bag_index, slot_index) | 574 local function HandleItemUse(item_link, bag_index, slot_index) |
574 if not item_link then | 575 if not item_link then |