本文整理汇总了C++中PlayerObject::addKnownObjectSafe方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerObject::addKnownObjectSafe方法的具体用法?C++ PlayerObject::addKnownObjectSafe怎么用?C++ PlayerObject::addKnownObjectSafe使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerObject
的用法示例。
在下文中一共展示了PlayerObject::addKnownObjectSafe方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initPlayersInRange
void WorldManager::initPlayersInRange(Object* object,PlayerObject* player)
{
// we still query for players here, cause they are found through the buildings and arent kept in a qtree
ObjectSet inRangeObjects;
mSpatialIndex->getObjectsInRange(object,&inRangeObjects,(ObjType_Player),gWorldConfig->getPlayerViewingRange());
// query the according qtree, if we are in one
if(object->getSubZoneId())
{
if(QTRegion* region = getQTRegion(object->getSubZoneId()))
{
float viewingRange = _GetMessageHeapLoadViewingRange();
//float viewingRange = (float)gWorldConfig->getPlayerViewingRange();
Anh_Math::Rectangle qRect;
if(!object->getParentId())
{
qRect = Anh_Math::Rectangle(object->mPosition.x - viewingRange,object->mPosition.z - viewingRange,viewingRange * 2,viewingRange * 2);
}
else
{
CellObject* cell = dynamic_cast<CellObject*>(getObjectById(object->getParentId()));
BuildingObject* building = dynamic_cast<BuildingObject*>(getObjectById(cell->getParentId()));
qRect = Anh_Math::Rectangle(building->mPosition.x - viewingRange,building->mPosition.z - viewingRange,viewingRange * 2,viewingRange * 2);
}
region->mTree->getObjectsInRange(object,&inRangeObjects,ObjType_Player,&qRect);
}
}
// iterate through the results
ObjectSet::iterator it = inRangeObjects.begin();
while(it != inRangeObjects.end())
{
PlayerObject* pObject = dynamic_cast<PlayerObject*>(*it);
if(pObject)
{
if(pObject != player)
{
gMessageLib->sendCreateObject(object,pObject);
pObject->addKnownObjectSafe(object);
object->addKnownObjectSafe(pObject);
}
}
++it;
}
}
示例2: createObjectForKnownPlayers
void WorldManager::createObjectForKnownPlayers(PlayerObjectSet* knownPlayers, Object* object)
{
PlayerObjectSet::iterator it = knownPlayers->begin();
while(it != knownPlayers->end())
{
PlayerObject* targetObject = (*it);
gMessageLib->sendCreateObject(object,targetObject);
targetObject->addKnownObjectSafe(object);
object->addKnownObjectSafe(targetObject);
++it;
}
}
示例3: createObjectinWorld
void WorldManager::createObjectinWorld(Object* object)
{
float viewingRange = _GetMessageHeapLoadViewingRange();
ObjectSet inRangeObjects;
mSpatialIndex->getObjectsInRange(object,&inRangeObjects,(ObjType_Player),viewingRange);
// query the according qtree, if we are in one
if(object->getSubZoneId())
{
if(QTRegion* region = getQTRegion(object->getSubZoneId()))
{
Anh_Math::Rectangle qRect;
if(!object->getParentId())
{
qRect = Anh_Math::Rectangle(object->mPosition.x - viewingRange,object->mPosition.z - viewingRange,viewingRange * 2,viewingRange * 2);
}
else
{
CellObject* cell = dynamic_cast<CellObject*>(getObjectById(object->getParentId()));
if(BuildingObject* house = dynamic_cast<BuildingObject*>(getObjectById(cell->getParentId())))
{
qRect = Anh_Math::Rectangle(house->mPosition.x - viewingRange,house->mPosition.z - viewingRange,viewingRange * 2,viewingRange * 2);
}
}
region->mTree->getObjectsInRange(object,&inRangeObjects,ObjType_Player,&qRect);
}
}
// iterate through the results
ObjectSet::iterator it = inRangeObjects.begin();
while(it != inRangeObjects.end())
{
PlayerObject* player = dynamic_cast<PlayerObject*> (*it);
if(player)
{
// send create for the type of object
if (object->getPrivateOwner()) //what is this about ?? does it concern instances ????
{
if (object->isOwnedBy(player))
{
gMessageLib->sendCreateObject(object,player);
object->addKnownObjectSafe(player);
player->addKnownObjectSafe(object);
}
}
else
{
gMessageLib->sendCreateObject(object,player);
object->addKnownObjectSafe(player);
player->addKnownObjectSafe(object);
}
}
++it;
}
}
示例4: _updateInRangeObjectsInside
bool ObjectController::_updateInRangeObjectsInside()
{
PlayerObject* player = dynamic_cast<PlayerObject*>(mObject);
CellObject* playerCell = dynamic_cast<CellObject*>(gWorldManager->getObjectById(player->getParentId()));
// make sure we got a cell
if (!playerCell)
{
gLogger->logMsgF("Error getting cell %"PRIu64" for %"PRIu64" type %u",MSG_NORMAL,player->getParentId(),player->getId(),player->getType());
return true; // We are done, nothing we can do...
}
// We may wan't to limit the amount of messages sent in one session.
uint32 updatedObjects = 0;
const uint32 objectSendLimit = 50;
//what do we do if the object has been deleted in the meantime?
//TODO
while ((mObjectSetIt != mInRangeObjects.end()) && (updatedObjects < objectSendLimit))
{
// Object* object = (*mObjectSetIt);
// Needed since object may be invalid due to the multi-session approach of this function.
Object* object = dynamic_cast<Object*>(*mObjectSetIt);
// Create objects that are in the same building as we are OR outside near the building.
if ((object) && (!player->checkKnownObjects(object)))
{
bool validObject = true; // Assume it's an object we shall add.
// Object inside a building ?
if (object->getParentId())
{
validObject = false;
// Yes, get the objects cell.
CellObject* objectCell = dynamic_cast<CellObject*>(gWorldManager->getObjectById(object->getParentId()));
if (objectCell)
{
// Are we in the same building?
if (objectCell->getParentId() == playerCell->getParentId())
{
// We are in the same building as the object.
validObject = true;
}
}
else
{
gLogger->logMsgF("Error getting cell %"PRIu64" for %"PRIu64" type %u",MSG_NORMAL,object->getParentId(),object->getId(),object->getType());
}
}
if (validObject)
{
// send the according create for the type of object
#if defined(_MSC_VER)
if (object->getId() > 0x0000000100000000)
#else
if (object->getId() > 0x0000000100000000LLU)
#endif
{
//if its an instance and per chance *our* instance
if (object->getPrivateOwner()&&object->isOwnedBy(player))
{
gMessageLib->sendCreateObject(object,player);
player->addKnownObjectSafe(object);
object->addKnownObjectSafe(player);
updatedObjects++;
}
else
{
//if(!player->checkKnownObjects(object))
//{
gMessageLib->sendCreateObject(object,player);
player->addKnownObjectSafe(object);
object->addKnownObjectSafe(player);
updatedObjects++;
//}
}
}
}
}
++mObjectSetIt;
}
return (mObjectSetIt == mInRangeObjects.end());
}
示例5: _updateInRangeObjectsOutside
bool ObjectController::_updateInRangeObjectsOutside()
{
PlayerObject* player = dynamic_cast<PlayerObject*>(mObject);
// We may wan't to limit the amount of messages sent in one session.
uint32 updatedObjects = 0;
const uint32 objectSendLimit = 50;
while ((mObjectSetIt != mInRangeObjects.end()) && (updatedObjects < objectSendLimit))
{
//BEWARE Object is at this time possibly not valid anymore!
//this actually causes a lot of crashes!!!!
Object* object = dynamic_cast<Object*>(*mObjectSetIt);
// Just simplified the code a little. Good find Schmunzel.
// only add it if its also outside
// see if its already observed, if yes, just send a position update out, if its a player
if ((object) && (!player->checkKnownObjects(object)))
{
// send the according create for the type of object
#if defined(_MSC_VER)
if (object->getId() > 0x0000000100000000)
#else
if (object->getId() > 0x0000000100000000LLU)
#endif
{
if (object->getPrivateOwner())
{
if (object->isOwnedBy(player))
{
gMessageLib->sendCreateObject(object,player);
player->addKnownObjectSafe(object);
object->addKnownObjectSafe(player);
//If player has a mount make sure add to its known objects
//but is the mount even near us ???
// does this even matter ?
if(player->checkIfMountCalled() && player->getMount())
{
if(player->getMount()->getId() != object->getId())
{
player->getMount()->addKnownObjectSafe(object);
object->addKnownObjectSafe(player->getMount());
}
}
updatedObjects++;
}
}
else
{
//if(!player->checkKnownObjects(object))
//{
gMessageLib->sendCreateObject(object,player);
player->addKnownObjectSafe(object);
object->addKnownObjectSafe(player);
//If player has a mount make sure add to its known objects
if(player->checkIfMountCalled() && player->getMount())
{
if(player->getMount()->getId() != object->getId())
{
player->getMount()->addKnownObjectSafe(object);
object->addKnownObjectSafe(player->getMount());
}
}
//}
updatedObjects++;
}
}
}
++mObjectSetIt;
}
return (mObjectSetIt == mInRangeObjects.end());
}