Go to Page... |
|
Thread Tools | Display Modes |
|
07-15-13, 08:58 AM | #1 |
damage meter issue related to Pet OwnerName and OwnerID
Hi Everyone !
I'm working on porting an old addon back from Cata. so far everything works fine except (it seems) Pet. (it's a kind of DPS meter) The way used in there to get the ownername,ownerID and petID is a bit scriptic for me (i'm not a huge LUA expert, i'm just digging info and fixing with the resources i find) Basically the issue is that (it seems) each time a hunter uses stampede, or any other classes that seem to have some weird pets, the addon floods me with errors : Code:
Message: Interface\AddOns\dMeter\Core.lua:411: bad argument #1 to 'band' (number expected, got string) Time: 07/14/13 14:37:15 Count: 4 Stack: [C]: ? [C]: in function `band' Interface\AddOns\dMeter\Core.lua:411: in function <Interface\AddOns\dMeter\Core.lua:409> Interface\AddOns\dMeter\Core.lua:435: in function <Interface\AddOns\dMeter\Core.lua:424> Interface\AddOns\dMeter\Core.lua:2734: in function <Interface\AddOns\dMeter\Core.lua:2636> Interface\AddOns\dMeter\Core.lua:3193: in function <Interface\AddOns\dMeter\Core.lua:3191> Locals: Code:
local function _RelevantMember(flag) if bit.band(flag, 0x0000FC00) == 0x00000400 then if bit.band(flag, 0x0000000F) == 0x00000001 or bit.band(flag, 0x0000000F) == 0x00000002 or bit.band(flag, 0x0000000F) == 0x00000004 then return true end end end local function _GetOwner(petid) if C_Pets[petid] then return C_Pets[petid]["OwnerID"], C_Pets[petid]["OwnerName"] end return nil end local function _CheckForOwner(petid) if GetNumGroupMembers() > 0 then for i = 1, GetNumGroupMembers() do if UnitGUID("raidpet"..i.."") == petid then return UnitGUID("raid"..i..""), UnitName("raid"..i.."") end end elseif GetNumGroupMembers() > 0 then for i = 1, GetNumGroupMembers() do if UnitGUID("partypet"..i.."") == petid then return UnitGUID("party"..i..""), UnitName("party"..i.."") end end if UnitGUID("pet") == petid then return UnitGUID("player"), UnitName("player") end else if UnitGUID("pet") == petid then return UnitGUID("player"), UnitName("player") end end return nil end local function _AddStupidEntryOrderPetsToOwner(petid, ownerid, ownername) if stupidOrderPets[petid] then for i = 1, #stupidOrderPets[petid] do _AddPet(ownerid,ownername,stupidOrderPets[petid][i]) end stupidOrderPets[petid] = nil end end local function _AddStupidEntryOrderPet(source, target) if not stupidOrderPets[source] then stupidOrderPets[source] = {target} else table.insert(stupidOrderPets, target) end end local function _RelevantPet(flag, guid) if (bit.band(flag,0x0000FC00) == 0x00000800 and bit.band(flag,0x000000F0) == 0x00000020) or bit.band(flag,0x0000FC00) == 0x00001000 or bit.band(flag,0x0000FC00) == 0x00002000 or bit.band(guid,0x00F0000000000000) == 0x0040000000000000 then local owner, ownername = _CheckForOwner(guid) if not owner then owner, ownername = _GetOwner(guid) return owner, ownername else return owner, ownername end end end local function _RelevantMob(flag, guid, name) if not guid then return false end if name == "The Skyfire" then return true end if bit.band(flag,0x000000F0) == 0x00000040 or bit.band(flag,0x000000F0) == 0x00000020 then local owner = _RelevantPet(flag, guid) if not owner then return true end end return false end Many thanks for your time and help! BuG |
|
07-15-13, 11:16 AM | #2 |
The problem is likely caused by the order of the arguments for COMBAT_LOG_EVENT_UNFILTERED being changed.
The error is from the variable 'flag' being a string instead of a number, which probably means it's holding the unit's name or something instead of its flags. Can you show us what the variables are being assigned to for the COMBAT_LOG_EVENT_UNFILTERED event? Although the fact that you say everything else is working fine would seem to indicate that it's something else.. Last edited by semlar : 07-15-13 at 11:19 AM. |
|
07-15-13, 12:48 PM | #3 |
Hi and thank you for your answer.
sorry for such a nebbish question but, what/where exactly should i find what you would like to see ? i do register the combat log unfiltered in the add-on, but i'm not familiar with such thing. is that printed somewhere in the cache/variables ? i tried a suggestion from someone to print what it is showing : Code:
local function _RelevantMember(flag) if type(flag) == 'string' then print("flag returned a string:", flag); return; end Although, here is a more complete error that happens (just realized the original one was missing a few lines) Code:
Core.lua:411: bad argument #1 to "band" (number expected, got string) <in C code> dMeter-3.6\Core.lua:411: in function <dMeter\Core.lua:409> dMeter-3.6\Core.lua:2776: in function <dMeter\Core.lua:2636> dMeter-3.6\Core.lua:3193: in function <dMeter\Core.lua:3191> Locals: flag = -2147483648 guid = "" bit = <table> { band = <func> =[C]:-1 mod = <func> =[C]:-1 rshift = <func> =[C]:-1 arshift = <func> =[C]:-1 bor = <func> =[C]:-1 bnot = <func> =[C]:-1 lshift = <func> =[C]:-1 bxor = <func> =[C]:-1 } _CheckForOwner = <func> @dMeter\Core.lua:361 _GetOwner = <func> @dMeter\Core.lua:352 Edit 2 : the easiest way i found to reproduce it is have a lock with me and wait for him to have a "proc Imp" this brings the error right away and will keep spamming it every few seconds. Now i'm "convinced" more and more that it has to do with Guardians and not pet (since pet seem to be coded "okish") as guardians do not have names or id or something the add-on just get lost Last edited by zbugrkx : 07-15-13 at 01:12 PM. |
|
07-15-13, 01:52 PM | #4 |
Okay, even though that function is where the error is being thrown, it isn't the source of the problem.
The problem is being caused by the fact that the function is being fed a string instead of the flags it's expecting. The stack trace shows you the line numbers of the function calls leading up to the error. Even though line 411 is the one that it's actually failing on, that function is being called from another line (2776 in your last post). The function _RelevantMember is being called with something other than the flags. You need to identify what it's being called with. Find where _RelevantMember is being called, look at what the variable it's being called with is named, then go back through the script until you find where that variable is assigned. That is the source of the problem. If you can't do that, post the entire script somewhere. |
|
07-15-13, 02:05 PM | #5 |
Hi Semiar,
this is very useful and your help is very appreciated. RelevantMember is called (as you said) further down the script in the following function : Code:
local function _LogParser(timeStamp, subEvent, hideCaster, sourceGUID, sourceName, sourceFlag, sourceRaidFlag, targetGUID, targetName, targetFlag, targetRaidFlag, …) local arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12 = … as soon as a Lock gets his Imp procs the error pops. for example the part around line 2776 : Code:
if _RelevantMember(sourceFlag) then if sourceGUID ~= targetGUID then if _RelevantMember(targetFlag) then if sourceName then _CheckEntity("Damage", "Friendly", sourceGUID, sourceName) _AddEntry("Damage", "Friendly", nil, "Player", subEvent, sourceGUID, targetName, arg1, arg2, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12) end _CheckEntity("Death", nil, targetGUID, targetName) _AddEntry("Death", "Damage", nil, "Player", subEvent, targetGUID, sourceName, arg1, arg2, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12) _CheckEntity("Damage", "Taken", targetGUID, targetName) _AddEntry("Damage", "Taken", nil, "Player", subEvent, targetGUID, sourceName, arg1, arg2, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12) return elseif subEvent ~= "DAMAGE_SPLIT" then _CheckEntity("Damage", "Done", sourceGUID, sourceName) _AddEntry("Damage", "Done", nil, "Player", subEvent, sourceGUID, targetName, arg1, arg2, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12) return end end end |
|
07-15-13, 02:28 PM | #6 |
sourceGUID is already defined, arg4 is referring to the fourth argument after "targetRaidFlag" in the parameters that the CLEU event contains. What arg4 happens to be depends on the subEvent.
The error isn't being caused by an incorrect value for flag, it's being caused by this little line inside of _RelevantPet.. Lua Code:
edit: It's expecting guid to be a number, not a string. I don't know if this was changed at some point, but it's certainly not a number today. Try changing it to or tonumber(strsub(guid or '00000', 5, 5) or 0, 16) % 8 == 4 which is basically pulling the fifth character out of the guid (which identifies the unit type) and checks if it's 4 (which identifies it as a pet). Last edited by semlar : 07-15-13 at 02:40 PM. |
|
WoWInterface » Developer Discussions » General Authoring Discussion » damage meter issue related to Pet OwnerName and OwnerID |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Switch to Linear Mode |
Hybrid Mode |
Switch to Threaded Mode |
|
|