View Issue Details

IDProjectCategoryView StatusLast Update
0005543Spring engineGeneralpublic2017-05-19 21:50
Reporterlamer Assigned Tohokomoko  
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
Product Version103.0 +git 
Summary0005543: Save/load is broken by maps with predefined units/features
DescriptionOn savefile loading Spring executes map's lua. It can create start units (that may be destroyed before save action occured).
And savefile already has actual state of those units (dead or alive).
Steps To ReproducePlay on Gunmetal Harbor and use save/load mechanics.
http://springfiles.com/spring/spring-maps/gunmetal-harbor-1
Additional InformationSeems ZK's сrutches with destroying all units (https://github.com/ZeroK-RTS/Zero-K/blob/0374d05a15bb5ef94195ef69204c278bdf2d6d15/LuaRules/Gadgets/api_saveload.lua#L514) and then creating new unitIDs (https://github.com/ZeroK-RTS/Zero-K/blob/0374d05a15bb5ef94195ef69204c278bdf2d6d15/LuaRules/Gadgets/api_saveload.lua#L224) is the way to go at the moment. But it breaks AI loading without additional crutches like passing old unitID in unitRulesParam: can't associate data with unit.
TagsNo tags attached.
Checked infolog.txt for Errors

Activities

lamer

2017-05-06 17:26

reporter   ~0017559

I'm unsure if there's ultimate solution.
Disabling Spring.CreateUnit/Spring.CreateFeature until gadget::Load(zip) was executed may produce unexpected results because people don't check results of CreateUnit/CreateFeature usually.

Maybe additional Spring.IsSaveLoading() may atleast give opportunity to maps with predefined units to support save/load.

Kloot

2017-05-06 23:55

developer   ~0017560

Last edited: 2017-05-07 00:02

with some work Spring.Destroy* could be extended to force releasing an object's id immediately, guaranteeing Spring.Create*(savedObjectID) calls would always succeed.

atm I can't consider this a high priority issue though.

hokomoko

2017-05-08 11:19

developer   ~0017565

I think a good approach is to only call PreGame and GameStart when the game isn't loaded from a save.

Google_Frog

2017-05-10 04:27

reporter   ~0017588

Be aware that using PreGame and GameStart like this will require some backwards compatibility changes. Whether an existing gadget/widget initializes in PreGame, GameStart, Initialize (or even GameFrame or Update) seems to be up personal preference/cargo cult.

This is not much of an extra gameside problem since games already require extensive changes to implement save/load. I'm worried about map compatibility, the thing that this feature would be primarily designed to fix.

hokomoko

2017-05-10 06:02

developer   ~0017591

Well you can't eat the cake and leave it whole...

silentwings

2017-05-11 14:29

reporter   ~0017602

> Whether an existing gadget/widget initializes in PreGame, GameStart, Initialize (or even GameFrame or Update) seems to be up personal preference/cargo cult.

This is not really true. It matters e.g. if you want units to be created "as though they are part of the map", if you have interaction with startpoint placing & team selection, if you need contact with other gadgets or use the action handler ... etc etc.

Possibly there are also gadget authors who were inexperienced enough to make a random choice when there is one; imho the solution there is that such people should not be writing synced code.

hokomoko

2017-05-19 21:16

developer   ~0017664

Fix 46f3180620e3a323f3fbbb901f7f6ccd9250b5b0 committed to develop branch: Maintain synced callin consistency through save/load (Fix 0005543)

GameStart and GamePreload won't be called when a saved game is loaded, repo: spring changeset id: 8230

hokomoko

2017-05-19 21:48

developer   ~0017665

Fix f9933f0b645a973d6642022d04bdabc2331bcbf4 committed to develop branch: Maintain synced callin consistency through save/load (Fix 0005543)

GameStart and GamePreload won't be called when a saved game is loaded, repo: spring changeset id: 8231

Issue History

Date Modified Username Field Change
2017-05-06 16:47 lamer New Issue
2017-05-06 17:26 lamer Note Added: 0017559
2017-05-06 23:55 Kloot Note Added: 0017560
2017-05-06 23:59 Kloot Note Edited: 0017560
2017-05-07 00:02 Kloot Note Edited: 0017560
2017-05-08 11:19 hokomoko Note Added: 0017565
2017-05-10 04:27 Google_Frog Note Added: 0017588
2017-05-10 06:02 hokomoko Note Added: 0017591
2017-05-11 14:29 silentwings Note Added: 0017602
2017-05-19 21:16 hokomoko Changeset attached => spring develop 46f31806
2017-05-19 21:16 hokomoko Note Added: 0017664
2017-05-19 21:16 hokomoko Assigned To => hokomoko
2017-05-19 21:16 hokomoko Status new => resolved
2017-05-19 21:16 hokomoko Resolution open => fixed
2017-05-19 21:48 hokomoko Changeset attached => spring develop f9933f0b
2017-05-19 21:48 hokomoko Note Added: 0017665
2017-05-19 21:50 hokomoko Changeset removed spring develop 46f31806 =>