float decoding - player entity
lm82jyke opened this issue · 3 comments
lm82jyke commented
when printing out vectors for player entities the values seem to be decoded wrong.
while the m_vecOrigin of non-player entities are shown as mapcoordinates,
the player m_vecOrigin is not given as mapcoordinate.
here is an example with the prop-decoding-flags printed out
Entity Enters PVS: id:2, class:35, serial:781
Table: DT_CSPlayer
Field: 2, m_vecOrigin = SPROP_NOSCALESPROP_NOSCALE3295974912.000000, 3255495936.000000
Field: 3, m_vecOrigin[2] = SPROP_NOSCALE1098924032.000000
Field: 4, m_vecVelocity[0] = SPROP_NOSCALE3227493120.000000
Field: 5, m_vecVelocity[1] = SPROP_NOSCALE3279223296.000000
Field: 7, m_vecOrigin = SPROP_NOSCALESPROP_NOSCALE3295974912.000000, 3255495936.000000
Field: 8, m_vecOrigin[2] = SPROP_NOSCALE1098924032.000000
Field: 14, m_vecViewOffset[2] = 64.062561
Field: 17, m_flFOVTime = SPROP_NOSCALE1128479744.000000
Field: 20, m_angEyeAngles[0] = SPROP_NOSCALE1103372544.000000
Field: 21, m_angEyeAngles[1] = SPROP_NOSCALE1132894976.000000
Entity Enters PVS: id:155, class:126, serial:953
Table: DT_RopeKeyframe
Field: 14, m_Width = SPROP_NOSCALE1073741824.000000
Field: 16, m_vecOrigin = SPROP_COORDSPROP_COORDSPROP_COORD3622.000000, -1014.000000, 264.000000
is this a bug or am i getting something wrong
thanks in advance
lucas-feijo commented
Did you ever find a solution for this? I'm having the same problem
trophymursky531 commented
I'm hitting this too, did anyone figure out why the flag is getting set wrong?
lucas-feijo commented
I did, the values are being decoded as int instead of as float. To fix it, just cast the values to int, then to binary, then back to float. Here's how I'm doing it in python, no idea if it's the best way:
import struct
def fix_position(x):
return struct.unpack('!f',struct.pack('!I', int(x)))[0]