summaryrefslogtreecommitdiff
path: root/src/state.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/state.cpp')
-rw-r--r--src/state.cpp27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/state.cpp b/src/state.cpp
index 9da71adc..b4853f68 100644
--- a/src/state.cpp
+++ b/src/state.cpp
@@ -88,18 +88,39 @@ State::update()
for (MovingObjectIterator o(map->getAroundPlayerIterator(*p)); o; ++o)
{
+
Point os = (*o)->getOldPosition();
Point on = (*o)->getPosition();
+ int flags = 0;
+
+ // Handle attacking
+ if ( (*o)->getUpdateFlags() & ATTACK
+ && (*o)->getPublicID() != (*p)->getPublicID()
+ && (*p)->getPosition().inRangeOf(on)
+ )
+ {
+ MessageOut AttackMsg (GPMSG_BEING_ATTACK);
+ AttackMsg.writeShort((*o)->getPublicID());
+
+ LOG_DEBUG( "Sending attack packet from " <<
+ (*o)->getPublicID() <<
+ " to " <<
+ (*p)->getPublicID(),
+ 0
+ );
+
+ gameHandler->sendTo(*p, AttackMsg);
+ }
+
+ // Handle moving
+
/* Check whether this player and this moving object were around
* the last time and whether they will be around the next time.
*/
bool wereInRange = (*p)->getOldPosition().inRangeOf(os) &&
!(((*p)->getUpdateFlags() | (*o)->getUpdateFlags()) & NEW_ON_MAP);
bool willBeInRange = (*p)->getPosition().inRangeOf(on);
-
- int flags = 0;
-
if (!wereInRange)
{
// o was outside p's range.