From a83af83ef20da0b7d2754079831fb6e90dc2e069 Mon Sep 17 00:00:00 2001
From: Tim Angus <tim@ngus.net>
Date: Thu, 29 Mar 2001 17:27:07 +0000
Subject: Rather large and obvious crashbug. D'oh

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

diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c
index 6891c15a..f41d714a 100644
--- a/src/game/g_buildable.c
+++ b/src/game/g_buildable.c
@@ -42,6 +42,9 @@ qboolean findPower( gentity_t *self )
   int       minDistance = 10000;
   vec3_t    temp_v;
   
+  if( self->parentNode && self->parentNode->active )
+    return qtrue;
+  
   //reset parent
   self->parentNode = NULL;
   
@@ -325,12 +328,7 @@ void HMCU_Think( gentity_t *self )
 {
   self->nextthink = level.time + REFRESH_TIME;
   
-  if( ( self->parentNode == NULL ) ||
-      !self->parentNode->inuse ||
-      !self->parentNode->active )
-  {
-    self->powered = findPower( self );
-  }
+  self->powered = findPower( self );
 }
 
 //TA: the following defense turret code was written by
@@ -490,16 +488,12 @@ void HDef1_Think( gentity_t *self )
 {
   self->nextthink = level.time + 50;
   
-  if( ( self->parentNode == NULL ) ||
-      !self->parentNode->inuse ||
-      !self->parentNode->active )
+  self->powered = findPower( self );
+
+  if( !self->powered )
   {
-    self->powered = findPower( self );
-    if( !self->powered )
-    {
-      self->nextthink = level.time + REFRESH_TIME;
-      return;
-    }
+    self->nextthink = level.time + REFRESH_TIME;
+    return;
   }
   
   if( !hdef1_checktarget( self, self->enemy) )
@@ -566,12 +560,7 @@ void HSpawn_Think( gentity_t *self )
 {
   self->nextthink = level.time + REFRESH_TIME;
 
-  if( ( self->parentNode == NULL ) ||
-      !self->parentNode->inuse ||
-      !self->parentNode->active )
-  {
-    self->powered = findPower( self );
-  }
+  self->powered = findPower( self );
 }
 
 
-- 
cgit