Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: fixed bug in SkyShphere, doubly deleted Model

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