From 207c84e3dd5e5b2cc8739c27aa575344b42cea4f Mon Sep 17 00:00:00 2001
From: Christoph Oelckers <coelckers@zdoom.fake>
Date: Sat, 1 Jul 2006 00:15:06 +0000
Subject: [PATCH] - Fixed: In multiplayer games, when trying to change targets,
 A_Chase forgot   to check whether the new target was the same as the old one
 and treated   this case as a real target change.

SVN r234 (trunk)
---
 docs/rh-log.txt | 5 +++++
 src/p_enemy.cpp | 3 ++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/docs/rh-log.txt b/docs/rh-log.txt
index f569d1484..f13ba337a 100644
--- a/docs/rh-log.txt
+++ b/docs/rh-log.txt
@@ -1,3 +1,8 @@
+July 1, 2006 (Changes by Graf Zahl)
+- Fixed: In multiplayer games, when trying to change targets, A_Chase forgot
+  to check whether the new target was the same as the old one and treated 
+  this case as a real target change.
+
 June 29, 2006
 - Added some hackery at the start of MouseRead_Win32() that prevents it from
   yanking the mouse around if they keys haven't been read yet to combat the
diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp
index 5d8ad6a9c..e5cf442bd 100644
--- a/src/p_enemy.cpp
+++ b/src/p_enemy.cpp
@@ -2009,12 +2009,13 @@ void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missi
 			actor->flags3 &= ~MF3_NOSIGHTCHECK;
 			lookForBetter = true;
 		}
+		AActor * oldtarget = actor->target;
 		gotNew = P_LookForPlayers (actor, true);
 		if (lookForBetter)
 		{
 			actor->flags3 |= MF3_NOSIGHTCHECK;
 		}
-		if (gotNew)
+		if (gotNew && actor->target != oldtarget)
 		{
 			actor->flags &= ~MF_INCHASE;
 			return; 	// got a new target