Page 1 of 1
Class Bitmask
Posted: Thu Jun 30, 2016 7:30 am
by Gangrenous
I am guessing at some point the item class structure changed? I am seeing references in places about a table that is now missing. Does anyone have a bitmask list for item classes and can someone verify this did change in the past?
Re: Class Bitmask
Posted: Thu Jun 30, 2016 9:56 am
by Gangrenous
Pretty sure this is it, if not I will correct it. I generated this today and it appears to be accurate. If it indeed is, I will put it on my wiki.
Code: Select all
COMMONER = 1,
FIGHTER = 2,
WARRIOR = 4,
GUARDIAN = 8,
BERSERKER = 16,
BRAWLER = 32,
MONK = 64,
BRUISER = 128,
CRUSADER = 256,
SHADOWKNIGHT = 512,
PALADIN = 1024,
PRIEST = 2048,
CLERIC = 4096,
TEMPLAR = 8192,
INQUISITOR = 16384,
DRUID = 32768,
WARDEN = 65536,
FURY = 131072,
SHAMAN = 262144,
MYSTIC = 524288,
DEFILER = 1048576,
MAGE = 2097152,
SORCERER = 4194304,
WIZARD = 8388608,
WARLOCK = 16777216,
ENCHANTER = 33554432,
ILLUSIONIST = 67108864,
COERCER = 134217728,
SUMMONER = 268435456,
CONJUROR = 536870912,
NECROMANCER = 1073741824,
SCOUT = 2147483648,
ROGUE = 4294967296,
SWASHBUCKLER = 8589934592,
BRIGAND = 17179869184,
BARD = 34359738368,
TROUBADOR = 68719476736,
DIRGE = 137438953472,
PREDATOR = 274877906944,
RANGER = 549755813888,
ASSASSIN = 1099511627776,
ANIMALIST = 2199023255552,
BEASTLORD = 4398046511104,
SHAPER = 8796093022208,
CHANNELER = 17592186044416
Re: Class Bitmask
Posted: Thu Jun 30, 2016 5:25 pm
by Jabantiz
Yea it has changed over time due to the addition of classes, therefore older clients can interpret the value different then new clients.
I believe commoner was suppose to be 0 with fighter as 1, really it was 2^(class id - 1) with class id being defined in classes.h
Re: Class Bitmask
Posted: Fri Jul 01, 2016 1:32 pm
by Gangrenous
Hey Jabantiz, maybe you can figure this out. It appears C# enum cannot handle doing bitmask on this long of a number, as high as our class mask. What happens is when you get into the higher numbers, it rolls back into negative and then starts back over in the positive range. Even if I do the enum as long, when you try to check against the mask it is treating it as a int32. Thoughts? There are plenty of threads regarding the problem but not much of a clean resultion.
http://stackoverflow.com/questions/1060 ... -too-large
Re: Class Bitmask
Posted: Fri Jul 01, 2016 3:09 pm
by Jabantiz
For this you should be using an unsigned int64 as the numbers get so large, you want to make sure it is unsigned as the value will never be negative for us so this will essentially double the range. int64 is a "long long" in c++, I am not sure if c# has a special type or not for it though.
When you check the values I assume you are just putting in a number like "8", when you put just a number the code treats it as a signed int32, you will probably need to tell it the number is an unsigned int64 for it to be accurate that would simply be "(int64)8"
EDIT: Just looked up the c# type and it is long for an int64 (really wish types where the same across languages), so you will want to use ulong for an unsigned int64 and put (ulong) in front of any hardcoded numbers you are using to check values.
Re: Class Bitmask
Posted: Tue Jul 05, 2016 7:15 am
by Gangrenous
Nothing I did seemed to help, it appears enum is not designed for it. It was a much simpler solution to do it via a MySQL query, in fact it took less code and was simpler to read.