Dungeon Siege Style Resource Management???

Started by
10 comments, last by Merick 21 years, 2 months ago
good question. i got an "international priority airmail" a while ago whit a code to save some money. but even 40% less wont help a student to fly to the us and still have money enough for the con *g*.
i wondered why the even bother to send that all the way to germany with only a slim chance that person will show up. well, after looking at the prices i guess its already worth it, if at least 1/100 will appear. but i guess thats not unusual, as its probably not meant as a con for hobby programmers (making me wonder again why i get this).

but: i think a lot of papers etc. show up later. i might be wrong, but a lot of the stuff i find on the net seem to be presentations from the gdc.
f@dzhttp://festini.device-zero.de
Advertisement
well, i''ll suggest some sort of garbage collector. that means, what ever you need for a scene, you load up (that you can find out. you move a bit forward, and load everything (best of all in another data-loading thread) that will be in front of you but not yet visible but soon visible..) that _should_ be rather easy

next thing is that your resource manager does save your data, even while you don''t use it, it will stay in ram.. the objects are refcounted => the resource manager knows when they are useless.. once they are useless, you start counting for how long they where useless.. if they where useless for too long, unload them from the ram..

a typical refcounted, gc collected obj wich _should_ be useful for you..


  class Object : IGCObject { int refCounter; int unusedSince;public: Object() {  refCounter = 1;  GarbageCollector::addObject(this);  this->addRef(); } void addRef() { ++refCounter; } void release() { if(!--refCounter) delete this; } int checkUnused() { if(refCounter==1) ++unusedSince; else unusedSince = 0; return unusedSince; } friend GarbageCollector;};  


and the gc has two methods:
addObject(IGCObject* obj) { objectList.push(obj);} 

and
garbageCollect() { foreach(IGCObject* obj in objectList) {  if(obj->checkUnused()>this->maxUnused) {   obj->release(); // deletes itself   obj = NULL;  } } objectList.removeAllEqual(NULL);} 

yes, the gc code is a bit pseudocode.. anyways...


of course (never forget!!), you have to check if the gc does have some resource when you want to load one..


  IGCObject* loadResource(someParams) { IGCObject* yetLoaded = GarbageCollector::hasObject(someParams); if(yetLoaded) {  yetLoaded->addRef(); } else {  yetLoaded = new ResourceFromFile(someParams); } return yetLoaded;}  


have i forgot something? i think thats about all..

"take a look around" - limp bizkit
www.google.com
If that's not the help you're after then you're going to have to explain the problem better than what you have. - joanusdmentia

My Page davepermen.net | My Music on Bandcamp and on Soundcloud

This topic is closed to new replies.

Advertisement