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


C++ House::getHouseTileEnd方法代码示例

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


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

示例1: loadMapRelational

bool IOMapSerialize::loadMapRelational(Map* map)
{
	Database* db = Database::getInstance();
	DBQuery query; //lock mutex!

	House* house = NULL;
	for(HouseMap::iterator it = Houses::getInstance()->getHouseBegin(); it != Houses::getInstance()->getHouseEnd(); ++it)
	{
		if(!(house = it->second))
			continue;

		query.str("");
		query << "SELECT * FROM `tiles` WHERE `house_id` = " << house->getId() <<
			" AND `world_id` = " << g_config.getNumber(ConfigManager::WORLD_ID);
		if(DBResult* result = db->storeQuery(query.str()))
		{
			do
			{
				query.str("");
				query << "SELECT * FROM `tile_items` WHERE `tile_id` = " << result->getDataInt("id") << " AND `world_id` = "
					<< g_config.getNumber(ConfigManager::WORLD_ID) << " ORDER BY `sid` DESC";
				if(DBResult* itemsResult = db->storeQuery(query.str()))
				{
					if(house->hasPendingTransfer())
					{
						if(Player* player = g_game.getPlayerByGuidEx(house->getOwner()))
						{
							loadItems(itemsResult, player->getInbox(), true);
							if(player->isVirtual())
							{
								IOLoginData::getInstance()->savePlayer(player);
								delete player;
							}
						}
					}
					else
					{
						Position pos(result->getDataInt("x"), result->getDataInt("y"), result->getDataInt("z"));
						if(Tile* tile = map->getTile(pos))
							loadItems(itemsResult, tile, false);
						else
							std::clog << "[Error - IOMapSerialize::loadMapRelational] Unserialization"
								<< " of invalid tile at position "<< pos << std::endl;
					}

					itemsResult->free();
				}
			}
			while(result->next());
			result->free();
		}
		else //backward compatibility
		{
			for(HouseTileList::iterator it = house->getHouseTileBegin(); it != house->getHouseTileEnd(); ++it)
			{
				query.str("");
				query << "SELECT `id` FROM `tiles` WHERE `x` = " << (*it)->getPosition().x << " AND `y` = "
					<< (*it)->getPosition().y << " AND `z` = " << (*it)->getPosition().z << " AND `world_id` = "
					<< g_config.getNumber(ConfigManager::WORLD_ID) << " LIMIT 1";
				if(DBResult* result = db->storeQuery(query.str()))
				{
					query.str("");
					query << "SELECT * FROM `tile_items` WHERE `tile_id` = " << result->getDataInt("id") << " AND `world_id` = "
						<< g_config.getNumber(ConfigManager::WORLD_ID) << " ORDER BY `sid` DESC";
					if(DBResult* itemsResult = db->storeQuery(query.str()))
					{
						if(house->hasPendingTransfer())
						{
							if(Player* player = g_game.getPlayerByGuidEx(house->getOwner()))
							{
								loadItems(itemsResult, player->getInbox(), true);
								if(player->isVirtual())
								{
									IOLoginData::getInstance()->savePlayer(player);
									delete player;
								}
							}
						}
						else
							loadItems(itemsResult, (*it), false);

						itemsResult->free();
					}

					result->free();
				}
			}
		}
	}

	return true;
}
开发者ID:Codex-NG,项目名称:TheImaginedServer,代码行数:92,代码来源:iomapserialize.cpp

示例2: payHouses

bool Houses::payHouses()
{
	if(rentPeriod == RENTPERIOD_NEVER)
		return true;

	uint32_t currentTime = time(NULL);
	for(HouseMap::iterator it = houseMap.begin(); it != houseMap.end(); ++it)
	{
		House* house = it->second;
		if(house->getHouseOwner() != 0)
		{
			uint32_t ownerid = house->getHouseOwner();
			Town* town = Towns::getInstance().getTown(house->getTownId());
			if(!town)
			{
				#ifdef __DEBUG_HOUSES__
				std::cout << "Warning: [Houses::payHouses] town = NULL, townid = " <<
					house->getTownId() << ", houseid = " << house->getHouseId() << std::endl;
				#endif
				continue;
			}

			std::string name;
			if(!IOLoginData::getInstance()->getNameByGuid(ownerid, name))
			{
				//player doesnt exist, remove it as house owner?
				house->setHouseOwner(0);
				continue;
			}

			Player* player = g_game.getPlayerByName(name);
			if(!player)
			{
				player = new Player(name, NULL);
				if(!IOLoginData::getInstance()->loadPlayer(player, name))
				{
					#ifdef __DEBUG__
					std::cout << "Failure: [Houses::payHouses], can not load player: " << name << std::endl;
					#endif
					delete player;
					continue;
				}
			}

			int32_t housePrice = 0;
			for(HouseTileList::iterator it = house->getHouseTileBegin(), end = house->getHouseTileEnd(); it != end; ++it)
				housePrice += g_config.getNumber(ConfigManager::HOUSE_PRICE);

			bool paid = false;
			if(player->getBankBalance() >= house->getRent())
			{
				player->setBankBalance(player->getBankBalance() - house->getRent());
				paid = true;
			}

			if(paid)
			{
				time_t paidUntil = currentTime;
				switch(rentPeriod)
				{
					case RENTPERIOD_DAILY:
						paidUntil += 24 * 60 * 60;
						break;
					case RENTPERIOD_WEEKLY:
						paidUntil += 24 * 60 * 60 * 7;
						break;
					case RENTPERIOD_MONTHLY:
						paidUntil += 24 * 60 * 60 * 30;
						break;
					case RENTPERIOD_YEARLY:
						paidUntil += 24 * 60 * 60 * 365;
						break;
					default:
						break;
				}
				house->setPaidUntil(paidUntil);
			}
			else
			{
				if(house->getPayRentWarnings() < 7)
				{
					int32_t daysLeft = 7 - house->getPayRentWarnings();

					Item* letter = Item::CreateItem(ITEM_LETTER_STAMPED);
					std::string period = "";

					switch(rentPeriod)
					{
						case RENTPERIOD_DAILY:
							period = "daily";
							break;

						case RENTPERIOD_WEEKLY:
							period = "weekly";
							break;

						case RENTPERIOD_MONTHLY:
							period = "monthly";
							break;

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


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