This got especially bad now with the increasing use of prop lists and arrays. Since they get enumerated, you end up with an unmaintainable mess of cross references where you cannot just add/remove objects and properties in the proper [Object] sections.
I built a patch that reworks the behaviour on "Save scenario" to serialize all objects into an Objects.c script file instead of Game.txt. By default, only a limited number of properties is saved. If an object wants to save more (or less), it may overload a number of callback function to control writing of the Objects.c file.
Objects.c files may also be used in scenario sections.
Also, note that this does not replace Game.txt. Game.txt serialization is still used for savegames, runtime join synchronization, runtime records and runtime scenario section saves.
The patch can be reviewed here: https://crucible.openclonk.org/cru/OC-5
Here's an example for an auto-generated Objects.c file: http://pastebin.com/E3dJuv2b
> so for example if you redesign an area you can only grab the changes.
I don't understand this use case. If you store an incomplete Objects.c that contains only objects in an area, then how would you merge this with an old existing Objects.c? Objects are ordered roughly by z-Order and object type, so you would have to copy your changes line by line manually into the existing file.
Independent of that, it would be cool if the editor had options to resize the map in any direction, move objects accordingly and issue script callbacks so e.g. MovingBricks can adjust their stored coordinates.
I think it simply might help scenario designers in the future if this serialization functionality was exposed.
> I think it simply might help scenario designers in the future if this serialization functionality was exposed.
It is exposed. It's all in a script function in System.ocg/SaveScenario.c, which you can copy or overload and make your changes e.g. to store only objects in a rectangle. Though I would argue it would be easier to just write a script that removes all objects outside a rectangle and save afterwards.
It might be interesting to have an editor function that e.g. serializes all currently selected objects and puts the script into the clipboard. But I'm not sure if that's a really high priority, since a) we don't have such big maps yet, b) there are a lot more important things to be added to the editor.
>It is exposed. It's all in a script function in System.ocg/SaveScenario.c, which you can copy or overload and make your changes e.g. to store only objects in a rectangle.
Okay thanks, all is clear then. I guess I'm not completely used to new stuff being outside of the engine nowadays.
* I combined the SaveScenarioObject / SaveScenarioObjectProps / SaveScenarioObjectExtraProps / SaveScenarioObjectIgnoreProps into a single SaveScenarioObject callback with a proplist parameter that has the remaining interface. E.g.:
if (!inherited(props, ...)) return false;
// Waterfall has its own creation procedure
props->Add(SAVEOBJ_Creation, "CreateWaterfall(%d,%d,%d,%v)",fx_waterfall.X, fx_waterfall.Y, fx_waterfall.Strength, fx_waterfall.Material);
// Don't save color modultion
// Save some properties
props->AddCall("Direction", this, "SetDirection", XDir, YDir);
* Actions no longer saved by default
* GetScenarioSaveName renamed to MakeScenarioSaveName
* Interface extended on some objects so Set*-functions can be called instead of setting locals directly
Btw, anyone can convert those. Just open the scenario in editor mode, save it, check if everything got saved and check if there's any unnecessary cruft in Objects.c.
You can always put your transform into the custom init script field of the object.
Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill