How to create a game save file format in c++ using STL

Griffin
  • How to create a game save file format in c++ using STL Griffin

    Hey so i just learned about the i/o part of the STL, more specifically fstream. Although I can now save binary info and classes i've made to the hard drive, i am not sure how to define how the info should be read.

    I saw the answer for making a file format from [this][1] post:

    Typically you would define a lot of records/structures, such as BITMAPINFOHEADER, and specify in what order they should come, how they should be nestled, and you might need to write a lot of indicies and look-up tables. Such files consists of a number of records (maybe nestled), look-up tables, magic words (indicating structure begin, structures end, etc.) and strings in a custom-defined format.

    What i want to know specifcally is how to do this with the STL and C++... Since the format is meant simply for the use of a game i would think it would be much easier though. The format should:

    • Be traversable (i can look through it and find the start of structure and maybe check it's name
    • Be able to hold multiple classes and data in a single file
    • have identifiable starts and ends to sections: such as the space in text files
    • Maybe have it's own icon to represent it??

    How do i do this in c++ ?

  • try using boost serialize! other than that what you are asking for is how to implement serialization and that's a real complicated thing! I've recently implemented an implementation for serialization and it's no easy case to talk about.

    there is also another way to only save one class into file which contains all the information you need, which makes saving/loading classes much more simpler.

    by the way icon is not anything related to file format it's something OS generates per file, and usually icons are stored somewhere between OS files. except for windows executable files(as far as I know). windows executable files are like a zipped folder, containing the actual binary operations, icon data for some various resolutions, and maybe some other data related to OS itself.

Tags
c++ file-format data-structure file
Related questions and answers
  • Say I develop a game for mobile platform running OpenGL ES 2.0. I have done 2D part, and now I wish to import some 3D objects. The imported 3D objects must contain the following: Vertices positions Normals UVs Texturing information Animation information Collision mesh Maybe some other things... I am aware, that I could and (maybe should) create my own file format that brings these data from 3D authoring application (3ds Max, Maya, Softimage) into the game. However, doing so from scratch is going to be really be a lot of work. Therefore, is there any available solution/middleware

  • intelligence, aggressivity, etc..) ..another assets.. Can I kindly ask for a hint, how to construct my custom file format. How to organize data within my files, please? Does anoybody have a good adivce on exporting animation information, especially when the mesh changes its geometry? I would be thankful for advices that could point me into right direction. It would be nice to save some time instead...After careful consideration to use middleware, I have decided on creating my own 3d file format format to export meshes from 3D authoring application (Softimage) into my game. I will need to export

  • I'm writing a game engine which is going very fine. However, I'm now posed with handling textures. My Engine is in 2D, for simplicity reasons mostly to get a good idea of how to work with OpenGL. I do this in C++, and I have a hierarchical set-up when it comes to classes. There's a base class and some other classes derive from that. So now I'm onto the part where I want to load up some textures... have to use glGenTextures to allocate a texture and that I then swap betwe--.. I actually have no clue. What's a good way to keep track of all the textures you loaded into the memory and switch

  • I was thinking about making smaller structures with the fTime variable each so I can have attribute keyframes, light keyframes and buffer keyframes, then make the node structure look like... animation I would end up storing a lot of data that I don't really need, even if I'm indexing node and frame data when saving and then store the hierarchy with the indices to the actual data. I don't know if my speculations are ok, as I don't have much experience with 3d animations yet. I want to make a well decision as any option I choose would require a lot of work to get it to render and I

  • GameSubsystems) can implement registerComponent(Component*). pro. Components and GameSubystems know nothing about each other. con. In C++ it would look like ugly and slow typeid-switch... a decision which Components to register (and how to organize them). For example, GameSubsystemRender can register Renderable Components. pro. Components know nothing about how they are used. Low... by title. Of course, ComponentTitle should not be rewrited or inherited in this case. B. We can reorganize existing GameSubsystems. For example, GameSubsystemAudio, GameSubsystemRender

  • \steamapps\common\doom 3\base\game01.pk4 (2 files) C:\Program Files (x86)\Steam\steamapps\common\doom 3\base\game00.pk4 (2 files) game DLL: 0x0 in pak: 0x0 Addon pk4s: file system initialized...I am trying to build and run Doom 3 from the open source release in order to better understand how the engine works. Unfortunately I am not able to run the game from the binary I built. I just get the console, but cannot run the actual game. Here is what I did: Downloaded the source code from the game repo Downloaded and installed the DirectX SDK Purchased, downloaded and installed Doom 3 from

  • I was recently listen to a talk that Jonathan Blow gave, you can find it here. In the talk, he was talking about what data structures he (and he seemed to imply many others) use, and why. Which... that. All this seems well and good, except I have one question, why not linked lists rather than arrays? Sure, if you had to make your own linked list class, I would be on board, but in c++ anyway, assuming.... And I could see a case there for using arrays rather than linked lists, because you would have to make your own (which while simple enough to do, could potentially lead to many more errors). I also

  • to do that. The challenge is how to make the game activate the function efficiently. This is what I've thought of so far: The algorithm can calculate a lot of time steps in a short time, so I could... double-buffering. The question is: who should be responsible for activating the spacecraft's algorithm? Should I do that directly in the game loop, or perhaps create a "timer object" that keeps track... there is a totally different and better way to do this, please let me know. Additional info: the game is in C++, and the graphics engine is Ogre3D. EDIT: changed the part about the trajectories of the non

  • I am creating a tetris game in C++ & SDL, and I'm trying to do it "good" by making it object-oriented and keeping scopes small. So far I have the following structure: A main with some lowlevel... by map and block. Now I have a though time where to place the time-management of this game. For example, where should be decided when a block bumps the bottom of the screen how long it takes the current block locks in place and a new block spawns? I also have an other unrelated question, is there some place where you can find some standard data on tetris like standard score tables, rulesets

Data information