Author: jtn
Date: Tue May 12 09:22:58 2015
New Revision: 29053

URL: http://svn.gna.org/viewcvs/freeciv?rev=29053&view=rev
Log:
Take account of multipliers in city dialog tooltips.

See gna bug #23583.

Modified:
    trunk/client/citydlg_common.c
    trunk/common/effects.c

Modified: trunk/client/citydlg_common.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/citydlg_common.c?rev=29053&r1=29052&r2=29053&view=diff
==============================================================================
--- trunk/client/citydlg_common.c       (original)
+++ trunk/client/citydlg_common.c       Tue May 12 09:22:58 2015
@@ -500,17 +500,31 @@
 
       effect_list_iterate(plist, peffect) {
        char buf2[512];
+        int delta;
        int new_total;
 
        get_effect_req_text(peffect, buf2, sizeof(buf2));
 
-       bonus += peffect->value;
+        if (peffect->multiplier) {
+          Multiplier_type_id index = multiplier_index(peffect->multiplier);
+          int mul = city_owner(pcity)->multipliers[index];
+          
+          if (mul == 0) {
+            /* Suppress text when multiplier setting suppresses effect
+             * (this will also suppress it when the city owner's policy
+             * settings are not known to us) */
+            continue;
+          }
+          delta = peffect->value * mul;
+        } else {
+          delta = peffect->value;
+        }
+        bonus += delta;
        new_total = bonus * base / 100;
        cat_snprintf(buf, bufsz,
-                     (peffect->value > 0) ? _("%+4d : Bonus from %s (%+d%%)\n")
-                                          : _("%+4d : Loss from %s (%+d%%)\n"),
-                    (new_total - total), buf2,
-                    peffect->value);
+                     (delta > 0) ? _("%+4d : Bonus from %s (%+d%%)\n")
+                                 : _("%+4d : Loss from %s (%+d%%)\n"),
+                    (new_total - total), buf2, delta);
        total = new_total;
       } effect_list_iterate_end;
       effect_list_destroy(plist);
@@ -618,13 +632,29 @@
 
   effect_list_iterate(plist, peffect) {
     char buf2[512];
+    int delta;
 
     get_effect_req_text(peffect, buf2, sizeof(buf2));
 
+    if (peffect->multiplier) {
+      Multiplier_type_id index = multiplier_index(peffect->multiplier);
+      int mul = city_owner(pcity)->multipliers[index];
+      
+      if (mul == 0) {
+        /* Suppress text when multiplier setting suppresses effect
+         * (this will also suppress it when the city owner's policy
+         * settings are not known to us) */
+        continue;
+      }
+      delta = peffect->value * mul;
+    } else {
+      delta = peffect->value;
+    }
+
     cat_snprintf(buf, bufsz,
-                 (peffect->value > 0) ? _("%+5.1f : Bonus from %s\n")
-                                      : _("%+5.1f : Risk from %s\n"),
-                 -(0.1 * ill_base * peffect->value / 100), buf2);
+                 (delta > 0) ? _("%+5.1f : Bonus from %s\n")
+                             : _("%+5.1f : Risk from %s\n"),
+                 -(0.1 * ill_base * delta / 100), buf2);
   } effect_list_iterate_end;
   effect_list_destroy(plist);
 
@@ -676,11 +706,24 @@
 
   effect_list_iterate(plist, peffect) {
     char buf2[512];
+    int mul = 1;
 
     get_effect_req_text(peffect, buf2, sizeof(buf2));
 
+    if (peffect->multiplier) {
+      Multiplier_type_id index = multiplier_index(peffect->multiplier);
+      mul = city_owner(pcity)->multipliers[index];
+      
+      if (mul == 0) {
+        /* Suppress text when multiplier setting suppresses effect
+         * (this will also suppress it when the city owner's policy
+         * settings are not known to us) */
+        continue;
+      }
+    }
+
     cat_snprintf(buf, bufsz,
-                 _("%4d : %s\n"), peffect->value, buf2);
+                 _("%4d : %s\n"), peffect->value * mul, buf2);
   } effect_list_iterate_end;
   effect_list_destroy(plist);
 

Modified: trunk/common/effects.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/effects.c?rev=29053&r1=29052&r2=29053&view=diff
==============================================================================
--- trunk/common/effects.c      (original)
+++ trunk/common/effects.c      Tue May 12 09:22:58 2015
@@ -919,6 +919,10 @@
 {
   buf[0] = '\0';
 
+  if (peffect->multiplier) {
+    fc_strlcat(buf, multiplier_name_translation(peffect->multiplier), buf_len);
+  }
+
   /* FIXME: should we do something for present==FALSE reqs?
    * Currently we just ignore them. */
   requirement_vector_iterate(&peffect->reqs, preq) {


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

Reply via email to