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

This commit is contained in:
David Rose 2011-12-09 19:38:29 +00:00
parent f9658303e7
commit 33398d9713
3 changed files with 18 additions and 16 deletions

View File

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

View File

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

View File

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