Not logged inOpenClonk Forum
Up Topic Development / Developer's Corner / Loading objects
- - By Maikel Date 2014-04-05 18:16
I think we need to find a solution to the following problem:

Let's say I have a scenario based on Objects.ocd and I decide to load that (obviously). Now I want some decoration, and someone created a pack with decoration objects or we ship one ourselves in the future. I want to load these objects obviously so I write my scenario script:

Definition1=Object.ocd
Definition2=Deco.ocd
Definition3=MyOwnPack.ocd

I also added my own pack which only contains a few objects. Now Deco.ocd grows over time in something massive (like MetalMagic, it might take ages to load) and I only need ten items out of those. I can't load them individually since I can only specify 9 definitions to be loaded.
So I end up with a scenario that takes ages to load, even though it is not needed. I could copy those objects to my scenario but that would leave us with lots of double copies of objects which is an even worse thing (like Missions.ocf/DarkCastle.ocs/EnvironmentObjs.ocd, these objects should not be there locally).

It would be good to have a more consistent way of loading objects. Any opinions and or ideas?

In any case it would be good to start gathering objects which are used for decoration only in special pack besides Objects.ocd
Parent - - By ala [de] Date 2014-04-06 08:01

> Now Deco.ocd grows over time in something massive (like MetalMagic, it might take ages to load) and I only need ten items out of those. I can't load them individually since I can only specify 9 definitions to be loaded.


In ClonkRage (I guess that also applies for OC) it's possible to specify, but it's not often used. I used FarWorlds.c4d\Jungle.c4d before to skip the Arctic and and DeepSea pack, and this works even for missions. Like using the Butterfly from the CR Demo Object, you could just do it like this: Tutorials.c4f\Objects.c4d\Butterfly.c4d.

As for quick loading, there was the possibility to use "SkipDefs", and fill this with like 100 Items. Well it's of cause a little annoying to pull in every skipped definition by hand. So I guess a little improvement to this wouldn't hurt.
Parent - By Maikel Date 2014-04-06 11:04
Yes indeed, this the current way to solve this but it is tedious and impossible to read afterwards.
Parent - - By Newton [cn] Date 2014-04-06 11:31
The coolest solution would be to lazy load objects - on demand. On scenario start, only go through all object definitions, read their ID and put them into a set<c4id>. Then, whenever an ID (which exists in the previously mentioned set) is referenced in executed code, it is loaded properly with graphics, sounds, script etc.

Though, my knowledge of the code is too shallow that I could tell whether the loading of graphics, sounds, script is actually the thing that takes long during loading. Also, at least sounds are global: One doesn't need to write Sound(Monster::"Groar") or anything like that to use them. So until e.g. a Sword is mentioned in script or defcore, one couldn't use the sword sounds if the sounds are only loaded if the object definition it is in is loaded.
Parent - - By test [de] Date 2014-04-06 12:15
That's not really feasible, because the script engine needs to be linked to resolve global functions, etc. The only sensible method I could see would be to lazy-load the graphics. But it would require us to implement random access reading from C4Group, which is currently very slow.

I think the best approach is to just create smaller packs.
Parent - By Newton [cn] Date 2014-04-07 13:34
Too bad. Personally I suspect that loading the script takes the longest, not the graphics.

P.S: login with Sven2 again please, this is irritating :-(
Parent - - By Caesar [de] Date 2014-04-06 14:33

>I can't load them individually since I can only specify 9 definitions to be loaded.


Wouldn't that be the easiest thing to fix?
Parent - By Maikel Date 2014-04-06 14:46
Yes, Isilkor also suggested that on IRC, basically an infinite list of objects or object folders which you want to load (possible in a different .txt file).

And we could do the same for things you want to exclude.
Up Topic Development / Developer's Corner / Loading objects

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill