Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5308 in orxonox.OLD for trunk/src/util


Ignore:
Timestamp:
Oct 8, 2005, 12:32:52 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: Fixed a reversive BUG in the ResourceManager:
Since resources, that depend on each other are loaded left tgo right they must be unlinked right to left… this cost me 3 hours.
What a luck i found this :)

Location:
trunk/src/util
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/util/resource_manager.cc

    r5307 r5308  
    251251    {
    252252      PRINTF(4)("not loading cached resource %s\n", tmpResource->name);
    253 //      printf("adding %s count: %d\n", tmpResource->pointer->getName(),  tmpResource->count);
    254253      tmpResource->count++;
    255254      if(tmpResource->prio < prio)
     
    409408    }
    410409  else
    411     unload(tmpResource, prio);
     410    return unload(tmpResource, prio);
    412411}
    413412
     
    416415 * @param resource: The resource to unloade
    417416 * @param prio the PriorityLevel to unload this resource
     417 * @returns true on success, false otherwise.
    418418*/
    419419bool ResourceManager::unload(Resource* resource, ResourcePriority prio)
     
    421421  if (resource == NULL)
    422422    return false;
    423 //  printf("removing %s count: %d\n", resource->pointer->getName(),  resource->count);
    424423  if (resource->count > 0)
    425424    resource->count--;
     
    427426  if (resource->prio <= prio)
    428427    {
    429       if (resource->count <= 0)
     428      if (resource->count == 0)
    430429        {
    431430          // deleting the Resource
     
    480479
    481480/**
    482  *  unloads all alocated Memory of Resources with a pririty lower than prio
     481 * unloads all alocated Memory of Resources with a pririty lower than prio
    483482 * @param prio The priority to delete
    484483*/
     
    486485{
    487486  tIterator<Resource>* iterator = resourceList->getIterator();
    488   Resource* enumRes = iterator->firstElement();
     487  Resource* enumRes = iterator->lastElement();
    489488  while (enumRes)
    490489    {
     
    496495                   enumRes->name, enumRes->count);
    497496      //enumRes = resourceList->nextElement();
    498       enumRes = iterator->nextElement();
     497      enumRes = iterator->prevElement();
    499498    }
    500499  delete iterator;
  • trunk/src/util/resource_manager.h

    r5306 r5308  
    6666{
    6767  BaseObject*       pointer;           //!< Pointer to the Resource.
    68   int               count;             //!< How many times this Resource has been loaded.
     68  unsigned int      count;             //!< How many times this Resource has been loaded.
    6969
    7070  char*             name;              //!< Name of the Resource.
     
    8585//! The ResourceManager is a class, that decides if a file/resource should be loaded
    8686/**
    87    If a file/resource was already loaded the resourceManager will
    88    return a void pointer to the desired resource.
    89    Otherwise it will instruct the corresponding resource-loader to load,
    90    and receive the pointer to it.
    91 
    92    It does it by looking, if a desired file has already been loaded.
    93 */
     87 * If a file/resource was already loaded the resourceManager will
     88 * return a pointer to the desired resource.
     89 * Otherwise it will instruct the corresponding resource-loader to load,
     90 * and receive the pointer to it.
     91 *
     92 * It does it by looking, if a desired file has already been loaded.
     93 * There is also the possibility to check for some variables
     94 */
    9495class ResourceManager : public BaseObject
    9596{
     
    101102  bool setDataDir(const char* dataDir);
    102103  /** @returns the Name of the data directory */
    103   inline const char* getDataDir() const {return this->dataDir;}
     104  inline const char* getDataDir() const { return this->dataDir; };
    104105
    105106  bool checkDataDir(const char* fileInside);
     
    135136  static ResourceManager*  singletonRef;       //!< singleton Reference
    136137
     138  char*                    dataDir;            //!< The Data Directory, where all relevant Data is stored.
    137139  tList<Resource>*         resourceList;       //!< The List of Resources, that has already been loaded.
    138   char*                    dataDir;            //!< The Data Directory, where all relevant Data is stored.
    139140  tList<char>*             imageDirs;          //!< A list of directories in which images are stored.
    140141
Note: See TracChangeset for help on using the changeset viewer.