diff --git a/direct/src/distributed/cConnectionRepository.I b/direct/src/distributed/cConnectionRepository.I index 3d549bc274..0a9aad525c 100644 --- a/direct/src/distributed/cConnectionRepository.I +++ b/direct/src/distributed/cConnectionRepository.I @@ -312,6 +312,28 @@ get_want_message_bundling() const { return _want_message_bundling; } +//////////////////////////////////////////////////////////////////// +// Function: CConnectionRepository::set_in_quiet_zone +// Access: Published +// Description: Enables/disables quiet zone mode +//////////////////////////////////////////////////////////////////// +INLINE void CConnectionRepository:: +set_in_quiet_zone(bool flag) { + ReMutexHolder holder(_lock); + _in_quiet_zone = flag; +} + +//////////////////////////////////////////////////////////////////// +// Function: CConnectionRepository::get_in_quiet_zone +// Access: Published +// Description: Returns true if repository is in quiet zone mode +//////////////////////////////////////////////////////////////////// +INLINE bool CConnectionRepository:: +get_in_quiet_zone() const { + ReMutexHolder holder(_lock); + return _in_quiet_zone; +} + //////////////////////////////////////////////////////////////////// // Function: CConnectionRepository::set_simulated_disconnect // Access: Published diff --git a/direct/src/distributed/cConnectionRepository.cxx b/direct/src/distributed/cConnectionRepository.cxx index 4f3b26ca87..9b685feeeb 100644 --- a/direct/src/distributed/cConnectionRepository.cxx +++ b/direct/src/distributed/cConnectionRepository.cxx @@ -71,7 +71,8 @@ CConnectionRepository(bool has_owner_view) : _has_owner_view(has_owner_view), _handle_c_updates(true), _want_message_bundling(true), - _bundling_msgs(0) + _bundling_msgs(0), + _in_quiet_zone(0) { #if defined(HAVE_NET) && defined(SIMULATE_NETWORK_DELAY) if (min_lag != 0.0 || max_lag != 0.0) { @@ -714,6 +715,19 @@ handle_update_field() { DCClass *dclass = (DCClass *)PyInt_AsLong(dclass_this); Py_DECREF(dclass_this); + // If in quiet zone mode, throw update away unless distobj + // has 'neverDisable' attribute set to non-zero + if (_in_quiet_zone) { + PyObject *neverDisable = PyObject_GetAttrString(distobj, "neverDisable"); + nassertr(neverDisable != NULL, false); + + unsigned int cNeverDisable = PyInt_AsLong(neverDisable); + if (!cNeverDisable) { + // in quiet zone and distobj is disable-able + // drop update on the floor + return true; + } + } // It's a good idea to ensure the reference count to distobj is // raised while we call the update method--otherwise, the update diff --git a/direct/src/distributed/cConnectionRepository.h b/direct/src/distributed/cConnectionRepository.h index af32f324fa..37958a90fb 100644 --- a/direct/src/distributed/cConnectionRepository.h +++ b/direct/src/distributed/cConnectionRepository.h @@ -127,6 +127,9 @@ PUBLISHED: INLINE void set_want_message_bundling(bool flag); INLINE bool get_want_message_bundling() const; + INLINE void set_in_quiet_zone(bool flag); + INLINE bool get_in_quiet_zone() const; + void start_message_bundle(); INLINE bool is_bundling_messages() const; void send_message_bundle(unsigned int channel, unsigned int sender_channel); @@ -191,6 +194,7 @@ private: bool _handle_datagrams_internally; bool _simulated_disconnect; bool _verbose; + bool _in_quiet_zone; Datagram _dg; DatagramIterator _di;