Freeciv21
Develop your civilization from humble roots to a global empire
threadedai.c File Reference
#include <fc_config.h>
#include "ai.h"
#include "aidata.h"
#include "aiferry.h"
#include "aihand.h"
#include "ailog.h"
#include "aiplayer.h"
#include "aisettler.h"
#include "aitools.h"
#include "daicity.h"
#include "daidiplomacy.h"
#include "daidomestic.h"
#include "daimilitary.h"
#include "taimsg.h"
#include "taiplayer.h"
+ Include dependency graph for threadedai.c:

Go to the source code of this file.

Macros

#define TAI_AIT   struct ai_type *ait = tai_get_self();
 
#define TAI_TFUNC(_func, ...)   _func(ait, ##__VA_ARGS__);
 
#define TAI_DFUNC(_func, ...)   _func(ait, ##__VA_ARGS__);
 

Functions

const char * fc_ai_threaded_capstr (void)
 Return module capability string. More...
 
bool fc_ai_threaded_setup (struct ai_type *ai)
 Setup player ai_funcs function pointers. More...
 
static void tai_init_self (struct ai_type *ai)
 Set pointer to ai type of the threaded ai. More...
 
static struct ai_typetai_get_self (void)
 Get pointer to ai type of the threaded ai. More...
 
static void tai_module_close (void)
 Free resources allocated by the threaded AI module. More...
 
static void twai_player_alloc (struct player *pplayer)
 Call default ai with threaded ai type as parameter. More...
 
static void twai_player_free (struct player *pplayer)
 Call default ai with threaded ai type as parameter. More...
 
static void twai_player_save (struct player *pplayer, struct section_file *file, int plrno)
 Call default ai with threaded ai type as parameter. More...
 
static void twai_player_load (struct player *pplayer, const struct section_file *file, int plrno)
 Call default ai with threaded ai type as parameter. More...
 
static void twai_control_gained (struct player *pplayer)
 Call default ai with threaded ai type as parameter. More...
 
static void twai_control_lost (struct player *pplayer)
 Call default ai with threaded ai type as parameter. More...
 
static void twai_split_by_civil_war (struct player *original, struct player *created)
 Call default ai with threaded ai type as parameter. More...
 
static void twai_created_by_civil_war (struct player *original, struct player *created)
 Call default ai with threaded ai type as parameter. More...
 
static void twai_phase_begin (struct player *pplayer, bool is_new_phase)
 Call default ai with threaded ai type as parameter. More...
 
static void twai_phase_finished (struct player *pplayer)
 Call default ai with threaded ai type as parameter. More...
 
static void twai_city_alloc (struct city *pcity)
 Call default ai with threaded ai type as parameter. More...
 
static void twai_city_free (struct city *pcity)
 Call default ai with threaded ai type as parameter. More...
 
static void twai_city_save (struct section_file *file, const struct city *pcity, const char *citystr)
 Call default ai with threaded ai type as parameter. More...
 
static void twai_city_load (const struct section_file *file, struct city *pcity, const char *citystr)
 Call default ai with threaded ai type as parameter. More...
 
static void twai_build_adv_override (struct city *pcity, struct adv_choice *choice)
 Call default ai with threaded ai type as parameter. More...
 
static void twai_wonder_city_distance (struct player *pplayer, struct adv_data *adv)
 Call default ai with threaded ai type as parameter. More...
 
static void twai_build_adv_init (struct player *pplayer)
 Call default ai with threaded ai type as parameter. More...
 
static void twai_build_adv_adjust (struct player *pplayer, struct city *wonder_city)
 Call default ai with threaded ai type as parameter. More...
 
static void twai_gov_value (struct player *pplayer, struct government *gov, adv_want *val, bool *override)
 Call default ai with threaded ai type as parameter. More...
 
static void twai_units_ruleset_init (void)
 Call default ai with threaded ai type as parameter. More...
 
static void twai_units_ruleset_close (void)
 Call default ai with threaded ai type as parameter. More...
 
static void twai_unit_alloc (struct unit *punit)
 Call default ai with threaded ai type as parameter. More...
 
static void twai_unit_free (struct unit *punit)
 Call default ai with threaded ai type as parameter. More...
 
static void twai_ferry_init_ferry (struct unit *ferry)
 Call default ai with threaded ai type as parameter. More...
 
static void twai_ferry_transformed (struct unit *ferry, const struct unit_type *old)
 Call default ai with threaded ai type as parameter. More...
 
static void twai_ferry_lost (struct unit *punit)
 Call default ai with threaded ai type as parameter. More...
 
static void twai_unit_turn_end (struct unit *punit)
 Call default ai with threaded ai type as parameter. More...
 
