[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: 'Filing' structure



Steve Baker:
[cut]
>  1) Always write your structures with the largest elements first
>  2) Always insert worst-case padding yourself:
>  3) Read and write structures one element at a time:
>  4) Don't use binary files at all.  Use XML or some other ASCII format.

My worste fears have come true.

Ok, it's just tedious and error prone for me as it is for many others...
No nice tricks.
I just have to be patient an map all my structures....

I usually do 1) and 3), and i'm starting to use a combination between 3) and 
4).

>  To keep pointers straight, I typically build up a table of all
>  the addresses used in the file as I write the file out - converting
>  pointers into indices into that table.  As I read the file, I
>  recreate the table and use it to convert indices back into addresses.
>  It's complicated though.
Yeah, but it seems the only solution.

>  If you need to do it **FAST**, you might want to consider using a
>  portable format (like XML/ASCII) and have the program read the file
>  in from XML - then write it back out in a machine-specific (but fast)
>  binary format.   The first time the program runs, it'll take a long
>  time - but subsequently it can read the binary format and run much
>  more quickly.
At the time i've some code to fill mapped structures from ascii files.
Very good, but enlarges data by a factor of 10, not affordable when sending 
initial data for a multiplayer.

Ok, back to the boring stuff.

Thank you,
Francesco Orsenigo