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


C++ House类代码示例

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


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

示例1: switch

bool HouseTransferItem::onTradeEvent(TradeEvents_t event, Player* owner)
{
	House* house;
	switch(event){
		case ON_TRADE_TRANSFER:
		{
			house = getHouse();
			if(house){
				house->executeTransfer(this, owner);
			}

			g_game.internalRemoveItem(this, 1);
			break;
		}

		case ON_TRADE_CANCEL:
		{
			house = getHouse();
			if(house){
				house->resetTransferItem();
			}

			break;
		}

		default:
			break;
	}

	return true;
}
开发者ID:WeDontGiveAF,项目名称:OOServer,代码行数:31,代码来源:house.cpp

示例2: computeReligionLevel

int HouseLevelSpec::computeReligionLevel(House &house)
{
   int res = 0;
   if (house.hasServiceAccess(S_TEMPLE_MERCURE))
   {
      res++;
   }
   if (house.hasServiceAccess(S_TEMPLE_VENUS))
   {
      res++;
   }
   if (house.hasServiceAccess(S_TEMPLE_MARS))
   {
      res++;
   }
   if (house.hasServiceAccess(S_TEMPLE_NEPTUNE))
   {
      res++;
   }
   if (house.hasServiceAccess(S_TEMPLE_CERES))
   {
      res++;
   }
   return res;
}
开发者ID:LMG,项目名称:opencaesar3,代码行数:25,代码来源:oc3_house_level.cpp

示例3: evaluateEducationNeed

float HouseLevelSpec::evaluateEducationNeed(House &house, const ServiceType service)
{
   float res = 0;
   int houseLevel = house.getLevelSpec().getHouseLevel();
   int minLevel = HouseSpecHelper::getInstance().getHouseLevelSpec(houseLevel+1)._minEducationLevel;
   if (minLevel == 1)
   {
      // need school or library
      if (service != S_COLLEGE)
      {
         res = (float)( 100 - std::max(house.getServiceAccess(S_SCHOOL), house.getServiceAccess(S_LIBRARY)) );
      } 
   }
   else if (minLevel == 2)
   {
      // need school and library
      if (service != S_COLLEGE)
      {
         res = (float)( 100 - house.getServiceAccess(service) );
      }
   }
   else if (minLevel == 3)
   {
      // need school and library and college
      res = (float)( 100 - house.getServiceAccess(service) );
   }
   // std::cout << "education need: " << service << " " << res << std::endl;
   return res;
}
开发者ID:LMG,项目名称:opencaesar3,代码行数:29,代码来源:oc3_house_level.cpp

示例4: time

bool IOMapSerialize::updateAuctions()
{
	Database* db = Database::getInstance();
	DBQuery query;

	time_t now = time(NULL);
	query << "SELECT `house_id`, `player_id`, `bid` FROM `house_auctions` WHERE `endtime` < " << now;

	DBResult* result;
	if(!(result = db->storeQuery(query.str())))
		return true;

	bool success = true;
	House* house = NULL;
	do
	{
		query.str("");
		query << "DELETE FROM `house_auctions` WHERE `house_id` = " << result->getDataInt("house_id");
		if(!(house = Houses::getInstance()->getHouse(result->getDataInt(
			"house_id"))) || !db->query(query.str()))
		{
			success = false;
			continue;
		}

		house->setOwner(result->getDataInt("player_id"));
		Houses::getInstance()->payHouse(house, now, result->getDataInt("bid"));
	}
	while(result->next());
	result->free();
	return success;
}
开发者ID:Codex-NG,项目名称:TheImaginedServer,代码行数:32,代码来源:iomapserialize.cpp

示例5: switch

