Author: jtn
Date: Thu May 28 00:00:35 2015
New Revision: 29137

URL: http://svn.gna.org/viewcvs/freeciv?rev=29137&view=rev
Log:
Display up to two decimal places for defense bonus in Gtk help.

See gna bug #23263.

Modified:
    branches/S2_6/client/gui-gtk-2.0/helpdlg.c
    branches/S2_6/client/gui-gtk-3.0/helpdlg.c

Modified: branches/S2_6/client/gui-gtk-2.0/helpdlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-2.0/helpdlg.c?rev=29137&r1=29136&r2=29137&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-2.0/helpdlg.c  (original)
+++ branches/S2_6/client/gui-gtk-2.0/helpdlg.c  Thu May 28 00:00:35 2015
@@ -1142,10 +1142,16 @@
   if (pterrain) {
     struct universal for_terr = { .kind = VUT_TERRAIN, .value = { .terrain = 
pterrain }};
 
-    sprintf(buf, "%d/%d.%d",
-           pterrain->movement_cost,
-           (int)((pterrain->defense_bonus + 100) / 100),
-           (pterrain->defense_bonus + 100) % 100 / 10);
+    {
+      /* 25 => "1.25"; 50 => "1.5"; 100 => "2.0" */
+      int defbonus = pterrain->defense_bonus + 100;
+      int frac = defbonus % 100;
+      if ((frac % 10) == 0) {
+        frac /= 10;
+      }
+      sprintf(buf, "%d/%d.%d",
+              pterrain->movement_cost, defbonus / 100, frac);
+    }
     gtk_label_set_text(GTK_LABEL(help_tlabel[0][1]), buf);
 
     sprintf(buf, "%d/%d/%d",

Modified: branches/S2_6/client/gui-gtk-3.0/helpdlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-3.0/helpdlg.c?rev=29137&r1=29136&r2=29137&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-3.0/helpdlg.c  (original)
+++ branches/S2_6/client/gui-gtk-3.0/helpdlg.c  Thu May 28 00:00:35 2015
@@ -1167,10 +1167,16 @@
   if (pterrain) {
     struct universal for_terr = { .kind = VUT_TERRAIN, .value = { .terrain = 
pterrain }};
 
-    sprintf(buf, "%d/%d.%d",
-           pterrain->movement_cost,
-           (int)((pterrain->defense_bonus + 100) / 100),
-           (pterrain->defense_bonus + 100) % 100 / 10);
+    {
+      /* 25 => "1.25"; 50 => "1.5"; 100 => "2.0" */
+      int defbonus = pterrain->defense_bonus + 100;
+      int frac = defbonus % 100;
+      if ((frac % 10) == 0) {
+        frac /= 10;
+      }
+      sprintf(buf, "%d/%d.%d",
+              pterrain->movement_cost, defbonus / 100, frac);
+    }
     gtk_label_set_text(GTK_LABEL(help_tlabel[0][1]), buf);
 
     sprintf(buf, "%d/%d/%d",


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

Reply via email to