Author: jtn
Date: Thu May 28 00:01:34 2015
New Revision: 29143

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

See gna bug #23263.

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

Modified: branches/S2_4/client/gui-gtk-2.0/helpdlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_4/client/gui-gtk-2.0/helpdlg.c?rev=29143&r1=29142&r2=29143&view=diff
==============================================================================
--- branches/S2_4/client/gui-gtk-2.0/helpdlg.c  (original)
+++ branches/S2_4/client/gui-gtk-2.0/helpdlg.c  Thu May 28 00:01:34 2015
@@ -1078,10 +1078,16 @@
   create_help_page(HELP_TERRAIN);
 
   if (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_4/client/gui-gtk-3.0/helpdlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_4/client/gui-gtk-3.0/helpdlg.c?rev=29143&r1=29142&r2=29143&view=diff
==============================================================================
--- branches/S2_4/client/gui-gtk-3.0/helpdlg.c  (original)
+++ branches/S2_4/client/gui-gtk-3.0/helpdlg.c  Thu May 28 00:01:34 2015
@@ -1104,10 +1104,16 @@
   create_help_page(HELP_TERRAIN);
 
   if (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