Mercurial > wow > wowdb-profiler
comparison Main.lua @ 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 | 3dd05b29bc6f |
children | 85f113524b19 |
comparison
equal
deleted
inserted
replaced
228:6c78c5c7aee4 | 229:25bfbe8b4826 |
---|---|
405 end | 405 end |
406 | 406 |
407 | 407 |
408 local ParseGUID | 408 local ParseGUID |
409 do | 409 do |
410 local UNIT_TYPES = private.UNIT_TYPES | |
410 local UNIT_TYPE_BITMASK = 0x007 | 411 local UNIT_TYPE_BITMASK = 0x007 |
411 | 412 |
412 function ParseGUID(guid) | 413 function ParseGUID(guid) |
413 if not guid then | 414 if not guid then |
414 return | 415 return |
415 end | 416 end |
416 local types = private.UNIT_TYPES | 417 local bitfield = tonumber(guid:sub(1, 5)) |
417 local unit_type = _G.bit.band(tonumber(guid:sub(1, 5)), UNIT_TYPE_BITMASK) | 418 |
418 | 419 if not bitfield then |
419 if unit_type ~= types.PLAYER and unit_type ~= types.PET then | 420 return UNIT_TYPES.UNKNOWN |
421 end | |
422 local unit_type = _G.bit.band(bitfield, UNIT_TYPE_BITMASK) | |
423 | |
424 if unit_type ~= UNIT_TYPES.PLAYER and unit_type ~= UNIT_TYPES.PET then | |
420 return unit_type, tonumber(guid:sub(6, 10), 16) | 425 return unit_type, tonumber(guid:sub(6, 10), 16) |
421 end | 426 end |
422 return unit_type | 427 return unit_type |
423 end | 428 end |
424 end -- do-block | 429 end -- do-block |