Bogus data using UDP

BlitzPlus Forums/BlitzPlus Beginners Area/Bogus data using UDP

acolite246(Posted 2009) [#1]
I'm using UDP to make my game multiplayer and I use types to store the data recieved from the messages.

The message is not corrupted and appears exactly how it should, but

                                               newx% = BP_StrToInt (Mid$(msg\msgData,1,3))    ; from BP with slight changes
						newy% = BP_StrToInt (Mid$(msg\msgData,4,3))
						newdir% = BP_StrToInt (Mid$(msg\msgData,8,3))
						newteam% = BP_StrToInt (Mid$(msg\msgData,11,1))
						newweapon = BP_StrToInt (Mid$(msg\msgData,13,1))
						newmovement = BP_StrToInt (Mid$(msg\msgData,15,1))
						newhealth = BP_StrToInt (Mid$(msg\msgData, 17,3))		;end from BP


that code (using a special command from the multiplayer thing I am using) buggers it up and I end up getting stuff like team = 48 even though the highest team number is 6.

What is happening?

this is the BP_StrToInt function
Function BP_StrToInt%(st$)
;-=-=-=Take a String of any length and turn it into an integer again.
	Local shiftin%
	Local num%
	For shiftin = 0 To (Len (st$) - 1)
		num = num Or (Asc (Mid$ (st$, shiftin + 1, 1)) Shl shiftin * 8)
	Next
	Return num
End Function



acolite246(Posted 2009) [#2]
Fixed. Issue on my part, I wasn't converting my data into a string when i sent the message.