[Freeciv-Dev] Settlers turns left calculation in GUI is wrong. (PR#981)
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Full_Name: Andreas Beckmann
Version: 1.12.1-devel
Distribution: Built from source
Client: Gtk+
OS: Linux
Submission from: (NULL) (217.226.252.168)
There is a bug in the new GTK addition that shows the remaining turns
of settler activity:
(1) Units with 0 moves left do not do any activity in the current turn but
were treated as units with moves left. The calculation could show 1 turn
less than actually needed. (This happens only in the first turn, when the
activity has been assigned, the result in the following turns will be
correct.)
Note: This doesn't alter the duration of any settler activity, only the
duration in the middle-click popup will be incorrect.
(2) By assigning an activity to too much settlers the remaining turns could
become <= 0 (not testet, I just re-read the patch).
Index: client/climisc.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/climisc.c,v
retrieving revision 1.61
diff -u -u -r1.61 climisc.c
--- client/climisc.c 2001/09/20 11:07:28 1.61
+++ client/climisc.c 2001/09/21 22:24:24
@@ -562,16 +562,19 @@
int activity_total[ACTIVITY_LAST];
int activity_units[ACTIVITY_LAST];
int num_activities = 0;
- int remains, i, mr;
+ int remains, turns, i, mr, au;
struct tile *ptile = map_get_tile(x, y);
memset(activity_total, 0, sizeof(activity_total));
memset(activity_units, 0, sizeof(activity_units));
unit_list_iterate(ptile->units, punit) {
- activity_total[punit->activity] += punit->activity_count;
mr = get_unit_type(punit->type)->move_rate;
- activity_units[punit->activity] += mr ? mr / SINGLE_MOVE : 1;
+ au = mr ? mr / SINGLE_MOVE : 1;
+ activity_total[punit->activity] += punit->activity_count;
+ if (punit->moves_left)
+ activity_total[punit->activity] += au; /* current turn */
+ activity_units[punit->activity] += au;
}
unit_list_iterate_end;
@@ -580,9 +583,11 @@
if (num_activities)
mystrlcat(buf, "/", buf_size);
remains = map_activity_time(i, x, y) - activity_total[i];
- cat_snprintf(buf, buf_size, "%s(%d)", get_activity_text(i),
- remains / activity_units[i] +
- (remains % activity_units[i] ? 1 : 0));
+ if (remains > 0)
+ turns = 1 + (remains + activity_units[i] - 1) / activity_units[i];
+ else /* activity will be finished this turn */
+ turns = 1;
+ cat_snprintf(buf, buf_size, "%s(%d)", get_activity_text(i), turns);
num_activities++;
}
}
- [Freeciv-Dev] Settlers turns left calculation in GUI is wrong. (PR#981),
andreas . beckmann <=
- [Freeciv-Dev] Re: Settlers turns left calculation in GUI is wrong. (PR#981), Raimar Falke, 2001/09/27
- [Freeciv-Dev] Re: Settlers turns left calculation in GUI is wrong. (PR#981), Stepan Roh, 2001/09/27
- [Freeciv-Dev] Re: Settlers turns left calculation in GUI is wrong. (PR#981), Raimar Falke, 2001/09/27
- [Freeciv-Dev] Re: Settlers turns left calculation in GUI is wrong. (PR#981), Stepan Roh, 2001/09/27
- [Freeciv-Dev] Re: Settlers turns left calculation in GUI is wrong. (PR#981), Raimar Falke, 2001/09/27
- [Freeciv-Dev] Re: Settlers turns left calculation in GUI is wrong. (PR#981), Stepan Roh, 2001/09/27
- [Freeciv-Dev] Re: Settlers turns left calculation in GUI is wrong. (PR#981), Raimar Falke, 2001/09/27
- [Freeciv-Dev] Re: Settlers turns left calculation in GUI is wrong. (PR#981), Stepan Roh, 2001/09/27
- [Freeciv-Dev] Re: Settlers turns left calculation in GUI is wrong. (PR#981), Raimar Falke, 2001/09/27
- [Freeciv-Dev] Re: Settlers turns left calculation in GUI is wrong. (PR#981), Paul Zastoupil, 2001/09/27
|
|