Complete.Org: Mailing Lists: Archives: freeciv-dev: July 1999:
[Freeciv-Dev] [PATCH] Change shifts and rotates to multiplications and d
Home

[Freeciv-Dev] [PATCH] Change shifts and rotates to multiplications and d

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] [PATCH] Change shifts and rotates to multiplications and divides
From: Markus Linnala <maage@xxxxxxxxx>
Date: 03 Jul 1999 01:56:47 +0300
Reply-to: Markus Linnala <maage@xxxxxxxxx>

This patch changes various shifts and rotates to divides and
multiplications. I think we should rely on compiler to optimize
these right. Main point is to avoid code obfuscation. I hope I
caught all divisions and multiplications. I also hope I left
alone all bitwise operations, as it is normal to use shifts and
rotates there.

------------------------------------------------------------------------
General ChangeLog

Change <<1 to *2, >>1 to /2 etc. to increase readability of the
code. 
------------------------------------------------------------------------
diff -u --recursive --new-file --exclude-from=.diffignore 
freeciv-cvs/ai/advdomestic.c freeciv-shift/ai/advdomestic.c
--- freeciv-cvs/ai/advdomestic.c        Sat Jun 12 15:03:19 1999
+++ freeciv-shift/ai/advdomestic.c      Sat Jul  3 01:41:10 1999
@@ -103,7 +103,7 @@
       if (is_worker_here(pcity, x, y)) i++;
     }
   }
-  return(i>>1);
+  return(i/2);
 }
 
 int railroad_trade(struct city *pcity)
@@ -163,16 +163,16 @@
   }
   p -= 20;
   if (p < 0) p = 0;
-  b = (POLLUTION_WEIGHTING + pplayer->ai.warmth)<<6;
+  b = (POLLUTION_WEIGHTING + pplayer->ai.warmth)*64;
   if (pcity->pollution > 0) {
     a = amortize(b, 100 / pcity->pollution);
-    c = ((a * b) / (MAX(1, b - a)))>>6;
+    c = ((a * b) / (MAX(1, b - a)))/64;
     freelog(LOG_DEBUG, "City: %s, Pollu: %d, cost: %d, Id: %d, P: %d",
            pcity->name, pcity->pollution, c, id, p);
   } else c = 0;
   if (p) {
     a = amortize(b, 100 / p);
-    c -= ((a * b) / (MAX(1, b - a)))>>6;
+    c -= ((a * b) / (MAX(1, b - a)))/64;
   } 
   return(c); /* benefit or cost of this building */
 }
@@ -195,8 +195,8 @@
   tax *= t;
 #else
 /* better might be a longterm weighted average, this is a quick-n-dirty fix -- 
Syela */
-  sci = ((sci + pcity->trade_prod) * t)>>1;
-  tax = ((tax + pcity->trade_prod) * t)>>1;
+  sci = ((sci + pcity->trade_prod) * t)/2;
+  tax = ((tax + pcity->trade_prod) * t)/2;
 #endif
   if (pplayer->research.researching == A_NONE) sci = 0; /* don't need 
libraries!! */
   prod = pcity->shield_prod * 100 / city_shield_bonus(pcity) * 
SHIELD_WEIGHTING;
@@ -223,7 +223,7 @@
     int asz = game.aqueduct_size;
     if (city_happy(pcity) && pcity->size > asz-1 && est_food > 0)
       values[B_AQUEDUCT] = ((((city_got_effect(pcity, B_GRANARY) ? 3 : 2) *
-         pcity->size * game.foodbox)>>1) - pcity->food_stock) * food;
+         pcity->size * game.foodbox)/2) - pcity->food_stock) * food;
     else values[B_AQUEDUCT] = food * est_food * asz * game.foodbox /
            MAX(1, ((asz+1 - MIN(asz, pcity->size)) * MAX(asz, pcity->size) *
            game.foodbox - pcity->food_stock));
