本文整理汇总了C++中House::getId方法的典型用法代码示例。如果您正苦于以下问题:C++ House::getId方法的具体用法?C++ House::getId怎么用?C++ House::getId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类House
的用法示例。
在下文中一共展示了House::getId方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadHouses
bool IOMapSerialize::loadHouses()
{
Database* db = Database::getInstance();
DBQuery query;
query << "SELECT * FROM `houses` WHERE `world_id` = " << g_config.getNumber(ConfigManager::WORLD_ID);
DBResult* result;
if(!(result = db->storeQuery(query.str())))
return false;
House* house = NULL;
do
{
if(!(house = Houses::getInstance()->getHouse(result->getDataInt("id"))))
continue;
house->setRentWarnings(result->getDataInt("warnings"));
house->setLastWarning(result->getDataInt("lastwarning"));
house->setPaidUntil(result->getDataInt("paid"));
if(result->getDataInt("clear") == 1)
house->setPendingTransfer(true);
house->setOwner(result->getDataInt("owner"));
if(house->getOwner() && house->hasSyncFlag(House::HOUSE_SYNC_UPDATE))
house->resetSyncFlag(House::HOUSE_SYNC_UPDATE);
}
while(result->next());
result->free();
for(HouseMap::iterator it = Houses::getInstance()->getHouseBegin(); it != Houses::getInstance()->getHouseEnd(); ++it)
{
if(!(house = it->second) || !house->getId() || !house->getOwner())
continue;
query.str("");
query << "SELECT `listid`, `list` FROM `house_lists` WHERE `house_id` = " << house->getId();
query << " AND `world_id` = " << g_config.getNumber(ConfigManager::WORLD_ID);
if(!(result = db->storeQuery(query.str())))
continue;
do
house->setAccessList(result->getDataInt("listid"), result->getDataString("list"));
while(result->next());
result->free();
}
return true;
}
示例2: saveMap
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;
}
示例3: 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;
}
示例4: 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;
}
示例5: loadMap
//.........这里部分代码省略.........
case OTBM_ATTR_TILE_FLAGS: {
uint32_t flags;
if (!propStream.read<uint32_t>(flags)) {
std::ostringstream ss;
ss << "[x:" << px << ", y:" << py << ", z:" << pz << "] Failed to read tile flags.";
setLastErrorString(ss.str());
return false;
}
if ((flags & TILESTATE_PROTECTIONZONE) == TILESTATE_PROTECTIONZONE) {
tileflags |= TILESTATE_PROTECTIONZONE;
} else if ((flags & TILESTATE_NOPVPZONE) == TILESTATE_NOPVPZONE) {
tileflags |= TILESTATE_NOPVPZONE;
} else if ((flags & TILESTATE_PVPZONE) == TILESTATE_PVPZONE) {
tileflags |= TILESTATE_PVPZONE;
}
if ((flags & TILESTATE_NOLOGOUT) == TILESTATE_NOLOGOUT) {
tileflags |= TILESTATE_NOLOGOUT;
}
break;
}
case OTBM_ATTR_ITEM: {
Item* item = Item::CreateItem(propStream);
if (!item) {
std::ostringstream ss;
ss << "[x:" << px << ", y:" << py << ", z:" << pz << "] Failed to create item.";
setLastErrorString(ss.str());
return false;
}
if (isHouseTile && item->isMoveable()) {
std::cout << "[Warning - IOMap::loadMap] Moveable item with ID: " << item->getID() << ", in house: " << house->getId() << ", at position [x: " << px << ", y: " << py << ", z: " << pz << "]." << std::endl;
delete item;
} else {
if (item->getItemCount() <= 0) {
item->setItemCount(1);
}
if (tile) {
tile->internalAddThing(item);
item->startDecaying();
item->setLoadedFromMap(true);
} else if (item->isGroundTile()) {
delete ground_item;
ground_item = item;
} else {
tile = createTile(ground_item, item, px, py, pz);
tile->internalAddThing(item);
item->startDecaying();
item->setLoadedFromMap(true);
}
}
break;
}
default:
std::ostringstream ss;
ss << "[x:" << px << ", y:" << py << ", z:" << pz << "] Unknown tile attribute.";
setLastErrorString(ss.str());
return false;
}
}
NODE nodeItem = f.getChildNode(nodeTile, type);
示例6: loadMap
//.........这里部分代码省略.........
else if((flags & TILESTATE_OPTIONALZONE) == TILESTATE_OPTIONALZONE)
tileflags |= TILESTATE_OPTIONALZONE;
else if((flags & TILESTATE_HARDCOREZONE) == TILESTATE_HARDCOREZONE)
tileflags |= TILESTATE_HARDCOREZONE;
if((flags & TILESTATE_NOLOGOUT) == TILESTATE_NOLOGOUT)
tileflags |= TILESTATE_NOLOGOUT;
if((flags & TILESTATE_REFRESH) == TILESTATE_REFRESH)
{
if(house)
std::clog << "[x:" << px << ", y:" << py << ", z:" << pz << "] House tile flagged as refreshing!";
tileflags |= TILESTATE_REFRESH;
}
break;
}
case OTBM_ATTR_ITEM:
{
Item* item = Item::CreateItem(propStream);
if(!item)
{
std::stringstream ss;
ss << "[x:" << px << ", y:" << py << ", z:" << pz << "] Failed to create item.";
setLastErrorString(ss.str());
return false;
}
if(house && item->isMoveable())
{
std::clog << "[Warning - IOMap::loadMap] Movable item in house: " << house->getId();
std::clog << ", item type: " << item->getID() << ", at position " << px << "/" << py << "/";
std::clog << pz << std::endl;
delete item;
item = NULL;
}
else if(tile)
{
tile->__internalAddThing(item);
item->__startDecaying();
item->setLoadedFromMap(true);
}
else if(item->isGroundTile())
{
if(ground)
delete ground;
ground = item;
}
else
{
tile = createTile(ground, item, px, py, pz);
tile->__internalAddThing(item);
item->__startDecaying();
item->setLoadedFromMap(true);
}
break;
}
default:
示例7: saveHouseInfo
bool IOMapSerialize::saveHouseInfo()
{
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 : g_game.map.houses.getHouses()) {
House* house = it.second;
query << "SELECT `id` FROM `houses` WHERE `id` = " << house->getId();
DBResult_ptr result = db.storeQuery(query.str());
if (result) {
query.str(std::string());
query << "UPDATE `houses` SET `owner` = " << house->getOwner() << ", `paid` = " << house->getPaidUntil() << ", `warnings` = " << house->getPayRentWarnings() << ", `name` = " << db.escapeString(house->getName()) << ", `town_id` = " << house->getTownId() << ", `rent` = " << house->getRent() << ", `size` = " << house->getTiles().size() << ", `beds` = " << house->getBedCount() << " WHERE `id` = " << house->getId();
} else {
query.str(std::string());
query << "INSERT INTO `houses` (`id`, `owner`, `paid`, `warnings`, `name`, `town_id`, `rent`, `size`, `beds`) VALUES (" << house->getId() << ',' << house->getOwner() << ',' << house->getPaidUntil() << ',' << house->getPayRentWarnings() << ',' << db.escapeString(house->getName()) << ',' << house->getTownId() << ',' << house->getRent() << ',' << house->getTiles().size() << ',' << house->getBedCount() << ')';
}
db.executeQuery(query.str());
query.str(std::string());
}
DBInsert stmt("INSERT INTO `house_lists` (`house_id` , `listid` , `list`) VALUES ");
for (const auto& it : g_game.map.houses.getHouses()) {
House* house = it.second;
std::string listText;
if (house->getAccessList(GUEST_LIST, listText) && !listText.empty()) {
query << house->getId() << ',' << GUEST_LIST << ',' << db.escapeString(listText);
if (!stmt.addRow(query)) {
return false;
}
listText.clear();
}
if (house->getAccessList(SUBOWNER_LIST, listText) && !listText.empty()) {
query << house->getId() << ',' << SUBOWNER_LIST << ',' << db.escapeString(listText);
if (!stmt.addRow(query)) {
return false;
}
listText.clear();
}
for (Door* door : house->getDoors()) {
if (door->getAccessList(listText) && !listText.empty()) {
query << house->getId() << ',' << door->getDoorId() << ',' << db.escapeString(listText);
if (!stmt.addRow(query)) {
return false;
}
listText.clear();
}
}
}
if (!stmt.execute()) {
return false;
}
return transaction.commit();
}
示例8: loadMap
//.........这里部分代码省略.........
}
else if((flags & TILESTATE_NOPVPZONE) == TILESTATE_NOPVPZONE){
tileflags |= TILESTATE_NOPVPZONE;
}
else if((flags & TILESTATE_PVPZONE) == TILESTATE_PVPZONE){
tileflags |= TILESTATE_PVPZONE;
}
if((flags & TILESTATE_NOLOGOUT) == TILESTATE_NOLOGOUT){
tileflags |= TILESTATE_NOLOGOUT;
}
if((flags & TILESTATE_REFRESH) == TILESTATE_REFRESH){
if(house){
std::cout << "Warning [x:" << px << ", y:" << py << ", z:" << pz << "] " << " House tile flagged as refreshing!";
}
tileflags |= TILESTATE_REFRESH;
}
break;
}
case OTBM_ATTR_ITEM:
{
Item* item = Item::CreateItem(propStream);
if(!item){
std::stringstream ss;
ss << "[x:" << px << ", y:" << py << ", z:" << pz << "] " << "Failed to create item.";
setLastErrorString(ss.str());
return false;
}
if(isHouseTile && !item->isNotMoveable()){
std::cout << "Warning: [OTBM loader] Moveable item in house id = " << house->getId() << " Item type = " << item->getID() << std::endl;
delete item;
item = NULL;
}
else{
if(tile){
tile->__internalAddThing(item);
item->__startDecaying();
}
else if(item->isGroundTile()){
if(ground_item)
delete ground_item;
ground_item = item;
}
else{ // !tile
tile = createTile(ground_item, item, px, py, pz);
tile->__internalAddThing(item);
item->__startDecaying();
}
}
break;
}
default:
std::stringstream ss;
ss << "[x:" << px << ", y:" << py << ", z:" << pz << "] " << "Unknown tile attribute.";
setLastErrorString(ss.str());
return false;
break;
}
}
示例9: parseTileArea
//.........这里部分代码省略.........
case OTBM_ATTR_TILE_FLAGS: {
uint32_t flags;
if (!propStream.read<uint32_t>(flags)) {
std::ostringstream ss;
ss << "[x:" << x << ", y:" << y << ", z:" << z << "] Failed to read tile flags.";
setLastErrorString(ss.str());
return false;
}
if ((flags & OTBM_TILEFLAG_PROTECTIONZONE) != 0) {
tileflags |= TILESTATE_PROTECTIONZONE;
} else if ((flags & OTBM_TILEFLAG_NOPVPZONE) != 0) {
tileflags |= TILESTATE_NOPVPZONE;
} else if ((flags & OTBM_TILEFLAG_PVPZONE) != 0) {
tileflags |= TILESTATE_PVPZONE;
}
if ((flags & OTBM_TILEFLAG_NOLOGOUT) != 0) {
tileflags |= TILESTATE_NOLOGOUT;
}
break;
}
case OTBM_ATTR_ITEM: {
Item* item = Item::CreateItem(propStream);
if (!item) {
std::ostringstream ss;
ss << "[x:" << x << ", y:" << y << ", z:" << z << "] Failed to create item.";
setLastErrorString(ss.str());
return false;
}
if (isHouseTile && item->isMoveable()) {
std::cout << "[Warning - IOMap::loadMap] Moveable item with ID: " << item->getID() << ", in house: " << house->getId() << ", at position [x: " << x << ", y: " << y << ", z: " << z << "]." << std::endl;
delete item;
} else {
if (item->getItemCount() <= 0) {
item->setItemCount(1);
}
if (tile) {
tile->internalAddThing(item);
item->startDecaying();
item->setLoadedFromMap(true);
} else if (item->isGroundTile()) {
delete ground_item;
ground_item = item;
} else {
tile = createTile(ground_item, item, x, y, z);
tile->internalAddThing(item);
item->startDecaying();
item->setLoadedFromMap(true);
}
}
break;
}
default:
std::ostringstream ss;
ss << "[x:" << x << ", y:" << y << ", z:" << z << "] Unknown tile attribute.";
setLastErrorString(ss.str());
return false;
}
}
for (auto& itemNode : tileNode.children) {