47 int activity_total[ACTIVITY_LAST];
48 int activity_units[ACTIVITY_LAST];
51 t =
new tmp_state[1]();
52 memset(calc, 0,
sizeof(*calc));
57 if (punit ==
nullptr) {
67 t->extra_total[eidx][act] += punit->activity_count;
73 t->rmextra_total[eidx][act] += punit->activity_count;
77 t->activity_total[act] += punit->activity_count;
94 int units_total = t->extra_units[ei][act];
96 if (units_total > 0) {
100 turns = 1 + (remains + units_total - 1) / units_total;
109 int units_total = t->rmextra_units[ei][act];
111 if (units_total > 0) {
115 turns = 1 + (remains + units_total - 1) / units_total;
126 int units_total = t->activity_units[act];
128 if (units_total > 0) {
132 turns = 1 + (remains + units_total - 1) / units_total;
151 int num_activities = 0;
163 if (calc->extra_turns[ei][i] > 0) {
164 if (num_activities > 0) {
165 str += QLatin1String(
"/");
167 str += QStringLiteral(
"%1(%2)").arg(
169 QString::number(calc->extra_turns[ei][i]));
175 enum extra_rmcause rmcause =
ERM_NONE;
178 case ACTIVITY_PILLAGE:
179 rmcause = ERM_PILLAGE;
181 case ACTIVITY_POLLUTION:
182 rmcause = ERM_CLEANPOLLUTION;
184 case ACTIVITY_FALLOUT:
185 rmcause = ERM_CLEANFALLOUT;
197 if (calc->rmextra_turns[ei][i] > 0) {
198 if (num_activities > 0) {
199 str += QLatin1String(
"/");
201 str += QString(rmcause == ERM_PILLAGE ?
_(
"Pillage %1(%2)")
204 QString::number(calc->rmextra_turns[ei][i]));
211 if (calc->activity_turns[i] > 0) {
212 if (num_activities > 0) {
213 str += QLatin1String(
"/");
215 str += QStringLiteral(
"%1(%2)").arg(
225 return qUtf8Printable(str);
static void calc_activity(struct actcalc *calc, const struct tile *ptile)
Calculate completion time for all unit activities on tile.
QString concat_tile_activity_text(struct tile *ptile)
Creates the activity progress text for the given tile.
enum unit_activity Activity_type_id
#define fc_assert(condition)
int rmextra_turns[MAX_EXTRA_TYPES][ACTIVITY_LAST]
int activity_turns[ACTIVITY_LAST]
int extra_turns[MAX_EXTRA_TYPES][ACTIVITY_LAST]
int tile_activity_time(enum unit_activity activity, const struct tile *ptile, const struct extra_type *tgt)
Time to complete the given activity on the given tile.
bool is_tile_activity(enum unit_activity activity)
Returns true if given activity affects tile.
int get_activity_rate_this_turn(const struct unit *punit)
Returns the amount of work a unit does (will do) on an activity this turn.
int get_activity_rate(const struct unit *punit)
Returns the speed of a unit doing an activity.
bool is_build_activity(enum unit_activity activity, const struct tile *ptile)
Returns true if given activity is some kind of building.
bool is_clean_activity(enum unit_activity activity)
Returns true if given activity is some kind of cleaning.
const char * get_activity_text(enum unit_activity activity)
Return the name of the activity in a static buffer.
#define activity_type_iterate(_act_)
#define activity_type_iterate_end
#define unit_list_iterate(unitlist, punit)
#define unit_list_iterate_end