boolean Floor::handle_xml_tag(Tag tag, xml_node *node) {
   switch (tag) {
      case ON_FLOOR_TAG: 
		case INSIDE_TAG: // new on 040803
			// following called reset_items prior to 240203
			just_add_items(xml_load_sprites(node),xml_get_attribute_int(node,L"TopLevel",0)); // new on 110803 to add to screen if pasting in the floor by itself		
		   // rewritten on 171202 to just do above rather than below
         // Sprites *floor_items = xml_load_sprites(node);
         // if (floor_items != NULL) {
		      //Sprites *remaining = floor_items;
		      //while (remaining != NULL) {
			     // // new on 101099 if priority of item is fixed then don't reset it
			     // // so Marty, for example, loads in with correct priority
			     // add_item(remaining->first(),FALSE); 
			     // // FALSE replaced !remaining->first()->priority_fixed() above on 211199 since priority is now saved correctly
			     // remaining = remaining->rest();
		      //};
		      //floor_items->recursively_propagate_changes();
		      //floor_items->activate();
         //    floor_items->remove_all();
         //    delete floor_items;
         // };
			current_priority = xml_get_attribute_int(node,L"Z",max_long);
         return(TRUE);
		case PREVIOUS_MOUSE_TAG:
			set_previous_mouse((Mouse *) xml_get_sprite(node,previous_mouse,MOUSE_WITH_HAMMER)); // args added on 070103
			return(TRUE);
		case MAIN_BOX_TAG: 
			body_cubby = (Cubby *) xml_get_sprite(node,body_cubby,CUBBY);
			if (body_cubby != NULL) { // new on 090203 - not clear if better to use set_body_cubby instead but it does much more
				body_cubby->increment_ref_count(); 
			};
			return(body_cubby != NULL);
		case ALTERNATIVES_FOR_MY_BOX_TAG:
			alternative_body_cubbies = xml_load_sprites(node);
			return(alternative_body_cubbies != NULL);
		case INITIAL_ROBOT_TAG: 
			set_initial_robot((Robot *) xml_get_sprite(node,initial_robot,ROBOT));
			return(initial_robot != NULL);
		case HOUSE_LOCATION_TAG: {
			House *house = house_at_location(node);
			if (house == NULL) return(FALSE);
			room = house->pointer_to_room();
			return(room != NULL);
									  };
      case NO_MORE_TAGS:
			// commented out on 041103 since this causes problem when jumping between segments in time travel and is only an optimization anyway
//			toolbox_status = (ToolboxCacheStatus) xml_get_attribute_int(node,L"ToolBoxStatusCode",TOOLBOX_CACHE_STATUS_UNINITIALIZED);
			floor_id = xml_get_attribute_int(node,L"FloorID",floor_id);
			at_left_wall = xml_get_attribute_int(node,L"AtLeftWall",0); // prior to 210404 at_left_wall
			at_right_wall = xml_get_attribute_int(node,L"AtRightWall",0); // prior to 210404 at_right_wall
			at_front_wall = xml_get_attribute_int(node,L"AtFrontWall",0); // prior to 210404 at_front_wall
         return(TRUE); // had been commented out on 090404 to fall through to call to super -- trying to fix time travel bug with containment region
			// restored 090404 since Floor is "self contained"
      default:
 //        return(FALSE); // extra_xml?? 051102
			return(Visible_Background::handle_xml_tag(tag,node)); // new on 090404 - though super doesn't do much better...
   };
};
开发者ID:ToonTalk,项目名称:desktop-toontalk,代码行数:59,代码来源:floor.cpp

示例6: OnListBoxDoubleClick

void HousePalettePanel::OnListBoxDoubleClick(wxCommandEvent& event)
{
	House* house = reinterpret_cast<House*>(event.GetClientData());
	// I find it extremly unlikely that one actually wants the exit at 0,0,0, so just treat it as the null value
	if(house && house->getExit() != Position(0,0,0)) {
		gui.CenterOnPosition(house->getExit());
	}
}
开发者ID:Codex-NG,项目名称:rme,代码行数:8,代码来源:palette_house.cpp

示例7: getHouseByPlayerId

House* Houses::getHouseByPlayerId(uint32_t playerId)
{
	for(HouseMap::iterator it = houseMap.begin(); it != houseMap.end(); ++it){
		House* house = it->second;
		if(house->getHouseOwner() == playerId){
			return house;
		}
	}
	return NULL;
}
开发者ID:WeDontGiveAF,项目名称:OOServer,代码行数:10,代码来源:house.cpp

示例8: getOwner

void RadarClass::destroy()
{
    House* owner = getOwner();

	StructureClass::destroy();

	if(!owner->hasRadar()) {
		owner->changeRadar(false);
	}
}
开发者ID:thebohemian,项目名称:dunelegacy-richiesbranch,代码行数:10,代码来源:RadarClass.cpp

