Public Group

What would u suggest the best file format is?

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

Recommended Posts

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

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 on other sites
Quote:
 Original post by harminalSo 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..

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 on other sites
Binary format...i guess ill just have to gritt my teeth and go with this as this is what most people say:S

Share on other sites
its not that hard :)

// write somethingFILE* fp = NULL;fopen_s(&fp, "path/to/file", "wb"); // wb for wribe binaryint somevalue = 4;fwrite(&somevalue, sizeof(int), 1, fp);fclose(fp);// read somethingint readval=0;// open file again using fopen, instead or wb you use rb, stands for read binaryfread(&readval, sizeof(int), 1, fp);// readval is now 4.

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 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 on other sites
Quote:
 Original post by wiegje85its not that hard :)*** Source Snippet Removed ***
is sizeof(int) 16,32,64, or something else?

Share on other sites
Quote:
Original post by Daaark
Quote:
 Original post by wiegje85its 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 on other sites
wouldnt sizeof() return the number of bytes anyway. so 2, 4, 8 instead of 16, 32, 64

1. 1
2. 2
Rutin
22
3. 3
4. 4
frob
18
5. 5

• 33
• 13
• 10
• 11
• 9
• Forum Statistics

• Total Topics
632563
• Total Posts
3007100

×