Index: client/climisc.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/climisc.c,v retrieving revision 1.55 diff -u -r1.55 climisc.c --- client/climisc.c 2001/08/29 12:01:36 1.55 +++ client/climisc.c 2001/08/30 22:13:56 @@ -561,3 +561,37 @@ ; /* do nothing */ } } + +/* + * Concats buf with activity progress text for given tile. + * Returns number of activities. + */ +int concat_tile_activity_text(char *buf, int buf_size, int x, int y) { + int activity_total[ACTIVITY_LAST]; + int activity_units[ACTIVITY_LAST]; + int num_activities = 0; + int remains, i, mr; + struct tile *ptile=map_get_tile(x, y); + + for (i = 0; i < ACTIVITY_LAST; i++) { + activity_total[i] = activity_units[i] = 0; + } + + 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; + unit_list_iterate_end; + + for (i = 0; i < ACTIVITY_LAST; i++) { + if (is_build_or_clean_activity(i) && activity_units[i]) { + 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)); + num_activities++; + } + } + + return num_activities; +} Index: client/climisc.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/climisc.h,v retrieving revision 1.19 diff -u -r1.19 climisc.h --- client/climisc.h 2001/08/28 18:41:54 1.19 +++ client/climisc.h 2001/08/30 20:47:06 @@ -39,5 +39,7 @@ void center_on_something(void); +int concat_tile_activity_text(char *buf, int buf_size, int x, int y); + #endif /* FC__CLIMISC_H */ Index: client/packhand.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v retrieving revision 1.181 diff -u -r1.181 packhand.c --- client/packhand.c 2001/08/29 10:32:22 1.181 +++ client/packhand.c 2001/08/30 20:47:08 @@ -747,6 +747,7 @@ if(punit) { int dest_x,dest_y; + punit->activity_count = packet->activity_count; if((punit->activity!=packet->activity) /* change activity */ || (punit->activity_target!=packet->activity_target)) { /* or act's target */ repaint_unit=1; @@ -890,8 +891,6 @@ punit=fc_malloc(sizeof(struct unit)); unpackage_unit(punit, packet); idex_register_unit(punit); - - punit->activity_count=0; /* never used in client/ or common/ --dwp */ unit_list_insert(&get_player(packet->owner)->units, punit); unit_list_insert(&map_get_tile(punit->x, punit->y)->units, punit); Index: client/gui-gtk/mapctrl.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/mapctrl.c,v retrieving revision 1.45 diff -u -r1.45 mapctrl.c --- client/gui-gtk/mapctrl.c 2001/08/24 08:22:02 1.45 +++ client/gui-gtk/mapctrl.c 2001/08/30 20:47:09 @@ -31,6 +31,7 @@ #include "citydlg.h" #include "civclient.h" #include "clinet.h" +#include "climisc.h" #include "colors.h" #include "control.h" #include "dialogs.h" @@ -156,6 +157,14 @@ count++; } + sz_strlcpy(s, _("Activity: ")); + if (concat_tile_activity_text(s, sizeof(s), xtile, ytile)) { + gtk_widget_new(GTK_TYPE_LABEL, "GtkWidget::parent", b, + "GtkLabel::label", s, + NULL); + count++; + } + if((punit=find_visible_unit(ptile)) && !pcity) { char cn[64]; struct unit_type *ptype=get_unit_type(punit->type); Index: common/map.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/map.c,v retrieving revision 1.82 diff -u -r1.82 map.c --- common/map.c 2001/08/26 09:28:16 1.82 +++ common/map.c 2001/08/30 20:47:12 @@ -788,6 +788,33 @@ } /*************************************************************** + Time to complete given activity on given tile. +***************************************************************/ +int map_activity_time(int activity, int x, int y) { + switch (activity) { + case ACTIVITY_POLLUTION: + return map_clean_pollution_time(x,y); + case ACTIVITY_ROAD: + return map_build_road_time(x,y); + case ACTIVITY_MINE: + return map_build_mine_time(x,y); + case ACTIVITY_IRRIGATE: + return map_build_irrigation_time(x,y); + case ACTIVITY_FORTRESS: + return map_build_fortress_time(x,y); + case ACTIVITY_RAILROAD: + return map_build_rail_time(x,y); + case ACTIVITY_TRANSFORM: + return map_transform_time(x,y); + case ACTIVITY_AIRBASE: + return map_build_airbase_time(x,y); + case ACTIVITY_FALLOUT: + return map_clean_fallout_time(x,y); + } + return 0; +} + +/*************************************************************** ... ***************************************************************/ static void clear_infrastructure(int x, int y) Index: common/map.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/map.h,v retrieving revision 1.87 diff -u -r1.87 map.h --- common/map.h 2001/08/26 09:28:17 1.87 +++ common/map.h 2001/08/30 20:47:12 @@ -260,6 +260,7 @@ int map_build_fortress_time(int x, int y); int map_clean_pollution_time(int x, int y); int map_clean_fallout_time(int x, int y); +int map_activity_time(int activity, int x, int y); int can_channel_land(int x, int y); int can_reclaim_ocean(int x, int y); Index: common/unit.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/unit.c,v retrieving revision 1.132 diff -u -r1.132 unit.c --- common/unit.c 2001/08/28 13:45:35 1.132 +++ common/unit.c 2001/08/30 20:47:15 @@ -1362,3 +1362,22 @@ return 1; } + +/* + * Returns true if given activity is some kind of building/cleaning + */ +int is_build_or_clean_activity(int activity) { + switch (activity) { + case ACTIVITY_POLLUTION: + case ACTIVITY_ROAD: + case ACTIVITY_MINE: + case ACTIVITY_IRRIGATE: + case ACTIVITY_FORTRESS: + case ACTIVITY_RAILROAD: + case ACTIVITY_TRANSFORM: + case ACTIVITY_AIRBASE: + case ACTIVITY_FALLOUT: + return 1; + } + return 0; +} Index: common/unit.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/unit.h,v retrieving revision 1.77 diff -u -r1.77 unit.h --- common/unit.h 2001/08/28 13:45:35 1.77 +++ common/unit.h 2001/08/30 20:47:15 @@ -262,4 +262,6 @@ int zoc_ok_move_gen(struct unit *punit, int x1, int y1, int x2, int y2); int zoc_ok_move(struct unit *punit, int x, int y); +int is_build_or_clean_activity(int activity); + #endif /* FC__UNIT_H */