On 10/26/06, Kai Sterker <[EMAIL PROTECTED]> wrote:
I was always thinking that stuff would be loaded at need. So if a new map is loaded, and it would reference some animations, a look up in the animation cache would take place, and if stuff is not in there it would be loaded.
Not sure if that made much sense, as I was in hurry writing it up, so let me try to refine it a little: +-----+ +-----------+ +------+ +--------------+ +---------+ | Map | | AnimCache | | Anim | | SurfaceCache | | Surface | +--.--+ +------.----+ +---.--+ +------.-------+ +----.----+ | | | : : 1: }----------->| | : : | load |---------->| : : |<- - - - - -| incRefCnt | : : 2: }----------->| | | | | load |---------->| | | | | load }----------->| | | | | load }-------------->| | | |----------->| incRefCnt | / / / load / / / / / / / | | |<- - - - - -{ | | }---------->| | | |<- - - - - -| incRefCnt | | | There are two scenarios for loading an animation. In the first case, it is already in the cache, so its refcount is increased and it is simply returned. In the second case, it's not in the cache, so it is loaded and all of the associated surfaces/images are "loaded". Which also means they are retrieved from a image cache if they exist, otherwise they will be loaded and added to that cache. Add more scenarios for cleaning up animations, thus decreasing their refcount and removing them from the cache if no longer referenced. Also, whenever an animation reaches refcount 0, the refcount of associated images would be decreased. That way, we have a fair amount of loading/unloading going on when switching between maps, but memory usage will be low. It also requires all animations to be seperated. A different alternative that would allow keeping a single file containing all animation would be to keep the animation data cached, but not load the actual images unless the animation is actually used. So the animation cache would always be populated with all available animations, but as long as their refcount is 0, the associated images will not be kept in memory. If it drops to 0 again, it also means the refcount of all associated images will be decreased by 1. Kai _______________________________________________ Adonthell-devel mailing list Adonthell-devel@nongnu.org http://lists.nongnu.org/mailman/listinfo/adonthell-devel