diff --git a/client/gui-gtk-3.22/menu.c b/client/gui-gtk-3.22/menu.c index 6471fd144..328fba17c 100644 --- a/client/gui-gtk-3.22/menu.c +++ b/client/gui-gtk-3.22/menu.c @@ -232,6 +232,7 @@ static void build_irrigation_callback(GtkMenuItem *item, gpointer data); static void build_mine_callback(GtkMenuItem *item, gpointer data); static void connect_road_callback(GtkMenuItem *item, gpointer data); static void connect_rail_callback(GtkMenuItem *item, gpointer data); +static void connect_maglev_callback(GtkMenuItem *item, gpointer data); static void connect_irrigation_callback(GtkMenuItem *item, gpointer data); static void transform_terrain_callback(GtkMenuItem *item, gpointer data); static void clean_pollution_callback(GtkMenuItem *item, gpointer data); @@ -503,6 +504,8 @@ static struct menu_entry_info menu_entries[] = G_CALLBACK(connect_road_callback), MGROUP_UNIT }, { "CONNECT_RAIL", N_("Connect With Rai_l"), GDK_KEY_l, GDK_SHIFT_MASK, G_CALLBACK(connect_rail_callback), MGROUP_UNIT }, + { "CONNECT_MAGLEV", N_("Connect With maglEv"), GDK_KEY_e, 0, + G_CALLBACK(connect_maglev_callback), MGROUP_UNIT }, { "CONNECT_IRRIGATION", N_("Connect With Irri_gation"), GDK_KEY_i, GDK_SHIFT_MASK, G_CALLBACK(connect_irrigation_callback), MGROUP_UNIT }, @@ -1603,6 +1606,9 @@ static void connect_road_callback(GtkMenuItem *action, gpointer data) { struct road_type *proad = road_by_compat_special(ROCO_ROAD); + fprintf(stderr, "%s", "AL1 : connect_road try \n"); + log_verbose("%s", "AL1 log : connect_road_callback try \n"); + if (proad != NULL) { struct extra_type *tgt; @@ -1619,6 +1625,9 @@ static void connect_rail_callback(GtkMenuItem *action, gpointer data) { struct road_type *prail = road_by_compat_special(ROCO_RAILROAD); + fprintf(stderr, "%s", "AL1 : connect_rail try \n"); + log_verbose("%s", "AL1 log : connect_rail_callback try \n"); + if (prail != NULL) { struct extra_type *tgt; @@ -1628,6 +1637,28 @@ static void connect_rail_callback(GtkMenuItem *action, gpointer data) } } +/**************************************************************** + Action "CONNECT_MAGLEV" callback. +*****************************************************************/ +static void connect_maglev_callback(GtkMenuItem *action, gpointer data) +{ + struct road_type *pmaglev = road_by_compat_special(ROCO_MAGLEV); + + /* see this one in terminal */ + fprintf(stderr, "%s", "AL1 : connect_maglev_callback try \n"); + /* see this one in the log */ + log_verbose("%s", "AL1 log : connect_maglev_callback try \n"); + + + if (pmaglev != NULL) { + struct extra_type *tgt; + + tgt = road_extra_get(pmaglev); + + key_unit_connect(ACTIVITY_GEN_ROAD, tgt); + } +} + /**************************************************************** Action "CONNECT_IRRIGATION" callback. *****************************************************************/ @@ -2330,6 +2361,18 @@ void real_menus_update(void) } menu_entry_set_sensitive("CONNECT_RAIL", conn_possible); + proad = road_by_compat_special(ROCO_MAGLEV); + if (proad != NULL) { + struct extra_type *tgt; + + tgt = road_extra_get(proad); + + conn_possible = can_units_do_connect(punits, ACTIVITY_GEN_ROAD, tgt); + } else { + conn_possible = FALSE; + } + menu_entry_set_sensitive("CONNECT_MAGLEV", conn_possible); + extras = extra_type_list_by_cause(EC_IRRIGATION); if (extra_type_list_size(extras) > 0) { diff --git a/common/fc_types.h b/common/fc_types.h index 2d830ccb0..c7768d473 100644 --- a/common/fc_types.h +++ b/common/fc_types.h @@ -878,7 +878,7 @@ enum test_result { /* Road type compatibility with old specials based roads. * Used in the network protocol. */ -enum road_compat { ROCO_ROAD, ROCO_RAILROAD, ROCO_RIVER, ROCO_NONE }; +enum road_compat { ROCO_ROAD, ROCO_RAILROAD, ROCO_MAGLEV, ROCO_RIVER, ROCO_NONE }; /* * Maximum number of trade routes a city can have in any situation. diff --git a/data/gtk3.22_menus.xml b/data/gtk3.22_menus.xml index b7d10e14a..5a6fa53b0 100644 --- a/data/gtk3.22_menus.xml +++ b/data/gtk3.22_menus.xml @@ -359,6 +359,9 @@ + + + diff --git a/server/ruleset.c b/server/ruleset.c index 2b44410d4..2826f4076 100644 --- a/server/ruleset.c +++ b/server/ruleset.c @@ -2728,6 +2728,7 @@ static bool load_ruleset_terrain(struct section_file *file, int j; bool compat_road = FALSE; bool compat_rail = FALSE; + bool compat_maglev = FALSE; bool compat_river = FALSE; const char **res; const char *filename = secfile_name(file); @@ -3594,6 +3595,13 @@ static bool load_ruleset_terrain(struct section_file *file, } compat_rail = TRUE; proad->compat = ROCO_RAILROAD; + } else if (!fc_strcasecmp(special, "Maglev")) { + if (compat_maglev) { + ruleset_error(LOG_ERROR, "Multiple maglev marked as compatibility \"Maglev\""); + ok = FALSE; + } + compat_maglev = TRUE; + proad->compat = ROCO_MAGLEV; } else if (!fc_strcasecmp(special, "River")) { if (compat_river) { ruleset_error(LOG_ERROR, "Multiple roads marked as compatibility \"River\""); diff --git a/tools/ruleutil/rulesave.c b/tools/ruleutil/rulesave.c index a7ddc9f33..2e2bb2c47 100644 --- a/tools/ruleutil/rulesave.c +++ b/tools/ruleutil/rulesave.c @@ -2396,6 +2396,9 @@ static bool save_terrain_ruleset(const char *filename, const char *name) case ROCO_RAILROAD: secfile_insert_str(sfile, "Railroad", "%s.compat_special", path); break; + case ROCO_MAGLEV: + secfile_insert_str(sfile, "Maglev", "%s.compat_special", path); + break; case ROCO_RIVER: secfile_insert_str(sfile, "River", "%s.compat_special", path); break;