Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2002:
[Freeciv-Dev] [PATCH] get rid of floating point calculations at advmilit
Home

[Freeciv-Dev] [PATCH] get rid of floating point calculations at advmilit

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Cc: bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] [PATCH] get rid of floating point calculations at advmilitary.c (PR#1320)
From: Markus Linnala <maage@xxxxxxxxx>
Date: Sun, 10 Mar 2002 08:58:30 -0800 (PST)

Get rid of floating point calculations at advmilitary.c.

diff -ur -X freeciv/diff_ignore freeciv/ai/advmilitary.c 
freeciv-rid-fp-2/ai/advmilitary.c
--- freeciv/ai/advmilitary.c    Wed Mar  6 12:05:09 2002
+++ freeciv-rid-fp-2/ai/advmilitary.c   Sun Mar 10 18:56:40 2002
@@ -449,8 +449,8 @@
   else cur *= a; /* wanted to rank Legion > Catapult > Archer */
 /* which we will do by munging f in the attacker want equations */
   if (unit_type_flag(i, F_IGTER) && !def) cur *= 3;
-  if (unit_type_flag(i, F_PIKEMEN) && def) cur *= 1.5;
-  if (unit_types[i].move_type == LAND_MOVING && def) cur *= 1.5;
+  if (unit_type_flag(i, F_PIKEMEN) && def) cur += cur / 2;
+  if (unit_types[i].move_type == LAND_MOVING && def) cur += cur / 2;
   return(cur);  
 }
 
@@ -595,7 +595,7 @@
 
       m = get_virtual_defense_power(i, n, x, y);
       m *= unit_types[n].hp * unit_types[n].firepower;
-      if (vet) m *= 1.5;
+      if (vet) m += m / 2;
       m /= 30;
       m *= m;
       d = m;
@@ -735,7 +735,7 @@
       n = ai_choose_defender_versus(acity, v);
       m = get_virtual_defense_power(v, n, x, y);
       m *= unit_types[n].hp * unit_types[n].firepower;
-      if (do_make_unit_veteran(acity, n)) m *= 1.5;
+      if (do_make_unit_veteran(acity, n)) m += m / 2;
       m /= 30;
       if (c > 1) {
         d = m * m;
@@ -752,7 +752,7 @@
 tech progression beyond all description.  Only when adding the override code
 did I realize the magnitude of my transgression.  How despicable. -- Syela */
         m = get_virtual_defense_power(v, pdef->type, x, y);
-        if (pdef->veteran) m *= 1.5; /* with real defenders, this must be 
before * hp -- Syela */
+        if (pdef->veteran) m += m / 2; /* with real defenders, this must be 
before * hp -- Syela */
        m *= (myunit->id != 0 ? pdef->hp : unit_type(pdef)->hp) *
            unit_type(pdef)->firepower;
 /*        m /= (pdef->veteran ? 20 : 30);  -- led to rounding errors.  Duh! -- 
Syela */

-- 
//Markus



[Prev in Thread] Current Thread [Next in Thread]