Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Dec 21, 2005, 1:49:06 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the christmas branche to the trunk
merged with command:
svn merge -r6165:HEAD christmas_branche/ ../trunk/
no conflicts

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore set to
      Makefile.in
      Makefile
      configure
      *.kdevelop
      Doxyfile
      config.log
      config.h
      config.status
      stamp-h1
      autom4te.cache
      aclocal.m4
  • trunk/src

    • Property svn:ignore set to
      .deps
      orxonox
      Makefile
      Makefile.in

  • trunk/src/util

    • Property svn:ignore set to
      Makefile
      Makefile.in
      .deps
      libORX*

  • trunk/src/util/animation/animation.h

    r5777 r6222  
    77#define _ANIMATION_H
    88
    9 #include "list.h"
    109#include "base_object.h"
    11 #include "confincl.h"  // must be here to determin the DEBUG-level
    1210#include "debug.h"
    1311
     12#include "list.h"
    1413// FORWARD DECLARATION
    1514
  • trunk/src/util/loading/resource_manager.cc

    r5994 r6222  
    1919
    2020#include "debug.h"
     21
     22#include <algorithm>
    2123
    2224// different resource Types
     
    4042#endif /* NO_SHADERS */
    4143
    42 #include "list.h"
    43 #include "sdlincl.h"
    44 
    4544// File Handling Includes
    4645#include <sys/types.h>
     
    6160  strcpy(this->dataDir, "./");
    6261  this->tryDataDir("./data");
    63   this->imageDirs = new tList<char>;
    64   this->resourceList = new tList<Resource>;
    6562}
    6663
     
    7673  this->unloadAllByPriority(RP_GAME);
    7774
    78   if (this->resourceList->getSize() > 0)
    79     PRINTF(1)("Not removed all Resources, since there are still %d resources registered\n", this->resourceList->getSize());
    80 
    81   delete this->resourceList;
     75  if (!this->resourceList.empty())
     76    PRINTF(1)("Not removed all Resources, since there are still %d resources registered\n", this->resourceList.size());
     77
    8278  // deleting the Directorie Lists
    83   tIterator<char>* tmpIt = imageDirs->getIterator();
    84   char* tmpDir = tmpIt->firstElement();
    85   while(tmpDir)
    86     {
    87       delete[] tmpDir;
    88       tmpDir = tmpIt->nextElement();
    89     }
    90   delete tmpIt;
    91   delete this->imageDirs;
     79  while (!this->imageDirs.empty())
     80    {
     81      delete[] this->imageDirs.front();
     82      this->imageDirs.pop_front();
     83    }
    9284
    9385  delete[] this->dataDir;
     
    211203    {
    212204      // check if the Directory has been added before
    213       tIterator<char>* tmpImageDirs = imageDirs->getIterator();
    214       char* tmpDir = tmpImageDirs->firstElement();
    215       while(tmpDir)
    216         {
    217           if (!strcmp(tmpDir, newDir))
    218             {
    219               PRINTF(3)("Path %s already loaded\n", newDir);
    220               delete[] newDir;
    221               delete tmpImageDirs;
    222               return true;
    223             }
    224           tmpDir = tmpImageDirs->nextElement();
    225         }
    226       delete tmpImageDirs;
    227 
     205      std::list<char*>::const_iterator imageDir;
     206      for (imageDir = this->imageDirs.begin(); imageDir != this->imageDirs.end(); imageDir++)
     207      {
     208         if (!strcmp(*imageDir, newDir))
     209         {
     210           PRINTF(3)("Path %s already loaded\n", newDir);
     211           delete[] newDir;
     212           return true;
     213         }
     214      }
    228215      // adding the directory to the List
    229       this->imageDirs->add(newDir);
     216      this->imageDirs.push_back(newDir);
    230217      return true;
    231218    }
     
    389376              else
    390377                tmpResource->secFileName = NULL;
    391               tmpResource->pointer = new MD2Data(fullName, tmpResource->secFileName);
     378                tmpResource->pointer = new MD2Data(fullName, tmpResource->secFileName);
     379//               tmpResource->pointer = new MD2Model(fullName, tmpResource->secFileName);
     380
    392381            }
    393382              break;
     
    425414          else
    426415            {
    427               char* tmpDir;
    428               tIterator<char>* iterator = imageDirs->getIterator();
    429               tmpDir = iterator->firstElement();
    430               while(tmpDir)
     416              std::list<char*>::iterator imageDir;
     417              for (imageDir = this->imageDirs.begin(); imageDir != this->imageDirs.end(); imageDir++)
    431418                {
    432                   char* imgName = new char[strlen(tmpDir)+strlen(fileName)+1];
    433                   sprintf(imgName, "%s%s", tmpDir, fileName);
     419                  char* imgName = new char[strlen(*imageDir)+strlen(fileName)+1];
     420                  sprintf(imgName, "%s%s", *imageDir, fileName);
    434421                  if(isFile(imgName))
    435422                    {
     
    440427                    }
    441428                  delete[] imgName;
    442                   tmpDir = iterator->nextElement();
    443429                }
    444               delete iterator;
    445430            }
    446431          if(!tmpResource)
     
    477462        }
    478463      if (tmpResource->pointer != NULL)
    479         this->resourceList->add(tmpResource);
     464        this->resourceList.push_back(tmpResource);
    480465      delete[] fullName;
    481466    }
     
    572557          PRINTF(4)("Resource %s safely removed.\n", resource->name);
    573558          delete[] resource->name;
    574           this->resourceList->remove(resource);
     559          std::list<Resource*>::iterator resourceIT = std::find(this->resourceList.begin(), this->resourceList.end(), resource);
     560          this->resourceList.erase(resourceIT);
    575561          delete resource;
    576562        }
     
    590576bool ResourceManager::unloadAllByPriority(ResourcePriority prio)
    591577{
    592   tIterator<Resource>* iterator = resourceList->getIterator();
    593   Resource* enumRes = iterator->lastElement();
    594   while (enumRes)
    595     {
    596       if (enumRes->prio <= prio)
    597         if (enumRes->count == 0)
    598           unload(enumRes, prio);
    599         else
    600           PRINTF(2)("unable to unload %s because there are still %d references to it\n",
    601                    enumRes->name, enumRes->count);
    602       //enumRes = resourceList->nextElement();
    603       enumRes = iterator->prevElement();
    604     }
    605   delete iterator;
     578  std::list<Resource*>::iterator resource, pre;
     579  pre = --this->resourceList.end();
     580  unsigned int removeCount;
     581  for (unsigned int round = 0; round < 3; round++)
     582  {
     583    removeCount = 0;
     584    while (pre != resourceList.end())
     585    {
     586      resource = pre;
     587      pre--;
     588        if ((*resource)->prio <= prio)
     589        {
     590          if ((*resource)->count == 0)
     591            unload((*resource), prio);
     592          else
     593          {
     594            PRINTF(2)("unable to unload %s because there are still %d references to it\n",
     595                     (*resource)->name, (*resource)->count);
     596            removeCount++;
     597          }
     598        }
     599     }
     600     if (removeCount == 0) break;
     601  }
    606602}
    607603
     
    619615                                                void* param1, void* param2, void* param3) const
    620616{
    621   //  Resource* enumRes = resourceList->enumerate();
    622   tIterator<Resource>* iterator = resourceList->getIterator();
    623   Resource* enumRes = iterator->firstElement();
    624   while (enumRes)
    625     {
    626       if (enumRes->type == type && !strcmp(fileName, enumRes->name))
     617  std::list<Resource*>::const_iterator resource;
     618  for (resource = this->resourceList.begin(); resource != this->resourceList.end(); resource++)
     619  {
     620    if ((*resource)->type == type && !strcmp(fileName, (*resource)->name))
    627621        {
    628622          bool match = false;
     
    635629              if (!param1)
    636630                {
    637                   if (enumRes->modelSize == 1.0)
     631                  if ((*resource)->modelSize == 1.0)
    638632                    match = true;
    639633                }
    640               else if (enumRes->modelSize == *(float*)param1)
     634              else if ((*resource)->modelSize == *(float*)param1)
    641635                match = true;
    642636              break;
     
    644638              if (!param1)
    645639                {
    646                   if (enumRes->secFileName == NULL)
     640                  if ((*resource)->secFileName == NULL)
    647641                    match = true;
    648642                }
    649               else if (!strcmp(enumRes->secFileName, (const char*)param1))
     643              else if (!strcmp((*resource)->secFileName, (const char*)param1))
    650644                match = true;
    651645              break;
     
    655649              if (param1 == NULL)
    656650                {
    657                   if (enumRes->ttfSize == FONT_DEFAULT_RENDER_SIZE)
     651                  if ((*resource)->ttfSize == FONT_DEFAULT_RENDER_SIZE)
    658652                    match = true;
    659653                }
    660               else if (enumRes->ttfSize == *(unsigned int*)param1)
     654              else if ((*resource)->ttfSize == *(unsigned int*)param1)
    661655                match = true;
    662656              break;
     
    666660                if (!param1)
    667661                {
    668                   if (enumRes->secFileName == NULL)
     662                  if ((*resource)->secFileName == NULL)
    669663                    match = true;
    670664                }
    671                 else if (!strcmp(enumRes->secFileName, (const char*)param1))
     665                else if (!strcmp((*resource)->secFileName, (const char*)param1))
    672666                  match = true;
    673667#endif /* NO_SHADERS */
     
    678672          if (match)
    679673            {
    680               delete iterator;
    681               return enumRes;
     674              return (*resource);
    682675            }
    683676        }
    684       enumRes = iterator->nextElement();
    685     }
    686   delete iterator;
     677    }
    687678  return NULL;
    688679}
     
    696687{
    697688  //  Resource* enumRes = resourceList->enumerate();
    698   tIterator<Resource>* iterator = resourceList->getIterator();
    699   Resource* enumRes = iterator->firstElement();
    700   while (enumRes)
    701     {
    702       if (pointer == enumRes->pointer)
    703         {
    704           delete iterator;
    705           return enumRes;
    706         }
    707       enumRes = iterator->nextElement();
    708     }
    709   delete iterator;
     689  std::list<Resource*>::const_iterator resource;
     690  for (resource = this->resourceList.begin(); resource != this->resourceList.end(); resource++)
     691    if (pointer == (*resource)->pointer)
     692        return (*resource);
    710693  return NULL;
    711694}
     
    920903  PRINT(0)(" Data-Directory is: %s\n", this->dataDir);
    921904  PRINT(0)(" List of Image-Directories: ");
    922   tIterator<char>* tmpIt = imageDirs->getIterator();
    923   char* tmpDir = tmpIt->firstElement();
    924   while(tmpDir)
    925     {
    926       PRINT(0)("%s ",tmpDir);
    927       tmpDir = tmpIt->nextElement();
    928     }
    929   delete tmpIt;
     905  std::list<char*>::const_iterator imageDir;
     906  for (imageDir = this->imageDirs.begin(); imageDir != this->imageDirs.end(); imageDir++)
     907      PRINT(0)("%s ", (*imageDir));
    930908  PRINT(0)("\n");
    931909
    932910  PRINT(0)("List of all stored Resources:\n");
    933   tIterator<Resource>* iterator = resourceList->getIterator();
    934   Resource* enumRes = iterator->firstElement();
    935   while (enumRes)
     911  std::list<Resource*>::const_iterator resource;
     912  for (resource = this->resourceList.begin(); resource != this->resourceList.end(); resource++)
     913
    936914    {
    937915      PRINT(0)("-----------------------------------------\n");
    938       PRINT(0)("Name: %s; References: %d; Type: %s ", enumRes->name, enumRes->count, ResourceManager::ResourceTypeToChar(enumRes->type));
     916      PRINT(0)("Name: %s; References: %d; Type: %s ", (*resource)->name, (*resource)->count, ResourceManager::ResourceTypeToChar((*resource)->type));
    939917
    940918      PRINT(0)("gets deleted at ");
    941       switch(enumRes->prio)
     919      switch((*resource)->prio)
    942920        {
    943921        default:
     
    955933          break;
    956934        }
    957       enumRes = iterator->nextElement();
    958     }
    959   delete iterator;
     935    }
    960936
    961937
  • trunk/src/util/loading/resource_manager.h

    r5994 r6222  
    2121#include "base_object.h"
    2222
    23 #include "stdlibincl.h"
    2423
    25 // FORWARD DECLARATION
    26 template<class T> class tList;
     24#include <list>
    2725
    2826//! An eumerator for different fileTypes the resourceManager supports
     
    144142
    145143  char*                    dataDir;            //!< The Data Directory, where all relevant Data is stored.
    146   tList<Resource>*         resourceList;       //!< The List of Resources, that has already been loaded.
    147   tList<char>*             imageDirs;          //!< A list of directories in which images are stored.
     144  std::list<Resource*>     resourceList;       //!< The List of Resources, that has already been loaded.
     145  std::list<char*>         imageDirs;          //!< A list of directories in which images are stored.
    148146
    149147};
  • trunk/src/util/state.cc

    r6142 r6222  
    2626
    2727
    28 const PNode* State::camera = NULL;
    29 const PNode* State::cameraTarget = NULL;
     28PNode* State::camera = NULL;
     29PNode* State::cameraTarget = NULL;
    3030
    3131ObjectManager* State::objectManager = NULL;
     
    3434 *  sets camera and target of the current Camera
    3535*/
    36 void State::setCamera(const PNode* camera, const PNode* cameraTarget)
     36void State::setCamera(PNode* camera, PNode* cameraTarget)
    3737{
    3838  State::camera = camera;
  • trunk/src/util/state.h

    r6142 r6222  
    2525   //////////////
    2626  /** @param camera the PNode to the Camera, @param cameraTarget the PNode to the Camera's target */
    27   static void setCamera(const PNode* camera, const PNode* cameraTarget);
     27  static void setCamera(PNode* camera, PNode* cameraTarget);
    2828  /** @returns a Pointer to the PNode of the Camera */
    29   static inline const PNode* getCamera() { return State::camera; };
     29  static inline PNode* getCamera() { return State::camera; };
    3030  /** @returns a Pointer to the CameraTarget */
    31   static inline const PNode* getCameraTarget() { return State::cameraTarget; };
     31  static inline PNode* getCameraTarget() { return State::cameraTarget; };
    3232
    3333  //////////////////////
     
    4646  State();
    4747
    48   static const PNode*           camera;             //!< A reference to the camera
    49   static const PNode*           cameraTarget;       //!< A reference to the cameraTarget
     48  static PNode*                 camera;             //!< A reference to the camera
     49  static PNode*                 cameraTarget;       //!< A reference to the cameraTarget
    5050  static PNode*                 nullParent;         //!< A reference to the Null-PNode.
    5151  static ObjectManager*         objectManager;      //!< A referenct to the current ObjectManager
Note: See TracChangeset for help on using the changeset viewer.