Browse Source

set_repository() and set_clock_delta() should be instance methods, not static class methods

David Rose 14 years ago
parent
commit
33398d9713

+ 2 - 2
direct/src/distributed/cDistributedSmoothNodeBase.I

@@ -16,7 +16,7 @@
 ////////////////////////////////////////////////////////////////////
 //     Function: CDistributedSmoothNodeBase::set_repository
 //       Access: Published, Static
-//  Description: Tells the C++ class definition about the AI or Client
+//  Description: Tells the C++ instance definition about the AI or Client
 //               repository, used for sending datagrams.
 ////////////////////////////////////////////////////////////////////
 INLINE void CDistributedSmoothNodeBase::
@@ -31,7 +31,7 @@ set_repository(CConnectionRepository *repository,
 ////////////////////////////////////////////////////////////////////
 //     Function: CDistributedSmoothNodeBase::set_clock_delta
 //       Access: Published, Static
-//  Description: Tells the C++ class definition about the global
+//  Description: Tells the C++ instance definition about the global
 //               ClockDelta object.
 ////////////////////////////////////////////////////////////////////
 INLINE void CDistributedSmoothNodeBase::

+ 10 - 8
direct/src/distributed/cDistributedSmoothNodeBase.cxx

@@ -22,14 +22,6 @@
 static const PN_stdfloat smooth_node_epsilon = 0.01;
 static const double network_time_precision = 100.0;  // Matches ClockDelta.py
 
-CConnectionRepository *CDistributedSmoothNodeBase::_repository = NULL;
-bool CDistributedSmoothNodeBase::_is_ai;
-CHANNEL_TYPE CDistributedSmoothNodeBase::_ai_id;
-
-#ifdef HAVE_PYTHON
-PyObject *CDistributedSmoothNodeBase::_clock_delta = NULL;
-#endif
-
 ////////////////////////////////////////////////////////////////////
 //     Function: CDistributedSmoothNodeBase::Constructor
 //       Access: Published
@@ -37,6 +29,14 @@ PyObject *CDistributedSmoothNodeBase::_clock_delta = NULL;
 ////////////////////////////////////////////////////////////////////
 CDistributedSmoothNodeBase::
 CDistributedSmoothNodeBase() {
+  _repository = NULL;
+  _is_ai = false;
+  _ai_id = 0;
+
+#ifdef HAVE_PYTHON
+  _clock_delta = NULL;
+#endif
+
   _currL[0] = 0;
   _currL[1] = 0;
 }
@@ -320,6 +320,7 @@ begin_send_update(DCPacker &packer, const string &field_name) {
 void CDistributedSmoothNodeBase::
 finish_send_update(DCPacker &packer) {
 #ifdef HAVE_PYTHON
+  nassertv(_clock_delta != NULL);
   PyObject *clock_delta = PyObject_GetAttrString(_clock_delta, "delta");
   nassertv(clock_delta != NULL);
   double delta = PyFloat_AsDouble(clock_delta);
@@ -340,6 +341,7 @@ finish_send_update(DCPacker &packer) {
   bool pack_ok = packer.end_pack();
   if (pack_ok) {
     Datagram dg(packer.get_data(), packer.get_length());
+    nassertv(_repository != NULL);
     _repository->send_datagram(dg);
 
   } else {

+ 6 - 6
direct/src/distributed/cDistributedSmoothNodeBase.h

@@ -36,12 +36,12 @@ PUBLISHED:
   CDistributedSmoothNodeBase();
   ~CDistributedSmoothNodeBase();
   
-  INLINE static void
+  INLINE void
   set_repository(CConnectionRepository *repository,
                  bool is_ai, CHANNEL_TYPE ai_id);
 
 #ifdef HAVE_PYTHON
-  INLINE static void
+  INLINE void
   set_clock_delta(PyObject *clock_delta);
 #endif
 
@@ -88,11 +88,11 @@ private:
   DCClass *_dclass;
   CHANNEL_TYPE _do_id;
 
-  static CConnectionRepository *_repository;
-  static bool _is_ai;
-  static CHANNEL_TYPE _ai_id;
+  CConnectionRepository *_repository;
+  bool _is_ai;
+  CHANNEL_TYPE _ai_id;
 #ifdef HAVE_PYTHON
-  static PyObject *_clock_delta;
+  PyObject *_clock_delta;
 #endif
 
   LPoint3 _store_xyz;