Freeciv-3.1
Loading...
Searching...
No Matches
Data Structures | Macros | Enumerations | Functions
ai.h File Reference
#include "fc_types.h"

Go to the source code of this file.

Data Structures

struct  ai_type
 

Macros

#define FC_AI_MOD_CAPSTR   "+Freeciv-3.1-ai-module"
 
#define ai_timer_init(...)   (void) 0
 
#define ai_timer_free(...)   (void) 0
 
#define ai_timer_start(...)   (void) 0
 
#define ai_timer_stop(...)   (void) 0
 
#define ai_timer_player_start(...)   (void) 0
 
#define ai_timer_player_stop(...)   (void) 0
 
#define ai_type_iterate(NAME_ai)
 
#define ai_type_iterate_end
 
#define CALL_PLR_AI_FUNC(_func, _player, ...)
 
#define CALL_FUNC_EACH_AI(_func, ...)
 

Enumerations

enum  incident_type { INCIDENT_ACTION = 0 , INCIDENT_WAR , INCIDENT_LAST }
 

Functions

struct ai_typeai_type_alloc (void)
 
void ai_type_dealloc (void)
 
struct ai_typeget_ai_type (int id)
 
int ai_type_number (const struct ai_type *ai)
 
void init_ai (struct ai_type *ai)
 
int ai_type_get_count (void)
 
const char * ai_name (const struct ai_type *ai)
 
struct ai_typeai_type_by_name (const char *search)
 
const char * ai_type_name_or_fallback (const char *orig_name)
 

Macro Definition Documentation

◆ ai_timer_free

#define ai_timer_free (   ...)    (void) 0

Definition at line 355 of file ai.h.

◆ ai_timer_init

#define ai_timer_init (   ...)    (void) 0

Definition at line 354 of file ai.h.

◆ ai_timer_player_start

#define ai_timer_player_start (   ...)    (void) 0

Definition at line 358 of file ai.h.

◆ ai_timer_player_stop

#define ai_timer_player_stop (   ...)    (void) 0

Definition at line 359 of file ai.h.

◆ ai_timer_start

#define ai_timer_start (   ...)    (void) 0

Definition at line 356 of file ai.h.

◆ ai_timer_stop

#define ai_timer_stop (   ...)    (void) 0

Definition at line 357 of file ai.h.

◆ ai_type_iterate

#define ai_type_iterate (   NAME_ai)
Value:
do { \
int _aii_; \
int _aitotal_ = ai_type_get_count(); \
for (_aii_ = 0; _aii_ < _aitotal_ ; _aii_++) { \
struct ai_type *NAME_ai = get_ai_type(_aii_);
int ai_type_get_count(void)
Definition ai.c:321
struct ai_type * get_ai_type(int id)
Definition ai.c:254
Definition ai.h:50

Definition at line 362 of file ai.h.

◆ ai_type_iterate_end

#define ai_type_iterate_end
Value:
} \
} while (FALSE);
#define FALSE
Definition support.h:47

Definition at line 369 of file ai.h.

◆ CALL_FUNC_EACH_AI

#define CALL_FUNC_EACH_AI (   _func,
  ... 
)
Value:
do { \
ai_type_iterate(_ait_) { \
if (_ait_->funcs._func) { \
ai_timer_start(_ait_); \
_ait_->funcs._func( __VA_ARGS__ ); \
ai_timer_stop(_ait_); \
} \
} while (FALSE)
#define ai_type_iterate_end
Definition ai.h:369

Definition at line 384 of file ai.h.

◆ CALL_PLR_AI_FUNC

#define CALL_PLR_AI_FUNC (   _func,
  _player,
  ... 
)
Value:
do { \
struct player *_plr_ = _player; /* _player expanded just once */ \
if (_plr_ && _plr_->ai && _plr_->ai->funcs._func) { \
ai_timer_player_start(_plr_); \
_plr_->ai->funcs._func( __VA_ARGS__ ); \
ai_timer_player_stop(_plr_); \
} \
} while (FALSE)
struct ai_type::@14 funcs
const struct ai_type * ai
Definition player.h:289

Definition at line 374 of file ai.h.

◆ FC_AI_MOD_CAPSTR

#define FC_AI_MOD_CAPSTR   "+Freeciv-3.1-ai-module"

Definition at line 27 of file ai.h.

Enumeration Type Documentation

◆ incident_type

Enumerator
INCIDENT_ACTION 
INCIDENT_WAR 
INCIDENT_LAST 

Definition at line 45 of file ai.h.

Function Documentation

◆ ai_name()

const char * ai_name ( const struct ai_type ai)

◆ ai_type_alloc()

struct ai_type * ai_type_alloc ( void  )

Return next free ai_type

Definition at line 298 of file ai.c.

Referenced by ai_init().

◆ ai_type_by_name()

struct ai_type * ai_type_by_name ( const char *  search)

Find ai type with given name.

Definition at line 284 of file ai.c.

Referenced by ai_init(), ai_type_name_or_fallback(), create_command_pregame(), and server_create_player().

◆ ai_type_dealloc()

void ai_type_dealloc ( void  )

Free latest ai_type

Definition at line 313 of file ai.c.

Referenced by ai_init().

◆ ai_type_get_count()

int ai_type_get_count ( void  )

Return number of ai types

Definition at line 321 of file ai.c.

Referenced by sg_save_game().

◆ ai_type_name_or_fallback()

const char * ai_type_name_or_fallback ( const char *  orig_name)

Return usable ai type name, if possible. This is either the name given as parameter or some fallback name for it. NULL is returned if no name matches.

Definition at line 340 of file ai.c.

Referenced by server_create_player().

◆ ai_type_number()

int ai_type_number ( const struct ai_type ai)

◆ get_ai_type()

struct ai_type * get_ai_type ( int  id)

Returns ai_type of given id.

Definition at line 254 of file ai.c.

Referenced by ai_type_alloc(), and client_main().

◆ init_ai()

void init_ai ( struct ai_type ai)

Initializes AI structure.

Definition at line 264 of file ai.c.

Referenced by ai_init(), and client_main().