From b6288929cfe874583ba071a678e3aa83065ecd52 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 1 Apr 2023 23:26:04 +0300 Subject: [PATCH 36/36] Rename agent Autosettler as Autoworker See osdn #47744 Signed-off-by: Marko Lindqvist --- ai/default/daiunit.c | 7 +++---- client/control.c | 18 +++++++++--------- client/control.h | 2 +- client/gui-gtk-3.22/menu.c | 2 +- client/gui-gtk-4.0/menu.c | 2 +- client/gui-qt/hudwidget.cpp | 2 +- client/gui-qt/menu.cpp | 6 +++--- client/gui-qt/menu.h | 2 +- client/gui-sdl2/gui_id.h | 2 +- client/gui-sdl2/menu.c | 12 ++++++------ client/tilespec.c | 27 +++++++++++++++++++++++---- common/unit.c | 10 +++++----- common/unit.h | 6 +++--- data/amplio/tiles.spec | 2 +- data/amplio2/tiles.spec | 2 +- data/hex2t/items.spec | 2 +- data/hexemplio/unitextras.spec | 2 +- data/isotrident/tiles.spec | 2 +- data/trident/auto_ll.spec | 2 +- data/trident/tiles.spec | 2 +- server/advisors/autoworkers.c | 4 ++-- server/savegame/savecompat.c | 6 +++--- server/savegame/savegame2.c | 6 +++--- server/unithand.c | 4 ++-- 24 files changed, 75 insertions(+), 57 deletions(-) diff --git a/ai/default/daiunit.c b/ai/default/daiunit.c index 7d20700a01..873f57ff38 100644 --- a/ai/default/daiunit.c +++ b/ai/default/daiunit.c @@ -2603,13 +2603,12 @@ static void dai_manage_settler(struct ai_type *ait, struct player *pplayer, { struct unit_ai *unit_data = def_ai_unit_data(punit, ait); - unit_server_side_agent_set(pplayer, punit, SSA_AUTOSETTLER); - unit_data->done = TRUE; /* we will manage this unit later... ugh */ - /* if BUILD_CITY must remain BUILD_CITY, otherwise turn into autosettler */ + unit_server_side_agent_set(pplayer, punit, SSA_AUTOWORKER); + unit_data->done = TRUE; /* We will manage this unit later... ugh */ + /* If BUILD_CITY must remain BUILD_CITY, otherwise turn into autosettler */ if (unit_data->task == AIUNIT_NONE) { adv_unit_new_task(punit, AUT_AUTO_SETTLER, NULL); } - return; } /**********************************************************************//** diff --git a/client/control.c b/client/control.c index c1accf03c8..a7583258b7 100644 --- a/client/control.c +++ b/client/control.c @@ -2103,16 +2103,16 @@ void request_unit_ssa_set(const struct unit *punit, } /**********************************************************************//** - Call to request (from the server) that the settler unit is put into - autosettler mode. + Call to request (from the server) that the worker unit is put into + autoworker mode. **************************************************************************/ -void request_unit_autosettlers(const struct unit *punit) +void request_unit_autoworker(const struct unit *punit) { - if (punit && can_unit_do_autosettlers(punit)) { - request_unit_ssa_set(punit, SSA_AUTOSETTLER); + if (punit && can_unit_do_autoworker(punit)) { + request_unit_ssa_set(punit, SSA_AUTOWORKER); } else if (punit) { create_event(unit_tile(punit), E_BAD_COMMAND, ftc_client, - _("Only settler units can be put into auto mode.")); + _("Only worker units can be put into auto working mode.")); } } @@ -3551,13 +3551,13 @@ void key_unit_auto_explore(void) /**********************************************************************//** Call to request (from the server) that the focus unit is put into - autosettler mode. + autoworker mode. **************************************************************************/ void key_unit_auto_settle(void) { unit_list_iterate(get_units_in_focus(), punit) { - if (can_unit_do_autosettlers(punit)) { - request_unit_autosettlers(punit); + if (can_unit_do_autoworker(punit)) { + request_unit_autoworker(punit); } } unit_list_iterate_end; } diff --git a/client/control.h b/client/control.h index 634589b54d..8d5a347b89 100644 --- a/client/control.h +++ b/client/control.h @@ -92,7 +92,7 @@ void request_unit_load(struct unit *pcargo, struct unit *ptransporter, void request_unit_unload(struct unit *pcargo); void request_unit_ssa_set(const struct unit *punit, enum server_side_agent agent); -void request_unit_autosettlers(const struct unit *punit); +void request_unit_autoworker(const struct unit *punit); void request_unit_build_city(struct unit *punit); void request_unit_caravan_action(struct unit *punit, action_id action); void request_unit_change_homecity(struct unit *punit); diff --git a/client/gui-gtk-3.22/menu.c b/client/gui-gtk-3.22/menu.c index f8eeb7b78d..958690ee96 100644 --- a/client/gui-gtk-3.22/menu.c +++ b/client/gui-gtk-3.22/menu.c @@ -2591,7 +2591,7 @@ void real_menus_update(void) units_have_activity_on_tile(punits, ACTIVITY_SENTRY)); menu_entry_set_sensitive("AUTO_SETTLER", - can_units_do(punits, can_unit_do_autosettlers)); + can_units_do(punits, can_unit_do_autoworker)); menu_entry_set_sensitive("UNIT_EXPLORE", can_units_do_activity(punits, ACTIVITY_EXPLORE)); diff --git a/client/gui-gtk-4.0/menu.c b/client/gui-gtk-4.0/menu.c index fef336f937..c035b2b849 100644 --- a/client/gui-gtk-4.0/menu.c +++ b/client/gui-gtk-4.0/menu.c @@ -3952,7 +3952,7 @@ void real_menus_update(void) TRUE)); menu_entry_set_sensitive(map, "AUTO_SETTLER", - can_units_do(punits, can_unit_do_autosettlers)); + can_units_do(punits, can_unit_do_autoworker)); menu_entry_set_sensitive(map, "UNIT_EXPLORE", can_units_do_activity(punits, ACTIVITY_EXPLORE)); menu_entry_set_sensitive(map, "UNIT_BOARD", diff --git a/client/gui-qt/hudwidget.cpp b/client/gui-qt/hudwidget.cpp index d79e8e379b..cc37cb5e7c 100644 --- a/client/gui-qt/hudwidget.cpp +++ b/client/gui-qt/hudwidget.cpp @@ -1104,7 +1104,7 @@ int unit_actions::update_actions() } // Automate - if (can_unit_do_autosettlers(current_unit)) { + if (can_unit_do_autoworker(current_unit)) { a = new hud_action(this); a->action_shortcut = SC_AUTOMATE; a->set_pixmap(fc_icons::instance()->get_pixmap("automate")); diff --git a/client/gui-qt/menu.cpp b/client/gui-qt/menu.cpp index 5cc668fa32..6f4ee9fef6 100644 --- a/client/gui-qt/menu.cpp +++ b/client/gui-qt/menu.cpp @@ -1304,7 +1304,7 @@ void mr_menu::setup_menus() act = main_menu->addAction(_("Auto Settler")); act->setShortcut(QKeySequence(shortcut_to_string( fc_shortcuts::sc()->get_shortcut(SC_AUTOMATE)))); - menu_list.insert(AUTOSETTLER, act); + menu_list.insert(AUTOWORKER, act); connect(act, &QAction::triggered, this, &mr_menu::slot_auto_settler); main_menu->addSeparator(); act = main_menu->addAction(_("Build Road")); @@ -2391,8 +2391,8 @@ void mr_menu::menus_sensitive() } break; - case AUTOSETTLER: - if (can_units_do(punits, can_unit_do_autosettlers)) { + case AUTOWORKER: + if (can_units_do(punits, can_unit_do_autoworker)) { i.value()->setEnabled(true); } if (units_contain_cityfounder(punits)) { diff --git a/client/gui-qt/menu.h b/client/gui-qt/menu.h index 8c3e6df199..2f3c83179d 100644 --- a/client/gui-qt/menu.h +++ b/client/gui-qt/menu.h @@ -61,7 +61,7 @@ enum munit { SENTRY, HOMECITY, WAKEUP, - AUTOSETTLER, + AUTOWORKER, CONNECT_ROAD, CONNECT_RAIL, CONNECT_MAGLEV, diff --git a/client/gui-sdl2/gui_id.h b/client/gui-sdl2/gui_id.h index 3d883463f8..bbcee3ed0d 100644 --- a/client/gui-sdl2/gui_id.h +++ b/client/gui-sdl2/gui_id.h @@ -106,7 +106,7 @@ enum GUI_ID { ID_UNIT_ORDER_BOARD, ID_UNIT_ORDER_DEBOARD, ID_UNIT_ORDER_WAKEUP_OTHERS, - ID_UNIT_ORDER_AUTO_SETTLER, + ID_UNIT_ORDER_AUTO_WORKER, ID_UNIT_ORDER_AUTO_EXPLORE, ID_UNIT_ORDER_CONNECT_ROAD, ID_UNIT_ORDER_CONNECT_RAILROAD, diff --git a/client/gui-sdl2/menu.c b/client/gui-sdl2/menu.c index 12a2536730..367f3a99c1 100644 --- a/client/gui-sdl2/menu.c +++ b/client/gui-sdl2/menu.c @@ -179,9 +179,9 @@ static int unit_order_callback(struct widget *order_widget) case ID_UNIT_ORDER_WAKEUP_OTHERS: key_unit_wakeup_others(); break; - case ID_UNIT_ORDER_AUTO_SETTLER: + case ID_UNIT_ORDER_AUTO_WORKER: unit_list_iterate(get_units_in_focus(), punit) { - request_unit_autosettlers(punit); + request_unit_autoworker(punit); } unit_list_iterate_end; break; case ID_UNIT_ORDER_AUTO_EXPLORE: @@ -641,7 +641,7 @@ void create_units_order_widgets(void) buf->action = unit_order_callback; buf->info_label = create_utf8_from_char(cbuf, adj_font(10)); buf->key = SDLK_a; - add_to_gui_list(ID_UNIT_ORDER_AUTO_SETTLER, buf); + add_to_gui_list(ID_UNIT_ORDER_AUTO_WORKER, buf); /* --------- */ /* Wake Up Others */ @@ -1408,10 +1408,10 @@ void real_menus_update(void) local_hide(ID_UNIT_ORDER_WAKEUP_OTHERS); } - if (can_unit_do_autosettlers(punit)) { - local_show(ID_UNIT_ORDER_AUTO_SETTLER); + if (can_unit_do_autoworker(punit)) { + local_show(ID_UNIT_ORDER_AUTO_WORKER); } else { - local_hide(ID_UNIT_ORDER_AUTO_SETTLER); + local_hide(ID_UNIT_ORDER_AUTO_WORKER); } if (can_unit_do_activity(punit, ACTIVITY_EXPLORE)) { diff --git a/client/tilespec.c b/client/tilespec.c index 1798589acb..bba810d6b9 100644 --- a/client/tilespec.c +++ b/client/tilespec.c @@ -287,7 +287,7 @@ struct named_sprites { *vet_lev[MAX_VET_LEVELS], *select[NUM_TILES_SELECT], *auto_attack, - *auto_settler, + *auto_worker, *auto_explore, *fortified, *fortifying, @@ -2853,6 +2853,24 @@ static bool sprite_exists(const struct tileset *t, const char *tag_name) } \ } while (FALSE) +/* Sets sprites.field to tag or (if tag isn't available) to deprecated alt */ +#define SET_SPRITE_DEPR_ALT(field, tag, alt, ver) \ + do { \ + t->sprites.field = load_sprite(t, tag, TRUE, TRUE, FALSE); \ + if (!t->sprites.field) { \ + t->sprites.field = load_sprite(t, alt, TRUE, TRUE, FALSE); \ + if (t->sprites.field != NULL) { \ + log_deprecation(_("%s: Using tag \"%s\" deprecated by \"%s\" in %s"), \ + tileset_name_get(t), alt, tag, ver); \ + } \ + } \ + if (t->sprites.field == NULL) { \ + tileset_error(LOG_FATAL, tileset_name_get(t), \ + _("Sprite for tags '%s' and alternate '%s' are " \ + "both missing."), tag, alt); \ + } \ + } while (FALSE) + /* Sets sprites.field to tag, or NULL if not available */ #define SET_SPRITE_OPT(field, tag) \ t->sprites.field = load_sprite(t, tag, TRUE, TRUE, FALSE) @@ -3230,7 +3248,8 @@ static void tileset_lookup_sprite_tags(struct tileset *t) } SET_SPRITE(unit.auto_attack, "unit.auto_attack"); - SET_SPRITE(unit.auto_settler, "unit.auto_settler"); + /* TODO: Drop backward compatibility with "unit.auto_settler" tag. */ + SET_SPRITE_DEPR_ALT(unit.auto_worker, "unit.auto_worker", "unit.auto_settler", "3.3"); SET_SPRITE(unit.auto_explore, "unit.auto_explore"); SET_SPRITE(unit.fortified, "unit.fortified"); SET_SPRITE(unit.fortifying, "unit.fortifying"); @@ -4614,8 +4633,8 @@ static int fill_unit_sprite_array(const struct tileset *t, switch (punit->ssa_controller) { case SSA_NONE: break; - case SSA_AUTOSETTLER: - s = t->sprites.unit.auto_settler; + case SSA_AUTOWORKER: + s = t->sprites.unit.auto_worker; break; case SSA_AUTOEXPLORE: s = t->sprites.unit.auto_explore; diff --git a/common/unit.c b/common/unit.c index 64585cb216..84265807a6 100644 --- a/common/unit.c +++ b/common/unit.c @@ -589,15 +589,15 @@ bool activity_requires_target(enum unit_activity activity) } /**********************************************************************//** - Return whether the unit can be put in auto-settler mode. + Return whether the unit can be put in auto-worker mode. - NOTE: we used to have "auto" mode including autosettlers and auto-attack. + NOTE: we used to have "auto" mode including autoworker and auto-attack. This was bad because the two were indestinguishable even though they - are very different. Now auto-attack is done differently so we just have - auto-settlers. If any new auto modes are introduced they should be + are very different. Now auto-attack is done differently so we just have + auto-worker. If any new auto modes are introduced they should be handled separately. **************************************************************************/ -bool can_unit_do_autosettlers(const struct unit *punit) +bool can_unit_do_autoworker(const struct unit *punit) { return unit_type_get(punit)->adv.worker; } diff --git a/common/unit.h b/common/unit.h index 87362abb74..8033391c12 100644 --- a/common/unit.h +++ b/common/unit.h @@ -124,8 +124,8 @@ struct unit_order { #define SPECENUM_NAME server_side_agent #define SPECENUM_VALUE0 SSA_NONE #define SPECENUM_VALUE0NAME N_("?serveragent:None") -#define SPECENUM_VALUE1 SSA_AUTOSETTLER -#define SPECENUM_VALUE1NAME N_("Autosettlers") +#define SPECENUM_VALUE1 SSA_AUTOWORKER +#define SPECENUM_VALUE1NAME N_("AutoWorker") #define SPECENUM_VALUE2 SSA_AUTOEXPLORE #define SPECENUM_VALUE2NAME N_("Autoexplore") #define SPECENUM_COUNT SSA_COUNT @@ -346,7 +346,7 @@ int get_turns_for_activity_at(const struct unit *punit, const struct tile *ptile, struct extra_type *tgt); bool activity_requires_target(enum unit_activity activity); -bool can_unit_do_autosettlers(const struct unit *punit); +bool can_unit_do_autoworker(const struct unit *punit); bool is_unit_activity_on_tile(enum unit_activity activity, const struct tile *ptile); bv_extras get_unit_tile_pillage_set(const struct tile *ptile); diff --git a/data/amplio/tiles.spec b/data/amplio/tiles.spec index a625f98751..7c1769e5d9 100644 --- a/data/amplio/tiles.spec +++ b/data/amplio/tiles.spec @@ -27,7 +27,7 @@ tiles = { "row", "column", "tag" ; Unit activity letters: (note unit icons have just "u.") 0, 18, "unit.auto_attack", - "unit.auto_settler" + "unit.auto_worker" 0, 19, "unit.stack" 1, 16, "unit.action_decision_want" 1, 17, "unit.loaded" diff --git a/data/amplio2/tiles.spec b/data/amplio2/tiles.spec index f8ac7d27b8..6d795ee6e8 100644 --- a/data/amplio2/tiles.spec +++ b/data/amplio2/tiles.spec @@ -112,7 +112,7 @@ tiles = { "row", "column", "tag" 3, 10, "unit.connect" 4, 10, "unit.auto_attack", - "unit.auto_settler" + "unit.auto_worker" 5, 10, "unit.stack" 6, 10, "unit.loaded" diff --git a/data/hex2t/items.spec b/data/hex2t/items.spec index e6d67cca39..1b7561db66 100644 --- a/data/hex2t/items.spec +++ b/data/hex2t/items.spec @@ -215,7 +215,7 @@ tiles = { "row", "column", "tag" 0, 12, "unit.action_decision_want" 0, 13, "unit.convert" 0, 14, "unit.auto_attack", - "unit.auto_settler" + "unit.auto_worker" 0, 15, "unit.stack" 0, 16, "unit.loaded" 0, 17, "unit.connect" diff --git a/data/hexemplio/unitextras.spec b/data/hexemplio/unitextras.spec index 63be5f3581..54846a8d61 100644 --- a/data/hexemplio/unitextras.spec +++ b/data/hexemplio/unitextras.spec @@ -63,6 +63,6 @@ tiles = { "row", "column", "tag" 2, 4, "unit.lowfuel" 2, 5, "unit.connect" 2, 6, "unit.auto_attack" - 2, 6, "unit.auto_settler" + 2, 6, "unit.auto_worker" 2, 7, "unit.patrol" ;[?] } diff --git a/data/isotrident/tiles.spec b/data/isotrident/tiles.spec index 042dd674db..198c13eda9 100644 --- a/data/isotrident/tiles.spec +++ b/data/isotrident/tiles.spec @@ -35,7 +35,7 @@ tiles = { "row", "column", "tag" 0, 17, "unit.airbase" 0, 18, "unit.auto_attack" - 0, 18, "unit.auto_settler" + 0, 18, "unit.auto_worker" 0, 19, "unit.stack" ; [GS] diff --git a/data/trident/auto_ll.spec b/data/trident/auto_ll.spec index d11d39a6c4..beb1384171 100644 --- a/data/trident/auto_ll.spec +++ b/data/trident/auto_ll.spec @@ -25,7 +25,7 @@ tiles = { "row", "column", "tag" ; Unit activity letters: (note unit icons have just "u.") 4, 17, "unit.auto_attack", - "unit.auto_settler" + "unit.auto_worker" 4, 18, "unit.connect" 4, 19, "unit.auto_explore" diff --git a/data/trident/tiles.spec b/data/trident/tiles.spec index 491f7721f9..75c954283a 100644 --- a/data/trident/tiles.spec +++ b/data/trident/tiles.spec @@ -589,7 +589,7 @@ tiles = { "row", "column", "tag" ; Unit activity letters: (note unit icons have just "u.") 6, 17, "unit.auto_attack", - "unit.auto_settler" + "unit.auto_worker" 6, 18, "unit.connect" 6, 19, "unit.auto_explore" diff --git a/server/advisors/autoworkers.c b/server/advisors/autoworkers.c index 69d4078ce7..adbdf10a02 100644 --- a/server/advisors/autoworkers.c +++ b/server/advisors/autoworkers.c @@ -1189,7 +1189,7 @@ void auto_settlers_player(struct player *pplayer) * auto-settle with a unit under orders even for an AI player - these come * from the human player and take precedence. */ unit_list_iterate_safe(pplayer->units, punit) { - if ((punit->ssa_controller == SSA_AUTOSETTLER || is_ai(pplayer)) + if ((punit->ssa_controller == SSA_AUTOWORKER || is_ai(pplayer)) && (unit_type_get(punit)->adv.worker || unit_is_cityfounder(punit)) && !unit_has_orders(punit) @@ -1198,7 +1198,7 @@ void auto_settlers_player(struct player *pplayer) nation_rule_name(nation_of_player(pplayer)), unit_rule_name(punit), TILE_XY(unit_tile(punit)), - server_side_agent_name(SSA_AUTOSETTLER)); + server_side_agent_name(SSA_AUTOWORKER)); if (punit->activity == ACTIVITY_SENTRY) { unit_activity_handling(punit, ACTIVITY_IDLE); } diff --git a/server/savegame/savecompat.c b/server/savegame/savecompat.c index b389ea938b..edb5b7cc76 100644 --- a/server/savegame/savecompat.c +++ b/server/savegame/savecompat.c @@ -1493,9 +1493,9 @@ static void insert_server_side_agent(struct loaddata *loading, plrno, unit); if (ai) { - /* Autosettler and Autoexplore are separated by - * compat_post_load_030100() when set to SSA_AUTOSETTLER */ - secfile_insert_int(loading->file, SSA_AUTOSETTLER, + /* Autoworker and Autoexplore are separated by + * compat_post_load_030100() when set to SSA_AUTOWORKER */ + secfile_insert_int(loading->file, SSA_AUTOWORKER, "player%d.u%d.server_side_agent", plrno, unit); } else { diff --git a/server/savegame/savegame2.c b/server/savegame/savegame2.c index e7463c2267..05152bbdf9 100644 --- a/server/savegame/savegame2.c +++ b/server/savegame/savegame2.c @@ -4303,9 +4303,9 @@ static bool sg_load_player_unit(struct loaddata *loading, "%s.ai", unitstr), FALSE, "%s", secfile_error()); if (ai_controlled) { - /* Autosettler and Autoexplore are separated by - * compat_post_load_030100() when set to SSA_AUTOSETTLER */ - punit->ssa_controller = SSA_AUTOSETTLER; + /* Autoworker and Autoexplore are separated by + * compat_post_load_030100() when set to SSA_AUTOWORKER */ + punit->ssa_controller = SSA_AUTOWORKER; } else { punit->ssa_controller = SSA_NONE; } diff --git a/server/unithand.c b/server/unithand.c index 80b39a2420..3aa0d99fa0 100644 --- a/server/unithand.c +++ b/server/unithand.c @@ -6342,8 +6342,8 @@ bool unit_server_side_agent_set(struct player *pplayer, { /* Check that the agent can be activated for this unit. */ switch (agent) { - case SSA_AUTOSETTLER: - if (!can_unit_do_autosettlers(punit)) { + case SSA_AUTOWORKER: + if (!can_unit_do_autoworker(punit)) { return FALSE; } break; -- 2.39.2