Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Save Game Support #2743

Open
Mailaender opened this Issue Mar 9, 2013 · 31 comments

Comments

Projects
None yet
Owner

Mailaender commented Mar 9, 2013 edited

It could just dump the current state of all units into a map.yaml file for the following use-cases:

  • Share auto-save files to better reproduce and understand desyncs.
  • Restart the game loading an auto-save when a player dropped.
  • Finish the longer single-player missions tomorrow.

This was referenced Jun 7, 2013

Owner

pchote commented Dec 1, 2013

Dumping and restoring the world state is going to be really fiddly to get right.

A much simpler approach would be to save a replay plus some additional metadata. When loading a save it can show a progress dialog on top of the load screen while it simulates the world state at maximum speed to the end of the replay, before handing control back to the player.

This is obviously nowhere near ideal, but it would be better to have something that works than something that is ideal, but is never implemented.

@pchote pchote was assigned Dec 1, 2013

@ScottNZ ScottNZ was assigned Dec 25, 2013

kaneCVR commented Jan 24, 2014

What about having the engine generate a new map.bin, map.yaml and mission.yaml + another file with all savestate actor actions included in a savegame0001.oramap? Would that work?

Owner

pchote commented Jan 24, 2014

The main difficulty is in serializing and restoring the state of all of the traits and (especially) activities that an actor may have active.

@Mailaender Mailaender added the bounty label Mar 4, 2014

This was referenced Mar 29, 2014

@Mailaender Mailaender changed the title from Save Game Support [$65] to Save Game Support [$75] Apr 2, 2014

@Mailaender Mailaender added the bounty label Apr 2, 2014

@Mailaender Mailaender changed the title from Save Game Support [$75] to Save Game Support [$80] May 12, 2014

@Mailaender Mailaender added the bounty label May 12, 2014

@Mailaender Mailaender changed the title from Save Game Support [$80] to Save Game Support [$85] Jul 6, 2014

@Mailaender Mailaender added the bounty label Jul 6, 2014

@ScottNZ ScottNZ removed their assignment Aug 1, 2014

Contributor

MunWolf commented Aug 12, 2014

#6238 is my prototype on this.

It already supports all single player saving, multiplayer loading is planned and a dedicated UI for saving/loading will be put in soon. Until then you can try this by going to the replay browser selecting a replay and hitting resume.

@MunWolf MunWolf was assigned by Mailaender Aug 13, 2014

Owner

Mailaender commented Aug 13, 2014

Awesome! So this is comparable to the "Take command" button in Starcraft 2 http://us.battle.net/sc2/en/blog/8501413/new-replay-and-resume-features-coming-in-heart-of-the-swarm-1-24-2013

Contributor

MunWolf commented Aug 13, 2014

Yes, I can't do normal save game functionality unless I start doing some real Serialization (which is a LOT of work), I might do that later on but until then I want a way that works :)

Contributor

MunWolf commented Aug 20, 2014

#6287 is my (hopefully) last implementation of the resume from replay feature.

Contributor

MunWolf commented Feb 2, 2015

well I started work on this again using serialization in last december but I didnt do any pull requests for it since no one seemed able to review it at the time.

Hopefully this will happen when I and the reviewers arent busy.

kaneCVR commented Feb 3, 2015

Wish I had the skills to help with this.

@orabot orabot changed the title from Save Game Support [$85] to Save Game Support [$115] Feb 24, 2015

@orabot orabot changed the title from Save Game Support [$115] to Save Game Support [$85] Apr 3, 2015

@orabot orabot changed the title from Save Game Support [$85] to Save Game Support [$90] Apr 11, 2015

would be totally awesome to have this fixed ;-)

@orabot orabot changed the title from Save Game Support [$90] to Save Game Support [$105] May 22, 2015

Would really love a quicksave/quickload function too.

@orabot orabot changed the title from Save Game Support [$105] to Save Game Support [$110] Jun 30, 2015

@orabot orabot changed the title from Save Game Support [$110] to Save Game Support [$200] Sep 4, 2015

Contributor

tohava commented Nov 3, 2016

@wolfgaming - So what happened? did you continue to work at this? Did none of the admins have time? If I am planning to try and understand your work, should I like at #6287 or is there something newer?

Owner

pchote commented Nov 3, 2016

