TeamSpeak-3-Java-API icon indicating copy to clipboard operation
TeamSpeak-3-Java-API copied to clipboard

negative icon id

Open teenriot opened this issue 6 years ago • 2 comments

For some icons i get negative ids, e.g via ServerGroup.getIconId() So i'm not able to download the icon file in this cases. I'm running on 64bit-jvm.

I found out that i can fix those ids by adding (1 << 32).

May there are internally some problems with handling icon ids. One reason could be that the long ids are threated as integers at some point.

teenriot avatar Sep 29 '18 18:09 teenriot

The icon ID is a 32-bit unsigned integer. Java doesn't have unsigned integers, so you may end up with negative icon IDs.

However, this problem is not restricted to our API, either. The server query sometimes sends the icon ID as an unsigned integer, and sometimes as a signed integer. In some places, like the permissions system, TS3 expects a signed integer, and in others, like the file system, they expect unsigned integers.

But I agree, as a user you shouldn't have to deal with those kinds of problems. We might just convert everything to a Java int and do the required signed <-> unsigned conversions internally.

rogermb avatar Sep 29 '18 22:09 rogermb

As temporary solution im fixing it like this:

public static long getUnsignedInt(int x) { return x & 0x00000000ffffffffL; }

Maybe I'll create PR tomorrow...

Catzy44 avatar Jul 05 '22 01:07 Catzy44