Autosave after reaching objective

Bug #536507 reported by bedouin on 2008-03-23
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
widelands
Medium
cghislai

Bug Description

Wish migrated from feature request #1403208.

After an objective has been reached, an autosave should take place. Toggling this behaviour should be possible.

Related branches

Sigra (sigra) wrote :

I suppose that the filename of the save should include something like:
  _("achieved %s"), objective.descname().c_str()

Changed in widelands:
status: New → Confirmed
importance: Undecided → Medium
tags: added: autosave savegame
Kiscsirke (csirkeee) on 2013-03-06
tags: added: lowhangingfruit
SirVer (sirver) wrote :

I am not sure how long hanging this is - there is a technical minuita that could make a problem:

Basically, the way I would implement this would be by adding a wl.Game().save() method into the Lua stack or by hooking it into the objective closing method im map (which is also called from inside Lua, so for the argument below there is no difference)[1]. The problem is now that a Lua coroutine that is currently running can not be saved - that is if save() is called from inside a coroutine, the game will crash. But objectives are very likely to be closed from inside a coroutine - so this is bad.

The solution to this is to instead add some state that defers saving until we are back in C++ code - i.e. all Couroutines are sleeping. This must most likely be done via a new variable in Game (something like: save_next_time_you_can). All of this should be fairly easy, but it is not trivial.

[1] There is already a method that saves a game, but it must not be called from a running coroutine or the game will crash.

cghislai (charlyghislain) wrote :

Hi,

I tried to fix this one to get my hands on the code.
I used the SaveHandler class to store the save request and the requested filename.

Achieved objectives are save as "map_name (Achieved obj_name)" as suggested by Sigra.
I also added a static function to be able to call save_game(my_save_filename) from a script.

I tested both way to trigger the save and it works as expected.

Changed in widelands:
assignee: nobody → cghislai (charlyghislain)
status: Confirmed → In Progress
cghislai (charlyghislain) wrote :
cghislai (charlyghislain) wrote :

Last patch include a new game option.

I had to change a bit the layout to make room for it. Here is a screenshot showing how it looks like.
I also allowed translation of the "achieved" string which i had forgotten.

Changed in widelands:
status: In Progress → Fix Released
cghislai (charlyghislain) wrote :

i wrongly set fix released please someone take care of this patch.

Regards,

Charly

Hans Joachim Desserud (hjd) wrote :

Thanks for your patch.

I set the status back to "In progress". No problem. :)

Btw, for future patches¸ could you push the changes to a branch here on launchpad and create a merge proposal? This makes it easier to deal with review of patches, especially if they are updated. See https://help.launchpad.net/YourAccount/CreatingAnSSHKeyPair and https://help.launchpad.net/Code/UploadingABranch if you haven't done this before. If you have questions, you can always ask here (or in the irc channel).

Changed in widelands:
status: Fix Released → In Progress
SirVer (sirver) wrote :

I didn't have time to look over the patch, but please remove the option. If autosave is enabled, autosaving after reaching objectives should be as well. Also, it seems that you did not register the lua method you defined, please have a look at this again.

I added you to the widelands-dev team. Please do not push to trunk though for now, instead use this ownership to push your branches to the team instead of your user, i.e.
bzr push lp:~widelands-dev/widelands/<branchname>.

This allows me and other devs to add comments into your code and fix trivialities more easily as if the branches are only owned by yourself and shorten review cycles and ease for everybody involved.

Changed in widelands:
status: In Progress → Fix Committed
Changed in widelands:
milestone: none → build18-rc1
SirVer (sirver) wrote :

Released in build-18 rc1.

Changed in widelands:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers