Sign in to follow this  

Best way to make campaign-file? (c++)

This topic is 822 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

Hi

(Game programming or general programming thread?)

 

In general how would i go about making a campaign (save-) file?

 

I have campaigns, with some campaign-data, and missions (each has a map, units, settings etc). Mission-files are not the same size as they may have different no of units etc.

 

Idea:

start file

save campaign-data

save mission1

save mission2

etc to last mission

end file

 

Now, if i want to load mission 4? Load from the beginning of the file until i hit mission 4? Or how to edit mission 3 and resave it? Or add another mission to the campaign or remove one? Or should i have a folder for the campaign with loose files for each mission? (seems ugly).

 

What is the general way to do this? It needs to be practical when i or the user creates and edits campaigns (and preferably all data in a single file)

Thanks a lot!

Erik

Edited by suliman

Share this post


Link to post
Share on other sites

The exact details are going to depend on your game and your implementation details.

 

In general you store whatever data is needed to restore critical state of your game. Exactly what is critical depends on your game and your save system.  Some pause the game and save the full state of the world, including animations mid-action. Others only save at key locations and restore the game by loading the list of objects in inventory and location in the story tree.

 

From your brief description, it looks like you have a data structure with a "campaign", which is likely some key/value pairs of data about the story tree, plus a collection of mission entries with their own key/value pairs of data.

 

For for that general plan, I would make your mission data be as little as possible, such as the steps required to complete the task at hand. Once the mission is complete I would mark it as a flag in the campaign (e.g. "mission 7 status: 1", "mission 8 status: 3", mission 9 status: 0") and only store the details of unfinished missions as sub-blocks within the campaign structure.

Share this post


Link to post
Share on other sites

Eh ok? But i already know how to save the missions... (the game state, all units etc. I wrote this in my post)

 

Im asking about the best way to bundle these into campaign files. And best way to save/load/edit such a bundle. I need to load from the beginning of the file right?

There should be a fairly standard problem for RTS-games etc (or actually many kinds of games). Im asking if there is a common practical way to deal with it.

 

Thanks

Edited by suliman

Share this post


Link to post
Share on other sites

Saves don't need to be in a single file, and for your arrangement of discreet missions and overarching campaign, it may be better to handle each mission as a single file and the campaign as a separate file with references to each mission save file.

Share this post


Link to post
Share on other sites

Yes missions are indeed discreet.

 

...and have folders for each campaign in that case (to not make a complete mess of the file structure)? Maybe easiest, but not so pretty:)

So a small file holding the campaign info and all missions as separate files?

 

I could save some state in each mission (campaign id and mission id) so a player can not "cheat" by moving around /renaming mission files i guess...

If those doesnt match, the mission will simply refuse to load (with a prompt of "file corrupted".

 

Then save player progression in another small file (which missions are completed, with what score/time and difficulty etc)

 

Does that make sense?

Edited by suliman

Share this post


Link to post
Share on other sites

Those are all implementation details.

 

As for cheating, don't worry about that. Players who want to cheat will do so, and on a local game they'll only affect themselves. If a player wants to use a save file cheat to get unlimited funds or whatever, let them do it.

 

You didn't mention it, but generally it is a good idea to use key/value pairs in save files, as well as a version number if appropriate.  This allows for systems to grow and change over development. If during development you drop a field you can stop reading the key and don't save it back out. If during development you add a field you can provide a default if read fails so you still get a full object. A version number or version key is slightly less useful unless it is automatically generated since it only indicates a change, but that too can be useful to tell the user something has changed.

Share this post


Link to post
Share on other sites


I could save some state in each mission (campaign id and mission id) so a player can not "cheat" by moving around /renaming mission files i guess...
If those doesnt match, the mission will simply refuse to load (with a prompt of "file corrupted".

 

I would generate checksums of the files to test for corruption, but as frob said, any effort put into anti-cheating for a single player game is just a waste of time.

Share this post


Link to post
Share on other sites

There are many ways you can achieve this and they all have different strengths and weaknesses so it really depends on your exact requirements.

A few of the ways are:

  • Folder for Campaign with individual files for missions

             Lots of individual files, but easy to read the exact mission file your interested in either for game or editor access.

  • Single file for entire campaign

             Only a single file to manage, but have to read through the file to find the section for the mission you want. Hard to edit since you have to replace data in the right part of the file.

  • Xml/Json file for campaign

             Only a single file to manage, relatively easy access to specific parts of the file.

  • Archive for campaign

             Lots of individual files for missions but packaged so not single files all over the place on the file system. Have to load archive to get to one single file though.

 

 

Regardless of what you use for the game to read the files you could have mission files as separate files for editing and then just pack them together (as a single file or achieve, preferably automated rather than manually) when putting a build of your game together.

Share this post


Link to post
Share on other sites

This topic is 822 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this