# HG changeset patch # User yellowfive # Date 1414177727 25200 # Node ID 0e78d6424532de6f3eb5fce7443e01d507611cb4 # Parent a489324103e5ea179378c55e7c0a6b616e2ce62d added region to import/export, some prep for new combat logging diff -r a489324103e5 -r 0e78d6424532 AskMrRobot.lua --- a/AskMrRobot.lua Wed Oct 22 00:28:44 2014 -0700 +++ b/AskMrRobot.lua Fri Oct 24 12:08:47 2014 -0700 @@ -139,7 +139,6 @@ -- global settings if not AmrSettings then AmrSettings = {} end - if not AmrSettings.Logins then AmrSettings.Logins = {} end -- per-character settings if not AmrDb then AmrDb = {} end @@ -179,37 +178,11 @@ -- record logins when the addon starts up, used to help figure out which character logged which parts of a log file function AskMrRobot.RecordLogin() - -- delete entries that are more than 10 days old to prevent the table from growing indefinitely - if AmrSettings.Logins and #AmrSettings.Logins > 0 then - local now = time() - local oldDuration = 60 * 60 * 24 * 10 - local entryTime - repeat - -- parse entry and get time - local parts = {} - for part in string.gmatch(AmrSettings.Logins[1], "([^;]+)") do - tinsert(parts, part) - end - entryTime = tonumber(parts[3]) + -- only need to record the region now (only thing we can't get from the log file still) + AmrSettings.Region = AskMrRobot.regionNames[GetCurrentRegion()] - -- entries are in order, remove first entry if it is old - if difftime(now, entryTime) > oldDuration then - tremove(AmrSettings.Logins, 1) - end - until #AmrSettings.Logins == 0 or difftime(now, entryTime) <= oldDuration - end - - -- record the time a player logs in, used to figure out which player logged which parts of their log file - local key = AmrDb.RealmName .. ";" .. AmrDb.CharacterName .. ";" - local loginData = key .. time() - if AmrSettings.Logins and #AmrSettings.Logins > 0 then - local last = AmrSettings.Logins[#AmrSettings.Logins] - if string.len(last) >= string.len(key) and string.sub(last, 1, string.len(key)) ~= key then - table.insert(AmrSettings.Logins, loginData) - end - else - table.insert(AmrSettings.Logins, loginData) - end + -- remove the old Logins data, don't need it anymore + AmrSettings.Logins = nil end function AskMrRobot.InitializeMinimap() @@ -271,6 +244,7 @@ -- gets all basic character properties function AskMrRobot.ScanCharacter() + AmrDb.Region = AskMrRobot.regionNames[GetCurrentRegion()] AmrDb.RealmName = GetRealmName() AmrDb.CharacterName = UnitName("player") AmrDb.Guild = GetGuildInfo("player") @@ -632,6 +606,7 @@ -- compressed string uses a fixed order rather than inserting identifiers table.insert(fields, GetAddOnMetadata(AskMrRobot.AddonName, "Version")) + table.insert(fields, AmrDb.Region) table.insert(fields, AmrDb.RealmName) table.insert(fields, AmrDb.CharacterName) @@ -766,7 +741,7 @@ function AskMrRobot.ExportToAddonChat(timestamp) local msg = AskMrRobot.ExportToCompressedString(false) - local msgPrefix = timestamp .. "\n" .. AmrDb.RealmName .. "\n" .. AmrDb.CharacterName .. "\n" + local msgPrefix = timestamp .. "\n" .. AmrDb.Region .. "\n" .. AmrDb.RealmName .. "\n" .. AmrDb.CharacterName .. "\n" -- break the data into 250 character chunks (to deal with the short limit on addon message size) local chunks = {} @@ -832,7 +807,7 @@ return L.AMR_IMPORT_ERROR_VERSION end - -- require realm/name match + -- require name match (don't match realm due to language issues for now) if not isTest then local realm = parts[2] local name = parts[3] @@ -863,9 +838,9 @@ -- require spec match local spec = tonumber(parts[11]) if spec ~= AmrDb.Specs[AmrDb.ActiveSpec] then - print(AmrDb.ActiveSpec) - print(spec) - print(AmrDb.Specs[AmrDb.ActiveSpec]) + --print(AmrDb.ActiveSpec) + --print(spec) + --print(AmrDb.Specs[AmrDb.ActiveSpec]) local _, specName = GetSpecializationInfoByID(AskMrRobot.gameSpecIds[spec]) return L.AMR_IMPORT_ERROR_SPEC:format(specName) end diff -r a489324103e5 -r 0e78d6424532 AskMrRobot.toc --- a/AskMrRobot.toc Wed Oct 22 00:28:44 2014 -0700 +++ b/AskMrRobot.toc Fri Oct 24 12:08:47 2014 -0700 @@ -1,7 +1,7 @@ ## Interface: 60000 ## Title: Ask Mr. Robot ## Author: Team Robot, Inc. -## Version: 12 +## Version: 13 ## Notes: Exports/Imports data to/from askmrrobot.com. ## URL: www.askmrrobot.com ## DefaultState: Enabled diff -r a489324103e5 -r 0e78d6424532 amr-constants.lua --- a/amr-constants.lua Wed Oct 22 00:28:44 2014 -0700 +++ b/amr-constants.lua Fri Oct 24 12:08:47 2014 -0700 @@ -123,6 +123,14 @@ end end +AskMrRobot.regionNames = { + [1] = "US", + [2] = "KR", + [3] = "EU", + [4] = "TW", + [5] = "CN" +} + AskMrRobot.classIds = { ["NONE"] = 0, ["DEATHKNIGHT"] = 1, diff -r a489324103e5 -r 0e78d6424532 ui/CombatLogTab.lua --- a/ui/CombatLogTab.lua Wed Oct 22 00:28:44 2014 -0700 +++ b/ui/CombatLogTab.lua Fri Oct 24 12:08:47 2014 -0700 @@ -425,13 +425,11 @@ AmrDb.LogData._wipes = AmrDb.LogData._wipes or {} end -local function GetPlayerExtraData(data, index) - - local unitId = "raid" .. index +local function GetPlayerExtraData(data, unitId, petId) local guid = UnitGUID(unitId) if guid == nil then - return nil + return end local fields = {} @@ -447,22 +445,23 @@ table.insert(fields, AskMrRobot.toCompressedNumberList(buffs)) end - local petGuid = UnitGUID("raidpet" .. index) + local petGuid = UnitGUID(petId) if petGuid then table.insert(fields, guid .. "," .. petGuid) else table.insert(fields, '_') end - local name = GetRaidRosterInfo(index) + local name = GetUnitName(unitId, true) -- GetRaidRosterInfo(rosterIndex) local realm = GetRealmName() + local region = AskMrRobot.regionNames[GetCurrentRegion()] local splitPos = string.find(name, "-") if splitPos ~= nil then realm = string.sub(name, splitPos + 1) name = string.sub(name, 1, splitPos - 1) end - data[realm .. ":" .. name] = table.concat(fields, ";") + data[region .. ":" .. realm .. ":" .. name] = table.concat(fields, ";") end function AskMrRobot.CombatLogTab.SaveExtras(timestamp) @@ -471,15 +470,29 @@ return end - -- we only get extra information for people if in a raid - if not IsInRaid() then - return - end + local units = {} + local petUnits = {} + + if IsInRaid() then + for i = 1,40 do + table.insert(units, "raid" .. i) + table.insert(petUnits, "raidpet" .. i) + end + elseif IsInGroup() then + table.insert(units, "player") + table.insert(petUnits, "pet") + for i = 1,4 do + table.insert(units, "party" .. i) + table.insert(petUnits, "partypet" .. i) + end + else + return + end local data = {} - for i = 1,40 do - GetPlayerExtraData(data, i) - end + for i = 1,#units do + GetPlayerExtraData(data, units[i], petUnits[i]) + end for name,val in pairs(data) do -- record aura stuff, we never check for duplicates, need to know it at each point in time @@ -493,15 +506,15 @@ -- read a message sent to the addon channel with a player's info at the time an encounter started function AskMrRobot.CombatLogTab:ReadAddonMessage(message) - -- message will be of format: timestamp\nrealm\nname\n[stuff] + -- message will be of format: timestamp\nregion\nrealm\nname\n[stuff] local parts = {} for part in string.gmatch(message, "([^\n]+)") do tinsert(parts, part) end local timestamp = parts[1] - local name = parts[2] .. ":" .. parts[3] - local data = parts[4] + local name = parts[2] .. ":" .. parts[3] .. ":" .. parts[4] + local data = parts[5] if (data == "done") then -- we have finished receiving this message; now process it to reduce the amount of duplicate data