diff -ur freeciv/client/civclient.c dip_popup/client/civclient.c --- freeciv/client/civclient.c Thu Mar 23 18:12:55 2000 +++ dip_popup/client/civclient.c Thu Mar 23 19:41:25 2000 @@ -330,6 +330,10 @@ case PACKET_CITY_NAME_SUGGESTION: handle_city_name_suggestion((struct packet_city_name_suggestion *)packet); break; + + case PACKET_DIPLOMAT_ACTION: + handle_diplomat_action((struct packet_diplomat_action *)packet); + break; default: freelog(LOG_FATAL, _("Received unknown packet from server!")); diff -ur freeciv/client/packhand.c dip_popup/client/packhand.c --- freeciv/client/packhand.c Thu Mar 23 18:12:56 2000 +++ dip_popup/client/packhand.c Thu Mar 23 19:42:08 2000 @@ -1511,3 +1511,23 @@ } /* maybe unit died; ignore */ } + +/************************************************************************** +... +**************************************************************************/ +void handle_diplomat_action(struct packet_diplomat_action *packet) +{ + struct unit *pdiplomat=unit_list_find(&game.player_ptr->units, packet->diplomat_id); + struct city *pcity=find_city_by_id(packet->target_id); + + if (!pdiplomat || !pcity) { + printf("Error: could not find city or diplomat."); + return; + } + + switch(packet->action_type) { + case DIPLOMAT_ACTION_POPUP: + popup_diplomat_dialog(pdiplomat, pcity->x, pcity->y); + break; + } +} diff -ur freeciv/client/packhand.h dip_popup/client/packhand.h --- freeciv/client/packhand.h Thu Mar 23 18:12:56 2000 +++ dip_popup/client/packhand.h Thu Mar 23 19:40:41 2000 @@ -45,5 +45,6 @@ void handle_city_name_suggestion(struct packet_city_name_suggestion *packet); void handle_ruleset_nation(struct packet_ruleset_nation *packet); void handle_ruleset_city(struct packet_ruleset_city *packet); +void handle_diplomat_action(struct packet_diplomat_action *packet); #endif /* FC__PACKHAND_H */ diff -ur freeciv/common/packets.h dip_popup/common/packets.h --- freeciv/common/packets.h Thu Mar 23 18:12:58 2000 +++ dip_popup/common/packets.h Thu Mar 23 18:52:58 2000 @@ -129,7 +129,7 @@ }; /********************************************************* - diplomat action! + diplomacy action! *********************************************************/ struct packet_diplomacy_info { int plrno0, plrno1; diff -ur freeciv/common/unit.c dip_popup/common/unit.c --- freeciv/common/unit.c Thu Mar 23 18:12:58 2000 +++ dip_popup/common/unit.c Thu Mar 23 20:02:51 2000 @@ -503,9 +503,17 @@ /************************************************************************** ... **************************************************************************/ -int is_military_unit(struct unit *this_unit) +int is_military_unit(struct unit *punit) { - return (unit_flag(this_unit->type, F_NONMIL) == 0); + return (unit_flag(punit->type, F_NONMIL) == 0); +} + +/************************************************************************** +... +**************************************************************************/ +int is_diplomat_unit(struct unit *punit) +{ + return (unit_flag(punit->type, F_DIPLOMAT)); } /************************************************************************** @@ -1433,4 +1441,9 @@ } } return L_LAST; +} + +struct player *unit_owner(struct unit *punit) +{ + return (&game.players[punit->owner]); } diff -ur freeciv/common/unit.h dip_popup/common/unit.h --- freeciv/common/unit.h Thu Mar 23 18:12:58 2000 +++ dip_popup/common/unit.h Thu Mar 23 19:32:28 2000 @@ -70,7 +70,8 @@ DIPLOMAT_BRIBE, DIPLOMAT_EMBASSY, DIPLOMAT_SABOTAGE, DIPLOMAT_STEAL, DIPLOMAT_INCITE, SPY_POISON, DIPLOMAT_INVESTIGATE, SPY_SABOTAGE_UNIT, - DIPLOMAT_ANY_ACTION + DIPLOMAT_ANY_ACTION, + DIPLOMAT_ACTION_POPUP /* from server to client */ }; struct unit_ai { @@ -266,7 +267,8 @@ int is_unit_activity_on_tile(enum unit_activity activity, int x, int y); int get_unit_tile_pillage_set(int x, int y); int unit_value(Unit_Type_id id); -int is_military_unit(struct unit *this_unit); /* !set !dip !cara */ +int is_military_unit(struct unit *punit); /* !set !dip !cara */ +int is_diplomat_unit(struct unit *punit); int is_ground_threat(struct player *pplayer, struct unit *punit); int is_square_threatened(struct player *pplayer, int x, int y); int is_field_unit(struct unit *this_unit); /* ships+aero */ @@ -317,5 +319,6 @@ int num_role_units(int role); Unit_Type_id get_role_unit(int role, int index); Unit_Type_id best_role_unit(struct city *pcity, int role); +struct player *unit_owner(struct unit *punit); #endif /* FC__UNIT_H */ diff -ur freeciv/server/unithand.c dip_popup/server/unithand.c --- freeciv/server/unithand.c Thu Mar 23 18:13:03 2000 +++ dip_popup/server/unithand.c Thu Mar 23 19:57:19 2000 @@ -827,6 +827,15 @@ return handle_unit_establish_trade(pplayer, &req); } + if (is_diplomat_unit(punit) && (pcity = map_get_city(dest_x, dest_y))) { + struct packet_diplomat_action popup; + popup.target_id = pcity->id; + popup.diplomat_id = punit->id; + popup.action_type = DIPLOMAT_ACTION_POPUP; + send_packet_diplomat_action(unit_owner(punit)->conn, &popup); + return 0; + } + pdefender=get_defender(pplayer, punit, dest_x, dest_y); if(pdefender && pdefender->owner!=punit->owner) {