@reaperrr and @obrakmann have been towards two of the main blockers for proper serialization (#12310, #12315). If you'd like to help advance save games, it would be better to help them.

My experience with using replays to debug desyncs shows that the replay approach will never work well enough to merge (nobody will want to wait 30 minutes to reload a save from an hour into a game).

Contributor

tohava commented Nov 3, 2016

@pchote - I have some questions:

  1. DelayedAction is bad because you can't serialize Action objects because serializing lambda/code is tricky, right?
  2. What is going on #12315? Why is it needed for save games?
Owner

pchote commented Nov 3, 2016

  1. Correct.
  2. The activity code is a hotspot of technical debt and subtle bugs related to the way activities are queued, cancelled, and managed. The activities need an overhaul to introduce a proper system for tracking the activity hierarchy and to kill off various one-off hacks that will otherwise cause headaches.

@Mailaender Mailaender referenced this issue in bountysource/core Nov 5, 2016

Closed

Github integration broken #1062

Owner

Mailaender commented Nov 7, 2016

My experience with using replays to debug desyncs shows that the replay approach will never work well enough to merge (nobody will want to wait 30 minutes to reload a save from an hour into a game).

Could we use that for reproducible performance stress tests instead?

Contributor

MunWolf commented Nov 8, 2016 edited

@tohava I still have my old save game branch somewhere on my git, it wasn't fully functional and I didn't have the time to finish it.

The main reason why it took so long to do is because of the activities, saving the hitpoints of units, position and money of the players etc is really easy compared to for example saving where a unit is moving simply because activities are quite a mess atm.

@Mailaender Mailaender removed the Bounty label Nov 10, 2016

@Mailaender Mailaender changed the title from Save Game Support [$200] to Save Game Support Nov 10, 2016

Hi all,

Apologies for asking a question without knowledge of the project:
Will progress here be usable with the RA2 mod?

Regards.

Owner

Mailaender commented Nov 24, 2016

Yes.

bartveurink commented Feb 9, 2017 edited

Solution for saving: Just dump whole memory that the game used to a file. When the gamer wants to resume, put the file back to the memory.
Saving is important for me, because i dont have the time to finish a combat in one evening. So for resuming is one slot enough. The file with the savegame takes up more space, but with one slot is it not a problem.

Owner

pchote commented Feb 9, 2017

That unfortunately isn't possible with C#. Objects in memory need to be explicitly serialized and deserialized.

bartveurink commented Feb 10, 2017 edited

Thus my idea is not possible. Is there a code available on the idea of the first message for testing and debugging?
Is there a similar project that has a working save-game function? Maybe there is a project written in c# with a save-game function and just copy and modify it.

Owner

pchote commented Feb 10, 2017 edited

@wolfgaming did a prototype of the replay approach, which showed that that shortcut was not feasible (it would take ~30 - 40 minutes to restore the state of a ~1h game).

That really only leaves the proper approach... which means rewriting the simulation code to be able to dump and restore the world at a given tick. @reaperrr and @obrakmann have been making progress towards that, but there is realistically a couple of years worth of work left with our current level of manpower.

Contributor

reaperrr commented Feb 11, 2017

That really only leaves the proper approach... which means rewriting the simulation code to be able to dump and restore the world at a given tick. @reaperrr and @obrakmann have been making progress towards that, but there is realistically a couple of years worth of work left with our current level of manpower.

Since you're talking about years, I wonder what else except getting rid of DelayedAction and refactoring Activities is needed?

I'd also like to point out that some very good commercial strategy games had only 'partial' savegame support, where only some, but not all aspects and states were saved. IIRC in SpellForce only actor positions and maybe health were saved, while even revealed shroud wasn't. Quite annoying, but still far better than no savegames.
MechCommander even only allowed you to save between missions, not during, but that was also better than nothing and at least allowed for campaign progression.

In my opinion starting with a basic, simple, more singleplayer-oriented savegame support that only saves the most important parts - actor position, health, faction and such, trigger states - would be good enough at least for singleplayer, at least much better than no savegames at all.
Also, a campaign progression system that saves between missions would be a great feature as well.

My point is, instead of aiming for the by far largest and hardest part right off the bat - namely fully-fledged multiplayer savegames - we should start with comparatively easier things ^ first.

Otherwise we might run into that unfortunate situation where at some point in the (hopefully distant) future, development comes more or less to a halt, and modders are left with a half-finished but still not working MP savegame system, but not even the most simplistic campaign/mission savegame system, when the latter could have been implemented easily with a smarter order of priority.

Owner

pchote commented Feb 11, 2017

Two things, really:

  • Can't avoid all activity serialization because activities frequently put actors into temporarily inconsistent states (e.g. spanning multiple cells, using custom animatations, etc) and writing special cases to force sane enough data to save/load would be more work than implementing the basic plumbing an essential activity serializers.
  • Lua is going to be a giant pain, and so far our best idea is "make the mission scripts deal with that"

@reaperr, do you mean that after saving a part of the current game, the code can later on be improved.
Some things I want to save:

  • Map
  • Structures with positions
  • Units with positions
  • Money

Further on:

  • Restart AI on that position

unfortunately it can lose some things, but that is later on. I dont think this will take half an hour.

I think there are some things we need to keep:
Money
The unit and structure that Player build
The unit and structure that Enemy build
Radar Map
Enemy AI behavior(AI need to 'continue' what they will do)

Further on:
The unit and structure that Player was building and the building percent
Super Weapon Status
Mission Status(Single Player Campaign mode)

Shall we make a Serialization for C#?

Contributor

MunWolf commented Mar 8, 2017 edited

A save state and a 'text format' file in this case are the same thing. If we don't save activities we get things like airplanes stuck in the sky (the ones that drop crates for example) and other bad things.

There really is no shortcut and the devs are slowly making headway to it.

Edit: We are making serialization for C# that's the point, it takes a lot of developer time which we don't have so you are just going to have to wait.

@wolfgaming that sounds very great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment