Browse Source

report p3dinstance startup

David Rose 16 years ago
parent
commit
6758007d8a

+ 33 - 1
direct/src/plugin/p3dFileParams.I

@@ -30,7 +30,39 @@ get_p3d_filename() const {
 //  Description: Returns the p3d file offset, the location
 //  Description: Returns the p3d file offset, the location
 //               in the file where the p3d data starts.
 //               in the file where the p3d data starts.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-inline const int &P3DFileParams::
+inline int P3DFileParams::
 get_p3d_offset() const {
 get_p3d_offset() const {
   return _p3d_offset;
   return _p3d_offset;
 }
 }
+
+////////////////////////////////////////////////////////////////////
+//     Function: P3DFileParams::get_num_tokens
+//       Access: Public
+//  Description: Returns the number of tokens in the params.
+////////////////////////////////////////////////////////////////////
+inline int P3DFileParams::
+get_num_tokens() const {
+  return _tokens.size();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: P3DFileParams::get_token_keyword
+//       Access: Public
+//  Description: Returns the keyword of the nth token.
+////////////////////////////////////////////////////////////////////
+inline const string &P3DFileParams::
+get_token_keyword(int n) const {
+  assert(n >= 0 && n < (int)_tokens.size());
+  return _tokens[n]._keyword;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: P3DFileParams::get_token_value
+//       Access: Public
+//  Description: Returns the value of the nth token.
+////////////////////////////////////////////////////////////////////
+inline const string &P3DFileParams::
+get_token_value(int n) const {
+  assert(n >= 0 && n < (int)_tokens.size());
+  return _tokens[n]._value;
+}

+ 5 - 1
direct/src/plugin/p3dFileParams.h

@@ -36,11 +36,15 @@ public:
   void set_args(int argc, const char *argv[]);
   void set_args(int argc, const char *argv[]);
 
 
   inline const string &get_p3d_filename() const;
   inline const string &get_p3d_filename() const;
-  inline const int &get_p3d_offset() const;
+  inline int get_p3d_offset() const;
   string lookup_token(const string &keyword) const;
   string lookup_token(const string &keyword) const;
   int lookup_token_int(const string &keyword) const;
   int lookup_token_int(const string &keyword) const;
   bool has_token(const string &keyword) const;
   bool has_token(const string &keyword) const;
 
 
+  inline int get_num_tokens() const;
+  inline const string &get_token_keyword(int n) const;
+  inline const string &get_token_value(int n) const;
+
   TiXmlElement *make_xml();
   TiXmlElement *make_xml();
 
 
 private:
 private:

+ 18 - 5
direct/src/plugin/p3dInstance.cxx

@@ -93,6 +93,13 @@ P3DInstance(P3D_request_ready_func *func,
   _fparams.set_tokens(tokens, num_tokens);
   _fparams.set_tokens(tokens, num_tokens);
   _fparams.set_args(argc, argv);
   _fparams.set_args(argc, argv);
 
 
+  nout << "Creating P3DInstance " << this << ": ";
+  for (int i = 0; i < _fparams.get_num_tokens(); ++i) {
+    nout << " " << _fparams.get_token_keyword(i)
+         << "=\"" << _fparams.get_token_value(i) << "\"";
+  }
+  nout << "\n";
+
   P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr();
   P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr();
   _instance_id = inst_mgr->get_unique_id();
   _instance_id = inst_mgr->get_unique_id();
   _hidden = (_fparams.lookup_token_int("hidden") != 0);
   _hidden = (_fparams.lookup_token_int("hidden") != 0);
@@ -307,6 +314,12 @@ P3DInstance::
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void P3DInstance::
 void P3DInstance::
 set_p3d_url(const string &p3d_url) {
 set_p3d_url(const string &p3d_url) {
+  if (p3d_url.empty()) {
+    nout << "No p3d URL specified.  Cannot run.\n";
+    set_failed();
+    return;
+  }
+
   // Save the last part of the URL as the p3d_basename, for reporting
   // Save the last part of the URL as the p3d_basename, for reporting
   // purposes or whatever.
   // purposes or whatever.
   determine_p3d_basename(p3d_url);
   determine_p3d_basename(p3d_url);
@@ -1321,7 +1334,7 @@ priv_set_p3d_filename(const string &p3d_filename, const int &p3d_offset) {
   _fparams.set_p3d_filename(p3d_filename);
   _fparams.set_p3d_filename(p3d_filename);
   // The default for p3d_offset is -1, which means not to change it.
   // The default for p3d_offset is -1, which means not to change it.
   if (p3d_offset >= 0) {
   if (p3d_offset >= 0) {
-	_fparams.set_p3d_offset(p3d_offset);
+    _fparams.set_p3d_offset(p3d_offset);
   }
   }
   _got_fparams = true;
   _got_fparams = true;
 
 
@@ -1333,12 +1346,12 @@ priv_set_p3d_filename(const string &p3d_filename, const int &p3d_offset) {
   send_notify("onpluginload");
   send_notify("onpluginload");
 
 
   if (!_mf_reader.open_read(_fparams.get_p3d_filename(), _fparams.get_p3d_offset())) {
   if (!_mf_reader.open_read(_fparams.get_p3d_filename(), _fparams.get_p3d_offset())) {
-	if (_fparams.get_p3d_offset() == 0) {
+    if (_fparams.get_p3d_offset() == 0) {
       nout << "Couldn't read " << _fparams.get_p3d_filename() << "\n";
       nout << "Couldn't read " << _fparams.get_p3d_filename() << "\n";
     } else {
     } else {
-	  nout << "Couldn't read " << _fparams.get_p3d_filename()
-	       << " at offset " << _fparams.get_p3d_offset() << "\n";
-	}
+      nout << "Couldn't read " << _fparams.get_p3d_filename()
+           << " at offset " << _fparams.get_p3d_offset() << "\n";
+    }
     set_failed();
     set_failed();
     return;
     return;
   }
   }