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


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

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


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

示例1: saveHouseInfo

bool IOMapSerialize::saveHouseInfo(Map* map)
{
	Database* db = Database::getInstance();

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

	if (!db->executeQuery("DELETE FROM `house_lists`")) {
		return false;
	}

	std::ostringstream query;
	for (const auto& it : Houses::getInstance().getHouses()) {
		House* house = it.second;
		query << "SELECT `id` FROM `houses` WHERE `id` = " << house->getHouseId();
		DBResult* result = db->storeQuery(query.str());
		if (result) {
			db->freeResult(result);
			query.str("");
			query << "UPDATE `houses` SET `owner` = " << house->getHouseOwner() << ", `paid` = " << house->getPaidUntil() << ", `warnings` = " << house->getPayRentWarnings() << ", `name` = " << db->escapeString(house->getName()) << ", `town_id` = " << house->getTownId() << ", `rent` = " << house->getRent() << ", `size` = " << house->getHouseTiles().size() << ", `beds` = " << house->getBedCount() << " WHERE `id` = " << house->getHouseId();
		} else {
			query.str("");
			query << "INSERT INTO `houses` (`id`, `owner`, `paid`, `warnings`, `name`, `town_id`, `rent`, `size`, `beds`) VALUES (" << house->getHouseId() << "," << house->getHouseOwner() << "," << house->getPaidUntil() << "," << house->getPayRentWarnings() << "," << db->escapeString(house->getName()) << "," << house->getTownId() << "," << house->getRent() << "," << house->getHouseTiles().size() << "," << house->getBedCount() << ")";
		}

		db->executeQuery(query.str());
		query.str("");
	}

	DBInsert stmt;
	stmt.setQuery("INSERT INTO `house_lists` (`house_id` , `listid` , `list`) VALUES ");

	for (const auto& it : Houses::getInstance().getHouses()) {
		House* house = it.second;

		std::string listText;

		if (house->getAccessList(GUEST_LIST, listText) && listText != "") {
			query << house->getHouseId() << "," << GUEST_LIST << "," << db->escapeString(listText);

			if (!stmt.addRow(query)) {
				return false;
			}
		}

		if (house->getAccessList(SUBOWNER_LIST, listText) && listText != "") {
			query << house->getHouseId() << "," << SUBOWNER_LIST << "," << db->escapeString(listText);
			if (!stmt.addRow(query)) {
				return false;
			}
		}

		for (Door* door : house->getHouseDoors()) {
			if (door->getAccessList(listText) && listText != "") {
				query << house->getHouseId() << "," << door->getDoorId() << "," << db->escapeString(listText);
				if (!stmt.addRow(query)) {
					return false;
				}
			}
		}
	}

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

	return transaction.commit();
}
开发者ID:Alvaritos,项目名称:forgottenserver,代码行数:70,代码来源:iomapserialize.cpp


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