Author: cazfi
Date: Sat Jan 10 21:54:00 2015
New Revision: 27607

URL: http://svn.gna.org/viewcvs/freeciv?rev=27607&view=rev
Log:
Renamed functions with name ending to _sq() as _squared() to make the meaning 
clear.

Based on report of James Spahlinger <nixeagle>

See patch #1948

Modified:
    trunk/ai/default/advmilitary.c
    trunk/ai/default/aiunit.c
    trunk/ai/default/aiunit.h
    trunk/server/advisors/advgoto.c
    trunk/server/advisors/advgoto.h

Modified: trunk/ai/default/advmilitary.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/advmilitary.c?rev=27607&r1=27606&r2=27607&view=diff
==============================================================================
--- trunk/ai/default/advmilitary.c      (original)
+++ trunk/ai/default/advmilitary.c      Sat Jan 10 21:54:00 2015
@@ -1026,9 +1026,9 @@
       /* Estimate strength of the enemy. */
 
       if (victim_unit_type) {
-        vuln = unittype_def_rating_sq(punittype, victim_unit_type,
-                                      victim_player,
-                                      ptile, FALSE, veteran);
+        vuln = unittype_def_rating_squared(punittype, victim_unit_type,
+                                           victim_player,
+                                           ptile, FALSE, veteran);
       } else {
         vuln = 0;
       }
