本文整理汇总了C++中PlayerObject::checkKnownObjects方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerObject::checkKnownObjects方法的具体用法?C++ PlayerObject::checkKnownObjects怎么用?C++ PlayerObject::checkKnownObjects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerObject
的用法示例。
在下文中一共展示了PlayerObject::checkKnownObjects方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _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());
}
示例2: _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());
}
示例3: playerWorldUpdate
//.........这里部分代码省略.........
{
// gLogger->logMsgF("... but to close to last update pos, %.1f",MSG_NORMAL, player->mPosition.distance2D(player->getLastUpdatePosition()));
}
}
}
}
else
{
mMovementInactivityTrigger = 2; // We only check this when we are running idle with slow frequency
// Need to be standstill for this amount of seconds * 5 (or whatever time we use for slow updates) before we update.
}
}
// Position check for SI-update.
OutOfUpdateRange |= !(glm::distance(player->mPosition, player->getLastUpdatePosition()) < 64.0f);
//OutOfUpdateRange |= !(player->mPosition.inRange2D(player->getLastUpdatePosition(),64.0f));
// gLogger->logMsgF("Distance = %f",MSG_NORMAL, player->mPosition.distance2D(player->getLastUpdatePosition()));
if (mUpdatingObjects || forcedUpdate || OutOfUpdateRange)
{
// More than 64 m from where we loaded SI, reload it.
// We need to abort any pending operation if we get a forcedUpdate (meaning entered, changed or left a cell or subzone).
if ((forcedUpdate) || OutOfUpdateRange)
{
// Save these coordinates
// gLogger->logMsg("forcedUpdate");
mDestroyOutOfRangeObjects = false; // Stop the destroy-messages, in case we already have started to send them.
if (OutOfUpdateRange)
{
// gLogger->logMsg("Out of 64m range");
player->setLastUpdatePosition(player->mPosition);
//If our player is mounted let's update his mount
if(player->checkIfMounted() && player->getMount())
{
player->getMount()->setLastUpdatePosition(player->mPosition);
}
// We shall destroy out of range objects when we are done with the update of known objects.
mDestroyOutOfRangeObjects = true;
}
_findInRangeObjectsOutside(true);
}
}
else if (!mDestroyOutOfRangeObjects)
{
// This is the fast update, based on qt.
// gLogger->logMsg("_findInRangeObjectsOutside(false)");
_findInRangeObjectsOutside(false);
}
// Update some of the objects we found.
mUpdatingObjects = !_updateInRangeObjectsOutside();
if (!mUpdatingObjects)
{
// We are not updating new objects.
if (mDestroyOutOfRangeObjects)
{
// We are ready to destroy objects out of range.
if (_destroyOutOfRangeObjects(&mInRangeObjects))
{
// All objects are now destroyed.
mDestroyOutOfRangeObjects = false;
// If active target out of range, clear.
if (player->getTarget())
{
// gLogger->logMsgF("playerWorldUpdate have a Target of type %d", MSG_NORMAL, player->getTarget()->getType());
// The list of objects we shall check for untargeting consist of all objects that we can "interact with".
if ((player->getTarget()->getType() & (ObjType_Player | ObjType_NPC | ObjType_Creature)) ||
((player->getTarget()->getType() == ObjType_Tangible) && (dynamic_cast<TangibleObject*>(player->getTarget())->getTangibleGroup() == TanGroup_TicketCollector)))
{
if (!(player->checkKnownObjects(player->getTarget())))
{
player->setTarget(NULL);
gMessageLib->sendTargetUpdateDeltasCreo6(player);
// gLogger->logMsg("playerWorldUpdate clear Target");
}
}
}
}
}
}
}
uint64 msToWait = 4900; // Will give 5 sec.
if (mUpdatingObjects || mDestroyOutOfRangeObjects)
{
// We are busy, need to continue processing asap.
msToWait = 900; // This should make us tick every second, since that's the base time for the timer we use.
}
return msToWait;
}