本文整理汇总了C++中HouseTile类的典型用法代码示例。如果您正苦于以下问题:C++ HouseTile类的具体用法?C++ HouseTile怎么用?C++ HouseTile使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了HouseTile类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setHouseOwner
bool Commands::setHouseOwner(Creature* creature, const std::string& cmd, const std::string& param)
{
Player* player = creature->getPlayer();
if(player){
HouseTile* houseTile = player->getTile()->getHouseTile();
if(houseTile){
std::string real_name = param;
uint32_t guid;
if(param == "none"){
houseTile->getHouse()->setHouseOwner(0);
}
else if(IOPlayer::instance()->getGuidByName(guid, real_name)){
houseTile->getHouse()->setHouseOwner(guid);
}
else{
player->sendTextMessage(MSG_STATUS_CONSOLE_BLUE, "Player not found.");
}
return true;
}
}
return false;
}
示例2: transferToDepot
void House::cleanHouse()
{
transferToDepot();
PlayerVector to_kick;
HouseTile* houseTile;
for(HouseTileList::iterator it = houseTiles.begin(); it != houseTiles.end(); ++it){
houseTile = (*it);
for(CreatureConstIterator cit = houseTile->creatures_begin(); cit != houseTile->creatures_end(); ++cit){
if((*cit)->getPlayer()){
to_kick.push_back((*cit)->getPlayer());
}
}
}
while(!to_kick.empty()){
Player* c = to_kick.back();
to_kick.pop_back();
kickPlayer(NULL, c->getName());
}
// we need to remove players from beds
for(HouseBedItemList::iterator it = bedsList.begin(); it != bedsList.end(); ++it){
if((*it)->getSleeper() != 0){
(*it)->wakeUp();
}
}
}
示例3: sellHouse
void Commands::sellHouse(Player& player, const std::string& param)
{
Player* tradePartner = g_game.getPlayerByName(param);
if (!tradePartner || tradePartner == &player) {
player.sendCancel("Trade player not found.");
return;
}
if (!Position::areInRange<2, 2, 0>(tradePartner->getPosition(), player.getPosition())) {
player.sendCancel("Trade player is too far away.");
return;
}
if (!tradePartner->isPremium()) {
player.sendCancel("Trade player does not have a premium account.");
return;
}
HouseTile* houseTile = dynamic_cast<HouseTile*>(player.getTile());
if (!houseTile) {
player.sendCancel("You must stand in your house to initiate the trade.");
return;
}
House* house = houseTile->getHouse();
if (!house || house->getOwner() != player.getGUID()) {
player.sendCancel("You don't own this house.");
return;
}
if (Houses::getInstance().getHouseByPlayerId(tradePartner->getGUID())) {
player.sendCancel("Trade player already owns a house.");
return;
}
if (IOLoginData::hasBiddedOnHouse(tradePartner->getGUID())) {
player.sendCancel("Trade player is currently the highest bidder of an auctioned house.");
return;
}
Item* transferItem = house->getTransferItem();
if (!transferItem) {
player.sendCancel("You can not trade this house.");
return;
}
transferItem->getParent()->setParent(&player);
if (!g_game.internalStartTrade(&player, tradePartner, transferItem)) {
house->resetTransferItem();
}
}
示例4: getHouseByPlayer
House* Houses::getHouseByPlayer(Player* player)
{
if(!player || player->isRemoved())
return nullptr;
HouseTile* houseTile = player->getTile()->getHouseTile();
if(!houseTile)
return nullptr;
if(House* house = houseTile->getHouse())
return house;
return nullptr;
}
示例5: getNextPosition
void Commands::buyHouse(Player* player, const std::string& cmd, const std::string& param)
{
if (!player->isPremium()) {
player->sendCancelMessage(RET_YOUNEEDPREMIUMACCOUNT);
return;
}
Position pos = player->getPosition();
pos = getNextPosition(player->direction, pos);
Tile* tile = g_game.getTile(pos.x, pos.y, pos.z);
if (!tile) {
player->sendCancel("You have to be looking at the door of the house you would like to buy.");
return;
}
HouseTile* houseTile = dynamic_cast<HouseTile*>(tile);
if (!houseTile) {
player->sendCancel("You have to be looking at the door of the house you would like to buy.");
return;
}
House* house = houseTile->getHouse();
if (!house || !house->getDoorByPosition(pos)) {
player->sendCancel("You have to be looking at the door of the house you would like to buy.");
return;
}
if (house->getHouseOwner()) {
player->sendCancel("This house alreadly has an owner.");
return;
}
for (const auto& it : Houses::getInstance().getHouses()) {
if (it.second->getHouseOwner() == player->guid) {
player->sendCancel("You are already the owner of a house.");
return;
}
}
uint64_t price = house->getHouseTiles().size() * g_config.getNumber(ConfigManager::HOUSE_PRICE);
if (!g_game.removeMoney(player, price)) {
player->sendCancel("You do not have enough money.");
return;
}
house->setHouseOwner(player->guid);
player->sendTextMessage(MSG_INFO_DESCR, "You have successfully bought this house, be sure to have the money for the rent in the bank.");
}
示例6: kickPlayer
bool House::kickPlayer(Player* player, Player* target)
{
if(!target || target->isRemoved())
return false;
HouseTile* houseTile = target->getTile()->getHouseTile();
if(!houseTile || houseTile->getHouse() != this)
return false;
bool self = player == target;
if(getHouseAccessLevel(player) < getHouseAccessLevel(target) && !self)
return false;
removePlayer(target, self);
return true;
}
示例7: if
void House::setAccessList(uint32_t listId, const std::string& textlist)
{
if(listId == GUEST_LIST)
guestList.parseList(textlist);
else if(listId == SUBOWNER_LIST)
subOwnerList.parseList(textlist);
else
{
Door* door = getDoorByNumber(listId);
if(door)
door->setAccessList(textlist);
else
{
#ifdef __DEBUG_HOUSES__
std::cout << "Failure: [House::setAccessList] door == NULL, listId = " << listId <<std::endl;
#endif
}
//We dont have kick anyone
return;
}
//kick uninvited players
typedef std::list<Player*> KickPlayerList;
KickPlayerList kickList;
HouseTileList::iterator it;
for(it = houseTiles.begin(); it != houseTiles.end(); ++it)
{
HouseTile* hTile = *it;
if(CreatureVector* creatures = hTile->getCreatures())
{
CreatureVector::iterator cit;
for(cit = creatures->begin(); cit != creatures->end(); ++cit)
{
Player* player = (*cit)->getPlayer();
if(player && isInvited(player) == false)
kickList.push_back(player);
}
}
}
KickPlayerList::iterator itkick;
for(itkick = kickList.begin(); itkick != kickList.end(); ++itkick)
{
if(g_game.internalTeleport(*itkick, getEntryPosition()) == RET_NOERROR)
g_game.addMagicEffect(getEntryPosition(), NM_ME_TELEPORT);
}
}
示例8: kickPlayer
bool House::kickPlayer(Player* player, const std::string& name)
{
Player* kickingPlayer = g_game.getPlayerByName(name);
if(kickingPlayer){
HouseTile* houseTile = dynamic_cast<HouseTile*>(kickingPlayer->getTile());
if(houseTile && houseTile->getHouse() == this){
if(getHouseAccessLevel(player) >= getHouseAccessLevel(kickingPlayer) && !kickingPlayer->hasFlag(PlayerFlag_CanEditHouses)){
if(g_game.internalTeleport(kickingPlayer, getEntryPosition()) == RET_NOERROR){
g_game.addMagicEffect(getEntryPosition(), NM_ME_ENERGY_AREA);
}
return true;
}
}
}
return false;
}
示例9: setHouseOwner
void Commands::setHouseOwner(Player* player, const std::string& cmd, const std::string& param)
{
if (player->getTile()->hasFlag(TILESTATE_HOUSE)) {
HouseTile* houseTile = dynamic_cast<HouseTile*>(player->getTile());
if (houseTile) {
uint32_t guid;
std::string name = param;
if (name == "none") {
houseTile->getHouse()->setHouseOwner(0);
} else if (IOLoginData::getGuidByName(guid, name)) {
houseTile->getHouse()->setHouseOwner(guid);
} else {
player->sendTextMessage(MSG_STATUS_CONSOLE_BLUE, "Player not found.");
}
}
}
}
示例10: kickPlayer
bool House::kickPlayer(Player* player, const std::string& name)
{
Player* kickingPlayer = g_game.getPlayerByName(name);
if(kickingPlayer){
HouseTile* houseTile = kickingPlayer->getParentTile()->getHouseTile();
if(houseTile && houseTile->getHouse() == this){
if(getHouseAccessLevel(player) >= getHouseAccessLevel(kickingPlayer) && !kickingPlayer->hasFlag(PlayerFlag_CanEditHouses)){
if(g_game.internalTeleport(player, kickingPlayer, getEntryPosition()) == RET_NOERROR){
g_game.addMagicEffect(getEntryPosition(), MAGIC_EFFECT_BLUE_BUBBLE);
}
return true;
}
}
}
return false;
}
示例11: if
void House::setAccessList(uint32_t listId, const std::string& textlist)
{
if(listId == GUEST_LIST){
guestList.parseList(textlist);
}
else if(listId == SUBOWNER_LIST){
subOwnerList.parseList(textlist);
}
else{
Door* door = getDoorByNumber(listId);
if(door){
door->setAccessList(textlist);
}
else{
#ifdef __DEBUG_HOUSES__
std::cout << "Failure: [House::setAccessList] door == NULL, listId = " << listId <<std::endl;
#endif
}
//We dont have kick anyone
return;
}
//kick uninvited players
typedef std::list<Player*> KickPlayerList;
KickPlayerList kickList;
HouseTileList::iterator it;
HouseTile* houseTile;
for(it = houseTiles.begin(); it != houseTiles.end(); ++it){
houseTile = (*it);
for(CreatureIterator cit = houseTile->creatures_begin(); cit != houseTile->creatures_end(); ++cit){
Player* player = (*cit)->getPlayer();
if(player && isInvited(player) == false){
kickList.push_back(player);
}
}
}
KickPlayerList::iterator itkick;
for(itkick = kickList.begin(); itkick != kickList.end(); ++itkick){
if(g_game.internalTeleport(NULL, *itkick, getEntryPosition()) == RET_NOERROR){
g_game.addMagicEffect(getEntryPosition(), MAGIC_EFFECT_BLUE_BUBBLE);
}
}
}
示例12: kickPlayer
bool House::kickPlayer(Player* player, Player* target)
{
if (!target) {
return false;
}
HouseTile* houseTile = dynamic_cast<HouseTile*>(target->getTile());
if (!houseTile || houseTile->getHouse() != this) {
return false;
}
if (getHouseAccessLevel(player) < getHouseAccessLevel(target) || target->hasFlag(PlayerFlag_CanEditHouses)) {
return false;
}
Position oldPosition = target->getPosition();
if (g_game.internalTeleport(target, getEntryPosition()) == RETURNVALUE_NOERROR) {
g_game.addMagicEffect(oldPosition, CONST_ME_POFF);
g_game.addMagicEffect(getEntryPosition(), CONST_ME_TELEPORT);
}
return true;
}
示例13: kickPlayer
bool House::kickPlayer(Player* player, Player* target)
{
if(!target || target->isRemoved())
return false;
HouseTile* houseTile = target->getTile()->getHouseTile();
if(!houseTile || houseTile->getHouse() != this)
return false;
if(player == target)
{
removePlayer(target, true);
return true;
}
if(getHouseAccessLevel(player) >= getHouseAccessLevel(target))
{
removePlayer(target, false);
return true;
}
return false;
}