python-airmash
python-airmash copied to clipboard
Projectile wrong y coord
Projectile has y coord that is always twice as much as it should be. E.g. if I fire a projectile and print out it's position immedietIy I get the following output:
Position: 1003 -1336
projectile: 990.5,-2692.5
So either player or projectile has wrong scale for y coord. Is this the culprit?
class AdapterCoordY(Adapter):
"""Converts X coordinate from a uint16 to the range +-16384
Although the default map only uses a +-8192 vertical range"""
def _encode(self, obj, ctx):
return (obj * 2) + 32768
def _decode(self, obj, ctx):
return (obj - 32768) / 2.0
I don't understand why some coord updates are using AdapterCoordX/Y and some are using AdapterCoord24.
Some of the coordinates are 16bit, and some are 24bit, these are then scaled to the same range with the 24bit coords offering additional accuracy after the decimal place.
I don't know why the more accurate coords aren't the norm, what's a byte among friends?
For example a PLAYER_UPDATE will use 24bit coords, whereas a PLAYER_NEW packet, only 16bit ones.
You are correct in your observation. The CoordY adapter is a copy-paste of the CoordX, and is wrong. It should be / 4.0 not / 2.0. I'll fix it immediately.
Done! Thank you.