示例9: sellHouse

void Commands::sellHouse(Player& player, const std::string& param)
{
	Player* tradePartner = g_game.getPlayerByName(param);
	if (!tradePartner || tradePartner == &player) {
		player.sendCancel("Trade player not found.");
		return;
	}

	if (!Position::areInRange<2, 2, 0>(tradePartner->getPosition(), player.getPosition())) {
		player.sendCancel("Trade player is too far away.");
		return;
	}

	if (!tradePartner->isPremium()) {
		player.sendCancel("Trade player does not have a premium account.");
		return;
	}

	HouseTile* houseTile = dynamic_cast<HouseTile*>(player.getTile());
	if (!houseTile) {
		player.sendCancel("You must stand in your house to initiate the trade.");
		return;
	}

	House* house = houseTile->getHouse();
	if (!house || house->getOwner() != player.getGUID()) {
		player.sendCancel("You don't own this house.");
		return;
	}

	if (Houses::getInstance().getHouseByPlayerId(tradePartner->getGUID())) {
		player.sendCancel("Trade player already owns a house.");
		return;
	}

	if (IOLoginData::hasBiddedOnHouse(tradePartner->getGUID())) {
		player.sendCancel("Trade player is currently the highest bidder of an auctioned house.");
		return;
	}

	Item* transferItem = house->getTransferItem();
	if (!transferItem) {
		player.sendCancel("You can not trade this house.");
		return;
	}

	transferItem->getParent()->setParent(&player);

	if (!g_game.internalStartTrade(&player, tradePartner, transferItem)) {
		house->resetTransferItem();
	}
}
开发者ID:felipetmartini,项目名称:testec,代码行数:52,代码来源:commands.cpp

示例10: sellHouse

void Commands::sellHouse(Player* player, const std::string& cmd, const std::string& param)
{
	House* house = Houses::getInstance().getHouseByPlayerId(player->guid);
	if (!house) {
		player->sendCancel("You do not own any house.");
		return;
	}

	Player* tradePartner = g_game.getPlayerByName(param);
	if (!(tradePartner && tradePartner != player)) {
		player->sendCancel("Trade player not found.");
		return;
	}

	if (tradePartner->level < 1) {
		player->sendCancel("Trade player level is too low.");
		return;
	}

	if (!Position::areInRange<2, 2, 0>(tradePartner->getPosition(), player->getPosition())) {
		player->sendCancel("Trade player is too far away.");
		return;
	}

	if (!tradePartner->isPremium()) {
		player->sendCancel("Trade player does not have a premium account.");
		return;
	}

	if (Houses::getInstance().getHouseByPlayerId(tradePartner->guid)) {
		player->sendCancel("Trade player already owns a house.");
		return;
	}

	if (IOLoginData::getInstance()->hasBiddedOnHouse(tradePartner->guid)) {
		player->sendCancel("Trade player is currently the highest bidder of an auctioned house.");
		return;
	}

	Item* transferItem = house->getTransferItem();
	if (!transferItem) {
		player->sendCancel("You can not trade this house.");
		return;
	}

	transferItem->getParent()->setParent(player);

	if (!g_game.internalStartTrade(player, tradePartner, transferItem)) {
		house->resetTransferItem();
	}
}
开发者ID:Remoq7,项目名称:forgottenserver,代码行数:51,代码来源:commands.cpp

示例11: OTSYS_TIME

