PDA

Click to See Complete Forum and Search --> : Sending Types with Winsock


QuakeStuff
Mar 17th, 2000, 07:40 PM
Hi there, any help would be much appreciated...

i'm programming the network code for a game, and i need to send user defined types using the vb winsock (6.0) control. the senddata function won't let me send a type, it says 'Only public user defined types defined in public object modules can be used as parameters or return types for public procedures of class modules or as fields of public user defined types'

apparently there's some way to do this using a byte array, but i have no idea how...

thanks again

pete
www.cintelsoftware.co.uk

KENNNY
Mar 18th, 2000, 07:00 PM
hmmmmm i wonder who you could be :)
urghhh byte array?
ur not doing net in a class are u?
BTW, sII building is 1/2 in

ljdarten
Mar 19th, 2000, 09:22 PM
i ran into this too. i had never come across the fact that you can only send standard types until i had almost finsihed a network game (i made the game work as one player then worried about the network part).
pissed me right off, had to rewrite half the game and still haven't gotten it working well.

as far as i have been able to find, you can only send standard types and theres no way to force it.

the way i did it (im sure there is a better one) was to make two functions that would convert the type to a string and back again. the extra processing killed the game, but it worked.

another thing i did on a different game was make the data_arrival recieve a sort of "script" (the first 3 characters coming in are "mov" so it knows the next x characters are for moving the character. all kinds of fun stuff like that.


hope something in this mess helps a little

Fox
Mar 20th, 2000, 01:24 AM
Hi,

I'm doing a network game too and I made a script system (A message looks like: "MOVE,Player,10,10"). I also thought about constants for less traffic (Like move = 2, Hit = 3: "2,10,10"). Well, there's no solution to send types directly I think :(.

(A way will be to have an array of values instead of named vars... it's very difficult to handle but it would work ;) See some example code:


'Module
Type tPlayer
Var( 10 ) As Long

'For example
'0 = x
'1 = y
'2 = Energy
'3 = Something
'...
End Type

Global Player As tPlayer

'Anywhere in Form
Public Sub SendPlayer
Dim A As Long

'Send all vars
For A = 0 to 10
WS.SendData Player.Var( A )
Next
End Sub


I think that would work but... ya know ;)

KENNNY
Mar 20th, 2000, 05:43 AM
yeah, that's what he's doing at the moment (we're working on the same game :) ). But it's soooo much repeated code :(
We're thinking of using DirectPlay..

Fox
Mar 20th, 2000, 10:49 AM
Uh, good luck ;) I heared that DPlay is very difficult to use (at least in C)...