void CellObjectImplementation::destroyAllPlayerItems() { ManagedReference<SceneObject*> strongParent = getParent().get(); if (strongParent == NULL) return; int containerSize = getContainerObjectsSize(); for (int j = containerSize - 1; j >= 0; --j) { ReadLocker rlocker(getContainerLock()); ManagedReference<SceneObject*> containerObject = getContainerObject(j); rlocker.release(); if (strongParent->containsChildObject(containerObject)) continue; if (containerObject->isCreatureObject()) continue; containerObject->destroyObjectFromWorld(true); //containerObject->broadcastDestroy(containerObject, false); //removeObject(containerObject, false); containerObject->destroyObjectFromDatabase(true); } }
void CellObjectImplementation::notifyLoadFromDatabase() { // objects are added to the container twice because if insertToZone() called while the objects are loaded into the map //temproary fix //info("CellObjectImplementation::notifyLoadFromDatabase()", true); Vector<ManagedReference<SceneObject*> > tempObjects; for (int j = 0; j < getContainerObjectsSize(); ++j) { SceneObject* containerObject = getContainerObject(j); tempObjects.add(containerObject); } containerObjects.removeAll(); for (int i = 0; i < tempObjects.size(); ++i) { SceneObject* obj = tempObjects.get(i); putInContainer(obj, obj->getObjectID()); } SceneObjectImplementation::notifyLoadFromDatabase(); }
void SceneObjectImplementation::destroyObjectFromDatabase(bool destroyContainedObjects) { //info("deleting from database", true); if (isPlayerCreature()) { assert(0 && "attempting to delete a player creature from database"); } if(dataObjectComponent != NULL) { dataObjectComponent->notifyObjectDestroyingFromDatabase(); } ZoneServer* server = getZoneServer(); server->destroyObjectFromDatabase(getObjectID()); asSceneObject()->setPersistent(0); if (!destroyContainedObjects) return; SortedVector<ManagedReference<SceneObject*> > destroyedObjects; destroyedObjects.setNoDuplicateInsertPlan(); for (int i = 0; i < getSlottedObjectsSize(); ++i) { ManagedReference<SceneObject*> object = getSlottedObject(i); if (destroyedObjects.put(object) != -1) { Locker locker(object); object->destroyObjectFromDatabase(true); } } for (int j = 0; j < getContainerObjectsSize(); ++j) { ManagedReference<SceneObject*> object = getContainerObject(j); if (destroyedObjects.put(object) != -1) { Locker locker(object); object->destroyObjectFromDatabase(true); } } //Remove all child objects from database for (int i = 0; i < childObjects.size(); ++i) { ManagedReference<SceneObject*> child = childObjects.get(i); if (child == NULL) continue; Locker locker(child); child->destroyObjectFromDatabase(true); } }
int CellObjectImplementation::getCurrentNumberOfPlayerItems() { int count = 0; ManagedReference<SceneObject*> strongParent = getParent().get(); if (strongParent != NULL) { for (int j = 0; j < getContainerObjectsSize(); ++j) { ReadLocker rlocker(getContainerLock()); ManagedReference<SceneObject*> containerObject = getContainerObject(j); rlocker.release(); if (!strongParent->containsChildObject(containerObject) && !containerObject->isCreatureObject() && !containerObject->isVendor()) { if (containerObject->isContainerObject()) count += containerObject->getCountableObjectsRecursive(); ++count; } } } return count; }