[Freeciv-Dev] (PR#13708) Bug in get_science_target_text
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: |
[Freeciv-Dev] (PR#13708) Bug in get_science_target_text |
From: |
"Mateusz Stefek" <mstefek@xxxxxxxxx> |
Date: |
Fri, 19 Aug 2005 00:35:23 -0700 |
Reply-to: |
bugs@xxxxxxxxxxx |
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=13708 >
There's a division by zero bug in get_science_target_text().
The attached patch fixes it.
--
mateusz
Index: client/text.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/text.c,v
retrieving revision 1.46
diff -u -r1.46 text.c
--- client/text.c 16 Aug 2005 06:54:53 -0000 1.46
+++ client/text.c 19 Aug 2005 07:33:37 -0000
@@ -439,10 +439,14 @@
int total = total_bulbs_required(game.player_ptr);
int done = research->bulbs_researched;
int perturn = get_bulbs_per_turn(NULL, NULL);
- int turns = (total - done + perturn - 1) / perturn;
- astr_add(&str, PL_("%d/%d (%d turn)", "%d/%d (%d turns)", turns),
- done, total, turns);
+ if (perturn > 0) {
+ int turns = (total - done + perturn - 1) / perturn;
+ astr_add(&str, PL_("%d/%d (%d turn)", "%d/%d (%d turns)", turns),
+ done, total, turns);
+ } else {
+ astr_add(&str, _("%d/%d (never)"), done, total);
+ }
if (percent) {
*percent = (double)done / (double)total;
*percent = CLIP(0.0, *percent, 1.0);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#13708) Bug in get_science_target_text,
Mateusz Stefek <=
|
|