[Orxonox-commit 5399] r10062 - code/branches/turretFS14/src/modules/objects/controllers

muemart at orxonox.net muemart at orxonox.net
Tue May 20 09:03:19 CEST 2014


Author: muemart
Date: 2014-05-20 09:03:19 +0200 (Tue, 20 May 2014)
New Revision: 10062

Modified:
   code/branches/turretFS14/src/modules/objects/controllers/TurretController.cc
Log:
Commit the right file this time

Modified: code/branches/turretFS14/src/modules/objects/controllers/TurretController.cc
===================================================================
--- code/branches/turretFS14/src/modules/objects/controllers/TurretController.cc	2014-05-20 07:02:05 UTC (rev 10061)
+++ code/branches/turretFS14/src/modules/objects/controllers/TurretController.cc	2014-05-20 07:03:19 UTC (rev 10062)
@@ -96,9 +96,9 @@
         	}
         }
 
-        float maxScore = 0;
+        float minScore = FLT_MAX;
         float tempScore;
-        Pawn* maxScorePawn = 0;
+        Pawn* minScorePawn = 0;
 
   		for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it)     
         {
@@ -108,15 +108,15 @@
             tempScore = turret->isInRange(entity);
             if(tempScore != -1.f)
             {
-            	if(tempScore > maxScore)
+            	if(tempScore < minScore)
             	{
-            		maxScore = tempScore;
-            		maxScorePawn = entity;
+            		minScore = tempScore;
+            		minScorePawn = entity;
             	}
             }
     	}
-        this->setTarget(maxScorePawn);
-        turret->setTarget(maxScorePawn);
+        this->setTarget(minScorePawn);
+        turret->setTarget(minScorePawn);
  	}
 
     /**
@@ -137,7 +137,7 @@
         @brief 
         Scores a pawn as a target, based on distance and health.
 
-        The more health and distance a pawn has, the higher the score. This means lower equals better target.
+        The more health and distance a pawn has, the higher the score. This means lower equals better.
 
 		@param pawn
 		The pawn to score




More information about the Orxonox-commit mailing list