Save Linked-List in binary file

Posted By: Nicotin

Save Linked-List in binary file - 01/20/12 19:39

Hi, so I have just returned to 3DGS and I'm totally lost now as I'm used to other languages then c.

Now to my question:
I have a struct
Code:
typedef struct INFANTRIST { 
	STRING* Name; 
	long ID;
	ENTITY* ent;
  
  struct INFANTRIST* next;
} INFANTRIST;



As you see it store it in some kind of linked List.
Now I want to save the whole List into a file.
I know how I'd do it with a normal .txt but I prefer binary files for saves.
I know
Code:
file_str_writeto( file_handle, (char*)&x , sizeof(INFANTRIST) );


but it will (obviously) just save the String Pointer, also it won't save the "long ID".

I tried some things but can't get it to work properly.
Any help for a successful comeback to 3DGS would be appreciated laugh

I hate it that I havn't used a c-like language for years, now that my university only uses java mostly smirk
Posted By: sivan

Re: Save Linked-List in binary file - 01/20/12 22:04

hi,
as a first guess, instead of ENTITY*, its handle should be used for saving somehow. it is said to be the same on every run. but I don't have a ready to use solution... or save the file name of the entity model with the necessary properties (x,y,z, pan,tilt... flags...)
Posted By: Nicotin

Re: Save Linked-List in binary file - 01/22/12 11:55

Ja das hatte ich dann sowieso vor.
Ich glaube auch das ich ne Lösung hätte, falls ich es hinbekommen würde einen String mit beliebiger Länge zu sichern und wieder auszulesen.
Aber da mehrere EInträge mit verschieden langen Strungs gespeichert und gelesen werden sollen, bin ich mir nicht ganz sicher wie ich das Binär lösen kann.
Weitere Tipps sind willkommen laugh
© 2024 lite-C Forums