fix onReceiveMail notification:

https://github.com/TwistedScorpio/Nostalrius/issues/53
This commit is contained in:
ErikasKontenis
2019-12-29 20:24:02 +02:00
parent a58e99cace
commit b0f1fd5239
7 changed files with 42 additions and 10 deletions

View File

@@ -567,14 +567,14 @@ bool Player::canSeeCreature(const Creature* creature) const
return true;
}
void Player::onReceiveMail() const
void Player::onReceiveMail(uint32_t townId) const
{
if (isNearDepotBox()) {
if (isNearDepotBox(townId)) {
sendTextMessage(MESSAGE_EVENT_ADVANCE, "New mail has arrived.");
}
}
bool Player::isNearDepotBox() const
bool Player::isNearDepotBox(uint32_t townId) const
{
const Position& pos = getPosition();
for (int32_t cx = -1; cx <= 1; ++cx) {
@@ -584,8 +584,10 @@ bool Player::isNearDepotBox() const
continue;
}
if (tile->hasFlag(TILESTATE_DEPOT)) {
return true;
if (DepotLocker* depotLocker = tile->getDepotLocker()) {
if (depotLocker->getDepotId() == townId) {
return true;
}
}
}
}