# HG changeset patch # User James D. Callahan III # Date 1360168058 21600 # Node ID 25bfbe8b4826711132a875910975af033841d305 # Parent 6c78c5c7aee4749020d532aca832add2d4abcb9c Account for invalid GUIDs when attempting to extract unit type and ID. diff -r 6c78c5c7aee4 -r 25bfbe8b4826 Main.lua --- 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