Zero-K icon indicating copy to clipboard operation
Zero-K copied to clipboard

ZK doesn't reuse unitID on save/load

Open rlcevg opened this issue 9 years ago • 4 comments

Spring.CreateUnit and Spring.CreateFeature supports unitID param. But ZK for some reason doesn't use it and generates new unitID that makes it impossible for AI to associate data with unit.

rlcevg avatar May 03 '17 10:05 rlcevg

The comment at https://github.com/ZeroK-RTS/Zero-K/blob/master/LuaRules/Gadgets/api_saveload.lua#L220 says that

		-- The 9th argument for unitID cannot be used here. If there is already a unit
		-- with that unitID then the new unit will fail to be created. The old unit
		-- do not immediately de-allocate their ID on Spring.DestroyUnit so some blocking
		-- can occur with explicitly set IDs.

Unsure if this is valid for situations where, as during a save load, all unitID's belong to freshly created units.

Anarchid avatar May 03 '17 10:05 Anarchid

https://github.com/ZeroK-RTS/Zero-K/blob/master/LuaRules/Gadgets/api_saveload.lua#L513 Ehm, what is this thing doing here?

Seems #units == 0. I don't see reasons to call Spring.DestroyUnit and Spring.DestroyFeature on loading. Unless someone is mixing creg-save with lua-save which is apparantly a bad idea (lua-save is current method).

rlcevg avatar May 03 '17 10:05 rlcevg

Maps can come with units or features. these exist by default when the game is loaded and must be removed. Removing old units and features also makes development easier. We're not going to be reusing unitID/featureIDs unless removing units and features beforehand is shown to work.

Use the unitRulesParam saveload_oldID.

GoogleFrog avatar May 06 '17 05:05 GoogleFrog

This deserves a ticket on mantis. Spring should ignore any map's unit/feature because they're already saved in separate unit/feature section of savefile.

rlcevg avatar May 06 '17 09:05 rlcevg