Make g_map.findItemsById return a map instead of a vector
This commit is contained in:
parent
e741a62ce9
commit
537508021e
|
@ -375,17 +375,19 @@ void Map::endGhostMode()
|
|||
g_painter->resetOpacity();
|
||||
}
|
||||
|
||||
ItemVector Map::findItemsById(uint16 clientId, uint32 max)
|
||||
std::map<Position, ItemPtr> Map::findItemsById(uint16 clientId, uint32 max)
|
||||
{
|
||||
ItemVector ret;
|
||||
std::map<Position, ItemPtr> ret;
|
||||
uint32 count = 0;
|
||||
for(uint8_t z = 0; z <= Otc::MAX_Z; ++z) {
|
||||
for(const auto& pair : m_tileBlocks[z]) {
|
||||
const TileBlock& block = pair.second;
|
||||
for(const TilePtr& tile : block.getTiles()) {
|
||||
if(unlikely(!tile || tile->isEmpty()))
|
||||
continue;
|
||||
for(const ItemPtr& item : tile->getItems()) {
|
||||
if(item->getId() == clientId) {
|
||||
ret.push_back(item);
|
||||
ret.insert(std::make_pair(tile->getPosition(), item));
|
||||
if(++count >= max)
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -197,7 +197,7 @@ public:
|
|||
void beginGhostMode(float opacity);
|
||||
void endGhostMode();
|
||||
|
||||
ItemVector findItemsById(uint16 clientId, uint32 max);
|
||||
std::map<Position, ItemPtr> findItemsById(uint16 clientId, uint32 max);
|
||||
|
||||
// known creature related
|
||||
void addCreature(const CreaturePtr& creature);
|
||||
|
|
|
@ -189,6 +189,8 @@ public:
|
|||
bool isInRange(const Position& pos, int minXRange, int maxXRange, int minYRange, int maxYRange) const {
|
||||
return (pos.x >= x-minXRange && pos.x <= x+maxXRange && pos.y >= y-minYRange && pos.y <= y+maxYRange && pos.z == z);
|
||||
}
|
||||
// operator less than for std::map
|
||||
bool operator<(const Position& other) const { return x < other.x && y < other.y && z < other.z; }
|
||||
|
||||
bool up(int n = 1) {
|
||||
int nz = z-n;
|
||||
|
|
Loading…
Reference in New Issue