本文整理汇总了C++中ManagedReference::cancelSession方法的典型用法代码示例。如果您正苦于以下问题:C++ ManagedReference::cancelSession方法的具体用法?C++ ManagedReference::cancelSession怎么用?C++ ManagedReference::cancelSession使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ManagedReference
的用法示例。
在下文中一共展示了ManagedReference::cancelSession方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: redeedStructure
int StructureManager::redeedStructure(CreatureObject* creature) {
ManagedReference<DestroyStructureSession*> session = creature->getActiveSession(SessionFacadeType::DESTROYSTRUCTURE).castTo<DestroyStructureSession*>();
if (session == NULL)
return 0;
ManagedReference<StructureObject*> structureObject =
session->getStructureObject();
if (structureObject == NULL)
return 0;
Locker _locker(structureObject);
ManagedReference<StructureDeed*> deed =
server->getObject(
structureObject->getDeedObjectID()).castTo<StructureDeed*>();
int maint = structureObject->getSurplusMaintenance();
int redeedCost = structureObject->getRedeedCost();
if (deed != NULL && structureObject->isRedeedable()) {
Locker _lock(deed, structureObject);
ManagedReference<SceneObject*> inventory = creature->getSlottedObject(
"inventory");
if (inventory == NULL || inventory->isContainerFull()) {
creature->sendSystemMessage("@player_structure:inventory_full"); //This installation can not be redeeded because your inventory does not have room to put the deed.
creature->sendSystemMessage(
"@player_structure:deed_reclaimed_failed"); //Structure destroy and deed reclaimed FAILED!
return session->cancelSession();
} else {
deed->setSurplusMaintenance(maint - redeedCost);
deed->setSurplusPower(structureObject->getSurplusPower());
structureObject->setDeedObjectID(0); //Set this to 0 so the deed doesn't get destroyed with the structure.
destroyStructure(structureObject);
inventory->transferObject(deed, -1, true);
inventory->broadcastObject(deed, true);
creature->sendSystemMessage("@player_structure:deed_reclaimed"); //Structure destroyed and deed reclaimed.
}
} else {
destroyStructure(structureObject);
creature->sendSystemMessage("@player_structure:structure_destroyed"); //Structured destroyed.
}
return session->cancelSession();
}
示例2: cancelConversationSession
void ConversationObserverImplementation::cancelConversationSession(CreatureObject* conversingPlayer, CreatureObject* npc, bool forceClose) {
ManagedReference<Facade*> session = conversingPlayer->getActiveSession(SessionFacadeType::CONVERSATION);
if (session != NULL) {
session->cancelSession();
}
conversingPlayer->dropActiveSession(SessionFacadeType::CONVERSATION);
conversingPlayer->dropObserver(ObserverEventType::POSITIONCHANGED, _this.get());
if (forceClose && npc != NULL)
conversingPlayer->sendMessage(new StopNpcConversation(conversingPlayer, npc->getObjectID()));
}
示例3: removeObject
//.........这里部分代码省略.........
while (closeObjects->size() > 0) {
ManagedReference<QuadTreeEntry*> obj = closeObjects->get(0);
if (obj != NULL && obj != object && obj->getCloseObjects() != NULL)
obj->removeInRangeObject(object);
object->removeInRangeObject((int) 0);
}
} catch (...) {
}
} else {
object->info("Null closeobjects vector in ZoneContainerComponent::removeObject", true);
SortedVector<ManagedReference<QuadTreeEntry*> > closeSceneObjects;
zone->getInRangeObjects(object->getPositionX(), object->getPositionY(), 512, &closeSceneObjects, false);
for (int i = 0; i < closeSceneObjects.size(); ++i) {
QuadTreeEntry* obj = closeSceneObjects.get(i);
if (obj != NULL && obj != object && obj->getCloseObjects() != NULL)
obj->removeInRangeObject(object);
}
}
// Zone* oldZone = zone;
zone = NULL;
oldZone->dropSceneObject(object);
SharedBuildingObjectTemplate* objtemplate = dynamic_cast<SharedBuildingObjectTemplate*>(object->getObjectTemplate());
if (objtemplate != NULL) {
String modFile = objtemplate->getTerrainModificationFile();
if (!modFile.isEmpty()) {
oldZone->getPlanetManager()->getTerrainManager()->removeTerrainModification(object->getObjectID());
}
}
zoneLocker.release();
if (object->isTangibleObject()) {
TangibleObject* tano = cast<TangibleObject*>(object);
Vector<ManagedReference<ActiveArea*> >* activeAreas = tano->getActiveAreas();
while (activeAreas->size() > 0) {
Locker _alocker(object->getContainerLock());
ManagedReference<ActiveArea*> area = activeAreas->get(0);
activeAreas->remove(0);
_alocker.release();
area->enqueueExitEvent(object);
}
}
SortedVector<ManagedReference<SceneObject*> >* childObjects = object->getChildObjects();
//Remove all outdoor child objects from zone
for (int i = 0; i < childObjects->size(); ++i) {
ManagedReference<SceneObject*> outdoorChild = childObjects->get(i);
if (outdoorChild == NULL)
continue;
if (outdoorChild->isInQuadTree()) {
Locker locker(outdoorChild);
outdoorChild->destroyObjectFromWorld(true);
}
}
} catch (Exception& e) {
}
object->notifyObservers(ObserverEventType::OBJECTREMOVEDFROMZONE, NULL, 0);
VectorMap<uint32, ManagedReference<Facade*> >* objectActiveSessions = object->getObjectActiveSessions();
while (objectActiveSessions->size()) {
ManagedReference<Facade*> facade = objectActiveSessions->remove(0).getValue();
if (facade == NULL)
continue;
facade->cancelSession();
}
//activeAreas.removeAll();
object->info("removed from zone");
object->notifyRemoveFromZone();
object->setZone(NULL);
return true;
}
示例4: transferObject
bool ContainerComponent::transferObject(SceneObject* sceneObject, SceneObject* object, int containmentType, bool notifyClient, bool allowOverflow) {
if (sceneObject == object) {
return false;
}
ManagedReference<SceneObject*> objParent = object->getParent();
ManagedReference<Zone*> objZone = object->getLocalZone();
if (object->containsActiveSession(SessionFacadeType::SLICING)) {
ManagedReference<Facade*> facade = object->getActiveSession(SessionFacadeType::SLICING);
ManagedReference<SlicingSession*> session = dynamic_cast<SlicingSession*>(facade.get());
if (session != NULL) {
session->cancelSession();
}
}
if (objParent != NULL || objZone != NULL) {
if (objParent != NULL)
objParent->removeObject(object, sceneObject, notifyClient);
if (object->getParent() != NULL) {
object->error("error removing from parent");
return false;
}
if (objZone != NULL)
objZone->remove(object);
object->setZone(NULL);
if (objParent == NULL)
objParent = objZone;
}
bool update = true;
VectorMap<String, ManagedReference<SceneObject*> >* slottedObjects = sceneObject->getSlottedObjects();
VectorMap<uint64, ManagedReference<SceneObject*> >* containerObjects = sceneObject->getContainerObjects();
//if (containerType == 1 || containerType == 5) {
if (containmentType >= 4) {
Locker contLocker(sceneObject->getContainerLock());
int arrangementGroup = containmentType - 4;
if (object->getArrangementDescriptorSize() > arrangementGroup) {
const Vector<String>* descriptors = object->getArrangementDescriptor(arrangementGroup);
for (int i = 0; i < descriptors->size(); ++i){
const String& childArrangement = descriptors->get(i);
if (slottedObjects->contains(childArrangement)) {
return false;
}
}
for (int i = 0; i < descriptors->size(); ++i) {
slottedObjects->put(descriptors->get(i), object);
}
} else {
return false;
}
object->setParent(sceneObject);
object->setContainmentType(containmentType);
} else if (containmentType == -1) { /* else if (containerType == 2 || containerType == 3) {*/
Locker contLocker(sceneObject->getContainerLock());
if (!allowOverflow && containerObjects->size() >= sceneObject->getContainerVolumeLimit()){
return false;
}
/*if (containerObjects.contains(object->getObjectID()))
return false*/
if (containerObjects->put(object->getObjectID(), object) == -1)
update = false;
object->setParent(sceneObject);
object->setContainmentType(containmentType);
} else {
sceneObject->error("unknown containment type " + String::valueOf(containmentType));
StackTrace::printStackTrace();
return false;
}
if ((containmentType >= 4) && objZone == NULL)
sceneObject->broadcastObject(object, true);
else if (notifyClient)
sceneObject->broadcastMessage(object->link(sceneObject->getObjectID(), containmentType), true);
notifyObjectInserted(sceneObject, object);
if (update) {
sceneObject->updateToDatabase();
//object->updateToDatabaseWithoutChildren()();
}
ManagedReference<SceneObject*> rootParent = object->getRootParent();
//.........这里部分代码省略.........
示例5: redeedStructure
int StructureManager::redeedStructure(CreatureObject* creature) {
ManagedReference<DestroyStructureSession*> session = creature->getActiveSession(SessionFacadeType::DESTROYSTRUCTURE).castTo<DestroyStructureSession*>();
if (session == NULL)
return 0;
ManagedReference<StructureObject*> structureObject =
session->getStructureObject();
if (structureObject == NULL)
return 0;
Locker _locker(structureObject);
ManagedReference<StructureDeed*> deed =
server->getObject(
structureObject->getDeedObjectID()).castTo<StructureDeed*>();
int maint = structureObject->getSurplusMaintenance();
int redeedCost = structureObject->getRedeedCost();
if (deed != NULL && structureObject->isRedeedable()) {
Locker _lock(deed, structureObject);
ManagedReference<SceneObject*> inventory = creature->getSlottedObject(
"inventory");
bool isSelfPoweredHarvester = false;
HarvesterObject* harvester = structureObject.castTo<HarvesterObject*>();
if(harvester != NULL)
isSelfPoweredHarvester = harvester->isSelfPowered();
if (inventory == NULL || inventory->getCountableObjectsRecursive() > (inventory->getContainerVolumeLimit() - (isSelfPoweredHarvester ? 2 : 1))) {
if(isSelfPoweredHarvester) {
//This installation can not be destroyed because there is no room for the Self Powered Harvester Kit in your inventory.
creature->sendSystemMessage("@player_structure:inventory_full_selfpowered");
} else {
//This installation can not be redeeded because your inventory does not have room to put the deed.
creature->sendSystemMessage("@player_structure:inventory_full");
}
creature->sendSystemMessage("@player_structure:deed_reclaimed_failed"); //Structure destroy and deed reclaimed FAILED!
return session->cancelSession();
} else {
if(isSelfPoweredHarvester) {
Reference<SceneObject*> rewardSceno = server->createObject(STRING_HASHCODE("object/tangible/veteran_reward/harvester.iff"), 1);
if( rewardSceno == NULL ){
creature->sendSystemMessage("@player_structure:deed_reclaimed_failed"); //Structure destroy and deed reclaimed FAILED!
return session->cancelSession();
}
// Transfer to player
if( !inventory->transferObject(rewardSceno, -1, false, true) ){ // Allow overflow
creature->sendSystemMessage("@player_structure:deed_reclaimed_failed"); //Structure destroy and deed reclaimed FAILED!
rewardSceno->destroyObjectFromDatabase(true);
return session->cancelSession();
}
harvester->setSelfPowered(false);
inventory->broadcastObject(rewardSceno, true);
creature->sendSystemMessage("@player_structure:selfpowered");
}
deed->setSurplusMaintenance(maint - redeedCost);
deed->setSurplusPower(structureObject->getSurplusPower());
structureObject->setDeedObjectID(0); //Set this to 0 so the deed doesn't get destroyed with the structure.
destroyStructure(structureObject);
inventory->transferObject(deed, -1, true);
inventory->broadcastObject(deed, true);
creature->sendSystemMessage("@player_structure:deed_reclaimed"); //Structure destroyed and deed reclaimed.
}
} else {
destroyStructure(structureObject);
creature->sendSystemMessage("@player_structure:structure_destroyed"); //Structured destroyed.
}
return session->cancelSession();
}