Skip to content

Commit

Permalink
Fix #1624
Browse files Browse the repository at this point in the history
  • Loading branch information
dalkon committed Dec 3, 2015
1 parent e1ffcf5 commit 192a8ca
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/tile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1676,7 +1676,7 @@ Item* Tile::getUseItem() const
return ground;
}

for (Item* item : *items) {
for (Item* item : boost::adaptors::reverse(*items)) {
if (Item::items[item->getID()].forceUse) {
return item;
}
Expand Down
34 changes: 20 additions & 14 deletions src/tile.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,23 @@ class TileItemVector
public:
TileItemVector() : downItemCount(0) {}

ItemVector::const_iterator begin() const {
using value_type = ItemVector::value_type;
using iterator = ItemVector::iterator;
using const_iterator = ItemVector::const_iterator;
using reverse_iterator = ItemVector::reverse_iterator;
using const_reverse_iterator = ItemVector::const_reverse_iterator;

This comment has been minimized.

Copy link
@ranisalt

ranisalt Dec 4, 2015

Member

Just with

        using ItemVector::value_type;
        using ItemVector::iterator;
        using ItemVector::const_iterator;
        using ItemVector::reverse_iterator;
        using ItemVector::const_reverse_iterator;

would work the same with less verbosity, no?

This comment has been minimized.

Copy link
@dalkon

dalkon Dec 4, 2015

Author Contributor

Not really, it's not the same thing. These are basically typedefs.

This comment has been minimized.

Copy link
@djarek

djarek Dec 6, 2015

Contributor

In this case they would be equivalent.

This comment has been minimized.

Copy link
@dalkon

dalkon Dec 6, 2015

Author Contributor

They would not, ItemVector is not the base class of TileItemVector.


const_iterator begin() const {
return items.begin();
}
ItemVector::const_reverse_iterator rbegin() const {
const_reverse_iterator rbegin() const {
return items.rbegin();
}

ItemVector::const_iterator end() const {
const_iterator end() const {
return items.end();
}
ItemVector::const_reverse_iterator rend() const {
const_reverse_iterator rend() const {
return items.rend();
}

Expand All @@ -109,10 +115,10 @@ class TileItemVector
return items.size();
}

ItemVector::iterator insert(ItemVector::iterator _where, Item* item) {
iterator insert(ItemVector::iterator _where, Item* item) {
return items.insert(_where, item);
}
ItemVector::iterator erase(ItemVector::iterator _pos) {
iterator erase(ItemVector::iterator _pos) {
return items.erase(_pos);
}
Item* at(size_t _pos) const {
Expand All @@ -125,28 +131,28 @@ class TileItemVector
return items.push_back(item);
}

ItemVector::iterator getBeginDownItem() {
iterator getBeginDownItem() {
return items.begin();
}
ItemVector::const_iterator getBeginDownItem() const {
const_iterator getBeginDownItem() const {
return begin();
}
ItemVector::iterator getEndDownItem() {
iterator getEndDownItem() {
return items.begin() + downItemCount;
}
ItemVector::const_iterator getEndDownItem() const {
const_iterator getEndDownItem() const {
return items.begin() + downItemCount;
}
ItemVector::iterator getBeginTopItem() {
iterator getBeginTopItem() {
return getEndDownItem();
}
ItemVector::const_iterator getBeginTopItem() const {
const_iterator getBeginTopItem() const {
return getEndDownItem();
}
ItemVector::iterator getEndTopItem() {
iterator getEndTopItem() {
return items.end();
}
ItemVector::const_iterator getEndTopItem() const {
const_iterator getEndTopItem() const {
return end();
}

Expand Down

2 comments on commit 192a8ca

@PrinterLUA
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job!

@Luckey1729
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Welcome back!

Please sign in to comment.