Freeciv-3.1
Loading...
Searching...
No Matches
Data Structures | Enumerations | Functions | Variables
taiplayer.c File Reference
#include "log.h"
#include "ai.h"
#include "city.h"
#include "game.h"
#include "unit.h"
#include "infracache.h"
#include "aiplayer.h"
#include "taicity.h"
#include "taiplayer.h"

Go to the source code of this file.

Data Structures

struct  tai_thr
 

Enumerations

enum  tai_abort_msg_class { TAI_ABORT_EXIT , TAI_ABORT_PHASE_END , TAI_ABORT_NONE }
 

Functions

static enum tai_abort_msg_class tai_check_messages (struct ai_type *ait)
 
void tai_init_threading (void)
 
static void tai_thread_start (void *arg)
 
void tai_player_alloc (struct ai_type *ait, struct player *pplayer)
 
void tai_player_free (struct ai_type *ait, struct player *pplayer)
 
void tai_control_gained (struct ai_type *ait, struct player *pplayer)
 
void tai_control_lost (struct ai_type *ait, struct player *pplayer)
 
void tai_refresh (struct ai_type *ait, struct player *pplayer)
 
void tai_msg_to_thr (struct tai_msg *msg)
 
void tai_req_from_thr (struct tai_req *req)
 
bool tai_thread_running (void)
 

Variables

struct tai_thr thrai
 

Enumeration Type Documentation

◆ tai_abort_msg_class

Enumerator
TAI_ABORT_EXIT 
TAI_ABORT_PHASE_END 
TAI_ABORT_NONE 

Definition at line 42 of file taiplayer.c.

Function Documentation

◆ tai_check_messages()

static enum tai_abort_msg_class tai_check_messages ( struct ai_type ait)
static

Handle messages from message queue.

Definition at line 97 of file taiplayer.c.

Referenced by tai_check_messages(), and tai_thread_start().

◆ tai_control_gained()

void tai_control_gained ( struct ai_type ait,
struct player pplayer 
)

We actually control the player

Definition at line 196 of file taiplayer.c.

Referenced by twai_control_gained().

◆ tai_control_lost()

void tai_control_lost ( struct ai_type ait,
struct player pplayer 
)

We no longer control the player

Definition at line 217 of file taiplayer.c.

Referenced by twai_control_lost().

◆ tai_init_threading()

void tai_init_threading ( void  )

Initialize ai thread.

Definition at line 63 of file taiplayer.c.

Referenced by tai_init_self().

◆ tai_msg_to_thr()

void tai_msg_to_thr ( struct tai_msg msg)

Send message to thread. Be sure that thread is running so that messages are not just piling up to the list without anybody reading them.

Definition at line 274 of file taiplayer.c.

Referenced by tai_send_msg().

◆ tai_player_alloc()

void tai_player_alloc ( struct ai_type ait,
struct player pplayer 
)

Initialize player for use with threaded AI.

Definition at line 167 of file taiplayer.c.

Referenced by twai_player_alloc().

◆ tai_player_free()

void tai_player_free ( struct ai_type ait,
struct player pplayer 
)

Free player from use with threaded AI.

Definition at line 180 of file taiplayer.c.

Referenced by twai_player_free().

◆ tai_refresh()

void tai_refresh ( struct ai_type ait,
struct player pplayer 
)

Check for messages sent by player thread

Definition at line 239 of file taiplayer.c.

Referenced by twai_refresh().

◆ tai_req_from_thr()

void tai_req_from_thr ( struct tai_req req)

Thread sends message.

Definition at line 285 of file taiplayer.c.

Referenced by tai_send_req().

◆ tai_thread_running()

bool tai_thread_running ( void  )

Return whether player thread is running

Definition at line 295 of file taiplayer.c.

Referenced by tai_send_msg().

◆ tai_thread_start()

static void tai_thread_start ( void *  arg)
static

This is main function of ai thread.

Definition at line 73 of file taiplayer.c.

Referenced by tai_control_gained().

Variable Documentation

◆ thrai

struct tai_thr thrai