bool IOMapSerialize::saveMap()
{
	int64_t start = OTSYS_TIME();
	Database* db = Database::getInstance();
	std::ostringstream query;

	//Start the transaction
	DBTransaction transaction;
	if (!transaction.begin()) {
		return false;
	}

	//clear old tile data
	if (!db->executeQuery("DELETE FROM `tile_store`")) {
		return false;
	}

	DBInsert stmt;
	stmt.setQuery("INSERT INTO `tile_store` (`house_id`, `data`) VALUES ");

	PropWriteStream stream;
	for (const auto& it : Houses::getInstance().getHouses()) {
		//save house items
		House* house = it.second;
		for (HouseTile* tile : house->getTiles()) {
			saveTile(stream, tile);

			size_t attributesSize;
			const char* attributes = stream.getStream(attributesSize);
			if (attributesSize > 0) {
				query << house->getId() << ',' << db->escapeBlob(attributes, attributesSize);
				if (!stmt.addRow(query)) {
					return false;
				}
			}

			stream.clear();
		}
	}

	if (!stmt.execute()) {
		return false;
	}

	//End the transaction
	bool success = transaction.commit();
	std::cout << "> Saved house items in: " <<
	          (OTSYS_TIME() - start) / (1000.) << " s" << std::endl;
	return success;
}
开发者ID:Emperian,项目名称:forgottenserver,代码行数:50,代码来源:iomapserialize.cpp

示例12: getNextPosition

void Commands::buyHouse(Player* player, const std::string& cmd, const std::string& param)
{
	if (!player->isPremium()) {
		player->sendCancelMessage(RET_YOUNEEDPREMIUMACCOUNT);
		return;
	}

	Position pos = player->getPosition();
	pos = getNextPosition(player->direction, pos);

	Tile* tile = g_game.getTile(pos.x, pos.y, pos.z);

	if (!tile) {
		player->sendCancel("You have to be looking at the door of the house you would like to buy.");
		return;
	}

	HouseTile* houseTile = dynamic_cast<HouseTile*>(tile);
	if (!houseTile) {
		player->sendCancel("You have to be looking at the door of the house you would like to buy.");
		return;
	}

	House* house = houseTile->getHouse();
	if (!house || !house->getDoorByPosition(pos)) {
		player->sendCancel("You have to be looking at the door of the house you would like to buy.");
		return;
	}

	if (house->getHouseOwner()) {
		player->sendCancel("This house alreadly has an owner.");
		return;
	}

	for (const auto& it : Houses::getInstance().getHouses()) {
		if (it.second->getHouseOwner() == player->guid) {
			player->sendCancel("You are already the owner of a house.");
			return;
		}
	}

	uint64_t price = house->getHouseTiles().size() * g_config.getNumber(ConfigManager::HOUSE_PRICE);
	if (!g_game.removeMoney(player, price)) {
		player->sendCancel("You do not have enough money.");
		return;
	}

	house->setHouseOwner(player->guid);
	player->sendTextMessage(MSG_INFO_DESCR, "You have successfully bought this house, be sure to have the money for the rent in the bank.");
}
开发者ID:Remoq7,项目名称:forgottenserver,代码行数:50,代码来源:commands.cpp

示例13: create

        static Target create( const Option& o )
        {

            House* house = new House( &o );
            TargetValue* THIS = new TargetValue( house );
            house->setTHIS(THIS);
            Target target = THIS;

            house->build(o);

            // Added to level in build()
            // l.addFeature( target );

            return target;
        }
开发者ID:anylonen,项目名称:abura-tan,代码行数:15,代码来源:features.hpp

示例14: evaluateReligionNeed

float HouseLevelSpec::evaluateReligionNeed(House &house, const ServiceType service)
{
   int houseLevel = house.getLevelSpec().getHouseLevel();
   int minLevel = HouseSpecHelper::getInstance().getHouseLevelSpec(houseLevel+1)._minReligionLevel;

   return (float)minLevel;
}
开发者ID:LMG,项目名称:opencaesar3,代码行数:7,代码来源:oc3_house_level.cpp

示例15: computeFoodLevel

int HouseLevelSpec::computeFoodLevel(House &house)
{
   int res = 0;

   GoodStore& goodStore = house.getGoodStore();
   if (goodStore.getCurrentQty(G_WHEAT) > 0)
   {
      res++;
   }
   if (goodStore.getCurrentQty(G_FISH) > 0)
   {
      res++;
   }
   if (goodStore.getCurrentQty(G_MEAT) > 0)
   {
      res++;
   }
   if (goodStore.getCurrentQty(G_FRUIT) > 0)
   {
      res++;
   }
   if (goodStore.getCurrentQty(G_VEGETABLE) > 0)
   {
      res++;
   }

   return res;
}
开发者ID:LMG,项目名称:opencaesar3,代码行数:28,代码来源:oc3_house_level.cpp


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