Freeciv-3.1
Loading...
Searching...
No Matches
Macros | Functions | Variables
threadedai.c File Reference
#include "ai.h"
#include "aidata.h"
#include "aiferry.h"
#include "aihand.h"
#include "ailog.h"
#include "aiplayer.h"
#include "aitools.h"
#include "daicity.h"
#include "daidiplomacy.h"
#include "daidomestic.h"
#include "daimilitary.h"
#include "daisettler.h"
#include "taimsg.h"
#include "taiplayer.h"

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)
 
bool fc_ai_threaded_setup (struct ai_type *ai)
 
static void tai_init_self (struct ai_type *ai)
 
static struct ai_typetai_get_self (void)
 
static void tai_module_close (void)
 
static void twai_player_alloc (struct player *pplayer)
 
static void twai_player_free (struct player *pplayer)
 
static void twai_player_save (struct player *pplayer, struct section_file *file, int plrno)
 
static void twai_player_load (struct player *pplayer, const struct section_file *file, int plrno)
 
static void twai_control_gained (struct player *pplayer)
 
static void twai_control_lost (struct player *pplayer)
 
static void twai_split_by_civil_war (struct player *original, struct player *created)
 
static void twai_created_by_civil_war (struct player *original, struct player *created)
 
static void twai_phase_begin (struct player *pplayer, bool is_new_phase)
 
static void twai_phase_finished (struct player *pplayer)
 
static void twai_city_alloc (struct city *pcity)
 
static void twai_city_free (struct city *pcity)
 
static void twai_city_save (struct section_file *file, const struct city *pcity, const char *citystr)
 
static void twai_city_load (const struct section_file *file, struct city *pcity, const char *citystr)
 
static void twai_build_adv_override (struct city *pcity, struct adv_choice *choice)
 
static void twai_wonder_city_distance (struct player *pplayer, struct adv_data *adv)
 
static void twai_build_adv_init (struct player *pplayer)
 
static void twai_build_adv_adjust (struct player *pplayer, struct city *wonder_city)
 
static void twai_gov_value (struct player *pplayer, struct government *gov, adv_want *val, bool *override)
 
static void twai_units_ruleset_init (void)
 
static void twai_units_ruleset_close (void)
 
static void twai_unit_alloc (struct unit *punit)
 
static void twai_unit_free (struct unit *punit)
 
static void twai_ferry_init_ferry (struct unit *ferry)
 
static void twai_ferry_transformed (struct unit *ferry, const struct unit_type *old)
 
static void twai_ferry_lost (struct unit *punit)
 
static void twai_unit_turn_end (struct unit *punit)
 
static void twai_unit_move_or_attack (struct unit *punit, struct tile *ptile, struct pf_path *path, int step)
 
static void twai_unit_new_adv_task (struct unit *punit, enum adv_unit_task task, struct tile *ptile)
 
static void twai_unit_save (struct section_file *file, const struct unit *punit, const char *unitstr)
 
static void twai_unit_load (const struct section_file *file, struct unit *punit, const char *unitstr)
 
static void twai_auto_settler_reset (struct player *pplayer)
 
static void twai_auto_settler_run (struct player *pplayer, struct unit *punit, struct settlermap *state)
 
static void twai_auto_settler_cont (struct player *pplayer, struct unit *punit, struct settlermap *state)
 
static void twai_switch_to_explore (struct unit *punit, struct tile *target, enum override_bool *allow)
 
static void twai_first_activities (struct player *pplayer)
 
static void twai_restart_phase (struct player *pplayer)
 
static void twai_diplomacy_actions (struct player *pplayer)
 
static void twai_last_activities (struct player *pplayer)
 
static void twai_treaty_evaluate (struct player *pplayer, struct player *aplayer, struct Treaty *ptreaty)
 
static void twai_treaty_accepted (struct player *pplayer, struct player *aplayer, struct Treaty *ptreaty)
 
static void twai_diplomacy_first_contact (struct player *pplayer, struct player *aplayer)
 
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 void twai_city_log (char *buffer, int buflength, const struct city *pcity)
 
static void twai_unit_log (char *buffer, int buflength, const struct unit *punit)
 
static void twai_consider_plr_dangerous (struct player *plr1, struct player *plr2, enum override_bool *result)
 
static void twai_consider_tile_dangerous (struct tile *ptile, struct unit *punit, enum override_bool *result)
 
static void twai_consider_wonder_city (struct city *pcity, bool *result)
 
static void twai_refresh (struct player *pplayer)
 

Variables

static struct ai_typeself = NULL
 

Macro Definition Documentation

◆ TAI_AIT

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

Definition at line 64 of file threadedai.c.

◆ TAI_DFUNC

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

Definition at line 66 of file threadedai.c.

◆ TAI_TFUNC

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

Definition at line 65 of file threadedai.c.

Function Documentation

◆ fc_ai_threaded_capstr()

const char * fc_ai_threaded_capstr ( void  )

Return module capability string

Definition at line 552 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 560 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 59 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 49 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 71 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 396 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 377 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 386 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 245 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 236 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 218 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 180 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 189 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 208 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 496 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 198 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 514 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 524 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 534 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 122 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 132 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 151 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 473 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 300 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 319 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 309 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 254 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 483 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 161 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 170 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 81 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 91 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 111 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 101 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 543 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 141 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 463 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 282 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 291 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 367 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 505 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 337 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 347 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 357 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 328 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 273 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 264 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 227 of file threadedai.c.

Referenced by fc_ai_threaded_setup().

Variable Documentation

◆ self

struct ai_type* self = NULL
static

Definition at line 44 of file threadedai.c.

Referenced by tai_get_self(), and tai_init_self().