@@ -295,12 +295,12 @@
     values[B_COLOSSEUM] = building_value(4, pcity, val) - building_value(3, 
pcity, val);
   
   if (could_build_improvement(pcity, B_COURTHOUSE)) {
-    values[B_COURTHOUSE] = (pcity->corruption * t)>>1;
+    values[B_COURTHOUSE] = (pcity->corruption * t)/2;
     if (gov == G_DEMOCRACY) values[B_COLOSSEUM] += building_value(1, pcity, 
val);
   }
   
   if (could_build_improvement(pcity, B_FACTORY))
-    values[B_FACTORY] = (prod>>1) + pollution_cost(pplayer, pcity, B_FACTORY);
+    values[B_FACTORY] = (prod/2) + pollution_cost(pplayer, pcity, B_FACTORY);
   
   if (could_build_improvement(pcity, B_GRANARY) &&
       !(improvement_variant(B_PYRAMIDS)==0 &&
@@ -311,10 +311,10 @@
     values[B_HARBOUR] = food * ocean_workers(pcity) * hunger;
 
   if (could_build_improvement(pcity, B_HYDRO) && !built_elsewhere(pcity, 
B_HOOVER))
-    values[B_HYDRO] = ((needpower * prod)>>2) + pollution_cost(pplayer, pcity, 
B_HYDRO);
+    values[B_HYDRO] = ((needpower * prod)/4) + pollution_cost(pplayer, pcity, 
B_HYDRO);
 
   if (could_build_improvement(pcity, B_LIBRARY))
-    values[B_LIBRARY] = sci>>1;
+    values[B_LIBRARY] = sci/2;
 
   if (could_build_improvement(pcity, B_MARKETPLACE))
     values[B_MARKETPLACE] = (tax + 3*pcity->ppl_taxman +
@@ -325,20 +325,20 @@
                      city_got_building(pcity, B_NUCLEAR) ||
                      city_got_building(pcity, B_POWER) ||
                      city_affected_by_wonder(pcity, B_HOOVER)) ?
-                     (prod * 3)>>2 : prod>>1) +
+                     (prod * 3)/4 : prod/2) +
                      pollution_cost(pplayer, pcity, B_MFG);
 
   if (could_build_improvement(pcity, B_NUCLEAR))
-    values[B_NUCLEAR] = ((needpower * prod)>>2) + pollution_cost(pplayer, 
pcity, B_NUCLEAR);
+    values[B_NUCLEAR] = ((needpower * prod)/4) + pollution_cost(pplayer, 
pcity, B_NUCLEAR);
 
   if (could_build_improvement(pcity, B_OFFSHORE)) /* ignoring pollu.  FIX? */
     values[B_OFFSHORE] = ocean_workers(pcity) * SHIELD_WEIGHTING;
 
   if (could_build_improvement(pcity, B_POWER))
-    values[B_POWER] = ((needpower * prod)>>2) + pollution_cost(pplayer, pcity, 
B_POWER);
+    values[B_POWER] = ((needpower * prod)/4) + pollution_cost(pplayer, pcity, 
B_POWER);
 
   if (could_build_improvement(pcity, B_RESEARCH) && !built_elsewhere(pcity, 
B_SETI))
-    values[B_RESEARCH] = sci>>1;
+    values[B_RESEARCH] = sci/2;
 
   if (could_build_improvement(pcity, B_SDI))
     values[B_SDI] = 50; /* WAG */
@@ -347,7 +347,7 @@
     int ssz = game.sewer_size;
     if (city_happy(pcity) && pcity->size > ssz-1 && est_food > 0)
       values[B_SEWER] = ((((city_got_effect(pcity, B_GRANARY) ? 3 : 2) *
-         pcity->size * game.foodbox)>>1) - pcity->food_stock) * food;
+         pcity->size * game.foodbox)/2) - pcity->food_stock) * food;
     else values[B_SEWER] = food * est_food * ssz * game.foodbox /
           MAX(1, ((ssz+1 - MIN(ssz, pcity->size)) * MAX(ssz, pcity->size) *
           game.foodbox - pcity->food_stock));
