Author: cazfi Date: Mon Mar 2 04:24:15 2015 New Revision: 28352 URL: http://svn.gna.org/viewcvs/freeciv?rev=28352&view=rev Log: Split "Have_Embassies" effect to two: 1) New "Have_Contacts" can provide contact with all the nations 2) "Have_Embassies" provide embassy only with those nations who the owner has had contact with
See patch #5832 Modified: trunk/ai/default/daieffects.c trunk/common/effects.c trunk/common/effects.h trunk/common/player.c trunk/data/alien/effects.ruleset trunk/data/civ2/effects.ruleset trunk/data/civ2civ3/effects.ruleset trunk/data/classic/effects.ruleset trunk/data/experimental/effects.ruleset trunk/doc/README.effects trunk/server/rscompat.c trunk/server/rssanity.c trunk/server/srv_main.c trunk/tools/ruledit/rulesave.c trunk/tools/ruledit/validity.c Modified: trunk/ai/default/daieffects.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/daieffects.c?rev=28352&r1=28351&r2=28352&view=diff ============================================================================== --- trunk/ai/default/daieffects.c (original) +++ trunk/ai/default/daieffects.c Mon Mar 2 04:24:15 2015 @@ -315,8 +315,11 @@ v += amount * (game.info.sciencebox + 1); } break; + case EFT_HAVE_CONTACTS: + v += 3 * nplayers; + break; case EFT_HAVE_EMBASSIES: - v += 5 * nplayers; + v += 2 * nplayers; break; case EFT_REVEAL_CITIES: case EFT_NO_ANARCHY: Modified: trunk/common/effects.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/common/effects.c?rev=28352&r1=28351&r2=28352&view=diff ============================================================================== --- trunk/common/effects.c (original) +++ trunk/common/effects.c Mon Mar 2 04:24:15 2015 @@ -183,7 +183,24 @@ /* Now add the effect to the ruleset cache. */ effect_list_append(ruleset_cache.tracker, peffect); effect_list_append(get_effects(type), peffect); + return peffect; +} + +/************************************************************************** + Return new copy of the effect +**************************************************************************/ +struct effect *effect_copy(struct effect *old) +{ + struct effect *new_eff = effect_new(old->type, old->value); + + new_eff->multiplier = old->multiplier; + + requirement_vector_iterate(&old->reqs, preq) { + effect_req_append(new_eff, *preq); + } requirement_vector_iterate_end; + + return new_eff; } /************************************************************************** Modified: trunk/common/effects.h URL: http://svn.gna.org/viewcvs/freeciv/trunk/common/effects.h?rev=28352&r1=28351&r2=28352&view=diff ============================================================================== --- trunk/common/effects.h (original) +++ trunk/common/effects.h Mon Mar 2 04:24:15 2015 @@ -273,6 +273,8 @@ #define SPECENUM_VALUE105NAME "Retire_Pct" #define SPECENUM_VALUE106 EFT_ILLEGAL_ACTION_MOVE_COST #define SPECENUM_VALUE106NAME "Illegal_Action_Move_Cost" +#define SPECENUM_VALUE107 EFT_HAVE_CONTACTS +#define SPECENUM_VALUE107NAME "Have_Contacts" /* keep this last */ #define SPECENUM_COUNT EFT_COUNT #include "specenum_gen.h" @@ -305,6 +307,7 @@ #define effect_list_iterate_end LIST_ITERATE_END struct effect *effect_new(enum effect_type type, int value); +struct effect *effect_copy(struct effect *old); void effect_req_append(struct effect *peffect, struct requirement req); struct astring; @@ -392,7 +395,7 @@ struct effect_list *get_effects(enum effect_type effect_type); -typedef bool (*iec_cb)(const struct effect*, void *data); +typedef bool (*iec_cb)(struct effect*, void *data); bool iterate_effect_cache(iec_cb cb, void *data); #ifdef __cplusplus Modified: trunk/common/player.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/common/player.c?rev=28352&r1=28351&r2=28352&view=diff ============================================================================== --- trunk/common/player.c (original) +++ trunk/common/player.c Mon Mar 2 04:24:15 2015 @@ -198,6 +198,7 @@ const struct player *pplayer2) { return (get_player_bonus(pplayer, EFT_HAVE_EMBASSIES) > 0 + && player_diplstate_get(pplayer, pplayer2)->type != DS_NO_CONTACT && !is_barbarian(pplayer2)); } Modified: trunk/data/alien/effects.ruleset URL: http://svn.gna.org/viewcvs/freeciv/trunk/data/alien/effects.ruleset?rev=28352&r1=28351&r2=28352&view=diff ============================================================================== --- trunk/data/alien/effects.ruleset (original) +++ trunk/data/alien/effects.ruleset Mon Mar 2 04:24:15 2015 @@ -428,7 +428,15 @@ "Building", "Training Facility", "City" } -[effect_communication] +[effect_communication_contact] +type = "Have_Contacts" +value = 1 +reqs = + { "type", "name", "range" + "Tech", "Communication", "Player" + } + +[effect_communication_embassy] type = "Have_Embassies" value = 1 reqs = Modified: trunk/data/civ2/effects.ruleset URL: http://svn.gna.org/viewcvs/freeciv/trunk/data/civ2/effects.ruleset?rev=28352&r1=28351&r2=28352&view=diff ============================================================================== --- trunk/data/civ2/effects.ruleset (original) +++ trunk/data/civ2/effects.ruleset Mon Mar 2 04:24:15 2015 @@ -1930,6 +1930,14 @@ "Building", "Manhattan Project", "World", TRUE } +[effect_marco_polos_contact] +type = "Have_Contacts" +value = 1 +reqs = + { "type", "name", "range" + "Building", "Marco Polo's Embassy", "Player" + } + [effect_marco_polos_embassy] type = "Have_Embassies" value = 1 Modified: trunk/data/civ2civ3/effects.ruleset URL: http://svn.gna.org/viewcvs/freeciv/trunk/data/civ2civ3/effects.ruleset?rev=28352&r1=28351&r2=28352&view=diff ============================================================================== --- trunk/data/civ2civ3/effects.ruleset (original) +++ trunk/data/civ2civ3/effects.ruleset Mon Mar 2 04:24:15 2015 @@ -3212,6 +3212,14 @@ "Building", "Manhattan Project", "World", TRUE } +[effect_marco_polos_contact] +type = "Have_Contacts" +value = 1 +reqs = + { "type", "name", "range" + "Building", "Marco Polo's Embassy", "Player" + } + [effect_marco_polos_embassy] type = "Have_Embassies" value = 1 Modified: trunk/data/classic/effects.ruleset URL: http://svn.gna.org/viewcvs/freeciv/trunk/data/classic/effects.ruleset?rev=28352&r1=28351&r2=28352&view=diff ============================================================================== --- trunk/data/classic/effects.ruleset (original) +++ trunk/data/classic/effects.ruleset Mon Mar 2 04:24:15 2015 @@ -2008,6 +2008,14 @@ "Building", "Manhattan Project", "World", TRUE } +[effect_marco_polos_contact] +type = "Have_Contacts" +value = 1 +reqs = + { "type", "name", "range" + "Building", "Marco Polo's Embassy", "Player" + } + [effect_marco_polos_embassy] type = "Have_Embassies" value = 1 Modified: trunk/data/experimental/effects.ruleset URL: http://svn.gna.org/viewcvs/freeciv/trunk/data/experimental/effects.ruleset?rev=28352&r1=28351&r2=28352&view=diff ============================================================================== --- trunk/data/experimental/effects.ruleset (original) +++ trunk/data/experimental/effects.ruleset Mon Mar 2 04:24:15 2015 @@ -2214,6 +2214,14 @@ "Building", "Manhattan Project", "World", TRUE } +[effect_marco_polos_contact] +type = "Have_Contacts" +value = 1 +reqs = + { "type", "name", "range" + "Building", "Marco Polo's Embassy", "Player" + } + [effect_marco_polos_embassy] type = "Have_Embassies" value = 1 Modified: trunk/doc/README.effects URL: http://svn.gna.org/viewcvs/freeciv/trunk/doc/README.effects?rev=28352&r1=28351&r2=28352&view=diff ============================================================================== --- trunk/doc/README.effects (original) +++ trunk/doc/README.effects Mon Mar 2 04:24:15 2015 @@ -156,8 +156,12 @@ Food left after cities grow or shrink is amount percent of the capacity of the city's foodbox. This also affects the 'aqueductloss' penalty. +Have_Contact + If value > 0, gives contact to all the other players. + Have_Embassies - Like having embassies with all other players. + If value > 0, gives an embassy with all the other players owner has ever + had contact with. Irrigation_Pct Irrigation output of the tile is value %. Modified: trunk/server/rscompat.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/server/rscompat.c?rev=28352&r1=28351&r2=28352&view=diff ============================================================================== --- trunk/server/rscompat.c (original) +++ trunk/server/rscompat.c Mon Mar 2 04:24:15 2015 @@ -27,6 +27,7 @@ /* common */ #include "actions.h" +#include "effects.h" #include "requirements.h" #include "unittype.h" @@ -156,6 +157,21 @@ /* No errors encountered. */ return TRUE; +} + +/************************************************************************** + Adjust effects +**************************************************************************/ +static bool effect_list_compat_cb(struct effect *peffect, void *data) +{ + if (peffect->type == EFT_HAVE_EMBASSIES) { + /* Create "Have_Contacts" effect matching each "Have_Embassies" */ + struct effect *contacts = effect_copy(peffect); + + contacts->type = EFT_HAVE_CONTACTS; + } + + return FALSE; } /************************************************************************** @@ -206,4 +222,6 @@ action_enabler_add(capture); } -} + + iterate_effect_cache(effect_list_compat_cb, NULL); +} Modified: trunk/server/rssanity.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/server/rssanity.c?rev=28352&r1=28351&r2=28352&view=diff ============================================================================== --- trunk/server/rssanity.c (original) +++ trunk/server/rssanity.c Mon Mar 2 04:24:15 2015 @@ -302,7 +302,7 @@ /************************************************************************** Sanity check callback for iterating effects cache. **************************************************************************/ -static bool effect_list_sanity_cb(const struct effect *peffect, void *data) +static bool effect_list_sanity_cb(struct effect *peffect, void *data) { int one_tile = -1; /* TODO: Determine correct value from effect. * -1 disables checking */ Modified: trunk/server/srv_main.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/server/srv_main.c?rev=28352&r1=28351&r2=28352&view=diff ============================================================================== --- trunk/server/srv_main.c (original) +++ trunk/server/srv_main.c Mon Mar 2 04:24:15 2015 @@ -637,13 +637,13 @@ } /************************************************************************** - Give contact to players with the EFT_HAVE_EMBASSIES effect (traditionally + Give contact to players with the EFT_HAVE_CONTACTS effect (traditionally from Marco Polo's Embassy). **************************************************************************/ -static void do_have_embassies_effect(void) +static void do_have_contacts_effect(void) { phase_players_iterate(pplayer) { - if (get_player_bonus(pplayer, EFT_HAVE_EMBASSIES) > 0) { + if (get_player_bonus(pplayer, EFT_HAVE_CONTACTS) > 0) { players_iterate(pother) { /* Note this gives pplayer contact with pother, but doesn't give * pother contact with pplayer. This may cause problems in other @@ -1149,7 +1149,7 @@ flush_packets(); /* to curb major city spam */ do_reveal_effects(); - do_have_embassies_effect(); + do_have_contacts_effect(); phase_players_iterate(pplayer) { CALL_PLR_AI_FUNC(phase_finished, pplayer, pplayer); Modified: trunk/tools/ruledit/rulesave.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/tools/ruledit/rulesave.c?rev=28352&r1=28351&r2=28352&view=diff ============================================================================== --- trunk/tools/ruledit/rulesave.c (original) +++ trunk/tools/ruledit/rulesave.c Mon Mar 2 04:24:15 2015 @@ -576,7 +576,7 @@ /************************************************************************** Save one effect. Callback called for each effect in cache. **************************************************************************/ -static bool effect_save(const struct effect *peffect, void *data) +static bool effect_save(struct effect *peffect, void *data) { effect_cb_data *cbdata = (effect_cb_data *)data; char path[512]; Modified: trunk/tools/ruledit/validity.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/tools/ruledit/validity.c?rev=28352&r1=28351&r2=28352&view=diff ============================================================================== --- trunk/tools/ruledit/validity.c (original) +++ trunk/tools/ruledit/validity.c Mon Mar 2 04:24:15 2015 @@ -55,7 +55,7 @@ /************************************************************************** Callback to check if effect needs universal. **************************************************************************/ -static bool effect_list_universal_needed_cb(const struct effect *peffect, +static bool effect_list_universal_needed_cb(struct effect *peffect, void *data) { struct effect_list_cb_data *cbdata = (struct effect_list_cb_data *)data; _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits