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


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

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


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

示例1: updateHouses

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

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

		query << "SELECT `price` FROM `houses` WHERE `id` = " << house->getId() << " AND `world_id` = "
			<< g_config.getNumber(ConfigManager::WORLD_ID) << " LIMIT 1";
		if(DBResult* result = db->storeQuery(query.str()))
		{
			if((uint32_t)result->getDataInt("price") != house->getPrice())
				house->setSyncFlag(House::HOUSE_SYNC_UPDATE);

			result->free();
			query.str("");

			query << "UPDATE `houses` SET ";
			if(house->hasSyncFlag(House::HOUSE_SYNC_NAME))
				query << "`name` = " << db->escapeString(house->getName()) << ", ";

			if(house->hasSyncFlag(House::HOUSE_SYNC_TOWN))
				query << "`town` = " << house->getTownId() << ", ";

			if(house->hasSyncFlag(House::HOUSE_SYNC_SIZE))
				query << "`size` = " << house->getSize() << ", ";

			if(house->hasSyncFlag(House::HOUSE_SYNC_PRICE))
				query << "`price` = " << house->getPrice() << ", ";

			if(house->hasSyncFlag(House::HOUSE_SYNC_RENT))
				query << "`rent` = " << house->getRent() << ", ";

			query << "`doors` = " << house->getDoorsCount() << ", `beds` = "
				<< house->getBedsCount() << ", `tiles` = " << house->getTilesCount();
			if(house->hasSyncFlag(House::HOUSE_SYNC_GUILD))
				query << ", `guild` = " << house->isGuild();

			query << " WHERE `id` = " << house->getId() << " AND `world_id` = "
				<< g_config.getNumber(ConfigManager::WORLD_ID) << db->getUpdateLimiter();
		}
		else
		{
			query.str("");
			query << "INSERT INTO `houses` (`id`, `world_id`, `owner`, `name`, `town`, `size`, `price`, `rent`, `doors`, `beds`, `tiles`, `guild`) VALUES ("
				<< house->getId() << ", " << g_config.getNumber(ConfigManager::WORLD_ID) << ", 0, "
				//we need owner for compatibility reasons (field doesn't have a default value)
				<< db->escapeString(house->getName()) << ", " << house->getTownId() << ", "
				<< house->getSize() << ", " << house->getPrice() << ", " << house->getRent() << ", "
				<< house->getDoorsCount() << ", " << house->getBedsCount() << ", "
				<< house->getTilesCount() << ", " << house->isGuild() << ")";
		}

		if(!db->query(query.str()))
			return false;

		query.str("");
	}

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


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