@@ -366,7 +366,7 @@
     values[B_TEMPLE] = building_value(get_temple_power(pcity), pcity, val);
 
   if (could_build_improvement(pcity, B_UNIVERSITY))
-    values[B_UNIVERSITY] = sci>>1;
+    values[B_UNIVERSITY] = sci/2;
 
   if (could_build_improvement(pcity, B_MASS))
     values[B_MASS] = pollution_cost(pplayer, pcity, B_MASS);
@@ -386,7 +386,7 @@
       if (i == B_COLLOSSUS)
         values[i] = (pcity->size + 1) * t; /* probably underestimates the 
value */
       if (i == B_COPERNICUS)
-        values[i] = sci>>1;
+        values[i] = sci/2;
       if (i == B_CURE)
         values[i] = building_value(1, pcity, val);
       if (i == B_DARWIN) /* this is a one-time boost, not constant */
@@ -408,7 +408,7 @@
       if (i == B_HOOVER && !city_got_building(pcity, B_HYDRO) &&
                            !city_got_building(pcity, B_NUCLEAR))
         values[i] = (city_got_building(pcity, B_POWER) ? 0 :
-               (needpower * prod)>>2) + pollution_cost(pplayer, pcity, 
B_HOOVER);
+               (needpower * prod)/4) + pollution_cost(pplayer, pcity, 
B_HOOVER);
       if (i == B_ISAAC)
         values[i] = sci;
       if (i == B_LEONARDO) {
@@ -445,7 +445,7 @@
          && !city_got_building(pcity, B_GRANARY))
         values[i] = food * pcity->food_surplus; /* different tech req's */
       if (i == B_SETI && !city_got_building(pcity, B_RESEARCH))
-        values[i] = sci>>1;
+        values[i] = sci/2;
       if (i == B_SHAKESPEARE)
         values[i] = building_value(pcity->size, pcity, val);
       if (i == B_SUNTZU)
@@ -543,7 +543,7 @@
         if (want > choice->want) {
           choice->want = want;
           choice->type = 1;
-         ai_choose_role_unit(pplayer, pcity, choice, F_CARAVAN, i>>1);
+         ai_choose_role_unit(pplayer, pcity, choice, F_CARAVAN, i/2);
         }
       } else
        pplayer->ai.tech_want[get_unit_type(iunit)->tech_requirement] += want;
diff -u --recursive --new-file --exclude-from=.diffignore 
freeciv-cvs/ai/advmilitary.c freeciv-shift/ai/advmilitary.c
--- freeciv-cvs/ai/advmilitary.c        Sat Jun 12 15:03:19 1999
+++ freeciv-shift/ai/advmilitary.c      Sat Jul  3 01:44:32 1999
@@ -134,7 +134,7 @@
     denom += (denom + m * 2) / (m * 4);
     dist--;
   }
-  v = (v*num + (denom>>1)) / denom;
+  v = (v*num + (denom/2)) / denom;
   return(v);
 #endif
 }
@@ -147,8 +147,8 @@
   if (is_sailing_unit(punit) && !is_terrain_near_tile(pcity->x, pcity->y, 
T_OCEAN)) v = 0;
 /* get_attack_power will be wrong if moves_left == 1 || == 2 */
   v *= punit->hp * get_unit_type(punit->type)->firepower;
-  if (city_got_building(pcity, B_COASTAL) && is_sailing_unit(punit)) v >>= 1;
-  if (city_got_building(pcity, B_SAM) && is_air_unit(punit)) v >>= 1;
+  if (city_got_building(pcity, B_COASTAL) && is_sailing_unit(punit)) v /= 2;
+  if (city_got_building(pcity, B_SAM) && is_air_unit(punit)) v /= 2;
   v /= 30; /* rescaling factor to stop the overflow nonsense */
   return(v);
 }
