pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] CVS: Games/Pingus/src pingus_resource.cxx,1.2,1.3 pingus_re


From: grumbel
Subject: [Pingus-CVS] CVS: Games/Pingus/src pingus_resource.cxx,1.2,1.3 pingus_resource.hxx,1.1,1.2 playfield.hxx,1.2,1.3 res_descriptor.hxx,1.2,1.3
Date: 18 Jun 2002 21:17:19 -0000

Update of /usr/local/cvsroot/Games/Pingus/src
In directory dark:/tmp/cvs-serv30598/src

Modified Files:
        pingus_resource.cxx pingus_resource.hxx playfield.hxx 
        res_descriptor.hxx 
Log Message:
- added resource garbage collector
- added new images to the makefiles/.scr files

Index: pingus_resource.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingus_resource.cxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- pingus_resource.cxx 13 Jun 2002 14:25:12 -0000      1.2
+++ pingus_resource.cxx 18 Jun 2002 21:17:16 -0000      1.3
@@ -195,8 +195,8 @@
        {
        case ResDescriptor::RD_RESOURCE:
          try {
-         font = CL_Font::load(res_desc.res_name.c_str(),
-                              get(suffix_fixer(res_desc.datafile)));
+           font = CL_Font::load(res_desc.res_name.c_str(),
+                                get(suffix_fixer(res_desc.datafile)));
          } catch (CL_Error err) {
            std::cout << "PingusResource: " << err.message << std::endl;
            std::cout << "PingusResource: Couldn't load font: " << res_desc << 
std::endl;
@@ -216,6 +216,31 @@
        default:
          std::cout << "PingusResource: Unknown ResDescriptor::type: " << 
res_desc.type  << std::endl;
          return 0;
+       }
+    }
+}
+
+void
+PingusResource::cleanup ()
+{
+  std::cout << "XXXX PingusResource::cleanup ()" << std::endl;
+  
+  for (std::map<ResDescriptor, CL_Surface>::iterator i = surface_map.begin ();
+       i != surface_map.end (); ++i)
+    {
+      if (i->first.type == ResDescriptor::RD_FILE
+         && i->second.get_reference_count () == 1)
+       {
+         std::cout << "XXX Releasing File: " << i->first
+                   << " => " << i->second.get_reference_count () << std::endl;
+         surface_map.erase(i);
+       }
+      else if (i->first.type == ResDescriptor::RD_RESOURCE
+              && i->second.get_reference_count () == 2)
+       {
+         std::cout << "XXX Releasing Resource : " << i->first
+                   << " => " << i->second.get_reference_count () << std::endl;
+         surface_map.erase(i);
        }
     }
 }

Index: pingus_resource.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingus_resource.hxx,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- pingus_resource.hxx 12 Jun 2002 19:06:12 -0000      1.1
+++ pingus_resource.hxx 18 Jun 2002 21:17:16 -0000      1.2
@@ -66,6 +66,9 @@
   /** Load a font from the ResDescriptor */
   static CL_Font* load_font(const ResDescriptor&);
 
+  /** Cleanup all currently unused surfaces */
+  static void cleanup ();
+
   /** */
   static CL_ResourceManager* get(const std::string&);
 };

Index: playfield.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/playfield.hxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- playfield.hxx       17 Jun 2002 15:45:26 -0000      1.2
+++ playfield.hxx       18 Jun 2002 21:17:16 -0000      1.3
@@ -31,7 +31,7 @@
 class ButtonPanel;
 class Controller;
 
-///
+/** This class encapsulates all the different Views */
 class Playfield : public GuiObj
 {
 private:  

Index: res_descriptor.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/res_descriptor.hxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- res_descriptor.hxx  14 Jun 2002 11:16:53 -0000      1.2
+++ res_descriptor.hxx  18 Jun 2002 21:17:16 -0000      1.3
@@ -26,7 +26,6 @@
 class ResDescriptor
 {
 public:
-  ///
   enum ResourceType { RD_RESOURCE, RD_FILE, RD_AUTO };
   
   /// Where to get the data from?
@@ -38,17 +37,12 @@
   /// The name of the data, filename or resourcename ("Textures/desert")
   std::string res_name;
 
-  ///
   ResDescriptor();
-  ///
   ResDescriptor(const ResDescriptor&);
 
-  ///
   ResDescriptor(const std::string& res_name, const std::string& datafile,
                ResourceType type);
-  ///
   ResDescriptor(const std::string& cast, const std::string& value);
-  ///
   ResDescriptor(const std::string& str);
 
   bool operator<(const ResDescriptor&) const;




reply via email to

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