Game Development Community

Array send/read problems...

by kc_0045 · in Torque Game Engine · 04/22/2006 (5:04 pm) · 4 replies

Hello, Im having problems with packUpdate and arrays...how do I do it? my array is mVHeight[100][100]
I tryed stream->write(mVHeight[100][100]); but it doesnt seem to be working :S how do I do this?

#1
04/22/2006 (5:46 pm)
Just write and read the values in the array with a couple for loops. You could check if there is a writeArray function or some such too. I just hope that's not something you plan on sending more than once over the network...
#2
04/22/2006 (6:02 pm)
That's 10.000 items in your array. I assume those are floats? If so, that's easily 30Kb worth of data, and it'll surely exceed the TGE network packet size.

For sending such amount of data, you'll have to split it up and use several net events to get it sent. Use the serach feature and look for a resource which deals with the pathManager. It had a similar problem: the path nodes were sent down the network all at once, and it would break on paths with too many nodes. The resource fixes the issue sending small batches of nodes at once.
#3
04/22/2006 (8:10 pm)
Its not for online play but it doesnt seem to be updating on the client without sending it(same thing with a differnt var, the change wouldnt take effect unless it was being sent)
#4
04/23/2006 (7:46 am)
In Torque, it's always online play. Even in single player you have a server and a client, but they happen to be running in the same executable, and the server-client communication is done internally, instead of using actual networking.

But even the internal client-server communication tries to obey network rules and limits, to keep the code consistent. So there is a maximum packet size you can write in a single packUpdate, and odds are you're exceeding that.

Did you try compiling and running a debug build? Those will thrown warnings and asserts when you try to write more stuff than a packet can hold.