本文整理汇总了C++中ManagedReference::broadcastMessagePrivate方法的典型用法代码示例。如果您正苦于以下问题:C++ ManagedReference::broadcastMessagePrivate方法的具体用法?C++ ManagedReference::broadcastMessagePrivate怎么用?C++ ManagedReference::broadcastMessagePrivate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ManagedReference
的用法示例。
在下文中一共展示了ManagedReference::broadcastMessagePrivate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: broadcastMessagePrivate
void SceneObjectImplementation::broadcastMessagePrivate(BasePacket* message, SceneObject* selfObject, bool lockZone) {
ZoneServer* zoneServer = getZoneServer();
if (zoneServer != NULL && zoneServer->isServerLoading())
return;
if (parent.get() != NULL) {
ManagedReference<SceneObject*> grandParent = cast<SceneObject*>(getRootParent().get().get());
if (grandParent != NULL) {
grandParent->broadcastMessagePrivate(message, selfObject, lockZone);
return;
} else {
delete message;
return;
}
}
if (zone == NULL) {
delete message;
return;
}
//Locker zoneLocker(zone);
//getZone()->rlock(lockZone);
// bool readlock = lockZone && !zone->isLockedByCurrentThread();
SortedVector<ManagedReference<QuadTreeEntry*> >* closeSceneObjects = NULL;
SortedVector<ManagedReference<QuadTreeEntry*> >* closeNoneReference = NULL;
int maxInRangeObjectCount = 0;
bool deleteVector = true;
try {
// zone->rlock(readlock);
if (closeobjects == NULL) {
info(String::valueOf(getObjectID()) + " Null closeobjects vector in SceneObjectImplementation::broadcastMessagePrivate", true);
closeSceneObjects = new SortedVector<ManagedReference<QuadTreeEntry*> >();
zone->getInRangeObjects(getPositionX(), getPositionY(), 192, closeSceneObjects, true);
maxInRangeObjectCount = closeSceneObjects->size();
deleteVector = true;
} else {
// maxInRangeObjectCount = closeobjects->size();
//closeSceneObjects = closeobjects;
closeNoneReference = new SortedVector<ManagedReference<QuadTreeEntry*> >(maxInRangeObjectCount, 50);
/* for (int i = 0; i < closeobjects->size(); ++i) {
closeNoneReference->add(closeobjects->get(i).get());
}
*/
closeobjects->safeCopyTo(*closeNoneReference);
maxInRangeObjectCount = closeNoneReference->size();
//closeSceneObjects.removeAll(maxInRangeObjectCount, 10);
//closeSceneObjects.addAll(*closeobjects);
}
/*
for (int i = 0; i < maxInRangeObjectCount; ++i) {
SceneObject* scno = cast<SceneObject*>(closeSceneObjects->get(i).get());
if (selfObject == scno)
continue;
ManagedReference<ZoneClientSession*> client = scno->getClient();
if (client != NULL || scno->isVehicleObject()) {
scno->sendMessage(message->clone());
}
}
*/
//zone->runlock(readlock);
} catch (...) {
// zone->runlock(readlock);
delete message;
throw;
}
for (int i = 0; i < maxInRangeObjectCount; ++i) {
SceneObject* scno;
if (closeSceneObjects != NULL)
scno = cast<SceneObject*>(closeSceneObjects->get(i).get());
else
scno = cast<SceneObject*>(closeNoneReference->get(i).get());
//.........这里部分代码省略.........
示例2: broadcastMessagePrivate
void SceneObjectImplementation::broadcastMessagePrivate(BasePacket* message, SceneObject* selfObject, bool lockZone) {
ZoneServer* zoneServer = getZoneServer();
if (zoneServer != NULL && zoneServer->isServerLoading())
return;
if (parent.get() != NULL) {
ManagedReference<SceneObject*> grandParent = getRootParent().get();
if (grandParent != NULL) {
grandParent->broadcastMessagePrivate(message, selfObject, lockZone);
return;
} else {
delete message;
return;
}
}
if (zone == NULL) {
delete message;
return;
}
SortedVector<ManagedReference<QuadTreeEntry*> >* closeSceneObjects = NULL;
SortedVector<ManagedReference<QuadTreeEntry*> >* closeNoneReference = NULL;
int maxInRangeObjectCount = 0;
bool deleteVector = true;
try {
if (closeobjects == NULL) {
info(String::valueOf(getObjectID()) + " Null closeobjects vector in SceneObjectImplementation::broadcastMessagePrivate", true);
closeSceneObjects = new SortedVector<ManagedReference<QuadTreeEntry*> >();
zone->getInRangeObjects(getPositionX(), getPositionY(), 192, closeSceneObjects, true);
maxInRangeObjectCount = closeSceneObjects->size();
deleteVector = true;
} else {
closeNoneReference = new SortedVector<ManagedReference<QuadTreeEntry*> >(maxInRangeObjectCount, 50);
closeobjects->safeCopyTo(*closeNoneReference);
maxInRangeObjectCount = closeNoneReference->size();
}
} catch (Exception& e) {
error(e.getMessage());
e.printStackTrace();
delete message;
throw;
} catch (...) {
delete message;
throw;
}
for (int i = 0; i < maxInRangeObjectCount; ++i) {
SceneObject* scno;
if (closeSceneObjects != NULL)
scno = static_cast<SceneObject*>(closeSceneObjects->get(i).get());
else
scno = static_cast<SceneObject*>(closeNoneReference->get(i).get());
ManagedReference<ZoneClientSession*> client = scno->getClient();
if (scno->isVehicleObject() || client != NULL || scno->isMount())
scno->sendMessage(message->clone());
}
delete message;
if (closeSceneObjects != NULL)
delete closeSceneObjects;
else
delete closeNoneReference;
}