On Wed, Nov 14, 2012 at 11:19:19PM -0600, Bob Tanner wrote:
> On 2012-10-24 06:56:25 +0000, James Cameron said:
> 
> >SP_PLANET_LOC pnum= 0 x= 20000 y= 80000 name= Earth
> 
> Getting closer.
> 
> Building  game packet for SP_PLANET_LOC I'm getting some whacky
> values for x and y
> 
> SP_PLANET_LOC pnum=0 x=541982720 y=2151153920 name=Earth

These numbers are byte swapped forms of the raw data.

541982720 is 0x204E0000 and should be 0x00004E20
2151153920 is 0x80380100 and should be 0x00013880

So check the order of the bytes as they are unpacked into your local
variables.

Should not cause misalignment though.

> 
> Looking at the raw data
> 
> 1a 			type
> 00 			pnum
> 00 			pad2
> 00 			pad3
> 00004e20 	x
> 00013880 	y
> 
> Putting that into a test program I get the right stuff
> 
> pnum=0 x=20000 y=80000 name=Earth
> 
> Here is the struct I'm using
> 
> typedef struct _serverPacketPlanetLocationStruct
> {
>    int8_t  type;                                /* SP_PLANET_LOC */
>    int8_t  pnum;
>    int8_t  pad2;
>    int8_t  pad3;
>    int32_t x;
>    int32_t y;
>    int8_t  name[16];
> } serverPacketPlanetLocationStruct;
> 
> Making sure the sizes is right
> 
> ServerPacketPlanetLocation 28
> SP_PLANET_LOC 28
> 
> NSLog is a lot like printf, it's what I use to debug
> 
>        NSLog(@"%@ pnum=%d x=%d y=%d name=%s", self, gamePacket.pnum,
> gamePacket.x, gamePacket.y, gamePacket.name);
> 
> Some reason it feels like an endian issue (don't ask me why)
> 
> Posting it here for comments. It's late. I'll look at it more tomorrow night.
> 
> -- 
> Bob Tanner <basic at us.netrek.org>          Key fingerprint = 9906
> 320A 8BB6 64AD 96A7  7785 CBFB 10BF 568B F98C
> 
> 
> _______________________________________________
> netrek-dev mailing list
> netrek-dev at us.netrek.org
> http://mailman.us.netrek.org/mailman/listinfo/netrek-dev
> 

-- 
James Cameron
http://quozl.linux.org.au/