From cedeac9325fd4b0a0de0a5fba1890d8368754a01 Mon Sep 17 00:00:00 2001
From: "Tony J. White" <tjw@tjw.org>
Date: Thu, 14 Sep 2006 16:18:33 +0000
Subject: * (bug 2952) repeaters could be built in some powered zones (Martin
 Doucha)

---
 src/game/g_buildable.c | 25 ++++++++++---------------
 1 file changed, 10 insertions(+), 15 deletions(-)

diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c
index 59040d0e..b9859258 100644
--- a/src/game/g_buildable.c
+++ b/src/game/g_buildable.c
@@ -166,7 +166,6 @@ static qboolean findPower( gentity_t *self )
   int       distance = 0;
   int       minDistance = 10000;
   vec3_t    temp_v;
-  qboolean  foundPower = qfalse;
 
   if( self->biteam != BIT_HUMANS )
     return qfalse;
@@ -194,26 +193,22 @@ static qboolean findPower( gentity_t *self )
     {
       VectorSubtract( self->s.origin, ent->s.origin, temp_v );
       distance = VectorLength( temp_v );
-      if( distance < minDistance && ent->powered )
-      {
-        closestPower = ent;
-        minDistance = distance;
-        foundPower = qtrue;
+
+      if( distance < minDistance && ent->powered &&
+          ( ( ent->s.modelindex == BA_H_REACTOR &&
+            distance <= REACTOR_BASESIZE ) ||
+          ( ent->s.modelindex == BA_H_REPEATER &&
+            distance <= REPEATER_BASESIZE ) ) ) {
+
+          closestPower = ent;
+          minDistance = distance;
       }
     }
   }
 
   //if there were no power items nearby give up
-  if( !foundPower )
-    return qfalse;
-
-  //bleh
-  if( ( closestPower->s.modelindex == BA_H_REACTOR && ( minDistance <= REACTOR_BASESIZE ) ) ||
-      ( closestPower->s.modelindex == BA_H_REPEATER && ( minDistance <= REPEATER_BASESIZE ) &&
-        closestPower->powered ) )
-  {
+  if( closestPower ) {
     self->parentNode = closestPower;
-
     return qtrue;
   }
   else
-- 
cgit