static void twai_unit_move_or_attack (struct unit *punit, struct tile *ptile, struct pf_path *path, int step)
 Call default ai with threaded ai type as parameter. More...
 
static void twai_unit_new_adv_task (struct unit *punit, enum adv_unit_task task, struct tile *ptile)
 Call default ai with threaded ai type as parameter. More...
 
static void twai_unit_save (struct section_file *file, const struct unit *punit, const char *unitstr)
 Call default ai with threaded ai type as parameter. More...
 
static void twai_unit_load (const struct section_file *file, struct unit *punit, const char *unitstr)
 Call default ai with threaded ai type as parameter. More...
 
static void twai_auto_settler_reset (struct player *pplayer)
 Call default ai with threaded ai type as parameter. More...
 
static void twai_auto_settler_run (struct player *pplayer, struct unit *punit, struct settlermap *state)
 Call default ai with threaded ai type as parameter. More...
 
static void twai_auto_settler_cont (struct player *pplayer, struct unit *punit, struct settlermap *state)
 Call default ai with threaded ai type as parameter. More...
 
static void twai_switch_to_explore (struct unit *punit, struct tile *target, enum override_bool *allow)
 Call default ai with threaded ai type as parameter. More...
 
static void twai_first_activities (struct player *pplayer)
 Call default ai with threaded ai type as parameter. More...
 
static void twai_restart_phase (struct player *pplayer)
 Start working on the thread again. More...
 
static void twai_diplomacy_actions (struct player *pplayer)
 Call default ai with threaded ai type as parameter. More...
 
static void twai_last_activities (struct player *pplayer)
 Call default ai with threaded ai type as parameter. More...
 
static void twai_treaty_evaluate (struct player *pplayer, struct player *aplayer, struct Treaty *ptreaty)
 Call default ai with threaded ai type as parameter. More...
 
static void twai_treaty_accepted (struct player *pplayer, struct player *aplayer, struct Treaty *ptreaty)
 Call default ai with threaded ai type as parameter. More...
 
static void twai_diplomacy_first_contact (struct player *pplayer, struct player *aplayer)
 Call default ai with threaded ai type as parameter. More...
 
static void twai_incident (enum incident_type type, enum casus_belli_range scope, const struct action *paction, struct player *receiver, struct player *violator, struct player *victim)
 Call default ai with threaded ai type as parameter. More...
 
static void twai_city_log (char *buffer, int buflength, const struct city *pcity)
 Call default ai with threaded ai type as parameter. More...
 
static void twai_unit_log (char *buffer, int buflength, const struct unit *punit)
 Call default ai with threaded ai type as parameter. More...
 
static void twai_consider_plr_dangerous (struct player *plr1, struct player *plr2, enum override_bool *result)
 Call default ai with threaded ai type as parameter. More...
 
static void twai_consider_tile_dangerous (struct tile *ptile, struct unit *punit, enum override_bool *result)
 Call default ai with threaded ai type as parameter. More...
 
static void twai_consider_wonder_city (struct city *pcity, bool *result)
 Call default ai with threaded ai type as parameter. More...
 
static void twai_refresh (struct player *pplayer)
 Call default ai with threaded ai type as parameter. More...
 

Variables

static struct ai_typeself = NULL
 

Macro Definition Documentation

◆ TAI_AIT

#define TAI_AIT   struct ai_type *ait = tai_get_self();

Definition at line 59 of file threadedai.c.

◆ TAI_DFUNC

