当前位置: 首页>>代码示例>>C++>>正文


C++ ManagedReference::broadcastMessagePrivate方法代码示例

本文整理汇总了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());

//.........这里部分代码省略.........
开发者ID:blacknightownzjoo,项目名称:SWGOOW,代码行数:101,代码来源:SceneObjectImplementation.cpp

示例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;
}
开发者ID:angelsounds777,项目名称:Core3-CU,代码行数:81,代码来源:SceneObjectImplementation.cpp


注:本文中的ManagedReference::broadcastMessagePrivate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。