enigma-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Enigma-cvs] enigma/src levelpack.cc,1.10,1.11


From: Ralf Westram <address@hidden>
Subject: [Enigma-cvs] enigma/src levelpack.cc,1.10,1.11
Date: Thu, 30 Oct 2003 19:05:33 +0000

Update of /cvsroot/enigma/enigma/src
In directory subversions:/tmp/cvs-serv18193/src

Modified Files:
        levelpack.cc 
Log Message:
- avoid loading the same levelpack multiple times. This happened
  if level pack was installed in /usr/local/share and in local
  enigma directory.



Index: levelpack.cc
===================================================================
RCS file: /cvsroot/enigma/enigma/src/levelpack.cc,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** levelpack.cc        27 Oct 2003 11:56:05 -0000      1.10
--- levelpack.cc        30 Oct 2003 19:05:28 -0000      1.11
***************
*** 28,31 ****
--- 28,32 ----
  #include <memory>
  #include <vector>
+ #include <set>
  #include <algorithm>
  #include <cstdio>
***************
*** 83,87 ****
--- 84,92 ----
          string      get_name() const { return m_name; }
          bool        load_level(size_t idx);
+ 
+         // never DECREASE the revision number!
          int         get_revision_number(size_t /*idx*/) const { return 1; }
+ 
+ 
      private:
          // Variables
***************
*** 344,354 ****
  //----------------------------------------
  
  void enigma::AddLevelPack (const char *init_file, const char *name)
  {
!     string filename;
!     if (FindFile(init_file, filename)) {
!         RegisterLevelPack (new LevelPack_Enigma (init_file, name));
!     } else {
!         enigma::Log << "Could not find level index file `" << init_file << 
"'\n";
      }
  }
--- 349,365 ----
  //----------------------------------------
  
+ // contains all levels packs added by AddLevelPack and AddZippedLevelPack
+ static set<string> addedLevelPacks;
+ 
  void enigma::AddLevelPack (const char *init_file, const char *name)
  {
!     if (addedLevelPacks.find(init_file) == addedLevelPacks.end()) {
!         string filename;
!         if (FindFile(init_file, filename)) {
!             RegisterLevelPack (new LevelPack_Enigma (init_file, name));
!             addedLevelPacks.insert(init_file);
!         } else {
!             enigma::Log << "Could not find level index file `" << init_file 
<< "'\n";
!         }
      }
  }
***************
*** 356,364 ****
  void enigma::AddZippedLevelPack (const char *zipfile)
  {
!     string filename;
!     if (FindFile (zipfile, filename)) {
!         RegisterLevelPack (new LevelPack_Zipped (filename));
!     } else {
!         enigma::Log << "Could not find zip file `" << zipfile << "'\n";
      }
  }
--- 367,378 ----
  void enigma::AddZippedLevelPack (const char *zipfile)
  {
!     if (addedLevelPacks.find(zipfile) == addedLevelPacks.end()) {
!         string filename;
!         if (FindFile (zipfile, filename)) {
!             RegisterLevelPack (new LevelPack_Zipped (filename));
!             addedLevelPacks.insert(zipfile);
!         } else {
!             enigma::Log << "Could not find zip file `" << zipfile << "'\n";
!         }
      }
  }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]