示例#1
0
void House::setHouseOwner(uint32_t guid)
{
  if(isLoaded && houseOwner == guid)
    return;

  isLoaded = true;

  if(houseOwner){
    cleanHouse();

    //clean access lists
    houseOwner = 0;
    setAccessList(SUBOWNER_LIST, "");
    setAccessList(GUEST_LIST, "");

    for(HouseDoorList::iterator it = doorList.begin(); it != doorList.end(); ++it){
      (*it)->setAccessList("");
    }

    //reset paid date
    paidUntil = 0;
    rentWarnings = 0;
  }

  std::string name;
  if(guid != 0 && IOPlayer::instance()->getNameByGuid(guid, name)){
    houseOwner = guid;
    houseOwnerName = name;
  }

  updateDoorDescription();
  setLastWarning(std::time(NULL)); //So the new owner has one day before he start the payment
}
示例#2
0
void House::setHouseOwner(uint32_t guid)
{
	if(isLoaded && houseOwner == guid)
		return;

	isLoaded = true;

	if(houseOwner){
		//send items to depot
		transferToDepot();

		PlayerVector to_kick;
		 for(HouseTileList::iterator it = houseTiles.begin(); it != houseTiles.end(); ++it){
			 for(uint32_t i = 0; i < (*it)->getThingCount(); ++i){
				 Creature* creature = (*it)->__getThing(i)->getCreature();
				 if(creature != NULL && creature->getPlayer())
					 to_kick.push_back(creature->getPlayer());
			 }
		 }
		 while(to_kick.empty() == false) {
			 Player* c = to_kick.back();
			 to_kick.pop_back();
			 kickPlayer(NULL, c->getName());
		 }

		// we need to remove players from beds
		HouseBedItemList::iterator bit;
		for(bit = bedsList.begin(); bit != bedsList.end(); ++bit) {
			if((*bit)->getSleeper() != 0) {
				(*bit)->wakeUp(NULL);
			}
		}

		//clean access lists
		houseOwner = 0;
		setAccessList(SUBOWNER_LIST, "");
		setAccessList(GUEST_LIST, "");

		for(HouseDoorList::iterator it = doorList.begin(); it != doorList.end(); ++it){
			(*it)->setAccessList("");
		}

		//reset paid date
		paidUntil = 0;
		rentWarnings = 0;
	}

	std::string name;
	if(guid != 0 && IOPlayer::instance()->getNameByGuid(guid, name)){
		houseOwner = guid;
		houseOwnerName = name;
	}

	updateDoorDescription();
	setLastWarning(std::time(NULL)); //So the new owner has one day before he start the payment
}