Mercurial > wow > wowdb-profiler
changeset 229:25bfbe8b4826
Account for invalid GUIDs when attempting to extract unit type and ID.
author | James D. Callahan III <jcallahan@curse.com> |
---|---|
date | Wed, 06 Feb 2013 10:27:38 -0600 |
parents | 6c78c5c7aee4 |
children | 85f113524b19 |
files | Main.lua |
diffstat | 1 files changed, 8 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/Main.lua Tue Jan 29 17:45:38 2013 -0600 +++ b/Main.lua Wed Feb 06 10:27:38 2013 -0600 @@ -407,16 +407,21 @@ local ParseGUID do + local UNIT_TYPES = private.UNIT_TYPES local UNIT_TYPE_BITMASK = 0x007 function ParseGUID(guid) if not guid then return end - local types = private.UNIT_TYPES - local unit_type = _G.bit.band(tonumber(guid:sub(1, 5)), UNIT_TYPE_BITMASK) + local bitfield = tonumber(guid:sub(1, 5)) - if unit_type ~= types.PLAYER and unit_type ~= types.PET then + if not bitfield then + return UNIT_TYPES.UNKNOWN + end + local unit_type = _G.bit.band(bitfield, UNIT_TYPE_BITMASK) + + if unit_type ~= UNIT_TYPES.PLAYER and unit_type ~= UNIT_TYPES.PET then return unit_type, tonumber(guid:sub(6, 10), 16) end return unit_type