<URL: http://bugs.freeciv.org/Ticket/Display.html?id=39690 >
This experimental and mostly untested patch removes the embassy concept from the game. Why? The embassy concept has never fitted well into the general game concept. Creating embassies the traditional way (with diplomats) is a tiresome way to achieve the effect, while exchanging embassies in treaties always cried out for a "close embassy" feature. The treaty and embassy fields in the player dialog seemed strange with often duplicated information about contact and embassy status. Removing the concept simplifies the game logic, the game code, and the game UI significantly. Instead, contact now automatically establishes embassy-like relations between players. There is also no contact count down anymore. Discuss :) - Per PS Not sure if the change in the lua code is good. Also not sure what will happen in the civil war case.
Index: server/srv_main.c =================================================================== --- server/srv_main.c (revision 13532) +++ server/srv_main.c (working copy) @@ -466,7 +466,6 @@ struct player_diplstate *state2 = &plr2->diplstates[player_index(plr1)]; state->has_reason_to_cancel = MAX(state->has_reason_to_cancel - 1, 0); - state->contact_turns_left = MAX(state->contact_turns_left - 1, 0); if (state->type == DS_ARMISTICE) { state->turns_left--; @@ -2043,7 +2042,6 @@ && player_number(pplayer) != player_number(pdest)) { pplayer->diplstates[player_index(pdest)].type = DS_TEAM; give_shared_vision(pplayer, pdest); - BV_SET(pplayer->embassy, player_index(pdest)); } } players_iterate_end; } players_iterate_end; Index: server/scripting/api.pkg =================================================================== --- server/scripting/api.pkg (revision 13532) +++ server/scripting/api.pkg (working copy) @@ -403,14 +403,12 @@ E_MY_DIPLOMAT_BRIBE @ MY_DIPLOMAT_BRIBE, E_DIPLOMATIC_INCIDENT @ DIPLOMATIC_INCIDENT, E_MY_DIPLOMAT_ESCAPE @ MY_DIPLOMAT_ESCAPE, - E_MY_DIPLOMAT_EMBASSY @ MY_DIPLOMAT_EMBASSY, E_MY_DIPLOMAT_FAILED @ MY_DIPLOMAT_FAILED, E_MY_DIPLOMAT_INCITE @ MY_DIPLOMAT_INCITE, E_MY_DIPLOMAT_POISON @ MY_DIPLOMAT_POISON, E_MY_DIPLOMAT_SABOTAGE @ MY_DIPLOMAT_SABOTAGE, E_MY_DIPLOMAT_THEFT @ MY_DIPLOMAT_THEFT, E_ENEMY_DIPLOMAT_BRIBE @ ENEMY_DIPLOMAT_BRIBE, - E_ENEMY_DIPLOMAT_EMBASSY @ ENEMY_DIPLOMAT_EMBASSY, E_ENEMY_DIPLOMAT_FAILED @ ENEMY_DIPLOMAT_FAILED, E_ENEMY_DIPLOMAT_INCITE @ ENEMY_DIPLOMAT_INCITE, E_ENEMY_DIPLOMAT_POISON @ ENEMY_DIPLOMAT_POISON, @@ -465,7 +463,6 @@ E_WONDER_STOPPED @ WONDER_STOPPED, E_WONDER_WILL_BE_BUILT @ WONDER_WILL_BE_BUILT, E_DIPLOMACY @ DIPLOMACY, - E_TREATY_EMBASSY @ TREATY_EMBASSY, E_BAD_COMMAND @ BAD_COMMAND, E_SETTING @ SETTING, E_CHAT_MSG @ CHAT_MSG, Index: server/edithand.c =================================================================== --- server/edithand.c (revision 13532) +++ server/edithand.c (working copy) @@ -373,8 +373,6 @@ for (i = 0; i < MAX_NUM_PLAYERS + MAX_NUM_BARBARIANS; i++) { pplayer->diplstates[i].type = packet->diplstates[i].type; pplayer->diplstates[i].turns_left = packet->diplstates[i].turns_left; - pplayer->diplstates[i].contact_turns_left - = packet->diplstates[i].contact_turns_left; pplayer->diplstates[i].has_reason_to_cancel = packet->diplstates[i].has_reason_to_cancel; } Index: server/diplhand.c =================================================================== --- server/diplhand.c (revision 13532) +++ server/diplhand.c (working copy) @@ -145,13 +145,6 @@ if (pclause->from == pplayer) { switch(pclause->type) { - case CLAUSE_EMBASSY: - if (player_has_embassy(pother, pplayer)) { - freelog(LOG_ERROR, "%s tried to give embassy to %s, who already " - "has an embassy", pplayer->name, pother->name); - return; - } - break; case CLAUSE_ADVANCE: if (!player_invention_is_ready(pother, pclause->value)) { /* It is impossible to give a technology to a civilization that @@ -356,15 +349,6 @@ pgiver->diplstates[player_index(pdest)].type; switch (pclause->type) { - case CLAUSE_EMBASSY: - establish_embassy(pdest, pgiver); /* sic */ - notify_player(pgiver, NULL, E_TREATY_SHARED_VISION, - _("You gave an embassy to %s."), - pdest->name); - notify_player(pdest, NULL, E_TREATY_SHARED_VISION, - _("%s allowed you to create an embassy!"), - pgiver->name); - break; case CLAUSE_ADVANCE: /* It is possible that two players open the diplomacy dialog * and try to give us the same tech at the same time. This @@ -544,18 +528,6 @@ } } -/**************************************************************************** - Create an embassy. pplayer gets an embassy with aplayer. -****************************************************************************/ -void establish_embassy(struct player *pplayer, struct player *aplayer) -{ - /* Establish the embassy. */ - BV_SET(pplayer->embassy, player_index(aplayer)); - send_player_info(pplayer, pplayer); - send_player_info(pplayer, aplayer); /* update player dialog with embassy */ - send_player_info(aplayer, pplayer); /* INFO_EMBASSY level info */ -} - /************************************************************************** ... **************************************************************************/ Index: server/diplhand.h =================================================================== --- server/diplhand.h (revision 13532) +++ server/diplhand.h (working copy) @@ -21,8 +21,6 @@ struct packet_diplomacy_info; struct connection; -void establish_embassy(struct player *pplayer, struct player *aplayer); - void diplhand_init(void); void diplhand_free(void); void free_treaties(void); Index: server/diplomats.c =================================================================== --- server/diplomats.c (revision 13532) +++ server/diplomats.c (working copy) @@ -232,73 +232,6 @@ } /****************************************************************************** - Establish an embassy. - - - Either a Diplomat or Spy can establish an embassy. - - - Barbarians always execute ambassadors. - - Otherwise, the embassy is created. - - It costs some minimal movement to establish an embassy. - - - Diplomats are consumed in creation of embassy. - - Spies always survive. -****************************************************************************/ -void diplomat_embassy(struct player *pplayer, struct unit *pdiplomat, - struct city *pcity) -{ - struct player *cplayer; - - /* Fetch target city's player. Sanity checks. */ - if (!pcity) - return; - cplayer = city_owner (pcity); - if ((cplayer == pplayer) || !cplayer) - return; - - freelog (LOG_DEBUG, "embassy: unit: %d", pdiplomat->id); - - /* Check for Barbarian response. */ - if (get_player_bonus(cplayer, EFT_NO_DIPLOMACY)) { - notify_player(pplayer, pcity->tile, E_MY_DIPLOMAT_FAILED, - _("Your %s was executed in %s by primitive %s."), - unit_name_translation(pdiplomat), - pcity->name, - nation_plural_for_player(cplayer)); - wipe_unit(pdiplomat); - return; - } - - freelog (LOG_DEBUG, "embassy: succeeded"); - - establish_embassy(pplayer, cplayer); - - /* Notify everybody involved. */ - notify_player(pplayer, pcity->tile, E_MY_DIPLOMAT_EMBASSY, - _("You have established an embassy in %s."), - pcity->name); - notify_player(cplayer, pcity->tile, E_ENEMY_DIPLOMAT_EMBASSY, - _("The %s have established an embassy in %s."), - nation_plural_for_player(pplayer), - pcity->name); - - /* Charge a nominal amount of movement for this. */ - (pdiplomat->moves_left)--; - if (pdiplomat->moves_left < 0) { - pdiplomat->moves_left = 0; - } - - /* this may cause a diplomatic incident */ - maybe_cause_incident(DIPLOMAT_EMBASSY, pplayer, NULL, pcity); - - /* Spies always survive. Diplomats never do. */ - if (!unit_has_type_flag(pdiplomat, F_SPY)) { - wipe_unit(pdiplomat); - } else { - send_unit_info (pplayer, pdiplomat); - } -} - -/****************************************************************************** Sabotage an enemy unit. - Only a Spy can sabotage an enemy unit. @@ -1304,7 +1237,6 @@ "revolt in %s."), offender->name, victim_city->name); break; case DIPLOMAT_MOVE: - case DIPLOMAT_EMBASSY: case DIPLOMAT_INVESTIGATE: case SPY_GET_SABOTAGE_LIST: return; /* These are not considered offences */ Index: server/diplomats.h =================================================================== --- server/diplomats.h (revision 13532) +++ server/diplomats.h (working copy) @@ -17,8 +17,6 @@ #include "gotohand.h" /* enum goto_move_restriction */ -void diplomat_embassy(struct player *pplayer, struct unit *pdiplomat, - struct city *pcity); void diplomat_investigate(struct player *pplayer, struct unit *pdiplomat, struct city *pcity); void spy_get_sabotage_list(struct player *pplayer, struct unit *pdiplomat, Index: server/unithand.c =================================================================== --- server/unithand.c (revision 13532) +++ server/unithand.c (working copy) @@ -232,12 +232,6 @@ diplomat_investigate(pplayer, pdiplomat, pcity); } break; - case DIPLOMAT_EMBASSY: - if(pcity && diplomat_can_do_action(pdiplomat, DIPLOMAT_EMBASSY, - pcity->tile)) { - diplomat_embassy(pplayer, pdiplomat, pcity); - } - break; case DIPLOMAT_INCITE: if(pcity && diplomat_can_do_action(pdiplomat, DIPLOMAT_INCITE, pcity->tile)) { Index: server/savegame.c =================================================================== --- server/savegame.c (revision 13532) +++ server/savegame.c (working copy) @@ -1861,27 +1861,6 @@ plr->target_government = government_of_player(plr); } - BV_CLR_ALL(plr->embassy); - if (has_capability("embassies", savefile_options)) { - players_iterate(pother) { - if (secfile_lookup_bool(file, "player%d.embassy%d", - plrno, player_number(pother))) { - BV_SET(plr->embassy, player_index(pother)); - } - } players_iterate_end; - } else { - /* Required for 2.0 and earlier savegames. Remove eventually and make - * the cap check mandatory. */ - int embassy = secfile_lookup_int(file, "player%d.embassy", plrno); - - players_iterate(pother) { - if (embassy & (1 << player_index(pother))) { - BV_SET(plr->embassy, player_index(pother)); - } - } players_iterate_end; - - } - p = secfile_lookup_str_default(file, NULL, "player%d.city_style_by_name", plrno); if (!p) { @@ -2080,9 +2059,6 @@ secfile_lookup_int_default(file, 0, "player%d.diplstate%d.has_reason_to_cancel", plrno, i); - plr->diplstates[i].contact_turns_left = - secfile_lookup_int_default(file, 0, - "player%d.diplstate%d.contact_turns_left", plrno, i); } /* We don't need this info, but savegames carry it anyway. To avoid getting "unused" warnings we touch the values like this. */ @@ -2094,8 +2070,6 @@ secfile_lookup_int_default(file, 0, "player%d.diplstate%d.has_reason_to_cancel", plrno, i); - secfile_lookup_int_default(file, 0, - "player%d.diplstate%d.contact_turns_left", plrno, i); } { /* spacerace */ @@ -2749,11 +2723,6 @@ "player%d.target_government_name", plrno); } - players_iterate(pother) { - secfile_insert_bool(file, BV_ISSET(plr->embassy, player_index(pother)), - "player%d.embassy%d", plrno, player_number(pother)); - } players_iterate_end; - /* Required for 2.0 and earlier servers. Remove eventually. */ secfile_insert_int(file, 0, "player%d.embassy", plrno); @@ -2861,8 +2830,6 @@ "player%d.diplstate%d.turns_left", plrno, i); secfile_insert_int(file, plr->diplstates[i].has_reason_to_cancel, "player%d.diplstate%d.has_reason_to_cancel", plrno, i); - secfile_insert_int(file, plr->diplstates[i].contact_turns_left, - "player%d.diplstate%d.contact_turns_left", plrno, i); } { Index: server/plrhand.c =================================================================== --- server/plrhand.c (revision 13532) +++ server/plrhand.c (working copy) @@ -728,7 +728,8 @@ /************************************************************************** Send message to all players who have an embassy with pplayer, - but excluding pplayer and specified player. + but excluding pplayer and specified player. Embassy is defined + as being in contact. **************************************************************************/ void notify_embassies(struct player *pplayer, struct player *exclude, struct tile *ptile, enum event_type event, @@ -892,9 +893,8 @@ /************************************************************************** Package player info depending on info_level. We send everything to - plr's connections, we send almost everything to players with embassy - to plr, we send a little to players we are in contact with and almost - nothing to everyone else. + plr's connections, we send almost everything to players we are in contact + with and almost nothing to everyone else. Receiver may be NULL in which cases dummy values are sent for some fields. @@ -928,7 +928,7 @@ } players_iterate_end; /* Only send score if we have contact */ - if (info_level >= INFO_MEETING) { + if (info_level >= INFO_EMBASSY) { packet->score = plr->score.game; } else { packet->score = 0; @@ -936,31 +936,18 @@ /* Send diplomatic status of the player to everyone they are in * contact with. */ - if (info_level >= INFO_EMBASSY - || (receiver - && receiver->diplstates[player_index(plr)].contact_turns_left > 0)) { + if (info_level >= INFO_EMBASSY) { packet->target_government = plr->target_government ? government_number(plr->target_government) : -1; - memset(&packet->embassy, 0, sizeof(packet->embassy)); - players_iterate(pother) { - packet->embassy[player_index(pother)] - = BV_ISSET(plr->embassy, player_index(pother)); - } players_iterate_end; packet->gives_shared_vision = plr->gives_shared_vision; for(i = 0; i < MAX_NUM_PLAYERS + MAX_NUM_BARBARIANS; i++) { packet->diplstates[i].type = plr->diplstates[i].type; packet->diplstates[i].turns_left = plr->diplstates[i].turns_left; - packet->diplstates[i].contact_turns_left = - plr->diplstates[i].contact_turns_left; packet->diplstates[i].has_reason_to_cancel = plr->diplstates[i].has_reason_to_cancel; } } else { packet->target_government = packet->government; - memset(&packet->embassy, 0, sizeof(packet->embassy)); - if (receiver && player_has_embassy(plr, receiver)) { - packet->embassy[player_index(receiver)] = TRUE; - } if (!receiver || !gives_shared_vision(plr, receiver)) { packet->gives_shared_vision = 0; } else { @@ -971,7 +958,6 @@ packet->diplstates[i].type = DS_WAR; packet->diplstates[i].turns_left = 0; packet->diplstates[i].has_reason_to_cancel = 0; - packet->diplstates[i].contact_turns_left = 0; } /* We always know the player's relation to us */ if (receiver) { @@ -979,8 +965,6 @@ packet->diplstates[p_no].type = plr->diplstates[p_no].type; packet->diplstates[p_no].turns_left = plr->diplstates[p_no].turns_left; - packet->diplstates[p_no].contact_turns_left = - plr->diplstates[p_no].contact_turns_left; packet->diplstates[p_no].has_reason_to_cancel = plr->diplstates[p_no].has_reason_to_cancel; } @@ -1071,9 +1055,6 @@ if (receiver && player_has_embassy(receiver, plr)) { return INFO_EMBASSY; } - if (receiver && could_intel_with_player(receiver, plr)) { - return INFO_MEETING; - } return INFO_MINIMUM; } @@ -1158,8 +1139,6 @@ } if (get_player_bonus(pplayer1, EFT_NO_DIPLOMACY) == 0 && get_player_bonus(pplayer2, EFT_NO_DIPLOMACY) == 0) { - pplayer1->diplstates[player2].contact_turns_left = game.info.contactturns; - pplayer2->diplstates[player1].contact_turns_left = game.info.contactturns; } if (pplayer_get_diplstate(pplayer1, pplayer2)->type == DS_NO_CONTACT) { pplayer1->diplstates[player2].type = DS_WAR; @@ -1500,10 +1479,8 @@ cplayer->diplstates[player_index(other_player)].has_reason_to_cancel = 0; cplayer->diplstates[player_index(other_player)].turns_left = 0; - cplayer->diplstates[player_index(other_player)].contact_turns_left = 0; other_player->diplstates[player_index(cplayer)].has_reason_to_cancel = 0; other_player->diplstates[player_index(cplayer)].turns_left = 0; - other_player->diplstates[player_index(cplayer)].contact_turns_left = 0; /* Send so that other_player sees updated diplomatic info; * pplayer will be sent later anyway @@ -1536,7 +1513,6 @@ } advance_index_iterate_end; cplayer->phase_done = TRUE; /* Have other things to think about - paralysis */ - BV_CLR_ALL(cplayer->embassy); /* all embassies destroyed */ /* Do the ai */ @@ -1558,18 +1534,7 @@ pplayer->revolution_finishes = game.info.turn + 1; } get_player_research(pplayer)->bulbs_researched = 0; - BV_CLR_ALL(pplayer->embassy); /* all embassies destroyed */ - /* give splitted player the embassies to his team mates back, if any */ - if (pplayer->team) { - players_iterate(pdest) { - if (pplayer->team == pdest->team - && pplayer != pdest) { - establish_embassy(pplayer, pdest); - } - } players_iterate_end; - } - player_limit_to_government_rates(pplayer); /* copy the maps */ Index: server/plrhand.h =================================================================== --- server/plrhand.h (revision 13532) +++ server/plrhand.h (working copy) @@ -27,7 +27,7 @@ struct connection; struct conn_list; -enum plr_info_level { INFO_MINIMUM, INFO_MEETING, INFO_EMBASSY, INFO_FULL }; +enum plr_info_level { INFO_MINIMUM, INFO_EMBASSY, INFO_FULL }; void server_player_init(struct player *pplayer, bool initmap, bool needs_team); Index: common/unit.c =================================================================== --- common/unit.c (revision 13532) +++ common/unit.c (working copy) @@ -34,17 +34,7 @@ #include "unit.h" #include "unitlist.h" - /************************************************************************** -bribe unit -investigate -poison -make revolt -establish embassy -sabotage city -**************************************************************************/ - -/************************************************************************** Whether a diplomat can move to a particular tile and perform a particular action there. **************************************************************************/ @@ -91,11 +81,6 @@ return pplayers_at_war(unit_owner(pdiplomat), city_owner(pcity)); if(action==DIPLOMAT_MOVE) return pplayers_allied(unit_owner(pdiplomat), city_owner(pcity)); - if (action == DIPLOMAT_EMBASSY - && !get_player_bonus(city_owner(pcity), EFT_NO_DIPLOMACY) - && !player_has_embassy(unit_owner(pdiplomat), city_owner(pcity))) { - return TRUE; - } if(action==SPY_POISON && pcity->size>1 && unit_has_type_flag(pdiplomat, F_SPY)) Index: common/unit.h =================================================================== --- common/unit.h (revision 13532) +++ common/unit.h (working copy) @@ -36,7 +36,7 @@ }; enum diplomat_actions { - DIPLOMAT_BRIBE, DIPLOMAT_EMBASSY, DIPLOMAT_SABOTAGE, + DIPLOMAT_BRIBE, DIPLOMAT_SABOTAGE, DIPLOMAT_STEAL, DIPLOMAT_INCITE, SPY_POISON, DIPLOMAT_INVESTIGATE, SPY_SABOTAGE_UNIT, SPY_GET_SABOTAGE_LIST, Index: common/dataio.c =================================================================== --- common/dataio.c (revision 13532) +++ common/dataio.c (working copy) @@ -714,7 +714,6 @@ dio_get_uint8(din, &value); pds->type = value; dio_get_uint16(din, &pds->turns_left); - dio_get_uint16(din, &pds->contact_turns_left); dio_get_uint8(din, &pds->has_reason_to_cancel); dio_get_uint16(din, &pds->first_contact_turn); value = 0; @@ -731,7 +730,6 @@ /* backward compatible order defined for this transaction */ dio_put_uint8(dout, pds->type); dio_put_uint16(dout, pds->turns_left); - dio_put_uint16(dout, pds->contact_turns_left); dio_put_uint8(dout, pds->has_reason_to_cancel); dio_put_uint16(dout, pds->first_contact_turn); dio_put_uint8(dout, pds->max_state); Index: common/events.c =================================================================== --- common/events.c (revision 13532) +++ common/events.c (working copy) @@ -72,14 +72,14 @@ GEN_EV(N_("Diplomat Action"), N_("Bribe"), E_MY_DIPLOMAT_BRIBE), GEN_EV(N_("Diplomat Action"), N_("Caused Incident"), E_DIPLOMATIC_INCIDENT), GEN_EV(N_("Diplomat Action"), N_("Escape"), E_MY_DIPLOMAT_ESCAPE), - GEN_EV(N_("Diplomat Action"), N_("Embassy"), E_MY_DIPLOMAT_EMBASSY), + GEN_EV(N_("Diplomat Action"), N_("Embassy"), E_UNUSED1), GEN_EV(N_("Diplomat Action"), N_("Failed"), E_MY_DIPLOMAT_FAILED), GEN_EV(N_("Diplomat Action"), N_("Incite"), E_MY_DIPLOMAT_INCITE), GEN_EV(N_("Diplomat Action"), N_("Poison"), E_MY_DIPLOMAT_POISON), GEN_EV(N_("Diplomat Action"), N_("Sabotage"), E_MY_DIPLOMAT_SABOTAGE), GEN_EV(N_("Diplomat Action"), N_("Theft"), E_MY_DIPLOMAT_THEFT), GEN_EV(N_("Enemy Diplomat"), N_("Bribe"), E_ENEMY_DIPLOMAT_BRIBE), - GEN_EV(N_("Enemy Diplomat"), N_("Embassy"), E_ENEMY_DIPLOMAT_EMBASSY), + GEN_EV(N_("Enemy Diplomat"), N_("Embassy"), E_UNUSED2), GEN_EV(N_("Enemy Diplomat"), N_("Failed"), E_ENEMY_DIPLOMAT_FAILED), GEN_EV(N_("Enemy Diplomat"), N_("Incite"), E_ENEMY_DIPLOMAT_INCITE), GEN_EV(N_("Enemy Diplomat"), N_("Poison"), E_ENEMY_DIPLOMAT_POISON), @@ -135,7 +135,7 @@ GEN_EV(N_("Wonder"), N_("Stopped"), E_WONDER_STOPPED), GEN_EV(N_("Wonder"), N_("Will Finish Next Turn"), E_WONDER_WILL_BE_BUILT), GEN_EV(NULL, N_("Diplomatic Message"), E_DIPLOMACY), - GEN_EV(N_("Treaty"), N_("Embassy"), E_TREATY_EMBASSY), + GEN_EV(N_("Treaty"), N_("Embassy"), E_UNUSED3), GEN_EV(NULL, N_("Error message from bad command"), E_BAD_COMMAND), GEN_EV(NULL, N_("Server settings changed"), E_SETTING), GEN_EV(NULL, N_("Chat messages"), E_CHAT_MSG), @@ -215,14 +215,12 @@ case E_UNIT_LOST: case E_UNIT_WIN: case E_ENEMY_DIPLOMAT_FAILED: - case E_ENEMY_DIPLOMAT_EMBASSY: case E_ENEMY_DIPLOMAT_POISON: case E_ENEMY_DIPLOMAT_BRIBE: case E_ENEMY_DIPLOMAT_INCITE: case E_ENEMY_DIPLOMAT_SABOTAGE: case E_ENEMY_DIPLOMAT_THEFT: case E_MY_DIPLOMAT_FAILED: - case E_MY_DIPLOMAT_EMBASSY: case E_MY_DIPLOMAT_POISON: case E_MY_DIPLOMAT_BRIBE: case E_MY_DIPLOMAT_INCITE: Index: common/diptreaty.c =================================================================== --- common/diptreaty.c (revision 13532) +++ common/diptreaty.c (working copy) @@ -51,13 +51,11 @@ && pplayer != aplayer && diplomacy_possible(pplayer,aplayer) && (player_has_embassy(aplayer, pplayer) - || player_has_embassy(pplayer, aplayer) - || pplayer->diplstates[player_index(aplayer)].contact_turns_left > 0 - || aplayer->diplstates[player_index(pplayer)].contact_turns_left > 0)); + || player_has_embassy(pplayer, aplayer))); } /************************************************************************** - Returns TRUE iff pplayer could do diplomatic meetings with aplayer. + Returns TRUE iff pplayer could get intelligence from aplayer. **************************************************************************/ bool could_intel_with_player(const struct player *pplayer, const struct player *aplayer) @@ -65,9 +63,7 @@ return (pplayer->is_alive && aplayer->is_alive && pplayer != aplayer - && (pplayer->diplstates[player_index(aplayer)].contact_turns_left > 0 - || aplayer->diplstates[player_index(pplayer)].contact_turns_left > 0 - || player_has_embassy(pplayer, aplayer))); + && player_has_embassy(pplayer, aplayer)); } /**************************************************************** Index: common/events.h =================================================================== --- common/events.h (revision 13532) +++ common/events.h (working copy) @@ -53,14 +53,14 @@ E_MY_DIPLOMAT_BRIBE, E_DIPLOMATIC_INCIDENT, E_MY_DIPLOMAT_ESCAPE, - E_MY_DIPLOMAT_EMBASSY, + E_UNUSED1, E_MY_DIPLOMAT_FAILED, E_MY_DIPLOMAT_INCITE, E_MY_DIPLOMAT_POISON, E_MY_DIPLOMAT_SABOTAGE, E_MY_DIPLOMAT_THEFT, E_ENEMY_DIPLOMAT_BRIBE, - E_ENEMY_DIPLOMAT_EMBASSY, + E_UNUSED2, E_ENEMY_DIPLOMAT_FAILED, E_ENEMY_DIPLOMAT_INCITE, E_ENEMY_DIPLOMAT_POISON, @@ -114,7 +114,7 @@ E_WONDER_STOPPED, E_WONDER_WILL_BE_BUILT, E_DIPLOMACY, - E_TREATY_EMBASSY, + E_UNUSED3, E_BAD_COMMAND, /* Illegal command sent from client. */ E_SETTING, /* Messages for changed server settings */ E_CHAT_MSG, /* Chatline messages */ Index: common/diptreaty.h =================================================================== --- common/diptreaty.h (revision 13532) +++ common/diptreaty.h (working copy) @@ -18,7 +18,7 @@ enum clause_type { CLAUSE_ADVANCE, CLAUSE_GOLD, CLAUSE_MAP, CLAUSE_SEAMAP, CLAUSE_CITY, CLAUSE_CEASEFIRE, CLAUSE_PEACE, CLAUSE_ALLIANCE, - CLAUSE_VISION, CLAUSE_EMBASSY, CLAUSE_LAST }; + CLAUSE_VISION, CLAUSE_LAST }; #define is_pact_clause(x) \ ((x == CLAUSE_CEASEFIRE) || (x == CLAUSE_PEACE) || (x == CLAUSE_ALLIANCE)) Index: common/player.c =================================================================== --- common/player.c (revision 13532) +++ common/player.c (working copy) @@ -146,16 +146,28 @@ } /*************************************************************** - Check if pplayer has an embassy with pplayer2. We always have - an embassy with ourselves. + Check if pplayer has diplomatic relations with pplayer2. + We always have that with ourselves. ***************************************************************/ bool player_has_embassy(const struct player *pplayer, const struct player *pplayer2) { - return (BV_ISSET(pplayer->embassy, player_index(pplayer2)) - || (pplayer == pplayer2) - || (get_player_bonus(pplayer, EFT_HAVE_EMBASSIES) > 0 - && !is_barbarian(pplayer2))); + enum diplstate_type treaty = pplayer_get_diplstate(pplayer, pplayer2)->type; + + if (pplayer == pplayer2) { + return TRUE; + } + + if (is_barbarian(pplayer2)) { + return FALSE; + } + + // Gives contact with everyone, except barbarians + if (get_player_bonus(pplayer, EFT_HAVE_EMBASSIES) > 0) { + return TRUE; + } + + return treaty != DS_NO_CONTACT; } /**************************************************************************** @@ -198,11 +210,9 @@ plr->is_alive=TRUE; plr->is_dying = FALSE; plr->surrendered = FALSE; - BV_CLR_ALL(plr->embassy); for(i = 0; i < MAX_NUM_PLAYERS + MAX_NUM_BARBARIANS; i++) { plr->diplstates[i].type = DS_NO_CONTACT; plr->diplstates[i].has_reason_to_cancel = 0; - plr->diplstates[i].contact_turns_left = 0; } plr->city_style=0; /* should be first basic style */ plr->ai.control=FALSE; @@ -881,9 +891,8 @@ bool are_diplstates_equal(const struct player_diplstate *pds1, const struct player_diplstate *pds2) { - return (pds1->type == pds2->type && pds1->turns_left == pds2->turns_left - && pds1->has_reason_to_cancel == pds2->has_reason_to_cancel - && pds1->contact_turns_left == pds2->contact_turns_left); + return (pds1->type == pds2->type + && pds1->has_reason_to_cancel == pds2->has_reason_to_cancel); } /*************************************************************************** Index: common/player.h =================================================================== --- common/player.h (revision 13532) +++ common/player.h (working copy) @@ -132,7 +132,6 @@ int first_contact_turn; /* turn we had first contact with this player */ int turns_left; /* until pact (e.g., cease-fire) ends */ int has_reason_to_cancel; /* 0: no, 1: this turn, 2: this or next turn */ - int contact_turns_left; /* until contact ends */ }; /*************************************************************************** @@ -174,7 +173,6 @@ int revolution_finishes; bool capital; /* used to give player init_buildings in first city. */ - bv_player embassy; struct player_diplstate diplstates[MAX_NUM_PLAYERS + MAX_NUM_BARBARIANS]; int city_style; struct unit_list *units; Index: ai/advdiplomacy.c =================================================================== --- ai/advdiplomacy.c (revision 13532) +++ ai/advdiplomacy.c (working copy) @@ -459,24 +459,6 @@ } break; - case CLAUSE_EMBASSY: - if (give) { - if (ds_after == DS_ALLIANCE) { - worth = 0; - } else if (ds_after == DS_PEACE) { - worth = -5 * game.info.turn; - } else { - worth = MIN(-50 * game.info.turn - + pplayer->ai.love[player_index(aplayer)], - -5 * game.info.turn); - } - } else { - worth = 0; /* We don't need no stinkin' embassy, do we? */ - } - DIPLO_LOG(LOG_DIPL, pplayer, aplayer, "embassy clause worth %d", - worth); - break; - case CLAUSE_LAST: break; } /* end of switch */ @@ -1052,13 +1034,6 @@ ai_diplomacy_suggest(aplayer, pplayer, CLAUSE_VISION, 0); } - if (!player_has_embassy(pplayer, aplayer)) { - ai_diplomacy_suggest(aplayer, pplayer, CLAUSE_EMBASSY, 0); - } - if (!player_has_embassy(aplayer, pplayer)) { - ai_diplomacy_suggest(pplayer, aplayer, CLAUSE_EMBASSY, 0); - } - if (!ai_handicap(pplayer, H_DIPLOMACY) || !aplayer->ai.control) { suggest_tech_exchange(pplayer, aplayer); } Index: ai/aidiplomat.c =================================================================== --- ai/aidiplomat.c (revision 13532) +++ ai/aidiplomat.c (working copy) @@ -226,13 +226,6 @@ want = military_amortize(pplayer, pcity, want, time_to_dest, utype_build_shield_cost(ut)); - if (!player_has_embassy(pplayer, city_owner(acity)) - && want < 99) { - freelog(LOG_DIPLOMAT_BUILD, - "A diplomat desired in %s to establish an embassy with %s " - "in %s", pcity->name, city_owner(acity)->name, acity->name); - want = 99; - } if (want > choice->want) { freelog(LOG_DIPLOMAT_BUILD, "%s, %s: %s is desired with want %d to spy in %s (incite " @@ -259,9 +252,7 @@ business! Note that punit may die or be moved during this function. We must be adjacent to target city. - We try to make embassy first, and abort if we already have one and target - is allied. Then we steal, incite, sabotage or poison the city, in that - order of priority. + We steal, incite, sabotage or poison the city, in that order of priority. **************************************************************************/ static void ai_diplomat_city(struct unit *punit, struct city *ctarget) { @@ -289,8 +280,6 @@ return; \ } - T(DIPLOMAT_EMBASSY,0); - if (pplayers_allied(pplayer, tplayer)) { return; /* Don't do the rest to allies */ } @@ -331,7 +320,6 @@ struct city **ctarget, int *move_dist, struct pf_map *map) { - bool has_embassy; int incite_cost = 0; /* incite cost */ bool dipldef; /* whether target is protected by diplomats */ @@ -351,10 +339,9 @@ } aplayer = city_owner(acity); - has_embassy = player_has_embassy(pplayer, aplayer); - - if (aplayer == pplayer || is_barbarian(aplayer) - || (pplayers_allied(pplayer, aplayer) && has_embassy)) { + if (aplayer == pplayer + || is_barbarian(aplayer) + || pplayers_allied(pplayer, aplayer)) { continue; } @@ -362,15 +349,13 @@ can_incite = (incite_cost < INCITE_IMPOSSIBLE_COST); dipldef = (count_diplomats_on_tile(acity->tile) > 0); - /* Three actions to consider: - * 1. establishing embassy OR - * 2. stealing techs OR - * 3. inciting revolt */ - if (!has_embassy - || (acity->steal == 0 - && (get_player_research(pplayer)->techs_researched - < get_player_research(aplayer)->techs_researched) - && !dipldef) + /* Two actions to consider: + * 1. stealing techs OR + * 2. inciting revolt */ + if ((acity->steal == 0 + && get_player_research(pplayer)->techs_researched + < get_player_research(aplayer)->techs_researched + && !dipldef) || (incite_cost < (pplayer->economic.gold - pplayer->ai.est_upkeep) && can_incite && !dipldef)) { /* We have the closest enemy city on the continent */ @@ -600,8 +585,7 @@ if (same_pos(ctarget->tile, punit->tile)) { failure = TRUE; } else if (pplayers_allied(pplayer, city_owner(ctarget)) - && punit->ai.ai_role == AIUNIT_ATTACK - && player_has_embassy(pplayer, city_owner(ctarget))) { + && punit->ai.ai_role == AIUNIT_ATTACK) { /* We probably incited this city with another diplomat */ failure = TRUE; } else if (!pplayers_allied(pplayer, city_owner(ctarget)) Index: client/gui-gtk-2.0/diplomat_dialog.c =================================================================== --- client/gui-gtk-2.0/diplomat_dialog.c (revision 13532) +++ client/gui-gtk-2.0/diplomat_dialog.c (working copy) @@ -145,19 +145,6 @@ /**************************************************************** ... *****************************************************************/ -static void diplomat_embassy_callback(GtkWidget *w, gpointer data) -{ - if(game_find_unit_by_number(diplomat_id) && - (game_find_city_by_number(diplomat_target_id))) { - request_diplomat_action(DIPLOMAT_EMBASSY, diplomat_id, - diplomat_target_id, 0); - } - gtk_widget_destroy(diplomat_dialog); -} - -/**************************************************************** -... -*****************************************************************/ static void spy_poison_callback(GtkWidget *w, gpointer data) { if(game_find_unit_by_number(diplomat_id) && @@ -623,7 +610,6 @@ if (!unit_has_type_flag(punit, F_SPY)){ shl = popup_choice_dialog(GTK_WINDOW(toplevel), _(" Choose Your Diplomat's Strategy"), buf, - _("Establish _Embassy"), diplomat_embassy_callback, NULL, _("_Investigate City"), diplomat_investigate_callback, NULL, _("_Sabotage City"), diplomat_sabotage_callback, NULL, _("Steal _Technology"), diplomat_steal_callback, NULL, @@ -632,8 +618,6 @@ 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)) @@ -647,7 +631,6 @@ } else { shl = popup_choice_dialog(GTK_WINDOW(toplevel), _("Choose Your Spy's Strategy"), buf, - _("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, @@ -657,8 +640,6 @@ 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)) Index: client/gui-gtk-2.0/diplodlg.c =================================================================== --- client/gui-gtk-2.0/diplodlg.c (revision 13532) +++ client/gui-gtk-2.0/diplodlg.c (working copy) @@ -82,7 +82,6 @@ static void diplomacy_dialog_peace_callback(GtkWidget *w, gpointer data); static void diplomacy_dialog_alliance_callback(GtkWidget *w, gpointer data); static void diplomacy_dialog_vision_callback(GtkWidget *w, gpointer data); -static void diplomacy_dialog_embassy_callback(GtkWidget *w, gpointer data); static void close_diplomacy_dialog(struct Diplomacy_dialog *pdialog); static void update_diplomacy_dialog(struct Diplomacy_dialog *pdialog); static void diplo_dialog_returnkey(GtkWidget *w, gpointer data); @@ -340,20 +339,6 @@ gtk_menu_shell_append(GTK_MENU_SHELL(parent), item); gtk_widget_show(item); - - /* Give embassy. */ - item = gtk_menu_item_new_with_mnemonic(_("Give _embassy")); - g_object_set_data(G_OBJECT(item), "plr", plr); - g_signal_connect(item, "activate", - G_CALLBACK(diplomacy_dialog_embassy_callback), pdialog); - - if (player_has_embassy(plr1, plr0)) { - gtk_widget_set_sensitive(item, FALSE); - } - gtk_menu_shell_append(GTK_MENU_SHELL(parent), item); - gtk_widget_show(item); - - /* Pacts. */ if (plr == pdialog->treaty.plr0) { menu = gtk_menu_new(); @@ -828,22 +813,6 @@ 0); } -/**************************************************************** -... -*****************************************************************/ -static void diplomacy_dialog_embassy_callback(GtkWidget *w, gpointer data) -{ - struct Diplomacy_dialog *pdialog = (struct Diplomacy_dialog *) data; - struct player *pgiver = - (struct player *) g_object_get_data(G_OBJECT(w), "plr"); - - dsend_packet_diplomacy_create_clause_req(&aconnection, - player_number(pdialog->treaty.plr1), - player_number(pgiver), CLAUSE_EMBASSY, - 0); -} - - /***************************************************************** ... *****************************************************************/ Index: client/packhand.c =================================================================== --- client/packhand.c (revision 13532) +++ client/packhand.c (working copy) @@ -1563,12 +1563,6 @@ pplayer->economic.luxury=pinfo->luxury; pplayer->government = government_by_number(pinfo->government); pplayer->target_government = government_by_number(pinfo->target_government); - BV_CLR_ALL(pplayer->embassy); - players_iterate(pother) { - if (pinfo->embassy[player_index(pother)]) { - BV_SET(pplayer->embassy, player_index(pother)); - } - } players_iterate_end; pplayer->gives_shared_vision = pinfo->gives_shared_vision; pplayer->city_style=pinfo->city_style; for (i = 0; i < MAX_NUM_PLAYERS + MAX_NUM_BARBARIANS; i++) { @@ -1601,8 +1595,6 @@ pinfo->diplstates[i].type; pplayer->diplstates[i].turns_left = pinfo->diplstates[i].turns_left; - pplayer->diplstates[i].contact_turns_left = - pinfo->diplstates[i].contact_turns_left; pplayer->diplstates[i].has_reason_to_cancel = pinfo->diplstates[i].has_reason_to_cancel; } Index: client/plrdlg_common.c =================================================================== --- client/plrdlg_common.c (revision 13532) +++ client/plrdlg_common.c (working copy) @@ -109,15 +109,6 @@ } /****************************************************************** - Returns a translated string giving the embassy status - (none/with us/with them/both). -*******************************************************************/ -static const char *col_embassy(const struct player *player) -{ - return get_embassy_status(game.player_ptr, player); -} - -/****************************************************************** Returns a translated string giving the diplomatic status ("war" or "ceasefire (5)"). *******************************************************************/ @@ -255,7 +246,6 @@ {TRUE, COL_TEXT, N_("Team"), col_team, NULL, NULL, "team"}, {TRUE, COL_BOOLEAN, N_("AI"), NULL, col_ai, NULL, "ai"}, {TRUE, COL_TEXT, N_("Attitude"), col_love, NULL, cmp_love, "attitude"}, - {TRUE, COL_TEXT, N_("Embassy"), col_embassy, NULL, NULL, "embassy"}, {TRUE, COL_TEXT, N_("Dipl.State"), col_diplstate, NULL, NULL, "diplstate"}, {TRUE, COL_TEXT, N_("Vision"), col_vision, NULL, NULL, "vision"}, {TRUE, COL_TEXT, N_("State"), col_state, NULL, NULL, "state"}, Index: client/climisc.c =================================================================== --- client/climisc.c (revision 13532) +++ client/climisc.c (working copy) @@ -194,34 +194,6 @@ } /*************************************************************************** - Return a string indicating one nation's embassy status with another -***************************************************************************/ -const char *get_embassy_status(const struct player *me, - const struct player *them) -{ - if (!me || !them - || me == them - || !them->is_alive - || !me->is_alive) { - return "-"; - } - if (player_has_embassy(me, them)) { - if (player_has_embassy(them, me)) { - return Q_("?embassy:Both"); - } else { - return Q_("?embassy:Yes"); - } - } else if (player_has_embassy(them, me)) { - return Q_("?embassy:With Us"); - } else if (me->diplstates[player_index(them)].contact_turns_left > 0 - || them->diplstates[player_index(me)].contact_turns_left > 0) { - return Q_("?embassy:Contact"); - } else { - return Q_("?embassy:No Contact"); - } -} - -/*************************************************************************** Return a string indicating one nation's shaed vision status with another ***************************************************************************/ const char *get_vision_status(const struct player *me, @@ -291,10 +263,6 @@ my_snprintf(buf, bufsiz, _("The %s gives shared vision"), nation_plural_translation(pclause->from->nation)); break; - case CLAUSE_EMBASSY: - my_snprintf(buf, bufsiz, _("The %s gives an embassy"), - nation_plural_translation(pclause->from->nation)); - break; default: assert(FALSE); if (bufsiz > 0) { Index: client/climisc.h =================================================================== --- client/climisc.h (revision 13532) +++ client/climisc.h (working copy) @@ -31,8 +31,6 @@ void client_change_all(struct universal from, struct universal to); -const char *get_embassy_status(const struct player *me, - const struct player *them); const char *get_vision_status(const struct player *me, const struct player *them); void client_diplomacy_clause_string(char *buf, int bufsiz,
_______________________________________________ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev