Author: cazfi Date: Tue Jun 24 01:54:43 2014 New Revision: 25253 URL: http://svn.gna.org/viewcvs/freeciv?rev=25253&view=rev Log: Civil war related AI callback API changes - Added parameter telling the created player to split_by_civil_war - Added callback created_by_civil_war, called for created player
See patch #4829 Modified: trunk/ai/classic/classicai.c trunk/ai/threaded/threadedai.c trunk/common/ai.h trunk/doc/README.AI_modules trunk/server/plrhand.c Modified: trunk/ai/classic/classicai.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/ai/classic/classicai.c?rev=25253&r1=25252&r2=25253&view=diff ============================================================================== --- trunk/ai/classic/classicai.c (original) +++ trunk/ai/classic/classicai.c Tue Jun 24 01:54:43 2014 @@ -124,6 +124,17 @@ /************************************************************************** Call default ai with classic ai type as parameter. **************************************************************************/ +static void cai_split_by_civil_war(struct player *original, + struct player *created) +{ + struct ai_type *deftype = classic_ai_get_self(); + + dai_assess_danger_player(deftype, original); +} + +/************************************************************************** + Call default ai with classic ai type as parameter. +**************************************************************************/ static void cai_data_phase_begin(struct player *pplayer, bool is_new_phase) { struct ai_type *deftype = classic_ai_get_self(); @@ -532,7 +543,8 @@ ai->funcs.player_load = cai_player_load; ai->funcs.gained_control = cai_assess_danger_player; /* ai->funcs.lost_control = NULL; */ - ai->funcs.split_by_civil_war = cai_assess_danger_player; + ai->funcs.split_by_civil_war = cai_split_by_civil_war; + /* ai->funcs.created_by_civil_war = NULL; */ ai->funcs.phase_begin = cai_data_phase_begin; ai->funcs.phase_finished = cai_data_phase_finished; Modified: trunk/ai/threaded/threadedai.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/ai/threaded/threadedai.c?rev=25253&r1=25252&r2=25253&view=diff ============================================================================== --- trunk/ai/threaded/threadedai.c (original) +++ trunk/ai/threaded/threadedai.c Tue Jun 24 01:54:43 2014 @@ -128,10 +128,11 @@ /************************************************************************** Call default ai with threaded ai type as parameter. **************************************************************************/ -static void twai_split_by_civil_war(struct player *pplayer) -{ - TAI_AIT; - TAI_DFUNC(dai_assess_danger_player, pplayer); +static void twai_split_by_civil_war(struct player *original, + struct player *created) +{ + TAI_AIT; + TAI_DFUNC(dai_assess_danger_player, original); } /************************************************************************** Modified: trunk/common/ai.h URL: http://svn.gna.org/viewcvs/freeciv/trunk/common/ai.h?rev=25253&r1=25252&r2=25253&view=diff ============================================================================== --- trunk/common/ai.h (original) +++ trunk/common/ai.h Tue Jun 24 01:54:43 2014 @@ -22,7 +22,7 @@ /* Update this capability string when ever there is changes to ai_type structure below */ -#define FC_AI_MOD_CAPSTR "+Freeciv-ai-module-2014.Feb.25" +#define FC_AI_MOD_CAPSTR "+Freeciv-ai-module-2014.Jun.20" /* Timers for all AI activities. Define it to get statistics about the AI. */ #ifdef DEBUG @@ -76,7 +76,10 @@ void (*lost_control)(struct player *pplayer); /* Called for AI type of the player who gets split to two. */ - void (*split_by_civil_war)(struct player *pplayer); + void (*split_by_civil_war)(struct player *original, struct player *created); + + /* Called for AI type of the player who got created from the split. */ + void (*created_by_civil_war)(struct player *original, struct player *created); /* Called for player AI type when player phase begins. This is in the * beginning of phase setup. See also first_activities. */ Modified: trunk/doc/README.AI_modules URL: http://svn.gna.org/viewcvs/freeciv/trunk/doc/README.AI_modules?rev=25253&r1=25252&r2=25253&view=diff ============================================================================== --- trunk/doc/README.AI_modules (original) +++ trunk/doc/README.AI_modules Tue Jun 24 01:54:43 2014 @@ -6,6 +6,7 @@ 2. Using freeciv built with AI-modules support 3. Building freeciv with AI-modules support 4. Coding new AI module +5. Callback interface ChangeLog 1. Default build @@ -89,3 +90,13 @@ For "--LoadAI <modulename>" to find the AI module, it must reside in ${libdir}/fcai/ (/usr/lib/fcai by default) under name fc_ai_<modulename>.so + + +5. Callback interface ChangeLog +------------------------------- + +New in Freeciv 2.6: +------------------- +- Added created_by_civil_war, called for AI type of the player who got created from + civil war +- Added "created" player parameter to split_by_civil_war Modified: trunk/server/plrhand.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/server/plrhand.c?rev=25253&r1=25252&r2=25253&view=diff ============================================================================== --- trunk/server/plrhand.c (original) +++ trunk/server/plrhand.c Tue Jun 24 01:54:43 2014 @@ -2448,9 +2448,8 @@ adv_data_phase_init(cplayer, TRUE); CALL_PLR_AI_FUNC(phase_begin, cplayer, cplayer, TRUE); CALL_PLR_AI_FUNC(gained_control, cplayer, cplayer); - if (pplayer->ai_controlled) { - CALL_PLR_AI_FUNC(split_by_civil_war, pplayer, pplayer); - } + CALL_PLR_AI_FUNC(split_by_civil_war, pplayer, pplayer, cplayer); + CALL_PLR_AI_FUNC(created_by_civil_war, cplayer, pplayer, cplayer); return cplayer; } _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits