From 67f644c898ee4057036d0fa3f2e8ad491c6f1aa8 Mon Sep 17 00:00:00 2001
From: Christoph Oelckers <c.oelckers@zdoom.fake>
Date: Sun, 24 Jan 2016 11:50:21 +0100
Subject: [PATCH] - fixed inverted NULL pointer check in A_SetAngle. - let
 COPY_AAPTR check the most common case AAPTR_DEFAULT first instead of running
 through all the other cases for it.

---
 src/actorptrselect.cpp            | 2 ++
 src/thingdef/thingdef_codeptr.cpp | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/actorptrselect.cpp b/src/actorptrselect.cpp
index 774067550d..54c41e6ba2 100644
--- a/src/actorptrselect.cpp
+++ b/src/actorptrselect.cpp
@@ -32,6 +32,8 @@
 
 AActor *COPY_AAPTR(AActor *origin, int selector)
 {
+	if (selector == AAPTR_DEFAULT) return origin;
+
 	if (origin)
 	{
 		if (origin->player)
diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp
index f61bd28257..ac1afcf495 100644
--- a/src/thingdef/thingdef_codeptr.cpp
+++ b/src/thingdef/thingdef_codeptr.cpp
@@ -4060,7 +4060,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetAngle)
 	ACTION_PARAM_INT(ptr, 2);
 
 	AActor *ref = COPY_AAPTR(self, ptr);
-	if (ref != NULL)
+	if (ref == NULL)
 	{
 		ACTION_SET_RESULT(false);
 		return;