Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,089 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Save Linked-List in binary file #392260
01/20/12 19:39
01/20/12 19:39
Joined: Jul 2008
Posts: 170
Germany, near Mainz
Nicotin Offline OP
Member
Nicotin  Offline OP
Member

Joined: Jul 2008
Posts: 170
Germany, near Mainz
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



Re: Save Linked-List in binary file [Re: Nicotin] #392279
01/20/12 22:04
01/20/12 22:04
Joined: Mar 2011
Posts: 3,150
Budapest
sivan Offline
Expert
sivan  Offline
Expert

Joined: Mar 2011
Posts: 3,150
Budapest
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...)


Free world editor for 3D Gamestudio: MapBuilder Editor
Re: Save Linked-List in binary file [Re: sivan] #392429
01/22/12 11:55
01/22/12 11:55
Joined: Jul 2008
Posts: 170
Germany, near Mainz
Nicotin Offline OP
Member
Nicotin  Offline OP
Member

Joined: Jul 2008
Posts: 170
Germany, near Mainz
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




Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1