本文整理汇总了C++中House::getHouseId方法的典型用法代码示例。如果您正苦于以下问题:C++ House::getHouseId方法的具体用法?C++ House::getHouseId怎么用?C++ House::getHouseId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类House
的用法示例。
在下文中一共展示了House::getHouseId方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadHouseInfo
bool IOMapSerialize::loadHouseInfo(Map* map)
{
Database* db = Database::getInstance();
std::ostringstream query;
DBResult* result = db->storeQuery("SELECT `id`, `owner`, `paid`, `warnings` FROM `houses`");
if (!result) {
return false;
}
do {
House* house = Houses::getInstance().getHouse(result->getDataInt("id"));
if (house) {
house->setHouseOwner(result->getDataInt("owner"));
house->setPaidUntil(result->getDataInt("paid"));
house->setPayRentWarnings(result->getDataInt("warnings"));
}
} while (result->next());
db->freeResult(result);
for (const auto& it : Houses::getInstance().getHouses()) {
House* house = it.second;
if (house->getHouseOwner() != 0 && house->getHouseId() != 0) {
query.str("");
query << "SELECT `listid`, `list` FROM `house_lists` WHERE `house_id` = " << house->getHouseId();
if ((result = db->storeQuery(query.str()))) {
do {
house->setAccessList(result->getDataInt("listid"), result->getDataString("list"));
} while (result->next());
db->freeResult(result);
}
}
}
return true;
}
示例2: saveMap
bool IOMapSerialize::saveMap(Map* map)
{
int64_t start = OTSYS_TIME();
Database* db = Database::getInstance();
std::ostringstream query;
//Start the transaction
DBTransaction transaction;
if (!transaction.begin()) {
return false;
}
if (!db->executeQuery("DELETE FROM `tile_store`")) {
return false;
}
DBInsert stmt;
stmt.setQuery("INSERT INTO `tile_store` (`house_id`, `data`) VALUES ");
//clear old tile data
for (const auto& it : Houses::getInstance().getHouses()) {
//save house items
House* house = it.second;
for (HouseTile* tile : house->getHouseTiles()) {
PropWriteStream stream;
saveTile(stream, tile);
uint32_t attributesSize;
const char* attributes = stream.getStream(attributesSize);
if (attributesSize > 0) {
query << house->getHouseId() << "," << db->escapeBlob(attributes, attributesSize);
if (!stmt.addRow(query)) {
return false;
}
}
}
}
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: 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 << "[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::cout << "[Warning - IOMap::loadMap] Movable item in house: " << house->getHouseId();
std::cout << ", item type: " << item->getID() << ", at position " << px << "/" << py << "/";
std::cout << pz << std::endl;
delete item;
item = NULL;
}
else if(tile)
{
tile->__internalAddThing(item);
item->__startDecaying();
item->setLoadedFromMap(true);
}
else if(item->isGroundTile())
{
if(groundItem)
delete groundItem;
groundItem = item;
}
else
{
tile = createTile(groundItem, item, px, py, pz);
tile->__internalAddThing(item);
item->__startDecaying();
item->setLoadedFromMap(true);
}
break;
}
default:
示例4: payHouses
bool Houses::payHouses()
{
if(rentPeriod == RENTPERIOD_NEVER) {
return true;
}
uint32_t currentTime = std::time(NULL);
for(HouseMap::iterator it = houseMap.begin(); it != houseMap.end(); ++it){
House* house = it->second;
if(house->getHouseOwner() != 0 && house->getPaidUntil() < currentTime &&
house->getRent() != 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(!IOPlayer::instance()->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(!IOPlayer::instance()->loadPlayer(player, name)){
#ifdef __DEBUG__
std::cout << "Failure: [Houses::payHouses], can not load player: " << name << std::endl;
#endif
delete player;
continue;
}
}
Depot* depot = player->getDepot(town->getTownID(), true);
// savePlayerHere is an ugly hack
// to avoid saving 2 times a not online player
// when items are transferred to his depot
bool savePlayerHere = true;
if(depot){
//get money from depot
bool useAccBalance = g_config.getBool(ConfigManager::USE_ACCBALANCE) != 0;
bool hasEnoughMoney = false;
if(useAccBalance){
if(player->balance >= house->getRent()){
player->balance -= house->getRent();
hasEnoughMoney = true;
}
}
else{
hasEnoughMoney = g_game.removeMoney(depot, house->getRent(), FLAG_NOLIMIT);
}
if(hasEnoughMoney){
uint32_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;
case RENTPERIOD_NEVER:
break;
}
house->setPaidUntil(paidUntil);
}
else if(currentTime >= house->getLastWarning() + 24 * 60 * 60){
if(house->getPayRentWarnings() >= 7){
house->setHouseOwner(0);
// setHouseOwner will load the player,
// transfer house items to his depot and then
// will save it, so here should not be saved
// again
savePlayerHere = false;
}
else{
int daysLeft = 7 - house->getPayRentWarnings();
Item* letter = Item::CreateItem(ITEM_LETTER_STAMPED);
std::string period = "";
switch(rentPeriod){
//.........这里部分代码省略.........
示例5: payHouses
bool Houses::payHouses()
{
if (rentPeriod == RENTPERIOD_NEVER) {
return true;
}
time_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;
}
}
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;
case RENTPERIOD_YEARLY:
period = "annual";
break;
default:
break;
}
//.........这里部分代码省略.........
示例6: loadMap
//.........这里部分代码省略.........
}
else if((flags & TILESTATE_NOPVPZONE) == TILESTATE_NOPVPZONE){
tile->setFlag(TILESTATE_NOPVPZONE);
}
else if((flags & TILESTATE_PVPZONE) == TILESTATE_PVPZONE){
tile->setFlag(TILESTATE_PVPZONE);
}
if((flags & TILESTATE_NOLOGOUT) == TILESTATE_NOLOGOUT){
tile->setFlag(TILESTATE_NOLOGOUT);
}
if((flags & TILESTATE_REFRESH) == TILESTATE_REFRESH){
if(house){
std::cout << "Warning [x:" << px << ", y:" << py << ", z:" << pz << "] " << " House tile flagged as refreshing!";
}
tile->setFlag(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->getHouseId() << " Item type = " << item->getID() << std::endl;
delete item;
item = NULL;
}
else{
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;
}
}
NODE nodeItem = f.getChildNode(nodeTile, type);
while(nodeItem){
if(type == OTBM_ITEM){
PropStream propStream;
f.getProps(nodeItem, propStream);
Item* item = Item::CreateItem(propStream);
if(!item){
std::stringstream ss;
ss << "[x:" << px << ", y:" << py << ", z:" << pz << "] " << "Failed to create item.";
setLastErrorString(ss.str());
示例7: loadMap
//.........这里部分代码省略.........
if (!propStream.GET_ULONG(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->isNotMoveable()) {
std::cout << "Warning: [OTBM loader] Moveable item with ID: " << item->getID() << ", in house: " << house->getHouseId() << ", at position [x: " << px << ", y: " << py << ", z: " << pz << "]." << std::endl;
delete item;
item = NULL;
} 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;
}
}
示例8: 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();
}