Archived

This topic is now archived and is closed to further replies.

brann

problem reading floats with directplay

Recommended Posts

brann    122
hi all I have a small problem usint directplay : i cant read floats, but it will work with ints here is the failing code
case MessageType.Move:
// handle the move internally

PlayerObject p = data.GetPlayer(e.Message.SenderID);
p.x = (float) e.Message.ReceiveData.Read(System.Type.GetType("System.Float"));
p.y = (float) e.Message.ReceiveData.Read(System.Type.GetType("System.Float"));
it fails on the first Read call, and says System.NullReferenceException of course, i'm sending floats on the other end, and p.x is float If i send ints and try to read System.Int32, it works fine any ideas? thx [edited by - brann on March 23, 2004 8:26:26 AM]

Share this post


Link to post
Share on other sites
brann    122
i''ve just tried his solution, but it says me the struct cannot be "blitted".

i''ve tried this to read:

p.x = (float) e.Message.ReceiveData.Read(typeof(float));
it doesnt fail anymore, but the value i get is totally wrong (i''m sending 0 and getting a random value)

Share this post


Link to post
Share on other sites