fixed implementation of quiet zone wrt field updates from C++

This commit is contained in:
Darren Ranalli 2009-08-27 22:00:40 +00:00
parent 227a0dfe2e
commit b373df5add
3 changed files with 41 additions and 1 deletions

View File

@ -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

View File

@ -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

View File

@ -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;