本文整理汇总了C++中House::getTilesCount方法的典型用法代码示例。如果您正苦于以下问题:C++ House::getTilesCount方法的具体用法?C++ House::getTilesCount怎么用?C++ House::getTilesCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类House
的用法示例。
在下文中一共展示了House::getTilesCount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadFromXml
bool Houses::loadFromXml(std::string filename)
{
xmlDocPtr doc = xmlParseFile(filename.c_str());
if(!doc)
{
LOGe("[Houses::loadFromXml] Cannot load houses file: " << getLastXMLError());
return false;
}
xmlNodePtr houseNode, root = xmlDocGetRootElement(doc);
if(xmlStrcmp(root->name,(const xmlChar*)"houses"))
{
LOGe("[Houses::loadFromXml] Malformed houses file.");
xmlFreeDoc(doc);
return false;
}
int32_t intValue;
std::string strValue;
houseNode = root->children;
while(houseNode)
{
if(xmlStrcmp(houseNode->name,(const xmlChar*)"house"))
{
houseNode = houseNode->next;
continue;
}
int32_t houseId = 0;
if(!readXMLInteger(houseNode, "houseid", houseId))
{
LOGe("[Houses::loadFromXml] Could not read houseId");
xmlFreeDoc(doc);
return false;
}
House* house = Houses::getInstance()->getHouse(houseId);
if(!house)
{
LOGe("[Houses::loadFromXml] Unknown house with id: " << houseId);
xmlFreeDoc(doc);
return false;
}
Position entry(0, 0, 0);
if(readXMLInteger(houseNode, "entryx", intValue))
entry.x = intValue;
if(readXMLInteger(houseNode, "entryy", intValue))
entry.y = intValue;
if(readXMLInteger(houseNode, "entryz", intValue))
entry.z = intValue;
house->setEntry(entry);
if(!entry.x || !entry.y)
{
LOGw("[Houses::loadFromXml] House entry not set for: " << house->getName() << " (" << houseId << ")");
}
if(readXMLString(houseNode, "name", strValue))
house->setName(strValue);
else
house->resetSyncFlag(House::HOUSE_SYNC_NAME);
if(readXMLInteger(houseNode, "townid", intValue))
house->setTownId(intValue);
else
house->resetSyncFlag(House::HOUSE_SYNC_TOWN);
if(readXMLInteger(houseNode, "size", intValue))
house->setSize(intValue);
else
house->resetSyncFlag(House::HOUSE_SYNC_SIZE);
if(readXMLString(houseNode, "guildhall", strValue))
house->setGuild(booleanString(strValue));
else
house->resetSyncFlag(House::HOUSE_SYNC_GUILD);
uint32_t rent = 0;
if(readXMLInteger(houseNode, "rent", intValue))
rent = intValue;
uint32_t price = house->getTilesCount() * server.configManager().getNumber(ConfigManager::HOUSE_PRICE);
if(server.configManager().getBool(ConfigManager::HOUSE_RENTASPRICE))
{
uint32_t tmp = rent;
if(!tmp)
tmp = price;
house->setPrice(tmp);
}
else
house->setPrice(price);
if(server.configManager().getBool(ConfigManager::HOUSE_PRICEASRENT))
house->setRent(price);
else
//.........这里部分代码省略.........
示例2: 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;
}