pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] CVS: Games/Pingus/src demo_recorder.cxx,1.14,1.15 game_sess


From: grumbel
Subject: [Pingus-CVS] CVS: Games/Pingus/src demo_recorder.cxx,1.14,1.15 game_session.cxx,1.36,1.37 plf.cxx,1.14,1.15 plf.hxx,1.9,1.10 plf_res_mgr.cxx,1.2,1.3 start_screen.cxx,1.7,1.8xml_plf.cxx,1.35,1.36
Date: 30 Mar 2003 20:43:54 -0000

Update of /var/lib/cvs/Games/Pingus/src
In directory dark:/tmp/cvs-serv20883

Modified Files:
        demo_recorder.cxx game_session.cxx plf.cxx plf.hxx 
        plf_res_mgr.cxx start_screen.cxx xml_plf.cxx 
Log Message:
fixed problems in the name handling of level file and savegame id's

Index: demo_recorder.cxx
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/src/demo_recorder.cxx,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- demo_recorder.cxx   25 Mar 2003 00:37:44 -0000      1.14
+++ demo_recorder.cxx   30 Mar 2003 20:43:52 -0000      1.15
@@ -28,7 +28,12 @@
 DemoRecorder::DemoRecorder (Server* server)
   : record_demo (true)
 {
-  std::string levelname = server->get_plf()->get_filename();
+  std::string levelname = server->get_plf()->get_resname();
+  
+  // 'Flatten' the levelname so that we don't need directories
+  for (std::string::iterator i = levelname.begin(); i != levelname.end(); ++i)
+    if (*i == '/')
+      *i = '_';
 
   if (!levelname.empty())
     {
@@ -38,8 +43,8 @@
       if (!out)
        {
           record_demo = false;
-
-         std::cout << "DemoRecorder: Error: Couldn't write DemoFile, demo 
recording will be disabled" << std::endl;
+         std::cout << "DemoRecorder: Error: Couldn't write DemoFile '" << 
filename 
+                    << "', demo recording will be disabled" << std::endl;
        }
       else
         {

Index: game_session.cxx
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/src/game_session.cxx,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- game_session.cxx    26 Mar 2003 12:01:17 -0000      1.36
+++ game_session.cxx    30 Mar 2003 20:43:52 -0000      1.37
@@ -116,7 +116,7 @@
 
       { // Write the savegame
         Savegame savegame;
-        savegame.levelname    = result.plf->get_filename();
+        savegame.levelname    = result.plf->get_resname();
         savegame.time         = result.used_time;
         savegame.saved_pingus = result.saved;
         if (result.saved >= result.needed)

Index: plf.cxx
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/src/plf.cxx,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- plf.cxx     19 Feb 2003 11:33:00 -0000      1.14
+++ plf.cxx     30 Mar 2003 20:43:52 -0000      1.15
@@ -102,6 +102,12 @@
   return filename;
 }
 
+std::string
+PLF::get_resname()
+{
+  return resname;
+}
+
 std::map<std::string, std::string>
 PLF::get_levelname()
 {

Index: plf.hxx
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/src/plf.hxx,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- plf.hxx     19 Feb 2003 11:33:00 -0000      1.9
+++ plf.hxx     30 Mar 2003 20:43:52 -0000      1.10
@@ -38,6 +38,9 @@
 
   /** The name of the file from were the current level was loaded */
   std::string filename;
+  
+  /** Resource name of the PLF, see PLFResMgr */
+  std::string resname;
 
   std::map<std::string, std::string> description;
   
@@ -138,8 +141,11 @@
   /** Returns the name of the current level, {\em not} the level file name. */
   std::map<std::string, std::string> get_levelname();
 
-  /** Returns the name of the plf file. */
+  /** Returns the name of the plf file, see  */
   std::string get_filename();
+
+  /** Returns the resname of the plf, see PLFResMgr */
+  std::string get_resname();
 
   /** Returns the name of the author, who creates this level */
   std::string get_author();

Index: plf_res_mgr.cxx
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/src/plf_res_mgr.cxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- plf_res_mgr.cxx     7 Mar 2003 18:49:20 -0000       1.2
+++ plf_res_mgr.cxx     30 Mar 2003 20:43:52 -0000      1.3
@@ -30,6 +30,8 @@
 PLFResMgr::load_plf_raw(const std::string& res_name,
                         const std::string& filename)
 {
+  std::cout << "PLFResMgr: " << res_name << "\n   " << filename << std::endl;
+
   PLFMap::iterator i = plf_map.find(res_name);
   
   if (i == plf_map.end())
@@ -84,12 +86,12 @@
 PLFHandle
 PLFResMgr::load_plf_from_filename(const std::string& filename)
 {
-  // FIXME: Might cut of the 'playable/' or 'wip/' directories, not so
-  // good. saving the PLF's under filenames would also lead to
-  // throuble, since multiple filenames can map to the same file
-  // (../../data/levels/bla.xml, ../levels/bla.xml, etc.)
   std::string res_name = System::basename(filename); 
-  return load_plf_raw(res_name.substr(0, res_name.length()-4),
+
+  // This should give us the tutorial/, wip/, etc. part of the res_name
+  std::string dirname  = System::basename(System::dirname(filename)); 
+  
+  return load_plf_raw(dirname + "/" + res_name.substr(0, res_name.length()-4),
                       filename);
 }
 

Index: start_screen.cxx
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/src/start_screen.cxx,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- start_screen.cxx    30 Mar 2003 16:51:43 -0000      1.7
+++ start_screen.cxx    30 Mar 2003 20:43:52 -0000      1.8
@@ -144,7 +144,7 @@
   gc.print_center(Fonts::chalk_small, 400, 470, _("Author: ") + 
plf->get_author());
 
   if (maintainer_mode)
-    gc.print_left(Fonts::chalk_small, 110, 430, _("Filename: ") + 
plf->get_filename());
+    gc.print_left(Fonts::chalk_small, 110, 430, _("Filename: ") + 
plf->get_resname());
 }
 
 StartScreen::StartScreen(PLFHandle arg_plf)

Index: xml_plf.cxx
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/src/xml_plf.cxx,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- xml_plf.cxx 5 Mar 2003 19:55:14 -0000       1.35
+++ xml_plf.cxx 30 Mar 2003 20:43:52 -0000      1.36
@@ -34,21 +34,18 @@
 
 XMLPLF::XMLPLF (const std::string& arg_filename)
 {
-  //  std::cout << "----- Parsing .xml file" << std::endl;
-  //std::cout << "--- Checksum: " << std::flush;
-  std::string str = System::checksum (arg_filename);
-  //std::cout << str << std::endl;
+  filename = arg_filename;
+  std::string str = System::checksum (filename);
 
-  doc = xmlParseFile(arg_filename.c_str());
+  doc = xmlParseFile(filename.c_str());
 
   if (doc == NULL)
-    PingusError::raise("XMLPLF: Couldn't open \"" + arg_filename + "\"");
+    PingusError::raise("XMLPLF: Couldn't open \"" + filename + "\"");
 
-  parse_file();
+  resname = System::basename(System::dirname(filename))
+    + "/" + System::basename(filename.substr(0, filename.length()-4));
 
-  // FIXME: Dirty hack, should be replaced with a unified file namespace
-  filename = System::basename(arg_filename);
-  filename = filename.substr(0, filename.length()-4);
+  parse_file();
 }
 
 XMLPLF::~XMLPLF()





reply via email to

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