@@ -256,9 +256,9 @@
           }
 
           if (unit_flag(funit->type, F_HORSE)) {
-            if (pikemen) v >>= 1;
+            if (pikemen) v /= 2;
             else ai_wants_role_unit(pplayer, pcity, F_PIKEMEN,
-                                   (v * m / (dist<<1)));
+                                   (v * m / (dist*2)));
           }
 
         if (unit_flag(funit->type, F_DIPLOMAT) && (dist <= 2 * m)) 
@@ -298,9 +298,9 @@
         }
 
         if (unit_flag(punit->type, F_HORSE)) {
-          if (pikemen) v >>= 1;
+          if (pikemen) v /= 2;
          else ai_wants_role_unit(pplayer, pcity, F_PIKEMEN,
-                                 (v * m / (dist<<1)));
+                                 (v * m / (dist*2)));
         }
 
         if (unit_flag(punit->type, F_DIPLOMAT) && (dist <= 2 * m))
@@ -400,7 +400,7 @@
   d = get_unit_type(i)->defense_strength;
   if (def) cur *= d;
   else if (d > a) return(0);
-/*  else if (d < 2) cur = (cur * (a + d))>>1; Don't believe in this anymore */
+/*  else if (d < 2) cur = (cur * (a + d))/2; Don't believe in this anymore */
   else cur *= a; /* wanted to rank Legion > Catapult > Archer */
 /* which we will do by munging f in the attacker want equations */
   if (unit_flag(i, F_IGTER) && !def) cur *= 3;
@@ -495,8 +495,8 @@
          unit_types[i].attack_strength && /* otherwise we get SIGFPE's */
          m == movetype) { /* I don't think I want the duplication otherwise -- 
Syela */
       l = k * (k + pplayer->research.researchpoints) * game.techlevel;
-      if (game.year > 0) l >>= 1;
-      else l >>= 2; /* cost (shield equiv) of gaining these techs */
+      if (game.year > 0) l /= 2;
+      else l /= 4; /* cost (shield equiv) of gaining these techs */
       l /= city_list_size(&pplayer->cities);
 /* Katvrr advises that with danger high, l should be weighted more heavily */
 
diff -u --recursive --new-file --exclude-from=.diffignore 
freeciv-cvs/ai/aicity.c freeciv-shift/ai/aicity.c
--- freeciv-cvs/ai/aicity.c     Sat Jun 12 15:03:20 1999
+++ freeciv-shift/ai/aicity.c   Sat Jul  3 01:33:37 1999
@@ -316,7 +316,7 @@
                 && is_on_unit_upgrade_path(bestchoice.choice, punit->type)))
            && ai_fuzzy(pplayer, 1)) {
           if (!did_upgrade) { /* might want to disband */
-            build = pcity->shield_stock + 
(get_unit_type(punit->type)->build_cost>>1);
+            build = pcity->shield_stock + 
(get_unit_type(punit->type)->build_cost/2);
             total = get_unit_type(bestchoice.choice)->build_cost;
             cost=(total-build)*2+(total-build)*(total-build)/20;
             if ((bestchoice.want <= 100 && build >= total) ||
diff -u --recursive --new-file --exclude-from=.diffignore 
freeciv-cvs/ai/aihand.c freeciv-shift/ai/aihand.c
--- freeciv-cvs/ai/aihand.c     Sat Jun 12 15:03:20 1999
+++ freeciv-shift/ai/aihand.c   Sat Jul  3 01:38:25 1999
@@ -272,10 +272,10 @@
        ai_fuzzy(pplayer,1)) {
       freelog(LOG_DEBUG, "%d happy people in %s",
                    pcity->ppl_happy[4], pcity->name);
-      n = ((pcity->size>>1) - pcity->ppl_happy[4]) * 20;
+      n = ((pcity->size/2) - pcity->ppl_happy[4]) * 20;
       if (n > pcity->ppl_content[1] * 20) n += (n - pcity->ppl_content[1] * 
20);
       m = ((((city_got_effect(pcity, B_GRANARY) ? 3 : 2) *
-            (pcity->size+1) * game.foodbox)>>1) -
+            (pcity->size+1) * game.foodbox)/2) -
            pcity->food_stock) * food_weighting(pcity->size);
       freelog(LOG_DEBUG, "Checking HHJJ for %s, m = %d", pcity->name, m);
       tot = 0;
@@ -283,7 +283,7 @@
         if (pcity->trade_prod * i * city_tax_bonus(pcity) >= n * 100) {
          if (!tot) freelog(LOG_DEBUG, "%s celebrates at %d.",
                            pcity->name, i * 10);
-          hhjj[i] += (pcity->was_happy ? m : m>>1);
+          hhjj[i] += (pcity->was_happy ? m : m/2);
           tot++;
         }
       }
