Ive been working with sfs2x for some time now and dont understand why there are so many limitations, its very frustrating.
Why dont you add support for a LONG user var??
Yes we have double, which is only 53 bits, so if we store a long inside this double which SFS2X does when we put a long inside an UserVar then the bits 54-63 will become corrupted and unreadable!
I cannot use .getDoubleValue().longValue() either, the double is still corrupt.
HOWEVER, on csharp side i can actually just do:
(long) .getDoubleValue(); // directly cast to long and then i can read the long corrrectly, but java doesnt support this, we get a class cast exception and when i try to use the java .longValue() method of the Double class it just returns garbage instead.
Code: Select all
long packedTypeData = 0;
packedTypeData |= ((long) MMOItemTypes.NPC_ENEMY.ordinal() & 0xFF) << 56; // bits 56-63
packedTypeData |= ((long) (_anchorCornerX - _halfWorldSize) & 0xFFFF) << 40; // bits 40-55
packedTypeData |= ((long) (_anchorCornerZ - _halfWorldSize) & 0xFFFF) << 24; // bits 24-39
packedTypeData |= ((long) _soEnemy.ID & 0xFFFF) << 8; // bits 8-23 // SONPC ID
_variables.add(new MMOItemVariable("n", packedTypeData));[/code]
Then later i try to unpack it in java but its not working:
Code: Select all
long packedTypeData = mmoItem.getVariable("n").getDoubleValue().longValue();
MMOItemTypes mmoItemType = MMOItemTypes.FromByte((byte) ((packedTypeData & 0xFF) >> 56)); // bits
// 56-63
StaticResources.Trace("MMOItemtype: " + mmoItemType); // always 0, corrupted bits
Listen, sorry if i sound angry, because im really frsutrated, its simple stuff, why isnt there support for a long value in user vars? It doesnt make any sense to me.
Cheers
EDIT: Also i tried .getVariable("n").GetValue(), but its exactly the same it just returns a double value.