本文整理汇总了C++中ObjectSet::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjectSet::begin方法的具体用法?C++ ObjectSet::begin怎么用?C++ ObjectSet::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectSet
的用法示例。
在下文中一共展示了ObjectSet::begin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
void City::update()
{
if(!mSubZoneId)
{
mQTRegion = mSI->getQTRegion(mPosition.x,mPosition.z);
mSubZoneId = (uint32)mQTRegion->getId();
mQueryRect = Anh_Math::Rectangle(mPosition.x - mWidth,mPosition.z - mHeight,mWidth * 2,mHeight * 2);
}
Object* object;
ObjectSet objList;
mSI->getObjectsInRange(this,&objList,ObjType_Player,mWidth);
if(mQTRegion)
{
mQTRegion->mTree->getObjectsInRange(this,&objList,ObjType_Player,&mQueryRect);
}
ObjectSet::iterator objIt = objList.begin();
while(objIt != objList.end())
{
object = (*objIt);
if(!(checkKnownObjects(object)))
{
onObjectEnter(object);
}
++objIt;
}
ObjectSet oldKnownObjects = mKnownObjects;
ObjectSet::iterator objSetIt = oldKnownObjects.begin();
while(objSetIt != oldKnownObjects.end())
{
object = (*objSetIt);
if(objList.find(object) == objList.end())
{
onObjectLeave(object);
}
++objSetIt;
}
}
示例2: loadObjects
MojErr MojDbSearchCursor::loadObjects(const ObjectSet& ids)
{
MojInt32 warns = 0;
for (ObjectSet::ConstIterator i = ids.begin(); i != ids.end(); ++i) {
// get item by id
MojObject obj;
MojDbStorageItem* item = NULL;
bool found = false;
MojErr err = m_storageQuery->getById(*i, item, found);
if (err == MojErrInternalIndexOnFind) {
warns++;
continue;
}
MojErrCheck(err);
if (found) {
// get object from item
err = item->toObject(obj, *m_kindEngine);
MojErrCheck(err);
// filter results
if (m_queryFilter.get() && !m_queryFilter->test(obj))
continue;
// create object item
MojRefCountedPtr<MojDbObjectItem> item(new MojDbObjectItem(obj));
MojAllocCheck(item.get());
// add to vec
err = m_items.push(item);
MojErrCheck(err);
}
}
if (warns > 0)
MojLogWarning(MojDb::s_log, _T("Search warnings: %d \n"), warns);
return MojErrNone;
}
示例3: _handleBoardTransport
void ObjectController::_handleBoardTransport(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
PlayerObject* playerObject = dynamic_cast<PlayerObject*>(mObject);
ObjectSet inRangeObjects;
float boardingRange = 25.0;
if(playerObject->states.getPosture() == CreaturePosture_SkillAnimating)
{
gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "wrong_state"), playerObject);
return;
}
BString str;
message->getStringUnicode16(str);
str.convert(BSTRType_ANSI);
str.toLower();
if((str.getCrc() != BString("transport").getCrc()))
{
gMessageLib->SendSystemMessage(::common::OutOfBand("travel", "boarding_what_shuttle"), playerObject);
return;
}
gSpatialIndexManager->getObjectsInRange(playerObject,&inRangeObjects,ObjType_Creature | ObjType_NPC, boardingRange, true);
// iterate through the results
ObjectSet::iterator it = inRangeObjects.begin();
while(it != inRangeObjects.end())
{
if(Shuttle* shuttle = dynamic_cast<Shuttle*>(*it))
{
// in range check
if(playerObject->getParentId() != shuttle->getParentId())
{
gMessageLib->SendSystemMessage(::common::OutOfBand("travel", "boarding_too_far"), playerObject);
return;
}
if (!shuttle->availableInPort())
{
gMessageLib->SendSystemMessage(::common::OutOfBand("travel", "shuttle_not_available"), playerObject);
return;
}
shuttle->useShuttle(playerObject);
return;
}
++it;
}
gMessageLib->SendSystemMessage(::common::OutOfBand("structure/structure_messages", "boarding_what_shuttle"), playerObject);
}
示例4: 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;
}
}
示例5: getAllInstanceEquivalent
SFUtils::ObjectSet SFUtils::getAllInstanceEquivalent( Udm::Object object ) {
Udm::Object archetype = getTopArchetype( object );
if ( archetype == Udm::null ) return ObjectSet();
ObjectList objectList;
objectList.push_back( archetype );
for( ObjectList::iterator oblItr = objectList.begin() ; oblItr != objectList.end() ; (void)++oblItr ) {
ObjectSet objectSet = oblItr->instances();
objectList.insert( objectList.end(), objectSet.begin(), objectSet.end() );
}
return ObjectSet( objectList.begin(), objectList.end() );
}
示例6: cleanUp
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
void Sync::cleanUp() {
SEISCOMP_INFO("Clean up inventory");
// Collect all untouched/remaining objects
ObjectSet toBeRemoved;
RemoveUntouchedObjects cleaner(_touchedObjects, toBeRemoved);
_inv->accept(&cleaner);
// Detach/delete them
ObjectSet::iterator it;
for ( it = toBeRemoved.begin(); it != toBeRemoved.end(); ++it )
(*it)->detach();
}
示例7: getAllInstanceEquivalent
SFUtils::ObjectSet SFUtils::getAllInstanceEquivalent( Udm::Object object ) {
Udm::Object archetype = getTopArchetype( object );
if ( archetype == Udm::null ) return ObjectSet();
ObjectList objectList;
/*objectList.push_back( archetype );
for( ObjectList::iterator oblItr = objectList.begin() ; oblItr != objectList.end() ; (void)++oblItr ) {*/
ObjectSet objectSet =archetype.instances();
for(ObjectSet::iterator obj_it=objectSet.begin();obj_it!=objectSet.end();++obj_it)
{
if(isFromSameSignalFlowModel(*obj_it))
objectList.push_back(*obj_it);
}
// objectList.insert( objectList.end(), objectSet.begin(), objectSet.end() );
//}
return ObjectSet( objectList.begin(), objectList.end() );
}
示例8: loadObjects
MojErr MojDbSearchCursor::loadObjects(const ObjectSet& ids)
{
LOG_TRACE("Entering function %s", __FUNCTION__);
MojInt32 warns = 0;
for (ObjectSet::ConstIterator i = ids.begin(); i != ids.end(); ++i) {
// get item by id
MojObject obj;
MojDbStorageItem* item = NULL;
bool found = false;
MojErr err = m_storageQuery->getById(*i, item, found);
if (err == MojErrInternalIndexOnFind) {
warns++;
continue;
}
MojErrCheck(err);
if (found) {
// get object from item
err = item->toObject(obj, *m_kindEngine);
MojErrCheck(err);
// filter results
if (m_queryFilter.get() && !MojBoolResult(m_queryFilter->test, obj))
continue;
// create object item
MojRefCountedPtr<MojDbObjectItem> item(new MojDbObjectItem(obj));
MojAllocCheck(item.get());
// add to vec
err = m_items.push(item);
MojErrCheck(err);
}
}
if (warns > 0)
LOG_DEBUG("[db_mojodb] Search warnings: %d \n", warns);
return MojErrNone;
}
示例9: generateDeliverMission
MissionObject* MissionManager::generateDeliverMission(MissionObject* mission)
{
mission->setMissionType(deliver);
//TEMP
missionData mission_deliver_hard[2] =
{
{"mission/mission_deliver_neutral_hard",25},
{"mission/mission_deliver_neutral_hard_non_persistent_from_npc",15},
};
//Randomly choose a stf file
int stf_file = gRandom->getRand() % 2;
//Randomly choose a mission in that file
int mission_num = (gRandom->getRand() % mission_deliver_hard[stf_file].num)+1;
mission->setNum(mission_num);
//END TEMP
ObjectSet inRangeNPCs;
gWorldManager->getSI()->getObjectsInRange(mission->getOwner(),&inRangeNPCs,ObjType_NPC,1500);
//Start & End
bool found = false;
Location mission_start;
Location mission_dest;
ObjectSet::iterator it = inRangeNPCs.begin();
//we may stall the main thread with the way it was done ???? however often enough the mission generation never finished!!!!!!!!!!!!!!!
//get a list containing all suitable npcs and generate a random number corresponding to one of the npcs
if(inRangeNPCs.size() < 2)
return NULL;
uint32 count = 0;
while(!found && !inRangeNPCs.empty())
{
count ++;
++it;
if(it == inRangeNPCs.end())
it = inRangeNPCs.begin();
NPCObject* npc = dynamic_cast<NPCObject*>(*it);
if(npc->getNpcFamily() == NpcFamily_Filler)
{
uint32 roll = (gRandom->getRand() / (RAND_MAX + 1ul) * (9 - 1) + 1);
if((roll = 5)||(count > inRangeNPCs.size()))
{
if(mission_dest.Coordinates.x == 0)
{
mission->setDestinationNPC(npc);
mission_dest.Coordinates = npc->mPosition;
mission_dest.CellID = 0;
mission_dest.PlanetCRC = BString(gWorldManager->getPlanetNameThis()).getCrc();
mission->setDestination(mission_dest);
}
else if(mission_start.Coordinates.x == 0 && mission->getDestinationNPC() != npc)
{
mission->setStartNPC(npc);
mission_start.Coordinates = npc->mPosition;
mission_start.CellID = 0;
mission_start.PlanetCRC = BString(gWorldManager->getPlanetNameThis()).getCrc();
mission->setStart(mission_start);
found = true;
}
}
}
}
//Creator
mission->setCreator(creators[gRandom->getRand() % 9]);
//Mission Title
sprintf(mt,"m%dt",mission_num);
mission->setTitleFile(mission_deliver_hard[stf_file].mSTF);
mission->setTitle(mt);
//Mission Description
sprintf(md,"m%dd",mission_num);
mission->setDetailFile(mission_deliver_hard[stf_file].mSTF);
mission->setDetail(md);
//Diffaculty
mission->setDifficulty((gRandom->getRand() % 10)+3);
//Payment
mission->setReward((gRandom->getRand() % 300)+50);
//Mission Target
mission->setTargetModel(0xE191DBAB); //crc = object/tangible/mission/shared_mission_datadisk.iff
//.........这里部分代码省略.........
示例10: update
void CampRegion::update()
{
//Camps have a max timer of 55 minutes
if(gWorldManager->GetCurrentGlobalTick() - mSetUpTime > 3300000)
{
//gLogger->logMsg("55 Minutes OLD! DEATH TO THE CAMP!", BACKGROUND_RED);
despawnCamp();
return;
}
if(mAbandoned)
{
if((gWorldManager->GetCurrentGlobalTick() >= mExpiresTime) && (!mDestroyed))
{
despawnCamp();
}
}
PlayerObject* owner = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(mOwnerId));
if(!owner)
{
despawnCamp();
return;
}
if(owner->checkState(CreatureState_Combat))
{
//abandon
mAbandoned = true;
mExpiresTime = gWorldManager->GetCurrentGlobalTick(); //There is no grace period for combat.
return;
}
if(!mSubZoneId)
{
mQTRegion = mSI->getQTRegion(mPosition.x,mPosition.z);
mSubZoneId = (uint32)mQTRegion->getId();
mQueryRect = Anh_Math::Rectangle(mPosition.x - mWidth,mPosition.z - mHeight,mWidth*2,mHeight*2);
}
Object* object;
ObjectSet objList;
if(mParentId)
{
mSI->getObjectsInRange(this,&objList,ObjType_Player,mWidth);
}
if(mQTRegion)
{
mQTRegion->mTree->getObjectsInRangeContains(this,&objList,ObjType_Player,&mQueryRect);
}
ObjectSet::iterator objIt = objList.begin();
while(objIt != objList.end())
{
object = (*objIt);
//one xp per player in camp every 2 seconds
if(!mAbandoned)
{
applyHAMHealing(object);
mXp++;
}
if(!(checkKnownObjects(object)))
{
onObjectEnter(object);
std::list<campLink*>::iterator i;
bool alreadyExists = false;
for(i = links.begin(); i != links.end(); i++)
{
if((*i)->objectID == object->getId())
{
alreadyExists = true;
}
}
if(!alreadyExists)
{
//gLogger->logMsg("CREATING A NEW LINK!");
campLink* temp = new campLink;
temp->objectID = object->getId();
temp->lastSeenTime = gWorldManager->GetCurrentGlobalTick();
temp->tickCount = 0;
links.push_back(temp);
}
}
else
{
//gLogger->logMsg("HANDLING TICK!");
//Find the right link
std::list<campLink*>::iterator i;
for(i = links.begin(); i != links.end(); i++)
//.........这里部分代码省略.........
示例11: configureIndexes
MojErr MojDbKind::configureIndexes(const MojObject& obj, const MojString& locale, MojDbReq& req)
{
MojLogTrace(s_log);
// make sure indexes changes count against our usage
MojErr err = req.curKind(this);
MojErrCheck(err);
// add default id index to set
MojObject idIndex;
err = idIndex.fromJson(IdIndexJson);
MojErrCheck(err);
ObjectSet newIndexObjects;
err = newIndexObjects.put(idIndex);
MojErrCheck(err);
// change back to a set and use contains
MojSet<MojString> indexNames;
MojString defaultIdxName;
err = defaultIdxName.assign(IdIndexName);
MojErrCheck(err);
err = indexNames.put(defaultIdxName);
MojErrCheck(err);
// add indexes to set to uniquify and order them
MojObject indexArray;
if (obj.get(IndexesKey, indexArray)) {
MojObject::ConstArrayIterator end = indexArray.arrayEnd();
for (MojObject::ConstArrayIterator i = indexArray.arrayBegin(); i != end; ++i) {
MojString indexName;
err = i->getRequired(MojDbIndex::NameKey, indexName);
MojErrCheck(err);
err = indexName.toLower();
MojErrCheck(err);
if (!indexNames.contains(indexName)) {
MojObject idx = *i;
// make sure we keep the lower-cased index name
err = idx.putString(MojDbIndex::NameKey, indexName);
MojErrCheck(err);
err = newIndexObjects.put(idx);
MojErrCheck(err);
err = indexNames.put(indexName);
MojErrCheck(err);
} else {
MojErrThrowMsg(MojErrDbInvalidIndexName, _T("db: cannot repeat index name: '%s'"), indexName.data());
}
}
}
// figure out what to add and what to delete
ObjectSet toDrop;
err = m_indexObjects.diff(newIndexObjects, toDrop);
MojErrCheck(err);
ObjectSet toAdd;
err = newIndexObjects.diff(m_indexObjects, toAdd);
MojErrCheck(err);
// drop deleted indexes
IndexVec newIndexes;
for (IndexVec::ConstIterator i = m_indexes.begin(); i != m_indexes.end(); ++i) {
if (toDrop.contains((*i)->object())) {
err = dropIndex(i->get(), req);
MojErrCheck(err);
} else {
err = newIndexes.push(*i);
MojErrCheck(err);
}
}
// add new indexes
for (ObjectSet::ConstIterator i = toAdd.begin(); i != toAdd.end(); ++i) {
// create index
MojRefCountedPtr<MojDbIndex> index(new MojDbIndex(this, m_kindEngine));
MojAllocCheck(index.get());
err = index->fromObject(*i, locale);
MojErrCheck(err);
// open index
err = openIndex(index.get(), req);
MojErrCheck(err);
err = newIndexes.push(index);
MojErrCheck(err);
}
// sort indexes by the prop vec so that for indexes that share prop prefixes, the shortest one comes first
err = newIndexes.sort();
MojErrCheck(err);
// update members
m_indexObjects = newIndexObjects;
m_indexes = newIndexes;
return MojErrNone;
}
示例12: die
void CreatureObject::die()
{
mIncapCount = 0;
mCurrentIncapTime = 0;
mFirstIncapTime = 0;
// gLogger->logMsg("CreatureObject::die I'm dead");
gMessageLib->sendIncapTimerUpdate(this);
if(PlayerObject* player = dynamic_cast<PlayerObject*>(this))
{
gMessageLib->sendSystemMessage(player,L"","base_player","victim_dead");
player->disableAutoAttack();
}
mPosture = CreaturePosture_Dead;
// reset ham regeneration
mHam.updateRegenRates();
gWorldManager->removeCreatureHamToProcess(mHam.getTaskId());
mHam.setTaskId(0);
updateMovementProperties();
// clear states
mState = 0;
gMessageLib->sendPostureAndStateUpdate(this);
if(PlayerObject* player = dynamic_cast<PlayerObject*>(this))
{
gMessageLib->sendUpdateMovementProperties(player);
gMessageLib->sendSelfPostureUpdate(player);
// update duel lists
PlayerList::iterator duelIt = player->getDuelList()->begin();
while(duelIt != player->getDuelList()->end())
{
if((*duelIt)->checkDuelList(player))
{
PlayerObject* duelPlayer = (*duelIt);
duelPlayer->removeFromDuelList(player);
gMessageLib->sendUpdatePvpStatus(player,duelPlayer);
gMessageLib->sendUpdatePvpStatus(duelPlayer,player);
}
++duelIt;
}
player->getDuelList()->clear();
// update defender lists
ObjectIDList::iterator defenderIt = mDefenders.begin();
while (defenderIt != mDefenders.end())
{
if (CreatureObject* defenderCreature = dynamic_cast<CreatureObject*>(gWorldManager->getObjectById((*defenderIt))))
{
defenderCreature->removeDefenderAndUpdateList(this->getId());
if (PlayerObject* defenderPlayer = dynamic_cast<PlayerObject*>(defenderCreature))
{
gMessageLib->sendUpdatePvpStatus(this,defenderPlayer);
// gMessageLib->sendDefenderUpdate(defenderPlayer,0,0,this->getId());
}
// Defender not hostile to me any more.
gMessageLib->sendUpdatePvpStatus(defenderCreature, player);
// if no more defenders, clear combat state
if (!defenderCreature->getDefenders()->size())
{
defenderCreature->toggleStateOff((CreatureState)(CreatureState_Combat + CreatureState_CombatAttitudeNormal));
gMessageLib->sendStateUpdate(defenderCreature);
}
}
// If we remove self from all defenders, then we should remove all defenders from self. Remember, we are dead.
defenderIt = mDefenders.erase(defenderIt);
}
// bring up the clone selection window
ObjectSet inRangeBuildings;
BStringVector buildingNames;
std::vector<BuildingObject*> buildings;
BuildingObject* nearestBuilding = NULL;
BuildingObject* preDesignatedBuilding = NULL;
// Search for cloning facilities.
gWorldManager->getSI()->getObjectsInRange(this,&inRangeBuildings,ObjType_Building,8192);
ObjectSet::iterator buildingIt = inRangeBuildings.begin();
while (buildingIt != inRangeBuildings.end())
{
BuildingObject* building = dynamic_cast<BuildingObject*>(*buildingIt);
if (building)
{
// Do we have any personal clone location?
//.........这里部分代码省略.........
示例13: 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;
}
}
示例14: initObjectsInRange
void WorldManager::initObjectsInRange(PlayerObject* playerObject)
{
float viewingRange = _GetMessageHeapLoadViewingRange();
//if we are in a playerbuilding create the playerbuilding first
//otherwise our items will not show when they are created before the cell
if(CellObject* cell = dynamic_cast<CellObject*>(gWorldManager->getObjectById(playerObject->getParentId())))
{
if(HouseObject* playerHouse = dynamic_cast<HouseObject*>(gWorldManager->getObjectById(cell->getParentId())))
{
//gLogger->logMsgF("create playerbuilding",MSG_HIGH);
gMessageLib->sendCreateObject(playerHouse,playerObject);
playerHouse->addKnownObjectSafe(playerObject);
playerObject->addKnownObjectSafe(playerHouse);
}
}
// we still query for players here, cause they are found through the buildings and arent kept in a qtree
ObjectSet inRangeObjects;
mSpatialIndex->getObjectsInRange(playerObject,&inRangeObjects,(ObjType_Player | ObjType_Tangible | ObjType_NPC | ObjType_Creature | ObjType_Building | ObjType_Structure ),viewingRange);
// query the according qtree, if we are in one
if(playerObject->getSubZoneId())
{
if(QTRegion* region = getQTRegion(playerObject->getSubZoneId()))
{
Anh_Math::Rectangle qRect;
if(!playerObject->getParentId())
{
qRect = Anh_Math::Rectangle(playerObject->mPosition.x - viewingRange,playerObject->mPosition.z - viewingRange,viewingRange * 2,viewingRange * 2);
}
else
{
CellObject* cell = dynamic_cast<CellObject*>(getObjectById(playerObject->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(playerObject,&inRangeObjects,ObjType_Player,&qRect);
}
}
// iterate through the results
ObjectSet::iterator it = inRangeObjects.begin();
while(it != inRangeObjects.end())
{
Object* object = (*it);
// send create for the type of object
if (object->getPrivateOwner()) //what is this about ?? does it concern instances ????
{
if (object->isOwnedBy(playerObject))
{
gMessageLib->sendCreateObject(object,playerObject);
object->addKnownObjectSafe(playerObject);
playerObject->addKnownObjectSafe(object);
}
}
else
{
gMessageLib->sendCreateObject(object,playerObject);
object->addKnownObjectSafe(playerObject);
playerObject->addKnownObjectSafe(object);
}
++it;
}
}
示例15: _destroyOutOfRangeObjects
bool ObjectController::_destroyOutOfRangeObjects(ObjectSet *inRangeObjects)
{
//TODO: when a container gets out of range
//we need to destroy the children, too!!!!!!!
// iterate our knowns
PlayerObject* player = dynamic_cast<PlayerObject*>(mObject);
ObjectSet* knownObjects = player->getKnownObjects();
ObjectSet::iterator objIt = knownObjects->begin();
PlayerObjectSet* knownPlayers = player->getKnownPlayers();
PlayerObjectSet::iterator playerIt = knownPlayers->begin();
const uint32 objectDestroyLimit = 5000;
// update players
while(playerIt != knownPlayers->end())
{
PlayerObject* playerObject = (*playerIt);
// if its not in the current inrange queries result, destroy it
if(inRangeObjects->find(playerObject) == inRangeObjects->end())
{
// send a destroy to us
gMessageLib->sendDestroyObject(playerObject->getId(),player);
//If player is mounted destroy his mount too
if(playerObject->checkIfMounted() && playerObject->getMount())
{
gMessageLib->sendDestroyObject(playerObject->getMount()->getId(),player);
player->removeKnownObject(playerObject->getMount());
playerObject->getMount()->removeKnownObject(player);
}
//send a destroy to him
gMessageLib->sendDestroyObject(player->getId(),playerObject);
//If we're mounted destroy our mount too
if(player->checkIfMounted() && playerObject->getMount())
{
gMessageLib->sendDestroyObject(player->getMount()->getId(),playerObject);
playerObject->removeKnownObject(player->getMount());
player->getMount()->removeKnownObject(playerObject);
}
// we don't know each other anymore
knownPlayers->erase(playerIt++);
playerObject->removeKnownObject(player);
continue;
}
++playerIt;
}
// We may want to limit the amount of messages sent in one session.
uint32 messageCount = 0;
// update objects
while(objIt != knownObjects->end())
{
Object* object = (*objIt);
// if its not in the current inrange queries result, destroy it
if(inRangeObjects->find(object) == inRangeObjects->end())
{
if(object->getType() == ObjType_Structure)
{
if(FactoryObject* factory = dynamic_cast<FactoryObject*>(object))
{
//delete the hoppers contents
TangibleObject* hopper = dynamic_cast<TangibleObject*>(gWorldManager->getObjectById(factory->getIngredientHopper()));
if(hopper)
{
ObjectIDList* ol = hopper->getObjects();
ObjectIDList::iterator it = ol->begin();
while(it != ol->end())
{
TangibleObject* tO = dynamic_cast<TangibleObject*>(gWorldManager->getObjectById((*it)));
if(!tO)
{
assert(false && "ObjectController::_destroyOutOfRangeObjects WorldManager unable to find TangibleObject instance");
}
tO->removeKnownObject(player);
player->removeKnownObject(tO);
gMessageLib->sendDestroyObject(tO->getId(),player);
it++;
}
hopper->removeKnownObject(player);
player->removeKnownObject(hopper);
gMessageLib->sendDestroyObject(hopper->getId(),player);
}
//.........这里部分代码省略.........