Take a look, that (BYTE*) thing is a pointer, you're letting the game write those for you.
I think you can properly figure out how many bytes the FArchive wrote by inspecting Pos() or something else in there...
Dynamic arrays are cool, provided you know how they work.
As long as you can, stick to UE structures and headers (even if you need some other UE2 game headers for this), and no platform specific stuff.
BTW if you know how much space will be using before the storage, don't even use TArray, go straight appMalloc
EDIT:
Code: Select all
INT RawData[32]; //128 bytes of something
FArchiveProxy ByteWriter(...); //Allocate it in the stack, not important anyways
ByteWriter->WriteTo = (BYTE*)RawData; //You can typecast any kind of pointer here
ByteWriter->Serialize( stuff, stuff's size); //Writing generic data
ByteWriter->Serialize( stuff, stuff's size); //Writing generic data
FCompactIndex Blah = Something; //I want to compress this, AND see how much bytes it took
BYTE* OldWriteTo = ByteWriter->WriteTo;
ByteWriter << Blah;
INT CompressedSize = (INT)ByteWriter->WriteTo- (INT)OldWriteTo;
//This code won't crash as long as you don't exceed your 128 byte buffer