Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/util/resource_manager.cc @ 5304

Last change on this file since 5304 was 5304, checked in by bensch, 19 years ago

orxonox/trunk: so, ResourceManager now operates on BaseObjects. If this is better, i do not know, but at least it is more intuitive, i think

File size: 23.8 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11   ### File Specific:
12   main-programmer: Benjamin Grauer
13   co-programmer: Patrick Boenzli
14*/
15
16#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_LOAD
17
18#include "resource_manager.h"
19
20#include "debug.h"
21
22// different resource Types
23#ifndef NO_MODEL
24#include "objModel.h"
25#include "primitive_model.h"
26#include "md2Model.h"
27#endif /* NO_MODEL */
28#ifndef NO_TEXTURES
29#include "texture.h"
30#endif /* NO_TEXTURES */
31#ifndef NO_TEXT
32#include "text_engine.h"
33#endif /* NO_TEXT */
34#ifndef NO_AUDIO
35#include "sound_engine.h"
36#include "ogg_player.h"
37#endif /* NO_AUDIO */
38
39#include "list.h"
40#include "sdlincl.h"
41
42// File Handling Includes
43#include <sys/types.h>
44#include <sys/stat.h>
45#include <unistd.h>
46
47using namespace std;
48
49/**
50 *  standard constructor
51*/
52ResourceManager::ResourceManager ()
53{
54  this->setClassID(CL_RESOURCE_MANAGER, "ResourceManager");
55  this->setName("ResourceManager");
56
57  this->dataDir = NULL;
58  this->setDataDir("./");
59  this->imageDirs = new tList<char>();
60  this->resourceList = new tList<Resource>();
61}
62
63//! Singleton Reference to the ResourceManager
64ResourceManager* ResourceManager::singletonRef = NULL;
65
66/**
67 *  standard destructor
68*/
69ResourceManager::~ResourceManager ()
70{
71  // deleting the Resources-List
72  this->unloadAllByPriority(RP_GAME);
73
74  if (this->resourceList->getSize() > 0)
75    PRINTF(1)("Not removed all Resources, since there are still %d resources registered\n", this->resourceList->getSize());
76
77  delete this->resourceList;
78  // deleting the Directorie Lists
79  tIterator<char>* tmpIt = imageDirs->getIterator();
80  char* tmpDir = tmpIt->firstElement();
81  while(tmpDir)
82    {
83      delete[] tmpDir;
84      tmpDir = tmpIt->nextElement();
85    }
86  delete tmpIt;
87  delete this->imageDirs;
88
89  delete[] this->dataDir;
90
91  ResourceManager::singletonRef = NULL;
92}
93
94/**
95 *  sets the data main directory
96 * @param dataDir the DataDirectory.
97*/
98bool ResourceManager::setDataDir(const char* dataDir)
99{
100  char* realDir = ResourceManager::homeDirCheck(dataDir);
101  if (isDir(realDir))
102    {
103      delete[] this->dataDir;
104      this->dataDir = new char[strlen(realDir)+1];
105      strcpy(this->dataDir, realDir);
106      delete[] realDir;
107      return true;
108    }
109  else
110    {
111      PRINTF(1)("%s is not a Directory, and can not be the Data Directory, leaving as %s \n", realDir, this->dataDir);
112      delete[] realDir;
113      return false;
114    }
115}
116
117/**
118 *  checks for the DataDirectory, by looking if
119 * @param fileInside is inisde??
120*/
121bool ResourceManager::checkDataDir(const char* fileInside)
122{
123  bool retVal;
124  if (!isDir(this->dataDir))
125    {
126      PRINTF(1)("%s is not a directory\n", this->dataDir);
127      return false;
128    }
129
130  char* testFile = new char[strlen(this->dataDir)+strlen(fileInside)+1];
131  sprintf(testFile, "%s%s", this->dataDir, fileInside);
132  retVal = isFile(testFile);
133  delete[] testFile;
134  return retVal;
135}
136
137#ifndef NO_TEXTURES
138/**
139 *  adds a new Path for Images
140 * @param imageDir The path to insert
141 * @returns true, if the Path was well and injected (or already existent within the list)
142   false otherwise
143*/
144bool ResourceManager::addImageDir(const char* imageDir)
145{
146  // check if the param is a Directory
147  if (isDir(imageDir))
148    {
149      // check if the Directory has been added before
150      tIterator<char>* tmpImageDirs = imageDirs->getIterator();
151      char* tmpDir = tmpImageDirs->firstElement();
152      while(tmpDir)
153        {
154          if (!strcmp(tmpDir, imageDir))
155            {
156              PRINTF(4)("Path %s already loaded\n", imageDir);
157              delete tmpImageDirs;
158              return true;
159            }
160          tmpDir = tmpImageDirs->nextElement();
161        }
162      delete tmpImageDirs;
163
164      // adding the directory to the List
165      tmpDir  = new char[strlen(imageDir)+1];
166      strcpy(tmpDir, imageDir);
167      this->imageDirs->add(tmpDir);
168      return true;
169    }
170  else
171    {
172      PRINTF(1)("%s is not a Directory, and can not be added to the Paths of Images\n", dataDir);
173      return false;
174    }
175}
176#endif /* NO_TEXTURES */
177
178/**
179 *  loads resources
180 * @param fileName: The fileName of the resource to load
181 * @param prio: The ResourcePriority of this resource (will only be increased)
182 * @param param1: an additional option to parse (see the constuctors for more help)
183 * @param param2: an additional option to parse (see the constuctors for more help)
184 * @param param3: an additional option to parse (see the constuctors for more help)
185 * @returns a pointer to a desired Resource.
186*/
187BaseObject* ResourceManager::load(const char* fileName, ResourcePriority prio, void* param1, void* param2, void* param3)
188{
189  ResourceType tmpType;
190#ifndef NO_MODEL
191#define __IF_OK
192  if (!strncmp(fileName+(strlen(fileName)-4), ".obj", 4))
193    tmpType = OBJ;
194  else if (!strncmp(fileName+(strlen(fileName)-4), ".md2", 4))
195    tmpType = MD2;
196  else if (!strcmp(fileName, "cube") ||
197           !strcmp(fileName, "sphere") ||
198           !strcmp(fileName, "plane") ||
199           !strcmp(fileName, "cylinder") ||
200           !strcmp(fileName, "cone"))
201    tmpType = PRIM;
202#endif /* NO_MODEL */
203#ifndef NO_AUDIO
204#ifdef __IF_OK
205  else
206#endif
207#define __IF_OK
208  if (!strncmp(fileName+(strlen(fileName)-4), ".wav", 4))
209    tmpType = WAV;
210  else if (!strncmp(fileName+(strlen(fileName)-4), ".mp3", 4))
211    tmpType = MP3;
212  else if (!strncmp(fileName+(strlen(fileName)-4), ".ogg", 4))
213    tmpType = OGG;
214#endif /* NO_AUDIO */
215#ifndef NO_TEXT
216#ifdef __IF_OK
217  else
218#endif
219#define __IF_OK
220 if (!strncmp(fileName+(strlen(fileName)-4), ".ttf", 4))
221    tmpType = TTF;
222#endif /* NO_TEXT */
223#ifndef NO_TEXTURES
224#ifdef __IF_OK
225  else
226#else
227  if
228#endif
229   tmpType = IMAGE;
230#endif /* NO_TEXTURES */
231#undef __IF_OK
232  return this->load(fileName, tmpType, prio, param1, param2, param3);
233}
234
235/**
236 * loads resources
237 * @param fileName: The fileName of the resource to load
238 * @param type: The Type of Resource to load (\see ResourceType)
239 * @param prio: The ResourcePriority of this resource (will only be increased)
240 * @param param1: an additional option to parse (see the constuctors for more help)
241 * @param param2: an additional option to parse (see the constuctors for more help)
242 * @param param3: an additional option to parse (see the constuctors for more help)
243 * @returns a pointer to a desired Resource.
244*/
245BaseObject* ResourceManager::load(const char* fileName, ResourceType type, ResourcePriority prio,
246                            void* param1, void* param2, void* param3)
247{
248  // searching if the resource was loaded before.
249  Resource* tmpResource = this->locateResourceByInfo(fileName, type, param1, param2,param3);
250  if (tmpResource) // if the resource was loaded before.
251    {
252      PRINTF(4)("not loading cached resource %s\n", tmpResource->name);
253      tmpResource->count++;
254      if(tmpResource->prio < prio)
255        tmpResource->prio = prio;
256    }
257  else
258    {
259      char* tmpDir;
260      // Setting up the new Resource
261      tmpResource = new Resource;
262      tmpResource->count = 1;
263      tmpResource->type = type;
264      tmpResource->prio = prio;
265      tmpResource->pointer = NULL;
266      tmpResource->name = new char[strlen(fileName)+1];
267      strcpy(tmpResource->name, fileName);
268
269      // creating the full name. (directoryName + FileName)
270      char* fullName = ResourceManager::getFullName(fileName);
271      // Checking for the type of resource \see ResourceType
272      switch(type)
273        {
274#ifndef NO_MODEL
275        case OBJ:
276          if (param1)
277            tmpResource->modelSize = *(float*)param1;
278          else
279            tmpResource->modelSize = 1.0;
280
281          if(ResourceManager::isFile(fullName))
282            tmpResource->pointer = new OBJModel(fullName, tmpResource->modelSize);
283          else
284            {
285              PRINTF(2)("Sorry, %s does not exist. Loading a cube-Model instead\n", fullName);
286              tmpResource->pointer = ResourceManager::load("cube", PRIM, prio, &tmpResource->modelSize);
287            }
288          break;
289        case PRIM:
290          if (param1)
291            tmpResource->modelSize = *(float*)param1;
292          else
293            tmpResource->modelSize = 1.0;
294
295          if (!strcmp(tmpResource->name, "cube"))
296            tmpResource->pointer = new PrimitiveModel(PRIM_CUBE, tmpResource->modelSize);
297          else if (!strcmp(tmpResource->name, "sphere"))
298            tmpResource->pointer = new PrimitiveModel(PRIM_SPHERE, tmpResource->modelSize);
299          else if (!strcmp(tmpResource->name, "plane"))
300            tmpResource->pointer = new PrimitiveModel(PRIM_PLANE, tmpResource->modelSize);
301          else if (!strcmp(tmpResource->name, "cylinder"))
302            tmpResource->pointer = new PrimitiveModel(PRIM_CYLINDER, tmpResource->modelSize);
303          else if (!strcmp(tmpResource->name, "cone"))
304            tmpResource->pointer = new PrimitiveModel(PRIM_CONE, tmpResource->modelSize);
305          break;
306        case MD2:
307          if(ResourceManager::isFile(fullName))
308            {
309              if (param1)
310                {
311                  tmpResource->skinFileName = new char[strlen((const char*)param1)+1];
312                  strcpy(tmpResource->skinFileName, (const char*) param1);
313                }
314              else
315                tmpResource->skinFileName = NULL;
316              tmpResource->pointer = new MD2Data(fullName, tmpResource->skinFileName);
317            }
318              break;
319#endif /* NO_MODEL */
320#ifndef NO_TEXT
321        case TTF:
322            if (param1)
323              tmpResource->ttfSize = *(int*)param1;
324            else
325              tmpResource->ttfSize = FONT_DEFAULT_SIZE;
326
327          if(isFile(fullName))
328            tmpResource->pointer = new Font(fullName,
329                                            tmpResource->ttfSize);
330          else
331            PRINTF(2)("Sorry, %s does not exist. Not loading Font\n", fullName);
332          break;
333#endif /* NO_TEXT */
334#ifndef NO_AUDIO
335        case WAV:
336          if(isFile(fullName))
337            tmpResource->pointer = new SoundBuffer(fullName);
338          break;
339        case OGG:
340          if (isFile(fullName))
341            tmpResource->pointer = new OggPlayer(fullName);
342          break;
343#endif /* NO_AUDIO */
344#ifndef NO_TEXTURES
345        case IMAGE:
346          if(isFile(fullName))
347            {
348              PRINTF(4)("Image %s resides to %s\n", fileName, fullName);
349              tmpResource->pointer = new Texture(fullName);
350            }
351          else
352            {
353              tIterator<char>* iterator = imageDirs->getIterator();
354              tmpDir = iterator->firstElement();
355              while(tmpDir)
356                {
357                  char* imgName = new char[strlen(tmpDir)+strlen(fileName)+1];
358                  sprintf(imgName, "%s%s", tmpDir, fileName);
359                  if(isFile(imgName))
360                    {
361                      PRINTF(4)("Image %s resides to %s\n", fileName, imgName);
362                      tmpResource->pointer = new Texture(imgName);
363                      delete[] imgName;
364                      break;
365                    }
366                  delete[] imgName;
367                  tmpDir = iterator->nextElement();
368                }
369              delete iterator;
370            }
371          if(!tmpResource)
372             PRINTF(2)("!!Image %s not Found!!\n", fileName);
373          break;
374#endif /* NO_TEXTURES */
375        default:
376          tmpResource->pointer = NULL;
377          PRINTF(1)("No type found for %s.\n   !!This should not happen unless the Type is not supported yet.!!\n", tmpResource->name);
378          break;
379        }
380      if (tmpResource->pointer != NULL)
381        this->resourceList->add(tmpResource);
382      delete[] fullName;
383    }
384  if (tmpResource->pointer != NULL)
385    return tmpResource->pointer;
386  else
387    {
388      PRINTF(2)("Resource %s could not be loaded\n", fileName);
389      delete[] tmpResource->name;
390      delete tmpResource;
391      return NULL;
392    }
393}
394
395/**
396 * unloads a Resource
397 * @param pointer: The pointer to free
398 * @param prio: the PriorityLevel to unload this resource
399 * @returns true if successful (pointer found, and deleted), false otherwise
400*/
401bool ResourceManager::unload(void* pointer, ResourcePriority prio)
402{
403  // if pointer is existent. and only one resource of this type exists.
404  Resource* tmpResource = this->locateResourceByPointer(pointer);
405  if (tmpResource == NULL)
406    {
407      PRINTF(2)("Resource not Found %p\n", pointer);
408      return false;
409    }
410  else
411    unload(tmpResource, prio);
412}
413
414/**
415 * unloads a Resource
416 * @param resource: The resource to unloade
417 * @param prio the PriorityLevel to unload this resource
418*/
419bool ResourceManager::unload(Resource* resource, ResourcePriority prio)
420{
421  if (resource->count > 0)
422    resource->count--;
423  if (resource->prio <= prio)
424    {
425      if (resource->count <= 0)
426        {
427          // deleting the Resource
428          switch(resource->type)
429            {
430#ifndef NO_MODEL
431            case OBJ:
432            case PRIM:
433              delete (Model*)resource->pointer;
434              break;
435            case MD2:
436              delete (MD2Data*)resource->pointer;
437              break;
438#endif /* NO_MODEL */
439#ifndef NO_AUDIO
440            case WAV:
441              delete (SoundBuffer*)resource->pointer;
442              break;
443            case OGG:
444              delete (OggPlayer*)resource->pointer;
445              break;
446#endif /* NO_AUDIO */
447#ifndef NO_TEXT
448            case TTF:
449              delete (Font*)resource->pointer;
450              break;
451#endif /* NO_TEXT */
452#ifndef NO_TEXTURES
453            case IMAGE:
454              delete (Texture*)resource->pointer;
455              break;
456#endif /* NO_TEXTURES */
457            default:
458              PRINTF(2)("NOT YET IMPLEMENTED !!FIX FIX!!\n");
459              return false;
460              break;
461            }
462          // deleting the List Entry:
463          PRINTF(4)("Resource %s safely removed.\n", resource->name);
464          delete[] resource->name;
465          this->resourceList->remove(resource);
466          delete resource;
467        }
468      else
469        PRINTF(4)("Resource %s not removed, because there are still %d References to it.\n", resource->name, resource->count);
470    }
471  else
472    PRINTF(4)("not deleting resource %s because DeleteLevel to high\n", resource->name);
473  return true;
474}
475
476
477/**
478 *  unloads all alocated Memory of Resources with a pririty lower than prio
479 * @param prio The priority to delete
480*/
481bool ResourceManager::unloadAllByPriority(ResourcePriority prio)
482{
483  tIterator<Resource>* iterator = resourceList->getIterator();
484  Resource* enumRes = iterator->firstElement();
485  while (enumRes)
486    {
487      if (enumRes->prio <= prio)
488        if (enumRes->count == 0)
489          unload(enumRes, prio);
490        else
491          PRINTF(2)("unable to unload %s because there are still %d references to it\n",
492                   enumRes->name, enumRes->count);
493      //enumRes = resourceList->nextElement();
494      enumRes = iterator->nextElement();
495    }
496  delete iterator;
497}
498
499/**
500 * Searches for a Resource by some information
501 * @param fileName: The name to look for
502 * @param type the Type of resource to locate.
503 * @param param1: an additional option to parse (see the constuctors for more help)
504 * @param param2: an additional option to parse (see the constuctors for more help)
505 * @param param3: an additional option to parse (see the constuctors for more help)
506 * @returns a Pointer to the Resource if found, NULL otherwise.
507*/
508Resource* ResourceManager::locateResourceByInfo(const char* fileName, ResourceType type,
509                                                void* param1, void* param2, void* param3)
510{
511  //  Resource* enumRes = resourceList->enumerate();
512  tIterator<Resource>* iterator = resourceList->getIterator();
513  Resource* enumRes = iterator->firstElement();
514  while (enumRes)
515    {
516      if (enumRes->type == type && !strcmp(fileName, enumRes->name))
517        {
518          bool match = false;
519          bool subMatch = false;
520
521          switch (type)
522            {
523#ifndef NO_MODEL
524            case PRIM:
525            case OBJ:
526              if (!param1)
527                {
528                  if (enumRes->modelSize == 1.0)
529                    match = true;
530                }
531              else if (enumRes->modelSize == *(float*)param1)
532                match = true;
533              break;
534            case MD2:
535              if (!param1)
536                {
537                  if (enumRes->skinFileName == NULL)
538                    match = true;
539                }
540              else if (!strcmp(enumRes->skinFileName, (const char*) param1))
541                match = true;
542              break;
543#endif /* NO_MODEL */
544#ifndef NO_TEXT
545            case TTF:
546              if (!param1)
547                {
548                  if (enumRes->ttfSize == FONT_DEFAULT_SIZE)
549                    subMatch = true;
550                }
551              else if (enumRes->ttfSize == *(int*)param1)
552                subMatch = true;
553              break;
554#endif /* NO_TEXT */
555            default:
556              match = true;
557              break;
558            }
559          if (match)
560            {
561              delete iterator;
562              return enumRes;
563            }
564        }
565      enumRes = iterator->nextElement();
566    }
567  delete iterator;
568  return NULL;
569}
570
571/**
572 * Searches for a Resource by Pointer
573 * @param pointer the Pointer to search for
574 * @returns a Pointer to the Resource if found, NULL otherwise.
575*/
576Resource* ResourceManager::locateResourceByPointer(const void* pointer)
577{
578  //  Resource* enumRes = resourceList->enumerate();
579  tIterator<Resource>* iterator = resourceList->getIterator();
580  Resource* enumRes = iterator->firstElement();
581  while (enumRes)
582    {
583      if (pointer == enumRes->pointer)
584        {
585          delete iterator;
586          return enumRes;
587        }
588      enumRes = iterator->nextElement();
589    }
590  delete iterator;
591  return NULL;
592}
593
594/**
595 * Checks if it is a Directory
596 * @param directoryName the Directory to check for
597 * @returns true if it is a directory/symlink false otherwise
598*/
599bool ResourceManager::isDir(const char* directoryName)
600{
601  if (directoryName == NULL)
602    return false;
603
604  char* tmpDirName = NULL;
605  struct stat status;
606
607  // checking for the termination of the string given. If there is a "/" at the end cut it away
608  if (directoryName[strlen(directoryName)-1] == '/' ||
609      directoryName[strlen(directoryName)-1] == '\\')
610    {
611      tmpDirName = new char[strlen(directoryName)+1];
612      strncpy(tmpDirName, directoryName, strlen(directoryName)-1);
613      tmpDirName[strlen(directoryName)-1] = '\0';
614    }
615  else
616    {
617      tmpDirName = new char[strlen(directoryName)+1];
618      strcpy(tmpDirName, directoryName);
619    }
620
621  if(!stat(tmpDirName, &status))
622    {
623      if (status.st_mode & (S_IFDIR
624#ifndef __WIN32__
625                            | S_IFLNK
626#endif
627                            ))
628        {
629          delete[] tmpDirName;
630          return true;
631        }
632      else
633        {
634          delete[] tmpDirName;
635          return false;
636        }
637    }
638  else
639  {
640    delete[] tmpDirName;
641    return false;
642  }
643}
644
645/**
646 * Checks if the file is either a Regular file or a Symlink
647 * @param fileName the File to check for
648 * @returns true if it is a regular file/symlink, false otherwise
649*/
650bool ResourceManager::isFile(const char* fileName)
651{
652  if (fileName == NULL)
653    return false;
654  char* tmpFileName = ResourceManager::homeDirCheck(fileName);
655  // actually checks the File
656  struct stat status;
657  if (!stat(tmpFileName, &status))
658    {
659      if (status.st_mode & (S_IFREG
660#ifndef __WIN32__
661                            | S_IFLNK
662#endif
663                            ))
664        {
665          delete[] tmpFileName;
666          return true;
667        }
668      else
669        {
670          delete[] tmpFileName;
671          return false;
672        }
673    }
674  else
675    {
676      delete[] tmpFileName;
677      return false;
678    }
679}
680
681/**
682 * touches a File on the disk (thereby creating it)
683 * @param fileName The file to touch
684*/
685bool ResourceManager::touchFile(const char* fileName)
686{
687  char* tmpName = ResourceManager::homeDirCheck(fileName);
688  if (tmpName == NULL)
689    return false;
690  FILE* stream;
691  if( (stream = fopen (tmpName, "w")) == NULL)
692    {
693      PRINTF(1)("could not open %s fro writing\n", fileName);
694      delete[] tmpName;
695      return false;
696    }
697  fclose(stream);
698
699  delete[] tmpName;
700}
701
702/**
703 * deletes a File from disk
704 * @param fileName the File to delete
705*/
706bool ResourceManager::deleteFile(const char* fileName)
707{
708  if (fileName == NULL)
709    return false;
710  char* tmpName = ResourceManager::homeDirCheck(fileName);
711  unlink(tmpName);
712  delete[] tmpName;
713}
714
715/**
716 * @param name the Name of the file to check
717 * @returns The name of the file, including the HomeDir
718 * IMPORTANT: this has to be deleted from the outside
719 */
720char* ResourceManager::homeDirCheck(const char* name)
721{
722  if (name == NULL)
723    return NULL;
724  char* retName;
725  if (!strncmp(name, "~/", 2))
726    {
727      char tmpFileName[500];
728#ifdef __WIN32__
729      strcpy(tmpFileName, getenv("USERPROFILE"));
730#else
731      strcpy(tmpFileName, getenv("HOME"));
732#endif
733      retName = new char[strlen(tmpFileName)+strlen(name)];
734      sprintf(retName, "%s%s", tmpFileName, name+1);
735    }
736  else
737    {
738      retName = new char[strlen(name)+1];
739      strcpy(retName, name);
740    }
741  return retName;
742}
743
744/**
745 * @param fileName the Name of the File to check
746 * @returns The full name of the file, including the DataDir, and NULL if the file does not exist
747 * !!IMPORTANT: this has to be deleted from the outside!!
748*/
749char* ResourceManager::getFullName(const char* fileName)
750{
751  if (fileName == NULL)
752    return NULL;
753
754  char* retName = new char[strlen(ResourceManager::getInstance()->getDataDir())
755                           + strlen(fileName) + 1];
756  sprintf(retName, "%s%s", ResourceManager::getInstance()->getDataDir(), fileName);
757  if (ResourceManager::isFile(retName) || ResourceManager::isDir(retName))
758    return retName;
759  else
760    {
761      delete[] retName;
762      return NULL;
763    }
764}
765
766
767/**
768 * outputs debug information about the ResourceManager
769*/
770void ResourceManager::debug() const
771{
772  PRINT(0)("=RM===================================\n");
773  PRINT(0)("= RESOURCE-MANAGER DEBUG INFORMATION =\n");
774  PRINT(0)("======================================\n");
775  // if it is not initialized
776  PRINT(0)(" Reference is: %p\n", ResourceManager::singletonRef);
777  PRINT(0)(" Data-Directory is: %s\n", this->dataDir);
778  PRINT(0)(" List of Image-Directories: ");
779  tIterator<char>* tmpIt = imageDirs->getIterator();
780  char* tmpDir = tmpIt->firstElement();
781  while(tmpDir)
782    {
783      PRINT(0)("%s ",tmpDir);
784      tmpDir = tmpIt->nextElement();
785    }
786  delete tmpIt;
787  PRINT(0)("\n");
788
789  PRINT(0)("List of all stored Resources:\n");
790  tIterator<Resource>* iterator = resourceList->getIterator();
791  Resource* enumRes = iterator->firstElement();
792  while (enumRes)
793    {
794      PRINT(0)("-----------------------------------------\n");
795      PRINT(0)("Name: %s; References: %d; Type:", enumRes->name, enumRes->count);
796      switch (enumRes->type)
797        {
798#ifndef NO_MODEL
799          case OBJ:
800          PRINT(0)("ObjectModel\n");
801          break;
802        case PRIM:
803          PRINT(0)("PrimitiveModel\n");
804          break;
805#endif
806#ifndef NO_TEXTURES
807        case IMAGE:
808          PRINT(0)("ImageFile (Texture)\n");
809          break;
810#endif
811#ifndef NO_AUDIO
812        case WAV:
813          PRINT(0)("SoundFile\n");
814          break;
815        case OGG:
816          PRINT(0)("MusicFile\n");
817          break;
818#endif
819        default:
820          PRINT(0)("Do not know this format\n");
821          break;
822        }
823      PRINT(0)("gets deleted at ");
824      switch(enumRes->prio)
825        {
826        default:
827        case RP_NO:
828          PRINT(0)("first posibility (0)\n");
829          break;
830        case RP_LEVEL:
831          PRINT(0)("the end of the Level (1)\n");
832          break;
833        case RP_CAMPAIGN:
834          PRINT(0)("the end of the campaign (2)\n");
835          break;
836        case RP_GAME:
837          PRINT(0)("when leaving the game (3)\n");
838          break;
839        }
840      enumRes = iterator->nextElement();
841    }
842  delete iterator;
843
844
845
846  PRINT(0)("==================================RM==\n");
847}
Note: See TracBrowser for help on using the repository browser.