@@ -358,7 +358,7 @@
   } else { /* have to balance things logically */
 /* if we need 50 gold and we have trade = 100, need 50 % tax (n = 5) */
 /*  n = ((ai_gold_reserve(pplayer) - gnow - expense) ... I hate typos. -- 
Syela */
-    n = ((ai_gold_reserve(pplayer) - gnow + expense + cities) * 20 + 
(trade<<1) - 1) / (trade<<1);
+    n = ((ai_gold_reserve(pplayer) - gnow + expense + cities) * 20 + (trade*2) 
- 1) / (trade*2);
 /* same bug here as above, caused us not to afford city walls we needed. -- 
Syela */
     if (n < 0) n = 0; /* shouldn't allow 0 tax? */
     while (n > 10 - (pplayer->economic.luxury / 10) || n > maxrate) n--;
diff -u --recursive --new-file --exclude-from=.diffignore 
freeciv-cvs/ai/aiunit.c freeciv-shift/ai/aiunit.c
--- freeciv-cvs/ai/aiunit.c     Thu Jun 24 14:55:19 1999
+++ freeciv-shift/ai/aiunit.c   Sat Jul  3 01:38:10 1999
@@ -1270,7 +1270,7 @@
   if (punit->activity != ACTIVITY_IDLE)
     return;
   if (punit->ai.ai_role == AIUNIT_NONE) {
-    if ((pcity = wonder_on_continent(pplayer, map_get_continent(punit->x, 
punit->y))) && build_points_left(pcity) > (pcity->shield_surplus<<1)) {
+    if ((pcity = wonder_on_continent(pplayer, map_get_continent(punit->x, 
punit->y))) && build_points_left(pcity) > (pcity->shield_surplus*2)) {
       if (!same_pos(pcity->x, pcity->y, punit->x, punit->y)) {
         if (!punit->moves_left) return;
        auto_settler_do_goto(pplayer,punit, pcity->x, pcity->y);
diff -u --recursive --new-file --exclude-from=.diffignore 
freeciv-cvs/server/gotohand.c freeciv-shift/server/gotohand.c
--- freeciv-cvs/server/gotohand.c       Sat Jun 12 15:03:30 1999
+++ freeciv-shift/server/gotohand.c     Sat Jul  3 01:45:05 1999
@@ -106,7 +106,7 @@
 
   if (punit && unit_flag(punit->type, F_IGTER)) igter++;
   if (punit && unit_flag(punit->type, F_SETTLERS)
-      && get_unit_type(punit->type)->move_rate==3) maxcost >>= 1;
+      && get_unit_type(punit->type)->move_rate==3) maxcost /= 2;
   /* (?) was punit->type == U_SETTLERS -- dwp */
 
   do {
@@ -129,7 +129,7 @@
 This led to a bad bug where a unit in a swamp was considered too far away */
         else {
           tm = map_get_tile(x1, y1)->move_cost[7-k];
-          c = (tile0->move_cost[k] + tm + (tile0->move_cost[k] > tm ? 1 : 
0))>>1;
+          c = (tile0->move_cost[k] + tm + (tile0->move_cost[k] > tm ? 1 : 
0))/2;
         }
         
         tm = warmap.cost[x][y] + c;
@@ -197,9 +197,9 @@
   if (y1 > y0) s = y1 - y0;
   else n = y0 - y1;
   dx = x1 - x0;
-  if (dx > map.xsize>>1) w = map.xsize - dx;
+  if (dx > map.xsize/2) w = map.xsize - dx;
   else if (dx > 0) e = dx;
-  else if (dx + (map.xsize>>1) > 0) w = 0 - dx;
+  else if (dx + (map.xsize/2) > 0) w = 0 - dx;
   else e = map.xsize + dx;
   if (e == map.xsize / 2 || w == map.xsize / 2) { /* thanks, Massimo */
     if (k < 3 && s >= MAX(e, w)) return 0;
@@ -616,7 +616,7 @@
         adjtile = map_get_tile(x + ii[n], y + jj[n]);
         if (adjtile->terrain != T_OCEAN) nearland++;
         if (!((adjtile->known)&(1u<<punit->owner))) {
-          if (punit->moves_left <= c) d[k] -= (d[k]>>4); /* Avoid the unknown 
*/
+          if (punit->moves_left <= c) d[k] -= (d[k]/16); /* Avoid the unknown 
*/
           else d[k]++; /* nice but not important */
         } else { /* NOTE: Not being omniscient here!! -- Syela */
           unit_list_iterate(adjtile->units, aunit) /* lookin for trouble */
diff -u --recursive --new-file --exclude-from=.diffignore 
freeciv-cvs/server/settlers.c freeciv-shift/server/settlers.c
--- freeciv-cvs/server/settlers.c       Thu Jun 24 14:55:21 1999
+++ freeciv-shift/server/settlers.c     Sat Jul  3 01:42:28 1999
@@ -98,7 +98,7 @@
       d--;
     }
     if (denom > 1) {
-      b = (b + (denom>>1)) / denom;
+      b = (b + (denom/2)) / denom;
     }
   }
   return(b * s);
@@ -818,11 +818,11 @@
 
        newv = pcity->ai.irrigate[i][j];
         if (newv >= oldv) { /* worth evaluating */
-          b = MAX((newv - oldv)<<6, MORT);
+          b = MAX((newv - oldv)*64, MORT);
           d = (map_build_irrigation_time(x, y) * 3 + mv_rate - 1) / mv_rate
            + mv_turns;
           a = amortize(b, d);
-          newv = ((a * b) / (MAX(1, b - a)))>>6;
+          newv = ((a * b) / (MAX(1, b - a)))/64;
         } else newv = 0;
         if ((newv > best_newv || (newv == best_newv && oldv > best_oldv))
            && ai_fuzzy(pplayer, 1)) {
@@ -835,11 +835,11 @@
 
        newv = pcity->ai.mine[i][j];
         if (newv >= oldv) {
-          b = MAX((newv - oldv)<<6, MORT);
+          b = MAX((newv - oldv)*64, MORT);
           d = (map_build_mine_time(x, y) * 3 + mv_rate - 1) / mv_rate
            + mv_turns;
           a = amortize(b, d);
-          newv = ((a * b) / (MAX(1, b - a)))>>6;
+          newv = ((a * b) / (MAX(1, b - a)))/64;
         } else newv = 0;
        if ((newv > best_newv || (newv == best_newv && oldv > best_oldv))
            && ai_fuzzy(pplayer, 1)) {
@@ -856,11 +856,11 @@
             newv = MAX(newv, oldv) + road_bonus(x, y, S_ROAD) * 8;
            /* guessing about the weighting based on unit upkeeps;
               (* 11) was too high! -- Syela */
-            b = MAX((newv - oldv)<<6, MORT);
+            b = MAX((newv - oldv)*64, MORT);
             d = (map_build_road_time(x, y) * 3 + 3 + mv_rate - 1) / mv_rate
              + mv_turns; /* uniquely weird! */
             a = amortize(b, d);
-            newv = ((a * b) / (MAX(1, b - a)))>>6;
+            newv = ((a * b) / (MAX(1, b - a)))/64;
           } else newv = 0;
           if ((newv > best_newv || (newv == best_newv && oldv > best_oldv))
              && ai_fuzzy(pplayer, 1)) {
@@ -874,11 +874,11 @@
          newv = pcity->ai.railroad[i][j];
           if (newv >= 0) {    
             newv = MAX(newv, oldv) + road_bonus(x, y, S_RAILROAD) * 4;
-            b = MAX((newv - oldv)<<6, MORT);
+            b = MAX((newv - oldv)*64, MORT);
             d = (3 * 3 + 3 * map_build_road_time(x,y) + 3 + mv_rate - 1)
                 / mv_rate + mv_turns;
             a = amortize(b, d);
-            newv = ((a * b) / (MAX(1, b - a)))>>6;
+            newv = ((a * b) / (MAX(1, b - a)))/64;
           } else newv = 0;
           if ((newv > best_newv || (newv == best_newv && oldv > best_oldv))
              && ai_fuzzy(pplayer, 1)) {
@@ -889,10 +889,10 @@
          newv = pcity->ai.railroad[i][j];
           if (newv >= 0) {    
             newv = MAX(newv, oldv) + road_bonus(x, y, S_RAILROAD) * 4;
-            b = MAX((newv - oldv)<<6, MORT);
+            b = MAX((newv - oldv)*64, MORT);
             d = (3 * 3 + mv_rate - 1) / mv_rate + mv_turns;
             a = amortize(b, d);
-            newv = ((a * b) / (MAX(1, b - a)))>>6;
+            newv = ((a * b) / (MAX(1, b - a)))/64;
           } else newv = 0;
           if ((newv > best_newv || (newv == best_newv && oldv > best_oldv))
              && ai_fuzzy(pplayer, 1)) {
@@ -904,10 +904,10 @@
        newv = pcity->ai.detox[i][j];
         if (newv >= 0) {
           newv = MAX(newv, oldv) + pplayer->ai.warmth;
-          b = MAX((newv - oldv)<<6, MORT);
+          b = MAX((newv - oldv)*64, MORT);
           d = (3 * 3 + mv_turns + mv_rate - 1) / mv_rate + mv_turns;
           a = amortize(b, d);
-          newv = ((a * b) / (MAX(1, b - a)))>>6;
+          newv = ((a * b) / (MAX(1, b - a)))/64;
         } else newv = 0;
         if (newv > best_newv || (newv == best_newv && oldv > best_oldv)) {
          best_act = ACTIVITY_POLLUTION;
diff -u --recursive --new-file --exclude-from=.diffignore 
freeciv-cvs/server/unitfunc.c freeciv-shift/server/unitfunc.c
--- freeciv-cvs/server/unitfunc.c       Sat Jun 12 15:03:33 1999
+++ freeciv-shift/server/unitfunc.c     Sat Jul  3 01:35:40 1999
@@ -116,7 +116,7 @@
 void spy_sabotage_unit(struct player *pplayer, struct unit *pdiplomat, struct 
unit *pvictim){
   
   if(pvictim && pvictim->hp > 1){
-    pvictim->hp = pvictim->hp >> 1;
+    pvictim->hp /= 2;
     notify_player_ex(get_player(pvictim->owner), 
                     pvictim->x, pvictim->y, E_DIPLOMATED,
                     "Your %s was sabotaged by %s!", 

-- 
//Markus

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] [PATCH] Change shifts and rotates to multiplications and divides, Markus Linnala <=