Complete.Org: Mailing Lists: Archives: freeciv-dev: April 1999:
[Freeciv-Dev] PATCH: server/unithand.c: cache defense value
Home

[Freeciv-Dev] PATCH: server/unithand.c: cache defense value

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxxx
Subject: [Freeciv-Dev] PATCH: server/unithand.c: cache defense value
From: Tony Stuckey <stuckey@xxxxxxxxxxxxxxxxx>
Date: Mon, 26 Apr 1999 14:28:44 -0500

        rate_unit_d is called multiple times for the same units.  Saving
the initial value would be more efficient.

Index: server/unittools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/unittools.c,v
retrieving revision 1.38
diff -u -r1.38 unittools.c
--- unittools.c 1999/04/25 02:31:01     1.38
+++ unittools.c 1999/04/26 19:23:56
@@ -318,14 +318,15 @@
                          int x, int y)
 {
   struct unit *bestdef = 0;
-  int bestvalue=-1;
-int ct=0;
+  int unit_d, bestvalue=-1, ct=0;
+
   unit_list_iterate(map_get_tile(x, y)->units, punit) {
     if (pplayer->player_no==punit->owner)
       return 0;
 ct++;
-    if(unit_can_defend_here(punit) && rate_unit_d(punit, aunit)>bestvalue) {
-      bestvalue=rate_unit_d(punit, aunit);
+       unit_d=rate_unit_d(punit, aunit);
+    if(unit_can_defend_here(punit) && unit_d>bestvalue) {
+      bestvalue=unit_d;
       bestdef=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: server/unithand.c: cache defense value, Tony Stuckey <=