Complete.Org: Mailing Lists: Archives: freeciv-dev: May 1999:
[Freeciv-Dev] PATCH: get_attacker not caching information.
Home

[Freeciv-Dev] PATCH: get_attacker not caching information.

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxxx
Subject: [Freeciv-Dev] PATCH: get_attacker not caching information.
From: Tony Stuckey <stuckey@xxxxxxxxxxxxxxxxx>
Date: Thu, 6 May 1999 21:49:18 -0500

        get_attacker calls rate_unit_a multiple times.  It would be better
to save the result.

Index: server/unittools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/unittools.c,v
retrieving revision 1.40
diff -u -r1.40 unittools.c
--- unittools.c 1999/05/02 04:19:43     1.40
+++ unittools.c 1999/05/07 02:43:01
@@ -358,12 +358,13 @@
                          int x, int y)
 { /* get unit at (x, y) that wants to kill aunit */
   struct unit *bestatt = 0;
-  int bestvalue=-1;
+  int bestvalue=-1, unit_a;
   unit_list_iterate(map_get_tile(x, y)->units, punit) {
     if (pplayer->player_no==punit->owner)
       return 0;
-    if(rate_unit_a(punit, aunit)>bestvalue) {
-      bestvalue=rate_unit_a(punit, aunit);
+    unit_a=rate_unit_a(punit, aunit);
+    if(unit_a>bestvalue) {
+      bestvalue=unit_a;
       bestatt=punit;
     }
   }

-- 
Anthony J. Stuckey                              stuckey@xxxxxxxxxxxxxxxxx
"When I was young, the sky was filled with stars.
 I watched them burn out one by one."  -Warren Zevon

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] PATCH: get_attacker not caching information., Tony Stuckey <=