Skip to content

Commit

Permalink
Fix double door listing on houses (otland#2075)
Browse files Browse the repository at this point in the history
  • Loading branch information
ranisalt authored Mar 17, 2017
1 parent f3f6d54 commit 166bb2a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
16 changes: 8 additions & 8 deletions src/house.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void House::setOwner(uint32_t guid, bool updateDatabase/* = true*/, Player* play
setAccessList(SUBOWNER_LIST, "");
setAccessList(GUEST_LIST, "");

for (Door* door : doorList) {
for (Door* door : doorSet) {
door->setAccessList("");
}

Expand Down Expand Up @@ -116,7 +116,7 @@ void House::updateDoorDescription() const
}
}

for (const auto& it : doorList) {
for (const auto& it : doorSet) {
it->setSpecialDescription(ss.str());
}
}
Expand Down Expand Up @@ -275,17 +275,17 @@ bool House::isInvited(const Player* player)
void House::addDoor(Door* door)
{
door->incrementReferenceCounter();
doorList.push_back(door);
doorSet.insert(door);
door->setHouse(this);
updateDoorDescription();
}

void House::removeDoor(Door* door)
{
auto it = std::find(doorList.begin(), doorList.end(), door);
if (it != doorList.end()) {
auto it = doorSet.find(door);
if (it != doorSet.end()) {
door->decrementReferenceCounter();
doorList.erase(it);
doorSet.erase(it);
}
}

Expand All @@ -297,7 +297,7 @@ void House::addBed(BedItem* bed)

Door* House::getDoorByNumber(uint32_t doorId) const
{
for (Door* door : doorList) {
for (Door* door : doorSet) {
if (door->getDoorId() == doorId) {
return door;
}
Expand All @@ -307,7 +307,7 @@ Door* House::getDoorByNumber(uint32_t doorId) const

Door* House::getDoorByPosition(const Position& pos)
{
for (Door* door : doorList) {
for (Door* door : doorSet) {
if (door->getPosition() == pos) {
return door;
}
Expand Down
7 changes: 4 additions & 3 deletions src/house.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#define FS_HOUSE_H_EB9732E7771A438F9CD0EFA8CB4C58C4

#include <regex>
#include <set>

#include "container.h"
#include "housetile.h"
Expand Down Expand Up @@ -212,8 +213,8 @@ class House
return houseTiles;
}

const std::list<Door*>& getDoors() const {
return doorList;
const std::set<Door*>& getDoors() const {
return doorSet;
}

void addBed(BedItem* bed);
Expand All @@ -234,7 +235,7 @@ class House
Container transfer_container{ITEM_LOCKER1};

HouseTileList houseTiles;
std::list<Door*> doorList;
std::set<Door*> doorSet;
HouseBedItemList bedsList;

std::string houseName;
Expand Down

0 comments on commit 166bb2a

Please sign in to comment.