// TODO: Support irrigation modes JNIEXPORT jbyteArray JNICALL Java_net_hackcasual_freeciv_NativeHarness_getAvailableCommandsForActiveUnit (JNIEnv * env, jobject obj) { struct unit * pUnit; char availCommands[COM_UNIT_LAST]; int commandCount = 0; pUnit = head_of_units_in_focus(); if (pUnit) { struct tile *pTile = pUnit->tile; struct city *pCity = tile_city(pTile); struct terrain *pTerrain = tile_terrain(pTile); struct base_type *pbase; struct unit_list *punits = get_units_in_focus(); if (can_unit_build_city(pUnit)) { availCommands[commandCount++] = COM_BUILD_CITY; } if (can_unit_do_activity(pUnit, ACTIVITY_GOTO)) { availCommands[commandCount++] = COM_GO_TO; availCommands[commandCount++] = COM_GO_TO_CITY; } if (can_unit_do_activity(pUnit, ACTIVITY_SENTRY)) { availCommands[commandCount++] = COM_SENTRY; } if (can_unit_do_activity(pUnit, ACTIVITY_FORTIFYING)) { availCommands[commandCount++] = COM_FORTIFY; } if (can_unit_do_activity(pUnit, ACTIVITY_EXPLORE)) { availCommands[commandCount++] = COM_EXPLORE; } availCommands[commandCount++] = COM_DISBAND; if (can_unit_do_activity(pUnit, ACTIVITY_ROAD) || can_unit_do_activity(pUnit, ACTIVITY_RAILROAD)) { availCommands[commandCount++] = COM_ROAD; } if (can_unit_do_activity(pUnit, ACTIVITY_IRRIGATE)) { availCommands[commandCount++] = COM_IRRIGATION; } if (can_unit_do_autosettlers(pUnit)) { availCommands[commandCount++] = COM_AUTO_WORKER; } if (can_unit_do_connect(pUnit, ACTIVITY_IRRIGATE)) { availCommands[commandCount++] = COM_CONNECT_IRRIGATION; } if (can_unit_do_connect(pUnit, ACTIVITY_ROAD)) { availCommands[commandCount++] = COM_CONNECT_ROAD; } if (can_unit_do_connect(pUnit, ACTIVITY_RAILROAD)) { availCommands[commandCount++] = COM_CONNECT_RAILROAD; } availCommands[commandCount++] = COM_WAIT; if (unit_can_help_build_wonder_here(pUnit)) { availCommands[commandCount++] = COM_BUILD_WONDER; } if (unit_can_est_trade_route_here(pUnit)) { availCommands[commandCount++] = COM_TRADE_ROUTE; } if (can_unit_do_activity(pUnit, ACTIVITY_MINE)) { availCommands[commandCount++] = COM_MINE; } if (can_unit_do_activity(pUnit, ACTIVITY_TRANSFORM)) { availCommands[commandCount++] = COM_TRANSFORM; } pbase = get_base_by_gui_type(BASE_GUI_FORTRESS, pUnit, pUnit->tile); if (!pCity && pbase) { availCommands[commandCount++] = COM_FORTRESS; } pbase = get_base_by_gui_type(BASE_GUI_AIRBASE, pUnit, pUnit->tile); if (!pCity && pbase) { availCommands[commandCount++] = COM_AIRBASE; } if (can_unit_do_activity(pUnit, ACTIVITY_POLLUTION)) { availCommands[commandCount++] = COM_POLLUTION; } if (can_unit_do_activity(pUnit, ACTIVITY_FALLOUT)) { availCommands[commandCount++] = COM_FALLOUT; } if (can_unit_paradrop(pUnit)) { availCommands[commandCount++] = COM_PARADROP; } if (can_unit_do_activity(pUnit, ACTIVITY_PILLAGE)) { availCommands[commandCount++] = COM_FALLOUT; } if (pCity && can_unit_change_homecity(pUnit) && pCity->id != pUnit->homecity) { availCommands[commandCount++] = COM_HOMECITY; } if (pUnit->occupy && get_transporter_occupancy(pUnit) > 0) { availCommands[commandCount++] = COM_UNLOAD_TRANSPORT; } if (units_can_load(punits)) { availCommands[commandCount++] = COM_LOAD; } if (units_can_unload(punits)) { availCommands[commandCount++] = COM_UNLOAD; } if (pCity && pCity->airlift) { availCommands[commandCount++] = COM_AIRLIFT; } if (pCity && can_upgrade_unittype(client.conn.playing, unit_type(pUnit))) { availCommands[commandCount++] = COM_UPGRADE; } if (diplomat_can_do_action(pUnit, DIPLOMAT_ANY_ACTION, pUnit->tile)) { availCommands[commandCount++] = COM_DIPLOMAT; } if (unit_has_type_flag(pUnit, F_NUCLEAR)) { availCommands[commandCount++] = COM_NUKE; } } jbyteArray commands; commands = (*env)->NewByteArray(env, commandCount); (*env)->SetByteArrayRegion(env, commands, 0, commandCount, (jbyte *)availCommands); return commands; }
/**************************************************************** Popups the diplomat dialog *****************************************************************/ void popup_diplomat_dialog(struct unit *punit, struct tile *dest_tile) { struct city *pcity; struct unit *ptunit; struct astring text = ASTRING_INIT; diplomat_id=punit->id; if((pcity=tile_city(dest_tile))){ /* Spy/Diplomat acting against a city */ diplomat_target_id=pcity->id; astr_set(&text, _("Your %s has arrived at %s.\nWhat is your command?"), unit_name_translation(punit), city_name(pcity)); if (!unit_has_type_flag(punit, UTYF_SPY)) { diplomat_dialog = popup_message_dialog(toplevel, "diplomatdialog", astr_str(&text), diplomat_embassy_callback, 0, 1, diplomat_investigate_callback, 0, 1, spy_poison_callback, 0, 1, diplomat_sabotage_callback, 0, 1, diplomat_steal_callback, 0, 1, diplomat_incite_callback, 0, 1, diplomat_keep_moving_callback_city, 0, 1, diplomat_cancel_callback, 0, 0, NULL); } else { diplomat_dialog = popup_message_dialog(toplevel, "spydialog", astr_str(&text), diplomat_embassy_callback, 0, 1, diplomat_investigate_callback, 0, 1, spy_poison_callback, 0, 1, spy_request_sabotage_list, 0, 1, spy_steal_popup, 0, 1, diplomat_incite_callback, 0, 1, diplomat_keep_moving_callback_city, 0, 1, diplomat_cancel_callback, 0, 0, NULL); } if(!diplomat_can_do_action(punit, DIPLOMAT_EMBASSY, dest_tile)) { XtSetSensitive(XtNameToWidget(diplomat_dialog, "*button0"), FALSE); } if(!diplomat_can_do_action(punit, DIPLOMAT_INVESTIGATE, dest_tile)) { XtSetSensitive(XtNameToWidget(diplomat_dialog, "*button1"), FALSE); } if(!diplomat_can_do_action(punit, SPY_POISON, dest_tile)) { XtSetSensitive(XtNameToWidget(diplomat_dialog, "*button2"), FALSE); } if(!diplomat_can_do_action(punit, DIPLOMAT_SABOTAGE, dest_tile)) { XtSetSensitive(XtNameToWidget(diplomat_dialog, "*button3"), FALSE); } if(!diplomat_can_do_action(punit, DIPLOMAT_STEAL, dest_tile)) { XtSetSensitive(XtNameToWidget(diplomat_dialog, "*button4"), FALSE); } if(!diplomat_can_do_action(punit, DIPLOMAT_INCITE, dest_tile)) { XtSetSensitive(XtNameToWidget(diplomat_dialog, "*button5"), FALSE); } if(!diplomat_can_do_action(punit, DIPLOMAT_MOVE, dest_tile)) { XtSetSensitive(XtNameToWidget(diplomat_dialog, "*button6"), FALSE); } } else { if ((ptunit = unit_list_get(dest_tile->units, 0))) { /* Spy/Diplomat acting against a unit */ Widget shl; astr_set(&text, _("Your %s is waiting for your command."), unit_name_translation(punit)); diplomat_target_id=ptunit->id; shl=popup_message_dialog(toplevel, "spybribedialog", astr_str(&text), diplomat_bribe_callback, 0, 0, spy_sabotage_unit_callback, 0, 0, diplomat_keep_moving_callback_unit, 0, 1, diplomat_cancel_callback, 0, 0, NULL); if(!diplomat_can_do_action(punit, DIPLOMAT_BRIBE, dest_tile)) XtSetSensitive(XtNameToWidget(shl, "*button0"), FALSE); if(!diplomat_can_do_action(punit, SPY_SABOTAGE_UNIT, dest_tile)) XtSetSensitive(XtNameToWidget(shl, "*button1"), FALSE); if(!diplomat_can_do_action(punit, DIPLOMAT_MOVE, dest_tile)) XtSetSensitive(XtNameToWidget(shl, "*button2"), FALSE); } } astr_free(&text); }
/************************************************************************** Popup a dialog giving a diplomatic unit some options when moving into the target tile. **************************************************************************/ void popup_diplomat_dialog(struct unit *pUnit, struct tile *ptile) { struct widget *pWindow = NULL, *pBuf = NULL; SDL_String16 *pStr; struct city *pCity; struct unit *pTunit; bool spy; SDL_Rect area; if (pDiplomat_Dlg) { return; } is_unit_move_blocked = TRUE; pCity = tile_city(ptile); spy = unit_has_type_flag(pUnit, F_SPY); pDiplomat_Dlg = fc_calloc(1, sizeof(struct diplomat_dialog)); pDiplomat_Dlg->diplomat_id = pUnit->id; pDiplomat_Dlg->pdialog = fc_calloc(1, sizeof(struct ADVANCED_DLG)); /* window */ if (pCity) { if(spy) { pStr = create_str16_from_char(_("Choose Your Spy's Strategy") , adj_font(12)); } else { pStr = create_str16_from_char(_("Choose Your Diplomat's Strategy"), adj_font(12)); } } else { pStr = create_str16_from_char(_("Subvert Enemy Unit"), adj_font(12)); } pStr->style |= TTF_STYLE_BOLD; pWindow = create_window_skeleton(NULL, pStr, 0); pWindow->action = diplomat_dlg_window_callback; set_wstate(pWindow, FC_WS_NORMAL); add_to_gui_list(ID_CARAVAN_DLG_WINDOW, pWindow); pDiplomat_Dlg->pdialog->pEndWidgetList = pWindow; area = pWindow->area; area.w = MAX(area.w, adj_size(8)); area.h = MAX(area.h, adj_size(2)); /* ---------- */ if((pCity)) { /* Spy/Diplomat acting against a city */ pDiplomat_Dlg->diplomat_target_id = pCity->id; /* -------------- */ if (diplomat_can_do_action(pUnit, DIPLOMAT_EMBASSY, ptile)) { create_active_iconlabel(pBuf, pWindow->dst, pStr, _("Establish Embassy"), diplomat_embassy_callback); pBuf->data.city = pCity; set_wstate(pBuf, FC_WS_NORMAL); add_to_gui_list(MAX_ID - pUnit->id, pBuf); area.w = MAX(area.w, pBuf->size.w); area.h += pBuf->size.h; } /* ---------- */ if (diplomat_can_do_action(pUnit, DIPLOMAT_INVESTIGATE, ptile)) { create_active_iconlabel(pBuf, pWindow->dst, pStr, _("Investigate City"), diplomat_investigate_callback); pBuf->data.city = pCity; set_wstate(pBuf, FC_WS_NORMAL); add_to_gui_list(MAX_ID - pUnit->id, pBuf); area.w = MAX(area.w, pBuf->size.w); area.h += pBuf->size.h; } /* ---------- */ if (spy && diplomat_can_do_action(pUnit, SPY_POISON, ptile)) { create_active_iconlabel(pBuf, pWindow->dst, pStr, _("Poison City"), spy_poison_callback); pBuf->data.city = pCity; set_wstate(pBuf, FC_WS_NORMAL); add_to_gui_list(MAX_ID - pUnit->id, pBuf); area.w = MAX(area.w, pBuf->size.w); area.h += pBuf->size.h; } /* ---------- */ if (diplomat_can_do_action(pUnit, DIPLOMAT_SABOTAGE, ptile)) { create_active_iconlabel(pBuf, pWindow->dst, pStr, _("Sabotage City"), spy ? spy_sabotage_request : diplomat_sabotage_callback); pBuf->data.city = pCity; set_wstate(pBuf, FC_WS_NORMAL); add_to_gui_list(MAX_ID - pUnit->id, pBuf); area.w = MAX(area.w, pBuf->size.w); area.h += pBuf->size.h; } /* ---------- */ if (diplomat_can_do_action(pUnit, DIPLOMAT_STEAL, ptile)) { create_active_iconlabel(pBuf, pWindow->dst, pStr, _("Steal Technology"), spy ? spy_steal_popup : diplomat_steal_callback); pBuf->data.city = pCity; set_wstate(pBuf , FC_WS_NORMAL); add_to_gui_list(MAX_ID - pUnit->id , pBuf); area.w = MAX(area.w , pBuf->size.w); area.h += pBuf->size.h; } /* ---------- */ if (diplomat_can_do_action(pUnit, DIPLOMAT_INCITE, ptile)) { create_active_iconlabel(pBuf, pWindow->dst, pStr, _("Incite a Revolt"), diplomat_incite_callback); pBuf->data.city = pCity; set_wstate(pBuf , FC_WS_NORMAL); add_to_gui_list(MAX_ID - pUnit->id , pBuf); area.w = MAX(area.w , pBuf->size.w); area.h += pBuf->size.h; } /* ---------- */ if (diplomat_can_do_action(pUnit, DIPLOMAT_MOVE, ptile)) { create_active_iconlabel(pBuf, pWindow->dst, pStr, _("Keep moving"), diplomat_keep_moving_callback); pBuf->data.city = pCity; set_wstate(pBuf , FC_WS_NORMAL); add_to_gui_list(MAX_ID - pUnit->id , pBuf); area.w = MAX(area.w, pBuf->size.w); area.h += pBuf->size.h; } } else { if((pTunit=unit_list_get(ptile->units, 0))){ /* Spy/Diplomat acting against a unit */ pDiplomat_Dlg->diplomat_target_id = pTunit->id; /* ---------- */ if (diplomat_can_do_action(pUnit, DIPLOMAT_BRIBE, ptile)) { create_active_iconlabel(pBuf, pWindow->dst, pStr, _("Bribe Enemy Unit"), diplomat_bribe_callback); pBuf->data.unit = pTunit; set_wstate(pBuf , FC_WS_NORMAL); add_to_gui_list(MAX_ID - pUnit->id , pBuf); area.w = MAX(area.w , pBuf->size.w); area.h += pBuf->size.h; } /* ---------- */ if (diplomat_can_do_action(pUnit, SPY_SABOTAGE_UNIT, ptile)) { create_active_iconlabel(pBuf, pWindow->dst, pStr, _("Sabotage Enemy Unit"), spy_sabotage_unit_callback); pBuf->data.unit = pTunit; set_wstate(pBuf , FC_WS_NORMAL); add_to_gui_list(MAX_ID - pUnit->id , pBuf); area.w = MAX(area.w , pBuf->size.w); area.h += pBuf->size.h; } } } /* ---------- */ create_active_iconlabel(pBuf, pWindow->dst, pStr, _("Cancel"), diplomat_close_callback); set_wstate(pBuf , FC_WS_NORMAL); pBuf->key = SDLK_ESCAPE; add_to_gui_list(ID_LABEL , pBuf); area.w = MAX(area.w, pBuf->size.w); area.h += pBuf->size.h; /* ---------- */ pDiplomat_Dlg->pdialog->pBeginWidgetList = pBuf; /* setup window size and start position */ resize_window(pWindow, NULL, NULL, (pWindow->size.w - pWindow->area.w) + area.w, (pWindow->size.h - pWindow->area.h) + area.h); area = pWindow->area; auto_center_on_focus_unit(); put_window_near_map_tile(pWindow, pWindow->size.w, pWindow->size.h, pUnit->tile); /* setup widget size and start position */ pBuf = pWindow->prev; setup_vertical_widgets_position(1, area.x, area.y + 1, area.w, 0, pDiplomat_Dlg->pdialog->pBeginWidgetList, pBuf); /* --------------------- */ /* redraw */ redraw_group(pDiplomat_Dlg->pdialog->pBeginWidgetList, pWindow, 0); widget_flush(pWindow); }
/**************************************************************** Popup new diplomat dialog. *****************************************************************/ void popup_diplomat_dialog(struct unit *punit, struct tile *dest_tile) { struct city *pcity; struct unit *ptunit; GtkWidget *shl; struct astring title = ASTRING_INIT, text = ASTRING_INIT; diplomat_id = punit->id; if ((pcity = tile_city(dest_tile))) { /* Spy/Diplomat acting against a city */ diplomat_target_id = pcity->id; astr_set(&title, /* TRANS: %s is a unit name, e.g., Spy */ _("Choose Your %s's Strategy"), unit_name_translation(punit)); astr_set(&text, _("Your %s has arrived at %s.\nWhat is your command?"), unit_name_translation(punit), city_name(pcity)); if (!unit_has_type_flag(punit, UTYF_SPY)) { shl = popup_choice_dialog(GTK_WINDOW(toplevel), astr_str(&title), astr_str(&text), _("Establish _Embassy"), diplomat_embassy_callback, NULL, _("_Investigate City"), diplomat_investigate_callback, NULL, _("_Sabotage City"), diplomat_sabotage_callback, NULL, _("Steal _Technology"), diplomat_steal_callback, NULL, _("Incite a _Revolt"), diplomat_incite_callback, NULL, _("_Keep moving"), diplomat_keep_moving_callback, NULL, GTK_STOCK_CANCEL, diplomat_cancel_callback, NULL, NULL); if (!diplomat_can_do_action(punit, DIPLOMAT_EMBASSY, dest_tile)) choice_dialog_button_set_sensitive(shl, 0, FALSE); if (!diplomat_can_do_action(punit, DIPLOMAT_INVESTIGATE, dest_tile)) choice_dialog_button_set_sensitive(shl, 1, FALSE); if (!diplomat_can_do_action(punit, DIPLOMAT_SABOTAGE, dest_tile)) choice_dialog_button_set_sensitive(shl, 2, FALSE); if (!diplomat_can_do_action(punit, DIPLOMAT_STEAL, dest_tile)) choice_dialog_button_set_sensitive(shl, 3, FALSE); if (!diplomat_can_do_action(punit, DIPLOMAT_INCITE, dest_tile)) choice_dialog_button_set_sensitive(shl, 4, FALSE); if (!diplomat_can_do_action(punit, DIPLOMAT_MOVE, dest_tile)) choice_dialog_button_set_sensitive(shl, 5, FALSE); } else { shl = popup_choice_dialog(GTK_WINDOW(toplevel), astr_str(&title), astr_str(&text), _("Establish _Embassy"), diplomat_embassy_callback, NULL, _("_Investigate City"), diplomat_investigate_callback, NULL, _("_Poison City"), spy_poison_callback, NULL, _("Industrial _Sabotage"), spy_request_sabotage_list, NULL, _("Steal _Technology"), spy_steal_popup, NULL, _("Incite a _Revolt"), diplomat_incite_callback, NULL, _("_Keep moving"), diplomat_keep_moving_callback, NULL, GTK_STOCK_CANCEL, diplomat_cancel_callback, NULL, NULL); if (!diplomat_can_do_action(punit, DIPLOMAT_EMBASSY, dest_tile)) choice_dialog_button_set_sensitive(shl, 0, FALSE); if (!diplomat_can_do_action(punit, DIPLOMAT_INVESTIGATE, dest_tile)) choice_dialog_button_set_sensitive(shl, 1, FALSE); if (!diplomat_can_do_action(punit, SPY_POISON, dest_tile)) choice_dialog_button_set_sensitive(shl, 2, FALSE); if (!diplomat_can_do_action(punit, DIPLOMAT_SABOTAGE, dest_tile)) choice_dialog_button_set_sensitive(shl, 3, FALSE); if (!diplomat_can_do_action(punit, DIPLOMAT_STEAL, dest_tile)) choice_dialog_button_set_sensitive(shl, 4, FALSE); if (!diplomat_can_do_action(punit, DIPLOMAT_INCITE, dest_tile)) choice_dialog_button_set_sensitive(shl, 5, FALSE); if (!diplomat_can_do_action(punit, DIPLOMAT_MOVE, dest_tile)) choice_dialog_button_set_sensitive(shl, 6, FALSE); } diplomat_dialog = shl; choice_dialog_set_hide(shl, TRUE); g_signal_connect(shl, "destroy", G_CALLBACK(diplomat_destroy_callback), NULL); g_signal_connect(shl, "delete_event", G_CALLBACK(diplomat_cancel_callback), NULL); } else { if ((ptunit = unit_list_get(dest_tile->units, 0))){ /* Spy/Diplomat acting against a unit */ diplomat_target_id = ptunit->id; astr_set(&text, /* TRANS: %s is a unit name, e.g., Diplomat, Spy */ _("Your %s is waiting for your command."), unit_name_translation(punit)); shl = popup_choice_dialog(GTK_WINDOW(toplevel), _("Subvert Enemy Unit"), astr_str(&text), _("_Bribe Enemy Unit"), diplomat_bribe_callback, NULL, _("_Sabotage Enemy Unit"), spy_sabotage_unit_callback, NULL, GTK_STOCK_CANCEL, diplomat_cancel_callback, NULL, NULL); if (!diplomat_can_do_action(punit, DIPLOMAT_BRIBE, dest_tile)) { choice_dialog_button_set_sensitive(shl, 0, FALSE); } if (!diplomat_can_do_action(punit, SPY_SABOTAGE_UNIT, dest_tile)) { choice_dialog_button_set_sensitive(shl, 1, FALSE); } diplomat_dialog = shl; choice_dialog_set_hide(shl, TRUE); g_signal_connect(shl, "destroy", G_CALLBACK(diplomat_destroy_callback), NULL); g_signal_connect(shl, "delete_event", G_CALLBACK(diplomat_cancel_callback), NULL); } } astr_free(&title); astr_free(&text); }
/**************************************************************** Popup new diplomat dialog. *****************************************************************/ void popup_diplomat_dialog(struct unit *punit, struct tile *dest_tile) { struct city *pcity; struct unit *ptunit; GtkWidget *shl; struct astring title = ASTRING_INIT, text = ASTRING_INIT; diplomat_target_id[ATK_CITY] = -1; diplomat_target_id[ATK_UNIT] = -1; diplomat_id = punit->id; astr_set(&title, /* TRANS: %s is a unit name, e.g., Spy */ _("Choose Your %s's Strategy"), unit_name_translation(punit)); astr_set(&text, /* TRANS: %s is a unit name, e.g., Diplomat, Spy */ _("Your %s is waiting for your command."), unit_name_translation(punit)); shl = choice_dialog_start(GTK_WINDOW(toplevel), astr_str(&title), astr_str(&text)); if ((pcity = tile_city(dest_tile))) { /* Spy/Diplomat acting against a city */ diplomat_target_id[ATK_CITY] = pcity->id; action_entry(shl, action_enabled_unit_on_city_local( ACTION_ESTABLISH_EMBASSY, punit, pcity), _("Establish _Embassy"), (GCallback)diplomat_embassy_callback); action_entry(shl, action_enabled_unit_on_city_local( ACTION_SPY_INVESTIGATE_CITY, punit, pcity), _("_Investigate City"), (GCallback)diplomat_investigate_callback); action_entry(shl, action_enabled_unit_on_city_local(ACTION_SPY_POISON, punit, pcity), _("_Poison City"), (GCallback)spy_poison_callback); action_entry(shl, action_enabled_unit_on_city_local( ACTION_SPY_SABOTAGE_CITY, punit, pcity), _("_Sabotage City"), (GCallback)diplomat_sabotage_callback); action_entry(shl, action_enabled_unit_on_city_local( ACTION_SPY_TARGETED_SABOTAGE_CITY, punit, pcity), _("Industrial _Sabotage"), (GCallback)spy_request_sabotage_list); action_entry(shl, action_enabled_unit_on_city_local( ACTION_SPY_STEAL_TECH, punit, pcity), _("Steal _Technology"), (GCallback)diplomat_steal_callback); action_entry(shl, action_enabled_unit_on_city_local( ACTION_SPY_TARGETED_STEAL_TECH, punit, pcity), _("Industrial espionage"), (GCallback)spy_steal_popup); action_entry(shl, action_enabled_unit_on_city_local(ACTION_SPY_INCITE_CITY, punit, pcity), _("Incite a _Revolt"), (GCallback)diplomat_incite_callback); } if ((ptunit = unit_list_get(dest_tile->units, 0))) { /* Spy/Diplomat acting against a unit */ diplomat_target_id[ATK_UNIT] = ptunit->id; action_entry(shl, action_enabled_unit_on_unit_local( ACTION_SPY_BRIBE_UNIT, punit, ptunit), _("_Bribe Enemy Unit"), (GCallback)diplomat_bribe_callback); action_entry(shl, action_enabled_unit_on_unit_local( ACTION_SPY_SABOTAGE_UNIT, punit, ptunit), _("_Sabotage Enemy Unit"), (GCallback)spy_sabotage_unit_callback); } if (diplomat_can_do_action(punit, DIPLOMAT_MOVE, dest_tile)) { if (pcity) { choice_dialog_add(shl, _("_Keep moving"), (GCallback)diplomat_keep_moving_city_callback, NULL, FALSE); } else { choice_dialog_add(shl, _("_Keep moving"), (GCallback)diplomat_keep_moving_unit_callback, NULL, FALSE); } } choice_dialog_add(shl, GTK_STOCK_CANCEL, (GCallback)diplomat_cancel_callback, NULL, FALSE); choice_dialog_end(shl); diplomat_dialog = shl; choice_dialog_set_hide(shl, TRUE); g_signal_connect(shl, "destroy", G_CALLBACK(diplomat_destroy_callback), NULL); g_signal_connect(shl, "delete_event", G_CALLBACK(diplomat_cancel_callback), NULL); astr_free(&title); astr_free(&text); }