From 18db4c8e418368e881a0af2499ff87c87a52c51e Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Thu, 13 Apr 2023 21:25:31 +0300 Subject: [PATCH 50/50] Add ERM_CLEAN For extras that can be cleaned by general "Clean" action. At this point of migration "Clean" can still also remove ERM_CLEANPOLLUTION and ERM_CLEANFALLOUT extras. See osdn #47839 Signed-off-by: Marko Lindqvist --- client/control.c | 14 ++++++- client/gui-gtk-3.22/citydlg.c | 6 +++ client/gui-gtk-3.22/menu.c | 23 ++++++++--- client/gui-gtk-4.0/citydlg.c | 6 +++ client/gui-gtk-4.0/menu.c | 64 ++++++++++++++++++++---------- client/gui-sdl2/menu.c | 25 ++++++++---- client/helpdata.c | 26 ++++++++++++ common/actions.c | 3 +- common/actres.c | 36 +++++++++-------- common/clientutils.c | 23 ++++++++++- common/extras.c | 5 ++- common/fc_types.h | 6 ++- data/alien/terrain.ruleset | 8 ++-- data/civ1/terrain.ruleset | 6 +-- data/civ2/terrain.ruleset | 6 +-- data/civ2civ3/terrain.ruleset | 8 ++-- data/classic/terrain.ruleset | 8 ++-- data/goldkeep/terrain.ruleset | 8 ++-- data/granularity/terrain.ruleset | 4 +- data/multiplayer/terrain.ruleset | 8 ++-- data/ruledit/comments-3.3.txt | 4 +- data/sandbox/terrain.ruleset | 8 ++-- data/stub/terrain.ruleset | 4 +- data/webperimental/terrain.ruleset | 8 ++-- server/rssanity.c | 4 +- server/unithand.c | 9 ++++- server/unittools.c | 32 ++++++--------- 27 files changed, 239 insertions(+), 123 deletions(-) diff --git a/client/control.c b/client/control.c index a7583258b7..e31067d63c 100644 --- a/client/control.c +++ b/client/control.c @@ -3714,7 +3714,7 @@ void key_unit_clean(void) { unit_list_iterate(get_units_in_focus(), punit) { struct extra_type *tgt = prev_extra_in_tile(unit_tile(punit), - ERM_CLEANPOLLUTION, + ERM_CLEAN, unit_owner(punit), punit); @@ -3723,13 +3723,23 @@ void key_unit_clean(void) request_new_unit_activity_targeted(punit, ACTIVITY_CLEAN, tgt); } else { tgt = prev_extra_in_tile(unit_tile(punit), - ERM_CLEANFALLOUT, + ERM_CLEANPOLLUTION, unit_owner(punit), punit); if (tgt != NULL && can_unit_do_activity_targeted(punit, ACTIVITY_CLEAN, tgt)) { request_new_unit_activity_targeted(punit, ACTIVITY_CLEAN, tgt); + } else { + tgt = prev_extra_in_tile(unit_tile(punit), + ERM_CLEANFALLOUT, + unit_owner(punit), + punit); + + if (tgt != NULL + && can_unit_do_activity_targeted(punit, ACTIVITY_CLEAN, tgt)) { + request_new_unit_activity_targeted(punit, ACTIVITY_CLEAN, tgt); + } } } } unit_list_iterate_end; diff --git a/client/gui-gtk-3.22/citydlg.c b/client/gui-gtk-3.22/citydlg.c index f6e17cf2d8..f60bda929a 100644 --- a/client/gui-gtk-3.22/citydlg.c +++ b/client/gui-gtk-3.22/citydlg.c @@ -3000,6 +3000,12 @@ static void popup_workertask_dlg(struct city *pcity, struct tile *ptile) G_CALLBACK(set_city_workertask), GINT_TO_POINTER(ACTIVITY_TRANSFORM), FALSE, NULL); } + if (prev_extra_in_tile(ptile, ERM_CLEAN, + city_owner(pcity), NULL) != NULL) { + choice_dialog_add(shl, _("Clean"), + G_CALLBACK(set_city_workertask), + GINT_TO_POINTER(ACTIVITY_CLEAN), FALSE, NULL); + } if (prev_extra_in_tile(ptile, ERM_CLEANPOLLUTION, city_owner(pcity), NULL) != NULL) { choice_dialog_add(shl, _("Clean Pollution"), diff --git a/client/gui-gtk-3.22/menu.c b/client/gui-gtk-3.22/menu.c index 4b3b13039d..f8ef5abc0e 100644 --- a/client/gui-gtk-3.22/menu.c +++ b/client/gui-gtk-3.22/menu.c @@ -3033,19 +3033,30 @@ void real_menus_init(void) g_list_free(list); /* Add new cleaning entries. */ - extra_type_by_rmcause_iterate(ERM_CLEANPOLLUTION, pextra) { + extra_type_by_rmcause_iterate(ERM_CLEAN, pextra) { item = gtk_menu_item_new_with_label(extra_name_translation(pextra)); g_object_set_data(G_OBJECT(item), "nuisance", pextra); g_signal_connect(item, "activate", G_CALLBACK(clean_callback), pextra); gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); gtk_widget_show(item); } extra_type_by_rmcause_iterate_end; + extra_type_by_rmcause_iterate(ERM_CLEANPOLLUTION, pextra) { + if (!is_extra_removed_by(pextra, ERM_CLEAN)) { + item = gtk_menu_item_new_with_label(extra_name_translation(pextra)); + g_object_set_data(G_OBJECT(item), "nuisance", pextra); + g_signal_connect(item, "activate", G_CALLBACK(clean_callback), pextra); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); + gtk_widget_show(item); + } + } extra_type_by_rmcause_iterate_end; extra_type_by_rmcause_iterate(ERM_CLEANFALLOUT, pextra) { - item = gtk_menu_item_new_with_label(extra_name_translation(pextra)); - g_object_set_data(G_OBJECT(item), "nuisance", pextra); - g_signal_connect(item, "activate", G_CALLBACK(clean_callback), pextra); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); - gtk_widget_show(item); + if (!is_extra_removed_by(pextra, ERM_CLEAN)) { + item = gtk_menu_item_new_with_label(extra_name_translation(pextra)); + g_object_set_data(G_OBJECT(item), "nuisance", pextra); + g_signal_connect(item, "activate", G_CALLBACK(clean_callback), pextra); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); + gtk_widget_show(item); + } } extra_type_by_rmcause_iterate_end; } diff --git a/client/gui-gtk-4.0/citydlg.c b/client/gui-gtk-4.0/citydlg.c index 026ece83d2..e0f7f91645 100644 --- a/client/gui-gtk-4.0/citydlg.c +++ b/client/gui-gtk-4.0/citydlg.c @@ -3118,6 +3118,12 @@ static void popup_workertask_dlg(struct city *pcity, struct tile *ptile) G_CALLBACK(set_city_workertask), GINT_TO_POINTER(ACTIVITY_TRANSFORM), FALSE, NULL); } + if (prev_extra_in_tile(ptile, ERM_CLEAN, + city_owner(pcity), NULL) != NULL) { + choice_dialog_add(shl, _("Clean"), + G_CALLBACK(set_city_workertask), + GINT_TO_POINTER(ACTIVITY_CLEAN), FALSE, NULL); + } if (prev_extra_in_tile(ptile, ERM_CLEANPOLLUTION, city_owner(pcity), NULL) != NULL) { choice_dialog_add(shl, _("Clean Pollution"), diff --git a/client/gui-gtk-4.0/menu.c b/client/gui-gtk-4.0/menu.c index 0ba2601bc2..afbb91dfc2 100644 --- a/client/gui-gtk-4.0/menu.c +++ b/client/gui-gtk-4.0/menu.c @@ -3663,7 +3663,7 @@ void real_menus_update(void) submenu = g_menu_new(); - extra_type_by_rmcause_iterate(ERM_CLEANPOLLUTION, pextra) { + extra_type_by_rmcause_iterate(ERM_CLEAN, pextra) { char actname[256]; GSimpleAction *act; @@ -3672,10 +3672,7 @@ void real_menus_update(void) g_simple_action_set_enabled(act, can_units_do_activity_targeted(punits, ACTIVITY_CLEAN, - pextra) - || can_units_do_activity_targeted(punits, - ACTIVITY_POLLUTION, - pextra)); + pextra)); g_action_map_add_action(map, G_ACTION(act)); g_signal_connect(act, "activate", G_CALLBACK(clean_menu_callback), pextra); @@ -3684,25 +3681,50 @@ void real_menus_update(void) g_menu_item_new(extra_name_translation(pextra), actname)); } extra_type_by_rmcause_iterate_end; + extra_type_by_rmcause_iterate(ERM_CLEANPOLLUTION, pextra) { + if (!is_extra_removed_by(pextra, ERM_CLEAN)) { + char actname[256]; + GSimpleAction *act; + + fc_snprintf(actname, sizeof(actname), "clean_%d", i); + act = g_simple_action_new(actname, NULL); + g_simple_action_set_enabled(act, + can_units_do_activity_targeted(punits, + ACTIVITY_CLEAN, + pextra) + || can_units_do_activity_targeted(punits, + ACTIVITY_POLLUTION, + pextra)); + g_action_map_add_action(map, G_ACTION(act)); + g_signal_connect(act, "activate", G_CALLBACK(clean_menu_callback), pextra); + + fc_snprintf(actname, sizeof(actname), "app.clean_%d", i++); + menu_item_append_unref(submenu, + g_menu_item_new(extra_name_translation(pextra), actname)); + } + } extra_type_by_rmcause_iterate_end; + extra_type_by_rmcause_iterate(ERM_CLEANFALLOUT, pextra) { - char actname[256]; - GSimpleAction *act; + if (!is_extra_removed_by(pextra, ERM_CLEAN)) { + char actname[256]; + GSimpleAction *act; - fc_snprintf(actname, sizeof(actname), "clean_%d", i); - act = g_simple_action_new(actname, NULL); - g_simple_action_set_enabled(act, - can_units_do_activity_targeted(punits, - ACTIVITY_CLEAN, - pextra) - || can_units_do_activity_targeted(punits, - ACTIVITY_FALLOUT, - pextra)); - g_action_map_add_action(map, G_ACTION(act)); - g_signal_connect(act, "activate", G_CALLBACK(clean_menu_callback), pextra); + fc_snprintf(actname, sizeof(actname), "clean_%d", i); + act = g_simple_action_new(actname, NULL); + g_simple_action_set_enabled(act, + can_units_do_activity_targeted(punits, + ACTIVITY_CLEAN, + pextra) + || can_units_do_activity_targeted(punits, + ACTIVITY_FALLOUT, + pextra)); + g_action_map_add_action(map, G_ACTION(act)); + g_signal_connect(act, "activate", G_CALLBACK(clean_menu_callback), pextra); - fc_snprintf(actname, sizeof(actname), "app.clean_%d", i++); - menu_item_append_unref(submenu, - g_menu_item_new(extra_name_translation(pextra), actname)); + fc_snprintf(actname, sizeof(actname), "app.clean_%d", i++); + menu_item_append_unref(submenu, + g_menu_item_new(extra_name_translation(pextra), actname)); + } } extra_type_by_rmcause_iterate_end; g_menu_remove(work_menu, 5); diff --git a/client/gui-sdl2/menu.c b/client/gui-sdl2/menu.c index 78816a4e49..6e3120da4d 100644 --- a/client/gui-sdl2/menu.c +++ b/client/gui-sdl2/menu.c @@ -1307,16 +1307,23 @@ void real_menus_update(void) set_wflag(order_airbase_button, WF_HIDDEN); } - clean_target = prev_extra_in_tile(ptile, ERM_CLEANPOLLUTION, + clean_target = prev_extra_in_tile(ptile, ERM_CLEAN, unit_owner(punit), punit); - if (clean_target != NULL + + pextra = prev_extra_in_tile(ptile, ERM_CLEANPOLLUTION, + unit_owner(punit), punit); + if (clean_target == NULL) { + clean_target = pextra; /* Fallback */ + } + + if (pextra != NULL && can_unit_do_activity_targeted(punit, ACTIVITY_POLLUTION, - clean_target)) { + pextra)) { time = turns_to_activity_done(ptile, ACTIVITY_POLLUTION, - clean_target, punit); + pextra, punit); /* TRANS: "Clean Pollution (P) 3 turns" */ fc_snprintf(cbuf, sizeof(cbuf), _("Clean %s (%s) %d %s"), - extra_name_translation(clean_target), "P", time, + extra_name_translation(pextra), "P", time, PL_("turn", "turns", time)); copy_chars_to_utf8_str(order_pollution_button->info_label, cbuf); clear_wflag(order_pollution_button, WF_HIDDEN); @@ -1332,6 +1339,11 @@ void real_menus_update(void) pextra = prev_extra_in_tile(ptile, ERM_CLEANFALLOUT, unit_owner(punit), punit); + + if (clean_target == NULL) { + clean_target = pextra; /* Fallback */ + } + if (pextra != NULL && can_unit_do_activity_targeted(punit, ACTIVITY_FALLOUT, pextra)) { time = turns_to_activity_done(ptile, ACTIVITY_FALLOUT, pextra, @@ -1346,9 +1358,6 @@ void real_menus_update(void) set_wflag(order_fallout_button, WF_HIDDEN); } - if (clean_target == NULL) { - clean_target = pextra; - } if (clean_target != NULL && can_unit_do_activity_targeted(punit, ACTIVITY_CLEAN, clean_target)) { diff --git a/client/helpdata.c b/client/helpdata.c index e4215813a2..723016883b 100644 --- a/client/helpdata.c +++ b/client/helpdata.c @@ -270,6 +270,17 @@ static bool insert_generated_text(char *outbuf, size_t outlen, const char *name) transform_result); if (clean_time != 0) { + extra_type_by_rmcause_iterate(ERM_CLEAN, pextra) { + int rmtime = pterrain->extra_removal_times[extra_index(pextra)]; + + if (rmtime != 0) { + if (clean_time < 0) { + clean_time = rmtime; + } else if (clean_time != rmtime) { + clean_time = 0; /* Give up */ + } + } + } extra_type_by_rmcause_iterate_end; extra_type_by_rmcause_iterate(ERM_CLEANPOLLUTION, pextra) { int rmtime = pterrain->extra_removal_times[extra_index(pextra)]; @@ -313,6 +324,21 @@ static bool insert_generated_text(char *outbuf, size_t outlen, const char *name) { int time = -1, factor = -1; + extra_type_by_rmcause_iterate(ERM_CLEAN, pextra) { + if (pextra->removal_time == 0) { + if (factor < 0) { + factor = pextra->removal_time_factor; + } else if (factor != pextra->removal_time_factor) { + factor = 0; /* Give up */ + } + } else { + if (time < 0) { + time = pextra->removal_time; + } else if (time != pextra->removal_time) { + time = 0; /* Give up */ + } + } + } extra_type_by_rmcause_iterate_end; extra_type_by_rmcause_iterate(ERM_CLEANPOLLUTION, pextra) { if (pextra->removal_time == 0) { if (factor < 0) { diff --git a/common/actions.c b/common/actions.c index acced0ac7e..9db2794150 100644 --- a/common/actions.c +++ b/common/actions.c @@ -2307,7 +2307,8 @@ bool action_removes_extra(const struct action *paction, case ACTRES_PILLAGE: return is_extra_removed_by(pextra, ERM_PILLAGE); case ACTRES_CLEAN: - return is_extra_removed_by(pextra, ERM_CLEANPOLLUTION) + return is_extra_removed_by(pextra, ERM_CLEAN) + || is_extra_removed_by(pextra, ERM_CLEANPOLLUTION) || is_extra_removed_by(pextra, ERM_CLEANFALLOUT); case ACTRES_CLEAN_POLLUTION: return is_extra_removed_by(pextra, ERM_CLEANPOLLUTION); diff --git a/common/actres.c b/common/actres.c index b9013e688f..e4e625edda 100644 --- a/common/actres.c +++ b/common/actres.c @@ -729,31 +729,38 @@ enum fc_tristate actres_possible(enum action_result result, case ACTRES_CLEAN: { const struct extra_type *pextra = NULL; - const struct extra_type *fextra = NULL; pterrain = tile_terrain(target->tile); if (target_extra != NULL) { - if (is_extra_removed_by(target_extra, ERM_CLEANPOLLUTION) - && tile_has_extra(target->tile, target_extra)) { + if (tile_has_extra(target->tile, target_extra) + && (is_extra_removed_by(target_extra, ERM_CLEAN) + || is_extra_removed_by(target_extra, ERM_CLEANPOLLUTION) + || is_extra_removed_by(target_extra, ERM_CLEANFALLOUT))) { pextra = target_extra; } - if (is_extra_removed_by(target_extra, ERM_CLEANFALLOUT) - && tile_has_extra(target->tile, target_extra)) { - fextra = target_extra; - } } else { /* TODO: Make sure that all callers set target so that * we don't need this fallback. */ pextra = prev_extra_in_tile(target->tile, - ERM_CLEANPOLLUTION, - actor->player, - actor->unit); - fextra = prev_extra_in_tile(target->tile, - ERM_CLEANFALLOUT, + ERM_CLEAN, actor->player, actor->unit); + + if (pextra == NULL) { + pextra = prev_extra_in_tile(target->tile, + ERM_CLEANPOLLUTION, + actor->player, + actor->unit); + + if (pextra == NULL) { + pextra = prev_extra_in_tile(target->tile, + ERM_CLEANFALLOUT, + actor->player, + actor->unit); + } + } } if (pextra != NULL && pterrain->extra_removal_times[extra_index(pextra)] > 0 @@ -761,11 +768,6 @@ enum fc_tristate actres_possible(enum action_result result, return TRI_YES; } - if (fextra != NULL && pterrain->extra_removal_times[extra_index(fextra)] > 0 - && can_remove_extra(fextra, actor->unit, target->tile)) { - return TRI_YES; - } - return TRI_NO; } diff --git a/common/clientutils.c b/common/clientutils.c index 93540e3dba..44a24ba537 100644 --- a/common/clientutils.c +++ b/common/clientutils.c @@ -258,7 +258,9 @@ const char *concat_tile_activity_text(struct tile *ptile) case ACTIVITY_PILLAGE: rmcause = ERM_PILLAGE; break; - case ACTIVITY_CLEAN: /* ERM_CLEANPOLLUTION first, ERM_CLEANFALLOUT later */ + case ACTIVITY_CLEAN: + rmcause = ERM_CLEAN; /* Also ERM_CLEANPOLLUTION and ERM_CLEANFALLOUT */ + break; case ACTIVITY_POLLUTION: rmcause = ERM_CLEANPOLLUTION; break; @@ -288,8 +290,25 @@ const char *concat_tile_activity_text(struct tile *ptile) } if (i == ACTIVITY_CLEAN) { + extra_type_by_rmcause_iterate(ERM_CLEANPOLLUTION, ep) { + /* Make sure it's not handled by earlier iteration already */ + if (!is_extra_caused_by(ep, ERM_CLEAN)) { + int ei = extra_index(ep); + + if (calc->rmextra_turns[ei][i] > 0) { + if (num_activities > 0) { + astr_add(&str, "/"); + } + astr_add(&str, _("Clean %s(%d)"), + extra_name_translation(ep), calc->rmextra_turns[ei][i]); + num_activities++; + } + } + } extra_type_by_rmcause_iterate_end; extra_type_by_rmcause_iterate(ERM_CLEANFALLOUT, ep) { - if (!is_extra_caused_by(ep, ERM_CLEANPOLLUTION)) { + /* Make sure it's not handled by earlier iterations already */ + if (!is_extra_caused_by(ep, ERM_CLEAN) + && !is_extra_caused_by(ep, ERM_CLEANPOLLUTION)) { int ei = extra_index(ep); if (calc->rmextra_turns[ei][i] > 0) { diff --git a/common/extras.c b/common/extras.c index dd381c0da2..0db1e033de 100644 --- a/common/extras.c +++ b/common/extras.c @@ -978,7 +978,8 @@ bool is_extra_removed_by_worker_action(const struct extra_type *pextra) { /* Is any of the worker remove action bits set? */ return (pextra->rmcauses - & (1 << ERM_CLEANPOLLUTION + & (1 << ERM_CLEAN + | 1 << ERM_CLEANPOLLUTION | 1 << ERM_CLEANFALLOUT | 1 << ERM_PILLAGE)); } @@ -1030,6 +1031,8 @@ enum extra_cause activity_to_extra_cause(enum unit_activity act) enum extra_rmcause activity_to_extra_rmcause(enum unit_activity act) { switch (act) { + case ACTIVITY_CLEAN: + return ERM_CLEAN; case ACTIVITY_PILLAGE: return ERM_PILLAGE; case ACTIVITY_POLLUTION: diff --git a/common/fc_types.h b/common/fc_types.h index ba8a3ceac2..e124758044 100644 --- a/common/fc_types.h +++ b/common/fc_types.h @@ -1092,14 +1092,16 @@ FC_STATIC_ASSERT(EC_COUNT < 16, extra_causes_over_limit); #define SPECENUM_NAME extra_rmcause #define SPECENUM_VALUE0 ERM_PILLAGE #define SPECENUM_VALUE0NAME "Pillage" -#define SPECENUM_VALUE1 ERM_CLEANPOLLUTION -#define SPECENUM_VALUE1NAME "CleanPollution" +#define SPECENUM_VALUE1 ERM_CLEAN +#define SPECENUM_VALUE1NAME "Clean" #define SPECENUM_VALUE2 ERM_CLEANFALLOUT #define SPECENUM_VALUE2NAME "CleanFallout" #define SPECENUM_VALUE3 ERM_DISAPPEARANCE #define SPECENUM_VALUE3NAME "Disappear" #define SPECENUM_VALUE4 ERM_ENTER #define SPECENUM_VALUE4NAME "Enter" +#define SPECENUM_VALUE5 ERM_CLEANPOLLUTION +#define SPECENUM_VALUE5NAME "CleanPollution" #define SPECENUM_COUNT ERM_COUNT #define SPECENUM_BITVECTOR bv_rmcauses #include "specenum_gen.h" diff --git a/data/alien/terrain.ruleset b/data/alien/terrain.ruleset index 10047d3a0a..5cf3846b1a 100644 --- a/data/alien/terrain.ruleset +++ b/data/alien/terrain.ruleset @@ -692,8 +692,8 @@ ui_name_base_airbase = _("?gui_type:Build Airforce base") ; (the last three require a corresponding ; [resource_*] / [base_*] / [road_*] section) ; rmcauses = events that can remove extra type. -; "CleanPollution", "CleanFallout", "Pillage", -; "Disappear", or "Enter" +; "Clean", "Pillage", "Disappear", or "Enter" +; For now also "CleanPollution", "CleanFallout" ; infracost = Number of infrapoints it costs to place this ; extra. 0, the default, means extra cannot be placed. ; graphic = tag specifying preferred graphic @@ -847,7 +847,7 @@ is known, Thick Mountains can also be mined.\ name = _("Pollution") category = "Nuisance" causes = "Pollution" -rmcauses = "CleanPollution" +rmcauses = "Clean", "CleanPollution" graphic = "tx.pollution" graphic_alt = "-" activity_gfx = "None" @@ -934,7 +934,7 @@ get Protein Houses as soon as they are available.\ name = _("Fallout") category = "Nuisance" causes = "Fallout" -rmcauses = "CleanFallout" +rmcauses = "Clean", "CleanFallout" graphic = "tx.fallout" graphic_alt = "-" activity_gfx = "None" diff --git a/data/civ1/terrain.ruleset b/data/civ1/terrain.ruleset index 68c56d9a0b..7695b5e289 100644 --- a/data/civ1/terrain.ruleset +++ b/data/civ1/terrain.ruleset @@ -859,8 +859,8 @@ ui_name_base_airbase = _("?gui_type:Build None") ; (the last three require a corresponding ; [resource_*] / [base_*] / [road_*] section) ; rmcauses = events that can remove extra type. -; "CleanPollution", "CleanFallout", "Pillage", -; "Disappear", or "Enter" +; "Clean", "Pillage", "Disappear", or "Enter" +; For now also "CleanPollution", "CleanFallout" ; infracost = Number of infrapoints it costs to place this ; extra. 0, the default, means extra cannot be placed. ; graphic = tag specifying preferred graphic @@ -1021,7 +1021,7 @@ Building a mine on an irrigated tile will destroy the irrigation.\ name = _("Pollution") category = "Nuisance" causes = "Pollution", "Fallout" -rmcauses = "CleanPollution" +rmcauses = "Clean", "CleanPollution" graphic = "tx.pollution" graphic_alt = "-" activity_gfx = "None" diff --git a/data/civ2/terrain.ruleset b/data/civ2/terrain.ruleset index f343c2d173..afb8c28c70 100644 --- a/data/civ2/terrain.ruleset +++ b/data/civ2/terrain.ruleset @@ -930,8 +930,8 @@ ui_name_base_airbase = _("?gui_type:Build Airforce base") ; (the last three require a corresponding ; [resource_*] / [base_*] / [road_*] section) ; rmcauses = events that can remove extra type. -; "CleanPollution", "CleanFallout", "Pillage", -; "Disappear", or "Enter" +; "Clean", "Pillage", "Disappear", or "Enter" +; For now also "CleanPollution", "CleanFallout" ; infracost = Number of infrapoints it costs to place this ; extra. 0, the default, means extra cannot be placed. ; graphic = tag specifying preferred graphic @@ -1093,7 +1093,7 @@ Building a mine on an irrigated tile will destroy the irrigation.\ name = _("Pollution") category = "Nuisance" causes = "Pollution", "Fallout" -rmcauses = "CleanPollution" +rmcauses = "Clean", "CleanPollution" graphic = "tx.pollution" graphic_alt = "-" activity_gfx = "None" diff --git a/data/civ2civ3/terrain.ruleset b/data/civ2civ3/terrain.ruleset index 847aae5f6b..170e38a4c1 100644 --- a/data/civ2civ3/terrain.ruleset +++ b/data/civ2civ3/terrain.ruleset @@ -1135,8 +1135,8 @@ ui_name_base_airbase = _("?gui_type:Build Airstrip/Airbase") ; (the last three require a corresponding ; [resource_*] / [base_*] / [road_*] section) ; rmcauses = events that can remove extra type. -; "CleanPollution", "CleanFallout", "Pillage", -; "Disappear", or "Enter" +; "Clean", "Pillage", "Disappear", or "Enter" +; For now also "CleanPollution", "CleanFallout" ; infracost = Number of infrapoints it costs to place this ; extra. 0, the default, means extra cannot be placed. ; graphic = tag specifying preferred graphic @@ -1365,7 +1365,7 @@ or directly by Transport units.\ name = _("Pollution") category = "Nuisance" causes = "Pollution" -rmcauses = "CleanPollution" +rmcauses = "Clean", "CleanPollution" graphic = "tx.pollution" graphic_alt = "-" activity_gfx = "None" @@ -1493,7 +1493,7 @@ Like irrigation, farmland is incompatible with mines and oil wells.\ name = _("Fallout") category = "Nuisance" causes = "Fallout" -rmcauses = "CleanFallout" +rmcauses = "Clean", "CleanFallout" graphic = "tx.fallout" graphic_alt = "-" activity_gfx = "None" diff --git a/data/classic/terrain.ruleset b/data/classic/terrain.ruleset index c81410148d..ce1ea39d3a 100644 --- a/data/classic/terrain.ruleset +++ b/data/classic/terrain.ruleset @@ -1114,8 +1114,8 @@ ui_name_base_airbase = _("?gui_type:Build Airbase") ; (the last three require a corresponding ; [resource_*] / [base_*] / [road_*] section) ; rmcauses = events that can remove extra type. -; "CleanPollution", "CleanFallout", "Pillage", -; "Disappear", or "Enter" +; "Clean", "Pillage", "Disappear", or "Enter" +; For now also "CleanPollution", "CleanFallout" ; infracost = Number of infrapoints it costs to place this ; extra. 0, the default, means extra cannot be placed. ; graphic = tag specifying preferred graphic @@ -1308,7 +1308,7 @@ Building an oil well on an irrigated tile will destroy the irrigation.\ name = _("Pollution") category = "Nuisance" causes = "Pollution" -rmcauses = "CleanPollution" +rmcauses = "Clean", "CleanPollution" graphic = "tx.pollution" graphic_alt = "-" activity_gfx = "None" @@ -1430,7 +1430,7 @@ Like irrigation, farmland is incompatible with mines and oil wells.\ name = _("Fallout") category = "Nuisance" causes = "Fallout" -rmcauses = "CleanFallout" +rmcauses = "Clean", "CleanFallout" graphic = "tx.fallout" graphic_alt = "-" activity_gfx = "None" diff --git a/data/goldkeep/terrain.ruleset b/data/goldkeep/terrain.ruleset index ce1c9afd61..53e9ce7755 100644 --- a/data/goldkeep/terrain.ruleset +++ b/data/goldkeep/terrain.ruleset @@ -1090,8 +1090,8 @@ ui_name_base_airbase = _("?gui_type:Build Airbase") ; (the last three require a corresponding ; [resource_*] / [base_*] / [road_*] section) ; rmcauses = events that can remove extra type. -; "CleanPollution", "CleanFallout", "Pillage", -; "Disappear", or "Enter" +; "Clean", "Pillage", "Disappear", or "Enter" +; For now also "CleanPollution", "CleanFallout" ; infracost = Number of infrapoints it costs to place this ; extra. 0, the default, means extra cannot be placed. ; graphic = tag specifying preferred graphic @@ -1284,7 +1284,7 @@ Building an oil well on an irrigated tile will destroy the irrigation.\ name = _("Pollution") category = "Nuisance" causes = "Pollution" -rmcauses = "CleanPollution" +rmcauses = "Clean", "CleanPollution" graphic = "tx.pollution" graphic_alt = "-" activity_gfx = "None" @@ -1406,7 +1406,7 @@ Like irrigation, farmland is incompatible with mines and oil wells.\ name = _("Fallout") category = "Nuisance" causes = "Fallout" -rmcauses = "CleanFallout" +rmcauses = "Clean", "CleanFallout" graphic = "tx.fallout" graphic_alt = "-" activity_gfx = "None" diff --git a/data/granularity/terrain.ruleset b/data/granularity/terrain.ruleset index cd2583a085..63aa983ac1 100644 --- a/data/granularity/terrain.ruleset +++ b/data/granularity/terrain.ruleset @@ -463,8 +463,8 @@ ui_name_base_airbase = _("?gui_type:Build Type B Base") ; (the last three require a corresponding ; [resource_*] / [base_*] / [road_*] section) ; rmcauses = events that can remove extra type. -; "CleanPollution", "CleanFallout", "Pillage", -; "Disappear", or "Enter" +; "Clean", "Pillage", "Disappear", or "Enter" +; For now also "CleanPollution", "CleanFallout" ; infracost = Number of infrapoints it costs to place this ; extra. 0, the default, means extra cannot be placed. ; graphic = tag specifying preferred graphic diff --git a/data/multiplayer/terrain.ruleset b/data/multiplayer/terrain.ruleset index fe467ed033..ebacb78ee2 100644 --- a/data/multiplayer/terrain.ruleset +++ b/data/multiplayer/terrain.ruleset @@ -1088,8 +1088,8 @@ ui_name_base_airbase = _("?gui_type:Build Airbase") ; (the last three require a corresponding ; [resource_*] / [base_*] / [road_*] section) ; rmcauses = events that can remove extra type. -; "CleanPollution", "CleanFallout", "Pillage", -; "Disappear", or "Enter" +; "Clean", "Pillage", "Disappear", or "Enter" +; For now also "CleanPollution", "CleanFallout" ; infracost = Number of infrapoints it costs to place this ; extra. 0, the default, means extra cannot be placed. ; graphic = tag specifying preferred graphic @@ -1282,7 +1282,7 @@ Building an oil well on an irrigated tile will destroy the irrigation.\ name = _("Pollution") category = "Nuisance" causes = "Pollution" -rmcauses = "CleanPollution" +rmcauses = "Clean", "CleanPollution" graphic = "tx.pollution" graphic_alt = "-" activity_gfx = "None" @@ -1403,7 +1403,7 @@ Like irrigation, farmland is incompatible with mines and oil wells.\ name = _("Fallout") category = "Nuisance" causes = "Fallout" -rmcauses = "CleanFallout" +rmcauses = "Clean", "CleanFallout" graphic = "tx.fallout" graphic_alt = "-" activity_gfx = "None" diff --git a/data/ruledit/comments-3.3.txt b/data/ruledit/comments-3.3.txt index 88a76b61d4..f1db299dfd 100644 --- a/data/ruledit/comments-3.3.txt +++ b/data/ruledit/comments-3.3.txt @@ -748,8 +748,8 @@ extras = "\ ; (the last three require a corresponding\n\ ; [resource_*] / [base_*] / [road_*] section)\n\ ; rmcauses = events that can remove extra type.\n\ -; \"CleanPollution\", \"CleanFallout\", \"Pillage\",\n\ -; \"Disappear\", or \"Enter\"\n\ +; \"Clean\", \"Pillage\", \"Disappear\", or \"Enter\"\n\ +; For now also \"CleanPollution\", \"CleanFallout\"\n\ ; infracost = Number of infrapoints it costs to place this\n\ ; extra. 0, the default, means extra cannot be placed.\n\ ; graphic = tag specifying preferred graphic\n\ diff --git a/data/sandbox/terrain.ruleset b/data/sandbox/terrain.ruleset index 013250443a..fa5b9bfd50 100644 --- a/data/sandbox/terrain.ruleset +++ b/data/sandbox/terrain.ruleset @@ -1136,8 +1136,8 @@ ui_name_base_airbase = _("?gui_type:Build Airstrip/Airbase") ; (the last three require a corresponding ; [resource_*] / [base_*] / [road_*] section) ; rmcauses = events that can remove extra type. -; "CleanPollution", "CleanFallout", "Pillage", -; "Disappear", or "Enter" +; "Clean", "Pillage", "Disappear", or "Enter" +; For now also "CleanPollution", "CleanFallout" ; infracost = Number of infrapoints it costs to place this ; extra. 0, the default, means extra cannot be placed. ; graphic = tag specifying preferred graphic @@ -1366,7 +1366,7 @@ or directly by Transport units.\ name = _("Pollution") category = "Nuisance" causes = "Pollution" -rmcauses = "CleanPollution" +rmcauses = "Clean", "CleanPollution" graphic = "tx.pollution" graphic_alt = "-" activity_gfx = "None" @@ -1523,7 +1523,7 @@ Like irrigation, farmland is incompatible with mines and oil wells.\ name = _("Fallout") category = "Nuisance" causes = "Fallout" -rmcauses = "CleanFallout" +rmcauses = "Clean", "CleanFallout" graphic = "tx.fallout" graphic_alt = "-" activity_gfx = "None" diff --git a/data/stub/terrain.ruleset b/data/stub/terrain.ruleset index b1aa9c75c8..6dae65d888 100644 --- a/data/stub/terrain.ruleset +++ b/data/stub/terrain.ruleset @@ -356,8 +356,8 @@ ui_name_base_airbase = _("?gui_type:Build Type B Base") ; (the last three require a corresponding ; [resource_*] / [base_*] / [road_*] section) ; rmcauses = events that can remove extra type. -; "CleanPollution", "CleanFallout", "Pillage", -; "Disappear", or "Enter" +; "Clean", "Pillage", "Disappear", or "Enter" +; For now also "CleanPollution", "CleanFallout" ; infracost = Number of infrapoints it costs to place this ; extra. 0, the default, means extra cannot be placed. ; graphic = tag specifying preferred graphic diff --git a/data/webperimental/terrain.ruleset b/data/webperimental/terrain.ruleset index 7bf224eaf9..fe069f17ea 100644 --- a/data/webperimental/terrain.ruleset +++ b/data/webperimental/terrain.ruleset @@ -1114,8 +1114,8 @@ ui_name_base_airbase = _("?gui_type:Build Airbase") ; (the last three require a corresponding ; [resource_*] / [base_*] / [road_*] section) ; rmcauses = events that can remove extra type. -; "CleanPollution", "CleanFallout", "Pillage", -; "Disappear", or "Enter" +; "Clean", "Pillage", "Disappear", or "Enter" +; For now also "CleanPollution", "CleanFallout" ; infracost = Number of infrapoints it costs to place this ; extra. 0, the default, means extra cannot be placed. ; graphic = tag specifying preferred graphic @@ -1308,7 +1308,7 @@ Building an oil well on an irrigated tile will destroy the irrigation.\ name = _("Pollution") category = "Nuisance" causes = "Pollution" -rmcauses = "CleanPollution" +rmcauses = "Clean", "CleanPollution" graphic = "tx.pollution" graphic_alt = "-" activity_gfx = "None" @@ -1430,7 +1430,7 @@ Like irrigation, farmland is incompatible with mines and oil wells.\ name = _("Fallout") category = "Nuisance" causes = "Fallout" -rmcauses = "CleanFallout" +rmcauses = "Clean", "CleanFallout" graphic = "tx.fallout" graphic_alt = "-" activity_gfx = "None" diff --git a/server/rssanity.c b/server/rssanity.c index b5fb44d983..4031f033c8 100644 --- a/server/rssanity.c +++ b/server/rssanity.c @@ -1196,8 +1196,8 @@ bool sanity_check_ruleset_data(struct rscompat_info *compat) } if ((requirement_vector_size(&pextra->rmreqs) > 0) && !(pextra->rmcauses - & (ERM_ENTER | ERM_CLEANPOLLUTION - | ERM_CLEANFALLOUT | ERM_PILLAGE))) { + & (ERM_ENTER | ERM_CLEAN | ERM_PILLAGE + | ERM_CLEANPOLLUTION | ERM_CLEANFALLOUT))) { ruleset_error(logger, LOG_WARN, "Requirements for extra removal defined but not " "a valid remove cause!"); diff --git a/server/unithand.c b/server/unithand.c index 3aa0d99fa0..61855ce93b 100644 --- a/server/unithand.c +++ b/server/unithand.c @@ -4321,11 +4321,16 @@ void handle_unit_change_activity(struct player *pplayer, int unit_id, } } else if (activity == ACTIVITY_CLEAN) { - activity_target = prev_extra_in_tile(unit_tile(punit), ERM_CLEANPOLLUTION, + activity_target = prev_extra_in_tile(unit_tile(punit), ERM_CLEAN, pplayer, punit); + if (activity_target == NULL) { - activity_target = prev_extra_in_tile(unit_tile(punit), ERM_CLEANFALLOUT, + activity_target = prev_extra_in_tile(unit_tile(punit), ERM_CLEANPOLLUTION, pplayer, punit); + if (activity_target == NULL) { + activity_target = prev_extra_in_tile(unit_tile(punit), ERM_CLEANFALLOUT, + pplayer, punit); + } } } else if (activity == ACTIVITY_POLLUTION) { activity_target = prev_extra_in_tile(unit_tile(punit), ERM_CLEANPOLLUTION, diff --git a/server/unittools.c b/server/unittools.c index 946bb43c5a..a4d25f5bc0 100644 --- a/server/unittools.c +++ b/server/unittools.c @@ -954,32 +954,31 @@ static void update_unit_activity(struct unit *punit) * set */ { struct extra_type *pextra; - struct extra_type *fextra; if (punit->activity_target == NULL) { - pextra = prev_extra_in_tile(ptile, ERM_CLEANPOLLUTION, + pextra = prev_extra_in_tile(ptile, ERM_CLEAN, NULL, punit); - if (pextra != NULL) { punit->activity_target = pextra; - fextra = NULL; /* fextra not needed, keep compiler happy */ } else { - fextra = prev_extra_in_tile(ptile, ERM_CLEANFALLOUT, + pextra = prev_extra_in_tile(ptile, ERM_CLEANPOLLUTION, NULL, punit); - punit->activity_target = fextra; + + if (pextra != NULL) { + punit->activity_target = pextra; + } else { + pextra = prev_extra_in_tile(ptile, ERM_CLEANFALLOUT, + NULL, punit); + punit->activity_target = pextra; + } } } else { - if (is_extra_removed_by(punit->activity_target, ERM_CLEANPOLLUTION)) { + if (is_extra_removed_by(punit->activity_target, ERM_CLEAN) + || is_extra_removed_by(punit->activity_target, ERM_CLEANPOLLUTION) + || is_extra_removed_by(punit->activity_target, ERM_CLEANFALLOUT)) { pextra = punit->activity_target; - fextra = NULL; /* fextra not needed, keep compiler happy */ } else { pextra = NULL; - - if (is_extra_removed_by(punit->activity_target, ERM_CLEANFALLOUT)) { - fextra = punit->activity_target; - } else { - fextra = NULL; - } } } @@ -988,11 +987,6 @@ static void update_unit_activity(struct unit *punit) destroy_extra(ptile, pextra); unit_activity_done = TRUE; } - } else if (fextra != NULL) { - if (total_activity_done(ptile, ACTIVITY_CLEAN, fextra)) { - destroy_extra(ptile, fextra); - unit_activity_done = TRUE; - } } } break; -- 2.39.2