- Possible fix for missing pre-potions.

- Second try in create a version checker.
This commit is contained in:
tercio
2014-07-03 19:27:49 -03:00
parent d33f89a393
commit 68557fa55f
7 changed files with 90 additions and 240 deletions
+4 -4
View File
@@ -9,10 +9,10 @@
_ = nil
_detalhes = LibStub("AceAddon-3.0"):NewAddon("_detalhes", "AceTimer-3.0", "AceComm-3.0", "AceSerializer-3.0", "NickTag-1.0", "LibHotCorners")
_detalhes.version = "v1.18.1 (core 20)"
_detalhes.userversion = "v1.18.1"
_detalhes.build_counter = 1
_detalhes.realversion = 20
_detalhes.version = "v1.18.2 (core 20)"
_detalhes.userversion = "v1.18.2"
_detalhes.build_counter = 3
_detalhes.realversion = 21
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--> initialization stuff
+27 -29
View File
@@ -21,6 +21,7 @@ local GameTooltip = GameTooltip
local _IsInRaid = IsInRaid
local _IsInGroup = IsInGroup
local _GetNumGroupMembers = GetNumGroupMembers
local _GetNumSubgroupMembers = GetNumSubgroupMembers
local _UnitAura = UnitAura
local _UnitGUID = UnitGUID
local _UnitName = UnitName
@@ -1138,7 +1139,7 @@ function _detalhes:CatchRaidDebuffUptime (in_or_out) -- "DEBUFF_UPTIME_IN"
checked [his_target] = true
for debuffIndex = 1, 40 do
for debuffIndex = 1, 41 do
local name, _, _, _, _, _, _, unitCaster, _, _, spellid = UnitDebuff ("raid"..raidIndex.."target", debuffIndex)
if (name and unitCaster) then
local playerName, realmName = _UnitName (unitCaster)
@@ -1217,41 +1218,49 @@ function _detalhes:CatchRaidBuffUptime (in_or_out)
if (_IsInRaid()) then
local pot_usage = {}
local pot_usage_test = {}
--> raid groups
for raidIndex = 1, _GetNumGroupMembers() do
for buffIndex = 1, 41 do
local name, _, _, _, _, _, _, unitCaster, _, _, spellid = _UnitAura ("raid"..raidIndex, buffIndex, nil, "HELPFUL")
if (in_or_out == "BUFF_UPTIME_IN") then
if (_detalhes.PotionList [spellid]) then
print ("Pre Potion Found on raidIndex", raidIndex, unitCaster, spellid)
local playerName, realmName = _UnitName ("raid"..raidIndex)
if (realmName and realmName ~= "") then
playerName = playerName .. "-" .. realmName
end
pot_usage_test [playerName] = spellid
end
end
--print (name, unitCaster, "==", "raid"..raidIndex)
if (name and unitCaster == "raid"..raidIndex) then
local playerName, realmName = _UnitName ("raid"..raidIndex)
if (realmName and realmName ~= "") then
playerName = playerName .. "-" .. realmName
end
_detalhes.parser:add_buff_uptime (nil, GetTime(), _UnitGUID ("raid"..raidIndex), playerName, 0x00000514, _UnitGUID ("raid"..raidIndex), playerName, 0x00000514, spellid, name, in_or_out)
if (in_or_out == "BUFF_UPTIME_IN") then
if (_detalhes.PotionList [spellid]) then
pot_usage [playerName] = spellid
end
end
end
end
end
-- /run print (GetNumSubgroupMembers());for i=1,GetNumSubgroupMembers()do print (UnitName("party"..i))end
--> player sub group
for partyIndex = 1, _GetNumSubgroupMembers() do
for buffIndex = 1, 41 do
local name, _, _, _, _, _, _, unitCaster, _, _, spellid = _UnitAura ("party"..partyIndex, buffIndex, nil, "HELPFUL")
if (name and unitCaster == "party"..partyIndex) then
local playerName, realmName = _UnitName ("party"..partyIndex)
if (realmName and realmName ~= "") then
playerName = playerName .. "-" .. realmName
end
_detalhes.parser:add_buff_uptime (nil, GetTime(), _UnitGUID ("raid"..raidIndex), playerName, 0x00000514, _UnitGUID ("raid"..raidIndex), playerName, 0x00000514, spellid, name, in_or_out)
_detalhes.parser:add_buff_uptime (nil, GetTime(), _UnitGUID ("party"..partyIndex), playerName, 0x00000514, _UnitGUID ("party"..partyIndex), playerName, 0x00000514, spellid, name, in_or_out)
else
--break
if (in_or_out == "BUFF_UPTIME_IN") then
if (_detalhes.PotionList [spellid]) then
pot_usage [playerName] = spellid
end
end
end
end
end
@@ -1275,16 +1284,6 @@ function _detalhes:CatchRaidBuffUptime (in_or_out)
end
if (in_or_out == "BUFF_UPTIME_IN") then
local string_output = "pre-potion raw: "
for playername, potspellid in _pairs (pot_usage_test) do
local name, _, icon = _GetSpellInfo (potspellid)
local _, class = UnitClass (playername)
local class_color = RAID_CLASS_COLORS [class].colorStr
string_output = string_output .. "|c" .. class_color .. playername .. "|r |T" .. icon .. ":14:14:0:0:64:64:0:64:0:64|t "
end
_detalhes.debug_pots1 = string_output
local string_output = "pre-potion: "
for playername, potspellid in _pairs (pot_usage) do
local name, _, icon = _GetSpellInfo (potspellid)
@@ -1293,7 +1292,6 @@ function _detalhes:CatchRaidBuffUptime (in_or_out)
string_output = string_output .. "|c" .. class_color .. playername .. "|r |T" .. icon .. ":14:14:0:0:64:64:0:64:0:64|t "
end
_detalhes.debug_pots2 = string_output
end
elseif (_IsInGroup()) then
+51 -203
View File
@@ -14,6 +14,7 @@
local _math_min = math.min
local _string_gmatch = string.gmatch
local _
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--> local pointers
@@ -50,14 +51,42 @@
if (type == "highfive") then
_detalhes:SendRaidData ("highfive_response")
_detalhes:SendRaidData ("highfive_response", _detalhes.userversion)
elseif (type == "highfive_response") then
if (_detalhes.sent_highfive and _detalhes.sent_highfive+30 > GetTime()) then
_detalhes.users [#_detalhes.users+1] = {player, realm, dversion}
_detalhes.users [#_detalhes.users+1] = {player, realm, (arg6 or "") .. " (" .. dversion .. ")"}
end
elseif (type == "check_version") then
local received_version = tonumber (arg6)
if (_detalhes.debug) then
_detalhes:Msg ("(debug) received version alert ", arg6)
end
if (not _detalhes.build_counter or not _detalhes.lastUpdateWarning or not received_version) then
return
end
if (time() > _detalhes.lastUpdateWarning + 72000) then
--print ("received check_version", received_version)
if (received_version > _detalhes.build_counter) then
local lower_instance = _detalhes:GetLowerInstanceNumber()
if (lower_instance) then
lower_instance = _detalhes:GetInstance (lower_instance)
if (lower_instance) then
lower_instance:InstanceAlert ("Update Available!", {[[Interface\GossipFrame\AvailableQuestIcon]], 16, 16, false}, 60, {function() _detalhes:Msg ("Check curse client to download the newer version.") end})
end
end
end
_detalhes.lastUpdateWarning = time()
end
elseif (type == "petowner") then
dversion, serial, nome, owner_table = player, realm, dversion, arg6
@@ -302,8 +331,23 @@
end
_detalhes:SendCommMessage ("details_comm", _detalhes:Serialize (type, player, realm, _detalhes.realversion, ...), "RAID")
end
function _detalhes:SendRaidData (type, ...)
_detalhes:SendCommMessage ("details_comm", _detalhes:Serialize (type, _UnitName ("player"), _GetRealmName(), _detalhes.realversion, ...), "RAID")
if (IsInGroup (LE_PARTY_CATEGORY_INSTANCE) and IsInInstance()) then
_detalhes:SendCommMessage ("details_comm", _detalhes:Serialize (type, _UnitName ("player"), _GetRealmName(), _detalhes.realversion, ...), "INSTANCE_CHAT")
else
_detalhes:SendCommMessage ("details_comm", _detalhes:Serialize (type, _UnitName ("player"), _GetRealmName(), _detalhes.realversion, ...), "RAID")
end
end
function _detalhes:SendPartyData (type, ...)
if (IsInGroup (LE_PARTY_CATEGORY_INSTANCE) and IsInInstance()) then
_detalhes:SendCommMessage ("details_comm", _detalhes:Serialize (type, _UnitName ("player"), _GetRealmName(), _detalhes.realversion, ...), "INSTANCE_CHAT")
else
_detalhes:SendCommMessage ("details_comm", _detalhes:Serialize (type, _UnitName ("player"), _GetRealmName(), _detalhes.realversion, ...), "PARTY")
end
end
function _detalhes:SendGuildData (type, ...)
_detalhes:SendCommMessage ("details_comm", _detalhes:Serialize (type, _UnitName ("player"), _GetRealmName(), _detalhes.realversion, ...), "GUILD")
end
function _detalhes:SendHighFive()
@@ -363,210 +407,14 @@
end
end
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--> update
function _detalhes:CheckVersion()
local room_name = "DetailsVCheck"
local CONST_VERSION_CHECK = "VCHECK"
local CONST_VERSION = "VERSION"
local CONST_SEND_OWNER = "SOWNER"
local CONST_OWNER_OUTDATE = "OWNEROUT"
local waiting_version = false
local waiting_owner = false
--entrar na sala
JoinChannelByName (room_name)
function _detalhes:GetChannelId()
local list = {GetChannelList()}
for i = 1, #list, 2 do
if (list [i+1] == room_name) then
return list [i]
end
end
return nil
if (IsInRaid()) then
_detalhes:SendRaidData ("check_version", _detalhes.build_counter)
elseif (IsInGroup()) then
_detalhes:SendPartyData ("check_version", _detalhes.build_counter)
end
function _detalhes:GetChannelInternalId()
for id = 1, GetNumDisplayChannels() do
local name = GetChannelDisplayInfo (id)
if (name == room_name) then
return id
end
end
end
function _detalhes:IamOwner()
local channel_id = _detalhes:GetChannelId()
local channel_id_internal = _detalhes:GetChannelInternalId()
if (not channel_id or not channel_id_internal) then
return
end
SetSelectedDisplayChannel (channel_id)
local name, _, _, _, count = GetChannelDisplayInfo (channel_id_internal)
if (name ~= room_name) then
return
end
for i = 1, count do
local name, owner = GetChannelRosterInfo (channel_id_internal, i)
if (name and name == _detalhes.playername) then
return owner
end
end
end
function _detalhes:LeaveChannel (force_leave)
if (_detalhes:IamOwner() and not force_leave) then
if (_detalhes.debug) then
_detalhes:Msg ("(debug) fail to leave the channel, we are the owner.")
end
return
end
if (_detalhes.debug) then
_detalhes:Msg ("(debug) leaving the update channel.")
end
LeaveChannelByName (room_name)
end
function _detalhes:CheckVersionChannel()
local channel_id = _detalhes:GetChannelId()
if (_detalhes.debug) then
_detalhes:Msg ("(debug) requesting version on update channel: ", channel_id)
end
if (not channel_id) then
return
end
waiting_version = true
SendChatMessage (room_name .. CONST_VERSION_CHECK .. " " .. _detalhes.build_counter, "CHANNEL", nil, channel_id)
end
_detalhes:ScheduleTimer ("CheckVersionChannel", 4)
self.listener:RegisterEvent ("CHAT_MSG_CHANNEL")
function _detalhes.parser_functions:CHAT_MSG_CHANNEL (...)
local channel_id = _detalhes:GetChannelId()
if (not channel_id) then
return
end
local message, sender, language, channelString, target, flags, unknown, channelNumber, channelName, unknown, counter, guid = ...
if (channelName == room_name) then
local key, value, extra = message:gsub (room_name, ""):match ("^(%S*)%s*(.-)$")
value, extra = value:match ("^(%S*)%s*(.-)$")
if (_detalhes.debug) then
_detalhes:Msg ("(debug) update channel received command: ", key, value, extra)
end
--> send version
if (key == CONST_VERSION_CHECK) then
if (_detalhes:IamOwner()) then
if (IsInRaid() or IsInGroup()) then
SendChatMessage (room_name .. CONST_VERSION .. " " .. _detalhes.build_counter .. " 1", "CHANNEL", nil, channel_id)
waiting_owner = true
if (_detalhes.debug) then
_detalhes:Msg ("(debug) version sent (we need a new owner).")
end
else
SendChatMessage (room_name .. CONST_VERSION .. " " .. _detalhes.build_counter, "CHANNEL", nil, channel_id)
if (_detalhes.debug) then
_detalhes:Msg ("(debug) version sent.")
end
end
end
elseif (key == CONST_VERSION and waiting_version) then
waiting_version = false
value = tonumber (value)
if (value > _detalhes.build_counter) then
--> nova versao encontrada
-- avisar o jogador
_detalhes:ScheduleTimer ("LeaveChannel", 5)
local lower_instance = _detalhes:GetLowerInstanceNumber()
if (lower_instance) then
lower_instance = _detalhes:GetInstance (lower_instance)
if (lower_instance) then
lower_instance:InstanceAlert ("Update Available!", {[[Interface\GossipFrame\AvailableQuestIcon]], 16, 16, false}, 60, {function() _detalhes:Msg ("Check curse client to download the newer version.") end})
end
end
if (_detalhes.debug) then
_detalhes:Msg ("(debug) found a new version.")
end
elseif (value == _detalhes.build_counter) then
--> mesma versao
if (_detalhes.debug) then
_detalhes:Msg ("(debug) no newer version found.")
end
if (extra and tonumber (extra)) then
if (not IsInRaid() and not IsInGroup()) then
if (_detalhes.debug) then
_detalhes:Msg ("(debug) owner need to leave, we can be the new owner.")
end
SendChatMessage (room_name .. CONST_SEND_OWNER, "CHANNEL", nil, channel_id)
end
end
_detalhes:ScheduleTimer ("LeaveChannel", 10)
elseif (value < _detalhes.build_counter) then
--> a versao do owner esta desatualizada
SendChatMessage (room_name .. CONST_OWNER_OUTDATE, "CHANNEL", nil, channel_id)
if (_detalhes.debug) then
_detalhes:Msg ("(debug) owner have a out date version, warning him.")
end
end
elseif (key == CONST_SEND_OWNER) then
if (_detalhes:IamOwner() and waiting_owner) then
SetChannelOwner (room_name, sender)
waiting_owner = false
_detalhes:ScheduleTimer ("LeaveChannel", 5)
if (_detalhes.debug) then
_detalhes:Msg ("(debug) we found a new owner, leaving the channel.")
end
end
elseif (key == CONST_OWNER_OUTDATE) then
if (_detalhes:IamOwner()) then
_detalhes:ScheduleTimer ("LeaveChannel", 5, true)
if (_detalhes.debug) then
_detalhes:Msg ("(debug) Oh ho, we are owner and our version is old, leaving...")
end
end
end
end
end
end
+1
View File
@@ -2754,6 +2754,7 @@
_detalhes:SchedulePetUpdate (1)
_detalhes:InstanceCall (_detalhes.SetCombatAlpha, nil, nil, true)
_detalhes:CheckSwitchOnLogon()
_detalhes:CheckVersion()
end
else
_detalhes.in_group = IsInGroup() or IsInRaid()
+1
View File
@@ -648,6 +648,7 @@ local default_global_data = {
savedStyles = {},
savedCustomSpells = {},
savedTimeCaptures = {},
lastUpdateWarning = 0,
tutorial = {
logons = 0,
unlock_button = 0,
File diff suppressed because one or more lines are too long
+3 -1
View File
@@ -2,7 +2,7 @@
--Last Modification: 27/07/2013
-- Change Log:
-- 27/07/2013: Finished alpha version.
function _G._detalhes:Start()
local Loc = LibStub ("AceLocale-3.0"):GetLocale ( "Details" )
@@ -175,6 +175,8 @@ function _G._detalhes:Start()
self.details_users = {}
self.in_group = IsInGroup() or IsInRaid()
_detalhes:SendGuildData ("check_version", _detalhes.build_counter)
--> done
self.initializing = nil