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


C++ ObjectSet::size方法代码示例

本文整理汇总了C++中ObjectSet::size方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjectSet::size方法的具体用法?C++ ObjectSet::size怎么用?C++ ObjectSet::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ObjectSet的用法示例。


在下文中一共展示了ObjectSet::size方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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_;
}
开发者ID:Blub,项目名称:pkgdepdb,代码行数:9,代码来源:db_format.cpp

示例2: ObjectSet

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());
}
开发者ID:adrianboguszewski,项目名称:inkscape-selection-prototype,代码行数:10,代码来源:ObjectSetTest.cpp

示例3: generateCraftingMission

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;
//.........这里部分代码省略.........
开发者ID:Arnold47525,项目名称:mmoserver,代码行数:101,代码来源:MissionManager.cpp

示例4: generateEntertainerMission

MissionObject* MissionManager::generateEntertainerMission(MissionObject* mission,int count)
{

	count < 5 ?
		mission->setMissionType(musician):
	    mission->setMissionType(dancer);

	//Randomly choose an entertainer mission
	int mission_num = (gRandom->getRand() % 50)+1;
	mission->setNum(mission_num);

	ObjectSet inRangeNPCs;
	gWorldManager->getSI()->getObjectsInRange(mission->getOwner(),&inRangeNPCs,ObjType_NPC,3000);
	//Start
	uint32 cntLoop = 0;
	bool found = false;
	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->getDestinationNPC() != npc)
				{
					mission->setStartNPC(npc);
					mission_dest.Coordinates = npc->mPosition;
					mission_dest.CellID = 0;
					mission_dest.PlanetCRC = BString(gWorldManager->getPlanetNameThis()).getCrc();
					mission->setDestination(mission_dest);
					mission->setDestinationNPC(npc);
					found = true;
				}
			}
		}
	}

	//Creator
	mission->setCreator(creators[gRandom->getRand() % 9]);

    //Mission Title
	sprintf(mt,"m%dt",mission_num);

	count < 5 ?
		mission->setTitleFile("mission/mission_npc_musician_neutral_easy") :
		mission->setTitleFile("mission/mission_npc_dancer_neutral_easy");
	mission->setTitle(mt);

	//Mission Description
	sprintf(md,"m%do",mission_num);

	count < 5 ?
		mission->setDetailFile("mission/mission_npc_musician_neutral_easy") :
		mission->setDetailFile("mission/mission_npc_dancer_neutral_easy");
	mission->setDetail(md);

   //Diffaculty
	mission->setDifficulty((gRandom->getRand() % 90)+3);

	//Payment
	mission->setReward((gRandom->getRand() % 2500)+500);

	//Target Name
	mission->setTarget("Entertainer");

	//Mission Target
	mission->setTargetModel(0x491099A6); //crc = object/tangible/instrument/shared_organ_max_rebo.iff

return mission;
}
开发者ID:Arnold47525,项目名称:mmoserver,代码行数:78,代码来源:MissionManager.cpp

示例5: 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

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


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