Game Development Community

Stream->read, stream->write

by Dan - · in Torque Game Engine · 05/02/2004 (9:20 am) · 2 replies

This maybe a simple questions, but does the stream->read know how to unpack based on the order it was packed?

For example if I:
stream->write(&mMinColour);
		stream->write(&mMaxColour);
		stream->write(&mMinBrightness);
		stream->write(&mMaxBrightness);
I would have to have in my unpackUpdate a read that matches the order exactly. Sort of "take it out in the order you stuck it in" or:
stream->read(&mMinColour);
		stream->read(&mMaxColour);
		stream->read(&mMinBrightness);
		stream->read(&mMaxBrightness);
and if I did:
stream->read(&mMinColour);
		stream->read(&mMinBrightness);
		stream->read(&mMaxColour);
		stream->read(&mMaxBrightness);
mMinBrightness would read what mMaxColour should have been. Corrent?

If this is not how it knows how to unpack the data how does it know?

Thanks,

#1
05/02/2004 (9:45 am)
It is order dependant; you must read it in the order that you wrote it.

- Melv.
#2
05/02/2004 (9:46 am)
Thanks Melv! Thats what I thought.