problem reading floats with directplay

Started by
1 comment, last by brann 20 years ago
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]
Advertisement
Check this thread.

Muhammad Haggag
Bitwise account: MHaggag -

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)

This topic is closed to new replies.

Advertisement