#define TAI_DFUNC (   _func,
  ... 
)    _func(ait, ##__VA_ARGS__);

Definition at line 61 of file threadedai.c.

◆ TAI_TFUNC

#define TAI_TFUNC (   _func,
  ... 
)    _func(ait, ##__VA_ARGS__);

Definition at line 60 of file threadedai.c.

Function Documentation

◆ fc_ai_threaded_capstr()

const char * fc_ai_threaded_capstr ( void  )

Return module capability string.

Definition at line 558 of file threadedai.c.

◆ fc_ai_threaded_setup()

bool fc_ai_threaded_setup ( struct ai_type ai)

Setup player ai_funcs function pointers.

Definition at line 563 of file threadedai.c.

Referenced by ai_init().

◆ tai_get_self()

static struct ai_type * tai_get_self ( void  )
static

Get pointer to ai type of the threaded ai.

Definition at line 57 of file threadedai.c.

◆ tai_init_self()

static void tai_init_self ( struct ai_type ai)
static

Set pointer to ai type of the threaded ai.

Definition at line 47 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

◆ tai_module_close()

static void tai_module_close ( void  )
static

Free resources allocated by the threaded AI module.

Definition at line 66 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

◆ twai_auto_settler_cont()

static void twai_auto_settler_cont ( struct player pplayer,
struct unit punit,
struct settlermap state 
)
static

Call default ai with threaded ai type as parameter.

Definition at line 395 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

◆ twai_auto_settler_reset()

static void twai_auto_settler_reset ( struct player pplayer)
static

Call default ai with threaded ai type as parameter.

Definition at line 376 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

◆ twai_auto_settler_run()

static void twai_auto_settler_run ( struct player pplayer,
struct unit punit,
struct settlermap state 
)
static

Call default ai with threaded ai type as parameter.

Definition at line 385 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

◆ twai_build_adv_adjust()

static void twai_build_adv_adjust ( struct player pplayer,
struct city wonder_city 
)
static

Call default ai with threaded ai type as parameter.

Definition at line 242 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

◆ twai_build_adv_init()

static void twai_build_adv_init ( struct player pplayer)
static

Call default ai with threaded ai type as parameter.

Definition at line 233 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

◆ twai_build_adv_override()

static void twai_build_adv_override ( struct city pcity,
struct adv_choice choice 
)
static

Call default ai with threaded ai type as parameter.

Definition at line 213 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

◆ twai_city_alloc()

static void twai_city_alloc ( struct city pcity)
static

Call default ai with threaded ai type as parameter.

Definition at line 175 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

◆ twai_city_free()

static void twai_city_free ( struct city pcity)
static

Call default ai with threaded ai type as parameter.

Definition at line 184 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

◆ twai_city_load()

static void twai_city_load ( const struct section_file file,
struct city pcity,
const char *  citystr 
)
static

Call default ai with threaded ai type as parameter.

Definition at line 203 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

◆ twai_city_log()

static void twai_city_log ( char *  buffer,
int  buflength,
const struct city pcity 
)
static

Call default ai with threaded ai type as parameter.

Definition at line 498 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

◆ twai_city_save()

static void twai_city_save ( struct section_file file,
const struct city pcity,
const char *  citystr 
)
static

Call default ai with threaded ai type as parameter.

Definition at line 193 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

◆ twai_consider_plr_dangerous()

static void twai_consider_plr_dangerous ( struct player plr1,
struct player plr2,
enum override_bool result 
)
static

Call default ai with threaded ai type as parameter.

Definition at line 518 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

◆ twai_consider_tile_dangerous()

static void twai_consider_tile_dangerous ( struct tile ptile,
struct unit punit,
enum override_bool result 
)
static

Call default ai with threaded ai type as parameter.

Definition at line 529 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

◆ twai_consider_wonder_city()

static void twai_consider_wonder_city ( struct city pcity,
bool *  result 
)
static

Call default ai with threaded ai type as parameter.

Definition at line 540 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

◆ twai_control_gained()

static void twai_control_gained ( struct player pplayer)
static

Call default ai with threaded ai type as parameter.

Definition at line 117 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

◆ twai_control_lost()

static void twai_control_lost ( struct player pplayer)
static

Call default ai with threaded ai type as parameter.

Definition at line 127 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

◆ twai_created_by_civil_war()

static void twai_created_by_civil_war ( struct player original,
struct player created 
)
static

Call default ai with threaded ai type as parameter.

Definition at line 146 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

◆ twai_diplomacy_actions()

static void twai_diplomacy_actions ( struct player pplayer)
static

Call default ai with threaded ai type as parameter.

Definition at line 435 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

◆ twai_diplomacy_first_contact()

static void twai_diplomacy_first_contact ( struct player pplayer,
struct player aplayer 
)
static

Call default ai with threaded ai type as parameter.

Definition at line 475 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

◆ twai_ferry_init_ferry()

static void twai_ferry_init_ferry ( struct unit ferry)
static

Call default ai with threaded ai type as parameter.

Definition at line 298 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

◆ twai_ferry_lost()

static void twai_ferry_lost ( struct unit punit)
static

Call default ai with threaded ai type as parameter.

Definition at line 317 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

◆ twai_ferry_transformed()

static void twai_ferry_transformed ( struct unit ferry,
const struct unit_type old 
)
static

Call default ai with threaded ai type as parameter.

Definition at line 307 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

◆ twai_first_activities()

static void twai_first_activities ( struct player pplayer)
static

Call default ai with threaded ai type as parameter.

Definition at line 416 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

◆ twai_gov_value()

static void twai_gov_value ( struct player pplayer,
struct government gov,
adv_want val,
bool *  override 
)
static

Call default ai with threaded ai type as parameter.

Definition at line 252 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

◆ twai_incident()

static void twai_incident ( enum incident_type  type,
enum casus_belli_range  scope,
const struct action paction,
struct player receiver,
struct player violator,
struct player victim 
)
static

Call default ai with threaded ai type as parameter.

Definition at line 485 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

◆ twai_last_activities()

static void twai_last_activities ( struct player pplayer)
static

Call default ai with threaded ai type as parameter.

Definition at line 444 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

◆ twai_phase_begin()

static void twai_phase_begin ( struct player pplayer,
bool  is_new_phase 
)
static

Call default ai with threaded ai type as parameter.

Definition at line 156 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

◆ twai_phase_finished()

static void twai_phase_finished ( struct player pplayer)
static

Call default ai with threaded ai type as parameter.

Definition at line 165 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

◆ twai_player_alloc()

static void twai_player_alloc ( struct player pplayer)
static

Call default ai with threaded ai type as parameter.

Definition at line 77 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

◆ twai_player_free()

static void twai_player_free ( struct player pplayer)
static

Call default ai with threaded ai type as parameter.

Definition at line 87 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

◆ twai_player_load()

static void twai_player_load ( struct player pplayer,
const struct section_file file,
int  plrno 
)
static

Call default ai with threaded ai type as parameter.

Definition at line 107 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

◆ twai_player_save()

static void twai_player_save ( struct player pplayer,
struct section_file file,
int  plrno 
)
static

Call default ai with threaded ai type as parameter.

Definition at line 97 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

◆ twai_refresh()

static void twai_refresh ( struct player pplayer)
static

Call default ai with threaded ai type as parameter.

Definition at line 549 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

◆ twai_restart_phase()

static void twai_restart_phase ( struct player pplayer)
static

Start working on the thread again.

Definition at line 426 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

◆ twai_split_by_civil_war()

static void twai_split_by_civil_war ( struct player original,
struct player created 
)
static

Call default ai with threaded ai type as parameter.

Definition at line 136 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

◆ twai_switch_to_explore()

static void twai_switch_to_explore ( struct unit punit,
struct tile target,
enum override_bool allow 
)
static

Call default ai with threaded ai type as parameter.

Definition at line 406 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

◆ twai_treaty_accepted()

static void twai_treaty_accepted ( struct player pplayer,
struct player aplayer,
struct Treaty ptreaty 
)
static

Call default ai with threaded ai type as parameter.

Definition at line 464 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

◆ twai_treaty_evaluate()

static void twai_treaty_evaluate ( struct player pplayer,
struct player aplayer,
struct Treaty ptreaty 
)
static

Call default ai with threaded ai type as parameter.

Definition at line 453 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

◆ twai_unit_alloc()

static void twai_unit_alloc ( struct unit punit)
static

Call default ai with threaded ai type as parameter.

Definition at line 280 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

◆ twai_unit_free()

static void twai_unit_free ( struct unit punit)
static

Call default ai with threaded ai type as parameter.

Definition at line 289 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

◆ twai_unit_load()

static void twai_unit_load ( const struct section_file file,
struct unit punit,
const char *  unitstr 
)
static

Call default ai with threaded ai type as parameter.

Definition at line 366 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

◆ twai_unit_log()

static void twai_unit_log ( char *  buffer,
int  buflength,
const struct unit punit 
)
static

Call default ai with threaded ai type as parameter.

Definition at line 508 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

◆ twai_unit_move_or_attack()

static void twai_unit_move_or_attack ( struct unit punit,
struct tile ptile,
struct pf_path *  path,
int  step 
)
static

Call default ai with threaded ai type as parameter.

Definition at line 335 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

◆ twai_unit_new_adv_task()

static void twai_unit_new_adv_task ( struct unit punit,
enum adv_unit_task  task,
struct tile ptile 
)
static

Call default ai with threaded ai type as parameter.

Definition at line 345 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

◆ twai_unit_save()

static void twai_unit_save ( struct section_file file,
const struct unit punit,
const char *  unitstr 
)
static

Call default ai with threaded ai type as parameter.

Definition at line 356 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

◆ twai_unit_turn_end()

static void twai_unit_turn_end ( struct unit punit)
static

Call default ai with threaded ai type as parameter.

Definition at line 326 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

◆ twai_units_ruleset_close()

static void twai_units_ruleset_close ( void  )
static

Call default ai with threaded ai type as parameter.

Definition at line 271 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

◆ twai_units_ruleset_init()

static void twai_units_ruleset_init ( void  )
static

Call default ai with threaded ai type as parameter.

Definition at line 262 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

◆ twai_wonder_city_distance()

static void twai_wonder_city_distance ( struct player pplayer,
struct adv_data adv 
)
static

Call default ai with threaded ai type as parameter.

Definition at line 223 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

Variable Documentation

◆ self

struct ai_type* self = NULL
static

Definition at line 42 of file threadedai.c.