Originally Posted by
ShortBuss
Can someone take me through some rough steps as to how to correct the playerselfposstruct? I may just have a big lack in understanding of how to convert the packet data into the proper variables in the structure. I located an NPC that doesn't move, got it's /loc, then looked at a pre-patch log file for that spawn. I got the 20 bytes for the position, converted to binary then tried to get x/y/z figured out based on the known location (/loc) and using the pre-patch structure. I couldn't get anything close but also realize that the values in the struct are signed int while the /loc return is decimal. Maybe there's a conversion I'm missing.
I use debugging code in player.cpp and spawnshell.cpp, it starts with:
Code:
#if 0
// Debug positioning without having to recompile everything...
there are two of these in spawnshell.cpp, use the 2nd one
my debugging code after today's patch, player.cpp:
Code:
#if 0
// Debug positioning without having to recompile everything...
#pragma pack(1)
struct pos
{
/*0000*/ uint16_t unknown0000; // ***Placeholder (update time counter?)
/*0002*/ uint16_t spawnId; // Player's spawn id
/*0004*/ uint16_t unknown0004; // ***Placeholder
/*0006*/ unsigned pitch:12; // pitch (up/down heading)
signed animation:10; // velocity
unsigned padding1:10; // ***Placeholder
/*0010*/ float x; // x coord (1st loc value)
/*0014*/ float deltaX; // Change in y
/*0018*/ float y; // y coord (2nd loc value)
/*0022*/ float z; // z coord (3rd loc value)
/*0026*/ float deltaY; // Change in x
/*0030*/ unsigned heading:12; // Directional heading
unsigned padding2:10; // ***Placeholder
unsigned padding3:10; // ***Placeholder
/*0034*/ float deltaZ; // Change in z
/*0038*/ signed deltaHeading:10; // change in heading
unsigned padding4:10; // ***Placeholder
unsigned padding5:12; // ***Placeholder
/*0042*/
};
#pragma pack(0)
struct pos *p = (struct pos *)data;
printf("[%.2x](%f, %f, %f), dx %f dy %f dz %f head %d dhead %d anim %d pitch %d (%x, %x, %x, %x %x)\n",
p->spawnId, p->x, p->y, p->z,
p->deltaX, p->deltaY, p->deltaZ,
p->heading, p->deltaHeading,
p->animation, p->pitch,
p->padding1, p->padding2, p->padding3,
p->padding4, p->padding5 );
#endif
and spawnshell.cpp,
i added the line "if (p->spawnId == 0x1234)"... that's the id of the 2nd char I use.
Code:
#if 0
// Debug positioning without having to recompile everything...
#pragma pack(1)
struct pos
{
/*0000*/ uint16_t spawnId;
/*0002*/ uint16_t spawnId2;
/*0004*/ unsigned pitch:12;
signed z:19; // z coord
unsigned padding01:1;
/*0008*/ signed deltaX:13; // change in x
signed y:19; // y coord
/*0012*/ signed deltaHeading:10;// change in heading
unsigned heading:12; // heading
signed animation:10; // velocity
/*0016*/ signed deltaZ:13; // change in z
signed x:19; // x coord
/*0020*/ signed deltaY:13; // change in y
unsigned padding02:19;
/*0024*/
};
#pragma pack(0)
struct pos *p = (struct pos *)data;
if (p->spawnId == 0x1234)
printf("[%.2x](%f, %f, %f), dx %f dy %f dz %f\n head %d dhead %d anim %d pitch %d (%x, %x)\n",
p->spawnId, float(p->x)/8.0, float(p->y/8.0), float(p->z)/8.0,
float(p->deltaX)/4.0, float(p->deltaY)/4.0,
float(p->deltaZ)/4.0,
p->heading, p->deltaHeading,
p->animation, p->pitch,
p->padding01, p->padding02);
#endif