summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/connectionhandler.cpp22
-rw-r--r--src/object.cpp5
-rw-r--r--src/object.h4
3 files changed, 16 insertions, 15 deletions
diff --git a/src/connectionhandler.cpp b/src/connectionhandler.cpp
index b7d1b1ba..e7ef6b9f 100644
--- a/src/connectionhandler.cpp
+++ b/src/connectionhandler.cpp
@@ -263,18 +263,18 @@ void ConnectionHandler::sendToEveryone(MessageOut &msg)
void ConnectionHandler::sendAround(tmwserv::BeingPtr beingPtr, MessageOut &msg)
{
- for (NetComputers::iterator i = clients.begin();
- i != clients.end();
- i++) {
+ unsigned speakerMapId = beingPtr->getMapId();
+ std::pair<unsigned, unsigned> speakerXY = beingPtr->getXY();
+ for (NetComputers::iterator i = clients.begin(), i_end = clients.end();
+ i != i_end;
+ ++i) {
// See if the other being is near enough, then send the message
- if (abs((*i)->getCharacter().get()->getX() - beingPtr.get()->getX()) <= (int)AROUND_AREA_IN_TILES )
- {
- if (abs((*i)->getCharacter().get()->getY() - beingPtr.get()->getY()) <= (int)AROUND_AREA_IN_TILES )
- {
- (*i)->send(msg.getPacket());
- break;
- }
- }
+ tmwserv::Being const *listener = (*i)->getCharacter().get();
+ if (listener->getMapId() != speakerMapId) continue;
+ std::pair<unsigned, unsigned> listenerXY = listener->getXY();
+ if (abs(listenerXY.first - speakerXY.first ) > (int)AROUND_AREA_IN_TILES) continue;
+ if (abs(listenerXY.second - speakerXY.second) > (int)AROUND_AREA_IN_TILES) continue;
+ (*i)->send(msg.getPacket());
}
}
diff --git a/src/object.cpp b/src/object.cpp
index 1eb31fc4..82be242a 100644
--- a/src/object.cpp
+++ b/src/object.cpp
@@ -139,8 +139,9 @@ Object::getStatistics(void)
return mStats;
}
-const unsigned int
-Object::getMapId() {
+unsigned int
+Object::getMapId() const
+{
return mMapId;
}
diff --git a/src/object.h b/src/object.h
index 17237be0..962f8202 100644
--- a/src/object.h
+++ b/src/object.h
@@ -156,8 +156,8 @@ class Object
*
* @return Name of map being is located.
*/
- const unsigned int
- getMapId();
+ unsigned int
+ getMapId() const;
/**
* Set map being is located