Jump to content
  • Advertisement
Sign in to follow this  
Guest

What would u suggest the best file format is?

This topic is 3084 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Guest
Ok say is started producing a terrainmaker in C# and terrainViewer in C++;

So i made a saver and loader using XML...
However many people have been criticizing me because apparently this method must use managed C++/Cli which shouldnt even be touched.. So too summ up my main points

Specifications
Must have a custom file extension
But be able to read in both c# and C++ without drawing critisim
Needs to store height,width,terrain heights, model positions,other misc map data

So far i have rakked up three methods

1: XML- people hate this way
2: Normal text file-No extensions
3: encrypted text file-same as above?

any suggestions?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by harminal
So i made a saver and loader using XML...
However many people have been criticizing me because apparently this method must use managed C++/Cli which shouldnt even be touched..
Umm.. in your last post about this, everyone told you that this is plain wrong.

Share this post


Link to post
Share on other sites
You can use XML without using CLI (for C++ tinyxml is nice)

The only real flaw with XML is that it is a bit bloated, the wide spread availability of libraries makes it a good option for a plain text format.

If you want something better i'd suggest going with a binary format of your own design that stores all the data you need. (You can quite easily write tools to convert the XML data to a binary format)

Share this post


Link to post
Share on other sites
Guest
Binary format...i guess ill just have to gritt my teeth and go with this as this is what most people say:S

Share this post


Link to post
Share on other sites
its not that hard :)


// write something
FILE* fp = NULL;
fopen_s(&fp, "path/to/file", "wb"); // wb for wribe binary
int somevalue = 4;
fwrite(&somevalue, sizeof(int), 1, fp);
fclose(fp);

// read something
int readval=0;
// open file again using fopen, instead or wb you use rb, stands for read binary
fread(&readval, sizeof(int), 1, fp);

// readval is now 4.

Share this post


Link to post
Share on other sites
XML is great as an intermediate format. For example, exporting to XML from your tools is useful. However it is sensible to stream in from a binary format when loading data into your engine.

Share this post


Link to post
Share on other sites
Binary XML (or chunk based format) is also an option.
Everybody can generate XML from a chunk based format or back again.
Back in the day for amiga/playstation dev we used this a lot. Also for PC ofcourse.

The cool thing is that you don't have to have different file format versions. Older programs just ignore new features and new programs can load old files and just use what was available back then.
This is possible because you can just skip past chunks you don't know.

Share this post


Link to post
Share on other sites
Quote:
Original post by wiegje85
its not that hard :)

*** Source Snippet Removed ***
is sizeof(int) 16,32,64, or something else?

Share this post


Link to post
Share on other sites
Quote:
Original post by Daaark
Quote:
Original post by wiegje85
its not that hard :)

*** Source Snippet Removed ***
is sizeof(int) 16,32,64, or something else?


If it is C++ it depends on the implementation.

for C++ the only rules for int datatypes are:

sizeof(short)<=sizeof(int)<=sizeof(long)

and that int is able to hold atleast any value between -32767 to 32767 (Which means it has to be atleast 16 bits) (int is usually 32 bit on x86 systems, but a compiler can use a different size and still be standards compliant)

Share this post


Link to post
Share on other sites
wouldnt sizeof() return the number of bytes anyway. so 2, 4, 8 instead of 16, 32, 64

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!