本文整理汇总了C++中ObjectSet类的典型用法代码示例。如果您正苦于以下问题:C++ ObjectSet类的具体用法?C++ ObjectSet怎么用?C++ ObjectSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ObjectSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: _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);
}
示例3: TEST_F
TEST_F(ObjectSetTest, SetRemoving) {
ObjectSet *objectSet = new ObjectSet();
A->addChild(B);
objectSet->add(A);
objectSet->add(C);
EXPECT_EQ(2, objectSet->size());
delete objectSet;
EXPECT_EQ("A", A->getName());
EXPECT_EQ("C", C->getName());
}
示例4: _GetMessageHeapLoadViewingRange
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: getTopArchetype
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: SEISCOMP_INFO
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
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: playerInRange
bool LairObject::playerInRange(float range)
{
ObjectSet inRangeObjects;
// ObjectSet::iterator objectSetIt;
// Make Set ready,
// inRangeObjects.clear();
// objectSetIt = mInRangeObjects.begin(); // Will point to end of Set
if (QTRegion* region = gWorldManager->getSI()->getQTRegion(this->mPosition.x, this->mPosition.z))
{
// gLogger->logMsg("LairObject::playerInRange Looking for players");
Anh_Math::Rectangle qRect = Anh_Math::Rectangle(this->mPosition.x - range, this->mPosition.z - range, range * 2, range * 2);
region->mTree->getObjectsInRange(this, &inRangeObjects, ObjType_Player, &qRect);
}
return !inRangeObjects.empty();
}
示例8: LOG_TRACE
MojErr MojDbSearchCursor::loadIds(ObjectSet& idsOut)
{
LOG_TRACE("Entering function %s", __FUNCTION__);
MojUInt32 groupNum = 0;
bool found = false;
MojSharedPtr<ObjectSet> group;
GroupMap groupMap;
for(;;) {
// get current id
MojObject id;
MojUInt32 idGroupNum = 0;
MojErr err = m_storageQuery->getId(id, idGroupNum, found);
MojErrCheck(err);
if (!found)
break;
// if it is in a new group, create a new set
if (!group.get() || idGroupNum != groupNum) {
// find/create new group
GroupMap::Iterator iter;
err = groupMap.find(idGroupNum, iter);
MojErrCheck(err);
if (iter != groupMap.end()) {
group = iter.value();
} else {
err = group.resetChecked(new ObjectSet);
MojErrCheck(err);
err = groupMap.put(idGroupNum, group);
MojErrCheck(err);
}
groupNum = idGroupNum;
}
// add id to current set
err = group->put(id);
MojErrCheck(err);
}
// no matches unless all groups are accounted for
MojUInt32 groupCount = m_storageQuery->groupCount();
for (MojUInt32 i = 0; i < groupCount; ++i) {
if (!groupMap.contains(i))
return MojErrNone;
}
// find intersection of all groups
GroupMap::ConstIterator begin = groupMap.begin();
for (GroupMap::ConstIterator i = begin; i != groupMap.end(); ++i) {
if (i == begin) {
// special handling for first group
idsOut = *(i.value());
} else {
MojErr err = idsOut.intersect(*(i.value()));
MojErrCheck(err);
}
}
return MojErrNone;
}
示例9: getTopArchetype
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() );
}
示例10: write_objset
bool write_objset(SerialOut &out, const ObjectSet& list) {
auto len = static_cast<uint32_t>(list.size());
out.out_.Write((const char*)&len, sizeof(len));
for (auto &obj : list) {
if (!write_obj(out, obj))
return false;
}
return out.out_;
}
示例11: getModifiedObjects
void ObjectModifyingUndoStep::getModifiedObjects(int part_index, ObjectSet& out) const
{
if (part_index == getPartIndex())
{
MapPart* const map_part = map->getPart(part_index);
for (std::vector<int>::const_iterator it = modified_objects.begin(), end = modified_objects.end(); it != end; ++it)
{
Q_ASSERT(*it >= 0 && *it < map_part->getNumObjects());
out.insert(map_part->getObject(*it));
}
}
}
示例12: while
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;
}
}
示例13: read_objset
bool read_objset(SerialIn &in, ObjectSet& list, const Config& config) {
#if 0
ObjectList lst;
if (!read_objlist(in, lst, config))
return false;
list.~ObjectSet();
new (&list) ObjectSet(lst.begin(), lst.end());
#else
uint32_t len;
in >= len;
for (size_t i = 0; i != len; ++i) {
rptr<Elf> obj;
if (!read_obj(in, obj, config))
return false;
list.insert(obj);
}
#endif
return in.in_;
}
示例14: while
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
//for(ObjectSet::const_iterator objIt = knownObjects->begin(); objIt != knownObjects->end(); objIt++)
//we access the list above so it needs to be reset to the beginning
objIt = knownObjects->begin();
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)//ObjType_Tangible
{
}
// send a destroy to us
gMessageLib->sendDestroyObject(object->getId(),player);
// we don't know each other anymore
knownObjects->erase(objIt++);
object->removeKnownObject(player);
if (++messageCount >= objectDestroyLimit)
{
break;
}
continue;
}
++objIt;
}
// For test
bool allDestroyed = false;
if (objIt == knownObjects->end())
{
allDestroyed = true;
}
return allDestroyed;
//.........这里部分代码省略.........
示例15: sprintf
MissionObject* MissionManager::generateCraftingMission(MissionObject* mission)
{
mission->setMissionType(crafting);
//TEMP!
string targets[8][2] =
{
{"@item_n:output_governor","object/tangible/mission/quest_item/shared_attunement_grid.iff"},
{"@item_n:current_alternator","object/tangible/mission/quest_item/shared_current_alternator.iff"},
{"@item_n:nym_hard_drive","object/tangible/loot/quest/shared_nym_hard_drive.iff"},
{"@item_n:hyperdrive_part_s01","object/tangible/loot/misc/shared_hyperdrive_part_s01.iff"},
{"@item_n:dermal_analyzer","object/tangible/loot/npc_loot/shared_dermal_analyzer_generic.iff"},
{"@item_n:feedback_controller","object/tangible/mission/quest_item/shared_feedback_controller.iff"},
{"@item_n:power_regulator","object/tangible/mission/quest_item/shared_power_regulator.iff"},
{"@item_n:attunement_grid","object/tangible/mission/quest_item/shared_attunement_grid.iff"}
};
int target_num = gRandom->getRand() % 8;
//END TEMP
//Randomly choose a crafting mission
int mission_num = (gRandom->getRand() % 50)+1;
mission->setNum(mission_num);
//Creator
mission->setCreator(creators[gRandom->getRand() % 9]);
//Title
sprintf(mt,"m%dt",mission_num);
mission->setTitleFile("mission/mission_npc_crafting_neutral_easy");
mission->setTitle(mt);
//Details
sprintf(md,"m%dd",mission_num);
mission->setDetailFile("mission/mission_npc_crafting_neutral_easy");
mission->setDetail(md);
//END TEMP
ObjectSet inRangeNPCs;
gWorldManager->getSI()->getObjectsInRange(mission->getOwner(),&inRangeNPCs,ObjType_NPC,1500);
uint32 cntLoop = 0;
//Start & End
bool found = false;
Location mission_start;
Location mission_dest;
ObjectSet::iterator it = inRangeNPCs.begin();
while(!found && !inRangeNPCs.empty())
{
cntLoop++;
++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)||(cntLoop > 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);
}
else
{
found = true;
}
}
}
}
//Difficulty
mission->setDifficulty((gRandom->getRand() % 41) + 40); //value from 30 - 80
//Reward
mission->setReward(mission->getDifficulty() * ((gRandom->getRand() % 14) + 15)); //Difficulty * rand: 15-28
//Target
mission->setTarget((targets[target_num][0]).getRawData()); //will need to be located from the db
//Mission Target
mission->setTargetModel((targets[target_num][1]).getCrc()); //crc = object/tangible/mission/quest_item/shared_attunement_grid.iff
return mission;
//.........这里部分代码省略.........