Browse Source

split out otp.dc, pirates.dc

David Rose 21 năm trước cách đây
mục cha
commit
190bce1824

+ 1 - 1
direct/src/dcparse/dcparse.cxx

@@ -49,7 +49,7 @@ help() {
 
 
 int
 int
 main(int argc, char *argv[]) {
 main(int argc, char *argv[]) {
-  extern char *optarg;
+  //  extern char *optarg;
   extern int optind;
   extern int optind;
   const char *optstr = "bvh";
   const char *optstr = "bvh";
 
 

+ 39 - 0
direct/src/dcparser/dcFile.cxx

@@ -25,6 +25,7 @@
 #include "filename.h"
 #include "filename.h"
 #include "config_express.h"
 #include "config_express.h"
 #include "virtualFileSystem.h"
 #include "virtualFileSystem.h"
+#include "executionEnvironment.h"
 #endif
 #endif
 
 
 
 
@@ -50,6 +51,44 @@ DCFile::
   }
   }
 }
 }
 
 
+#ifdef WITHIN_PANDA
+
+////////////////////////////////////////////////////////////////////
+//     Function: DCFile::read_all
+//       Access: Published
+//  Description: This special method reads all of the .dc files named
+//               by the "dc-file" Configrc variable, and loads them
+//               into the DCFile namespace.
+////////////////////////////////////////////////////////////////////
+bool DCFile::
+read_all() {
+  Config::ConfigTable::Symbol dc_files;
+  config_express.GetAll("dc-file", dc_files);
+
+  if (dc_files.empty()) {
+    cerr << "No files specified via dc-file Configrc variable!\n";
+    return false;
+  }
+
+  // When we use GetAll(), we might inadvertently read duplicate
+  // lines.  Filter them out with a set.
+  pset<string> already_read;
+  
+  Config::ConfigTable::Symbol::iterator si;
+  for (si = dc_files.begin(); si != dc_files.end(); ++si) {
+    string dc_file = ExecutionEnvironment::expand_string((*si).Val());
+    if (already_read.insert(dc_file).second) {
+      if (!read(dc_file)) {
+        return false;
+      }
+    }
+  }
+
+  return true;
+}
+
+#endif  // WITHIN_PANDA
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: DCFile::read
 //     Function: DCFile::read
 //       Access: Published
 //       Access: Published

+ 4 - 0
direct/src/dcparser/dcFile.h

@@ -34,6 +34,10 @@ PUBLISHED:
   DCFile();
   DCFile();
   ~DCFile();
   ~DCFile();
 
 
+#ifdef WITHIN_PANDA
+  bool read_all();
+#endif
+
   bool read(Filename filename);
   bool read(Filename filename);
   bool read(istream &in, const string &filename = string());
   bool read(istream &in, const string &filename = string());
 
 

+ 5 - 5
direct/src/distributed/ClientRepository.py

@@ -18,7 +18,7 @@ from PyDatagramIterator import PyDatagramIterator
 class ClientRepository(ConnectionRepository.ConnectionRepository):
 class ClientRepository(ConnectionRepository.ConnectionRepository):
     notify = DirectNotifyGlobal.directNotify.newCategory("ClientRepository")
     notify = DirectNotifyGlobal.directNotify.newCategory("ClientRepository")
 
 
-    def __init__(self, dcFileName):
+    def __init__(self):
         ConnectionRepository.ConnectionRepository.__init__(self, base.config)
         ConnectionRepository.ConnectionRepository.__init__(self, base.config)
 
 
         self.recorder = base.recorder
         self.recorder = base.recorder
@@ -27,7 +27,7 @@ class ClientRepository(ConnectionRepository.ConnectionRepository):
         self.name2cdc={}
         self.name2cdc={}
         self.doId2do={}
         self.doId2do={}
         self.doId2cdc={}
         self.doId2cdc={}
-        self.parseDcFile(dcFileName)
+        self.parseDcFile()
         self.cache=CRCache.CRCache()
         self.cache=CRCache.CRCache()
         self.serverDelta = 0
         self.serverDelta = 0
 
 
@@ -97,11 +97,11 @@ class ClientRepository(ConnectionRepository.ConnectionRepository):
         """
         """
         return time.time() + self.serverDelta
         return time.time() + self.serverDelta
 
 
-    def parseDcFile(self, dcFileName):
+    def parseDcFile(self):
         self.dcFile = DCFile()
         self.dcFile = DCFile()
-        readResult = self.dcFile.read(dcFileName)
+        readResult = self.dcFile.readAll()
         if not readResult:
         if not readResult:
-            self.notify.error("Could not read dcfile: %s" % dcFileName.cStr())
+            self.notify.error("Could not read dc file.")
         self.hashVal = self.dcFile.getHash()
         self.hashVal = self.dcFile.getHash()
         return self.parseDcClasses(self.dcFile)
         return self.parseDcClasses(self.dcFile)