Hi all.
Dunno if anybody even answers here but i try.
In short:
If i write structs (UndoBlock) to streams like that:
Code:
hugestream.Write(UndoBlock, sizeof(UndoBlock));
This "kinda" works. Data is written and it seems that its written correctly.
But i have a real problem reading it back.
Do i need to read into array?
The amount of writings depends on how many changes user made to the map.
I can count that..
But when im trying to read the numwritten i get garbage.
Writing to stream (im just saving old block before modifying):
Code:
hugestream.Write(sbs, sizeof(sbs));
Reading back:
Code:
for i:=0 to NumWritten-1 do
begin
s.read(sbs, sizeof(sbs)); // is this even correct way to read???
ShowMessage('setstate '+IntToStr(sbs.LidTile)); // garbage displayed
end;
The cbs record only has Byte and Word fields. Nothing else.
maybe the record size is bad? Maybe i should add "pad"?
Or i just should read back every record item (field) one by one and not whole struct at once?
I have used lots of streams and stuff in my other projects but i always get the issues reading back stuff.
Im forgetting stuff.
Bookmarks