Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Looks good so far. Maybe more tweaking needed.

  • Loading branch information...
commit 83afa86076ef9db6ab506bca1f30ca05ece9dfef 1 parent fc386e3
@rcythr rcythr authored
Showing with 33 additions and 60 deletions.
  1. +33 −60 src/swganh_core/object/object.cc
View
93 src/swganh_core/object/object.cc
@@ -145,10 +145,10 @@ void Object::TransferObject(std::shared_ptr<Object> requester, std::shared_ptr<O
boost::upgrade_to_unique_lock<boost::shared_mutex> unique(uplock);
//Perform the transfer
- //for(auto& slot : slot_descriptor_)
- //{
- // slot.second->remove_object(object);
- //}
+ for(auto& slot : slot_descriptor_)
+ {
+ slot.second->remove_object(object);
+ }
arrangement_id = newContainer->__InternalInsert(object, new_position, arrangement_id);
}
@@ -370,15 +370,13 @@ void Object::__InternalTransfer(std::shared_ptr<Object> requester, std::shared_p
void Object::__InternalAddAwareObject(std::shared_ptr<swganh::object::Object> object, bool reverse_still_valid)
{
- std::shared_ptr<ObserverInterface> observer;
-
auto find_itr = aware_objects_.find(object);
if(find_itr == aware_objects_.end())
{
aware_objects_.insert(object);
if(!IsInSnapshot())
{
- observer = object->GetController();
+ auto observer = object->GetController();
if(observer)
{
Subscribe(observer);
@@ -386,34 +384,21 @@ void Object::__InternalAddAwareObject(std::shared_ptr<swganh::object::Object> ob
CreateBaselines(observer);
}
}
- }
-
- find_itr = object->aware_objects_.find(shared_from_this());
- if(find_itr == object->aware_objects_.end())
- {
- object->aware_objects_.insert(shared_from_this());
- if(!object->IsInSnapshot())
+
+ bool old_reverse = reverse_still_valid;
+ reverse_still_valid = GetPermissions()->canView(shared_from_this(), object);
+
+ for(auto& slot : slot_descriptor_)
{
- observer = GetController();
- if(observer)
- {
- object->Subscribe(observer);
- object->SendCreateByCrc(observer);
- object->CreateBaselines(observer);
- }
+ slot.second->view_objects([&] (const std::shared_ptr<Object>& v) {
+ if(old_reverse)
+ object->__InternalAddAwareObject(v, false);
+
+ if(reverse_still_valid)
+ v->__InternalAddAwareObject(object, reverse_still_valid);
+ });
}
}
-
- for(auto& slot : slot_descriptor_)
- {
- slot.second->view_objects([&] (const std::shared_ptr<Object>& v) {
- v->__InternalAddAwareObject(object, reverse_still_valid);
- if(reverse_still_valid)
- {
- object->__InternalAddAwareObject(v, reverse_still_valid);
- }
- });
- }
}
void Object::__InternalViewAwareObjects(std::function<void(std::shared_ptr<swganh::object::Object>)> func, std::shared_ptr<swganh::object::Object> hint)
@@ -423,25 +408,28 @@ void Object::__InternalViewAwareObjects(std::function<void(std::shared_ptr<swgan
void Object::__InternalRemoveAwareObject(std::shared_ptr<swganh::object::Object> object, bool reverse_still_valid)
{
- for(auto& slot : slot_descriptor_)
- {
- slot.second->view_objects([&] (const std::shared_ptr<Object>& v) {
- v->__InternalRemoveAwareObject(object, reverse_still_valid);
- if(!reverse_still_valid)
- {
- object->__InternalRemoveAwareObject(v, reverse_still_valid);
- }
- });
- }
-
- std::shared_ptr<ObserverInterface> observer;
auto find_itr = aware_objects_.find(object);
if(find_itr != aware_objects_.end())
{
+ bool old_reverse = reverse_still_valid;
+ reverse_still_valid = GetPermissions()->canView(shared_from_this(), object);
+
+ for(auto& slot : slot_descriptor_)
+ {
+ slot.second->view_objects([&] (const std::shared_ptr<Object>& v) {
+ if(reverse_still_valid)
+ v->__InternalRemoveAwareObject(object, reverse_still_valid);
+
+ if(old_reverse)
+ object->__InternalRemoveAwareObject(v, false);
+ });
+ }
+
aware_objects_.erase(find_itr);
+
if(!IsInSnapshot())
{
- observer = object->GetController();
+ auto observer = object->GetController();
if(observer)
{
//DLOG(info) << "DELETING " << GetObjectId() << " FOR " << observer->GetId();
@@ -450,21 +438,6 @@ void Object::__InternalRemoveAwareObject(std::shared_ptr<swganh::object::Object>
}
}
}
-
- find_itr = object->aware_objects_.find(shared_from_this());
- if(find_itr != object->aware_objects_.end())
- {
- object->aware_objects_.erase(find_itr);
- if(!object->IsInSnapshot())
- {
- observer = GetController();
- if(observer)
- {
- object->SendDestroy(observer);
- object->Unsubscribe(observer);
- }
- }
- }
}
bool Object::__HasAwareObject(std::shared_ptr<Object> object)
Please sign in to comment.
Something went wrong with that request. Please try again.