@@ -1222,9 +1222,9 @@
     def_owner = city_owner(acity);
     if (1 < move_time && def_type) {
       def_vet = do_make_unit_veteran(acity, def_type);
-      vulnerability = unittype_def_rating_sq(unit_type(myunit), def_type,
-                                             city_owner(acity), ptile,
-                                             FALSE, def_vet);
+      vulnerability = unittype_def_rating_squared(unit_type(myunit), def_type,
+                                                  city_owner(acity), ptile,
+                                                  FALSE, def_vet);
       benefit = utype_build_shield_cost(def_type);
     } else {
       vulnerability = 0;
@@ -1234,9 +1234,9 @@
 
     pdef = get_defender(myunit, ptile);
     if (pdef) {
-      int m = unittype_def_rating_sq(unit_type(myunit), unit_type(pdef),
-                                     city_owner(acity), ptile, FALSE,
-                                     pdef->veteran);
+      int m = unittype_def_rating_squared(unit_type(myunit), unit_type(pdef),
+                                          city_owner(acity), ptile, FALSE,
+                                          pdef->veteran);
       if (vulnerability < m) {
         vulnerability = m;
         benefit = unit_build_shield_cost(pdef);

Modified: trunk/ai/default/aiunit.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/aiunit.c?rev=27607&r1=27606&r2=27607&view=diff
==============================================================================
--- trunk/ai/default/aiunit.c   (original)
+++ trunk/ai/default/aiunit.c   Sat Jan 10 21:54:00 2015
@@ -104,8 +104,8 @@
                                 struct unit *punit);
 
 static bool unit_role_defender(const struct unit_type *punittype);
-static int unit_def_rating_sq(const struct unit *punit,
-                              const struct unit *pdef);
+static int unit_def_rating_squared(const struct unit *punit,
+                                   const struct unit *pdef);
 
 /*
  * Cached values. Updated by update_simple_ai_types.
@@ -259,9 +259,10 @@
 /****************************************************************************
   Square of the adv_unit_att_rating() function - used in actual computations.
 ****************************************************************************/
-static int unit_att_rating_sq(const struct unit *punit)
+static int unit_att_rating_squared(const struct unit *punit)
 {
   int v = adv_unit_att_rating(punit);
+
   return v * v;
 }
 
@@ -279,10 +280,11 @@
 /****************************************************************************
   Square of the previous function - used in actual computations.
 ****************************************************************************/
-static int unit_def_rating_sq(const struct unit *attacker,
-                              const struct unit *defender)
+static int unit_def_rating_squared(const struct unit *attacker,
+                                   const struct unit *defender)
 {
   int v = unit_def_rating(attacker, defender);
+
   return v * v;
 }
 
@@ -291,10 +293,11 @@
   See get_virtual_defense_power for the arguments att_type, def_type,
   x, y, fortified and veteran.
 **************************************************************************/
-int unittype_def_rating_sq(const struct unit_type *att_type,
-                          const struct unit_type *def_type,
-                          const struct player *def_player,
-                           struct tile *ptile, bool fortified, int veteran)
+int unittype_def_rating_squared(const struct unit_type *att_type,
+                                const struct unit_type *def_type,
+                                const struct player *def_player,
+                                struct tile *ptile, bool fortified,
+                                int veteran)
 {
   int v = get_virtual_defense_power(att_type, def_type, def_player, ptile,
                                     fortified, veteran)
@@ -699,7 +702,7 @@
   struct pf_map *pfm;
   struct city *pcity;
   struct ai_city *data, *best_data = NULL;
-  const int toughness = adv_unit_def_rating_basic_sq(punit);
+  const int toughness = adv_unit_def_rating_basic_squared(punit);
   int def, best_def = -1;
   /* Arbitrary: 3 turns. */
   const int max_move_cost = 3 * unit_move_rate(punit);
@@ -740,7 +743,7 @@
         continue;
       }
 
-      def = (toughness - adv_unit_def_rating_basic_sq(buddy));
+      def = (toughness - adv_unit_def_rating_basic_squared(buddy));
       if (0 >= def) {
         continue;
       }
@@ -1329,7 +1332,7 @@
 
       if (can_unit_attack_tile(punit, city_tile(acity))
           && (pdefender = get_defender(punit, city_tile(acity)))) {
-        vulnerability = unit_def_rating_sq(punit, pdefender);
+        vulnerability = unit_def_rating_squared(punit, pdefender);
         benefit = unit_build_shield_cost(pdefender);
       } else {
         pdefender = NULL;
@@ -1341,10 +1344,10 @@
         struct unit_type *def_type = dai_choose_defender_versus(acity, punit);
 
         if (def_type) {
-          int v = unittype_def_rating_sq(punit_type, def_type, aplayer,
-                                         atile, FALSE,
-                                         do_make_unit_veteran(acity,
-                                                              def_type));
+          int v = unittype_def_rating_squared(punit_type, def_type, aplayer,
+                                              atile, FALSE,
+                                              do_make_unit_veteran(acity,
+                                                                   def_type));
           if (v > vulnerability) {
             /* They can build a better defender! */
             vulnerability = v;
@@ -1474,7 +1477,7 @@
       }
     } city_list_iterate_end;
 
-    attack = unit_att_rating_sq(punit);
+    attack = unit_att_rating_squared(punit);
     /* I'm not sure the following code is good but it seems to be adequate.
      * I am deliberately not adding ferryboat code to the unit_list_iterate.
      * -- Syela */
@@ -1514,7 +1517,7 @@
         continue;
       }
 
-      vulnerability = unit_def_rating_sq(punit, aunit);
+      vulnerability = unit_def_rating_squared(punit, aunit);
       benefit = unit_build_shield_cost(aunit);
 
       move_time = pos.turn;
@@ -2926,7 +2929,7 @@
   extras_bonus += tile_extras_defense_bonus(ptile, unit_type(punit));
 
   db += (db * extras_bonus) / 100;
-  d = adv_unit_def_rating_basic_sq(punit) * db;
+  d = adv_unit_def_rating_basic_squared(punit) * db;
 
   adjc_iterate(ptile, ptile1) {
     if (has_handicap(pplayer, H_FOG)

Modified: trunk/ai/default/aiunit.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/aiunit.h?rev=27607&r1=27606&r2=27607&view=diff
==============================================================================
--- trunk/ai/default/aiunit.h   (original)
+++ trunk/ai/default/aiunit.h   Sat Jan 10 21:54:00 2015
@@ -116,10 +116,10 @@
                            int *pmove_time);
 
 int build_cost_balanced(const struct unit_type *punittype);
-int unittype_def_rating_sq(const struct unit_type *att_type,
-                          const struct unit_type *def_type,
-                          const struct player *def_player,
-                           struct tile *ptile, bool fortified, int veteran);
+int unittype_def_rating_squared(const struct unit_type *att_type,
+                                const struct unit_type *def_type,
+                                const struct player *def_player,
+                                struct tile *ptile, bool fortified, int 
veteran);
 int kill_desire(int benefit, int attack, int loss, int vuln, int attack_count);
 
 bool is_on_unit_upgrade_path(const struct unit_type *test,

Modified: trunk/server/advisors/advgoto.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/advisors/advgoto.c?rev=27607&r1=27606&r2=27607&view=diff
==============================================================================
--- trunk/server/advisors/advgoto.c     (original)
+++ trunk/server/advisors/advgoto.c     Sat Jan 10 21:54:00 2015
@@ -243,9 +243,10 @@
 /****************************************************************************
   Square of the previous function - used in actual computations.
 ****************************************************************************/
-int adv_unit_def_rating_basic_sq(const struct unit *punit)
+int adv_unit_def_rating_basic_squared(const struct unit *punit)
 {
   int v = adv_unit_def_rating_basic(punit);
+
   return v * v;
 }
 
@@ -278,7 +279,7 @@
   db = 10 + tile_terrain(ptile)->defense_bonus / 10;
   extras_bonus += tile_extras_defense_bonus(ptile, unit_type(punit));
   db += (db * extras_bonus) / 100;
-  d = adv_unit_def_rating_basic_sq(punit) * db;
+  d = adv_unit_def_rating_basic_squared(punit) * db;
 
   adjc_iterate(ptile, ptile1) {
     if (!map_is_known_and_seen(ptile1, unit_owner(punit), V_MAIN)) {

Modified: trunk/server/advisors/advgoto.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/advisors/advgoto.h?rev=27607&r1=27606&r2=27607&view=diff
==============================================================================
--- trunk/server/advisors/advgoto.h     (original)
+++ trunk/server/advisors/advgoto.h     Sat Jan 10 21:54:00 2015
@@ -47,6 +47,6 @@
                             int moves_left, int hp);
 int adv_unit_att_rating(const struct unit *punit);
 int adv_unit_def_rating_basic(const struct unit *punit);
-int adv_unit_def_rating_basic_sq(const struct unit *punit);
+int adv_unit_def_rating_basic_squared(const struct unit *punit);
 
 #endif   /* FC__ADVGOTO_H */


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to