14 #include <fc_config.h>
16 #include <QMutexLocker>
73 bool finished =
false;
110 case TAI_MSG_FIRST_ACTIVITIES:
138 case TAI_MSG_PHASE_FINISHED:
141 case TAI_MSG_THR_EXIT:
145 qCritical(
"Illegal message type %s (%d) for threaded ai!",
146 taimsgtype_name(msg->
type), msg->
type);
150 if (new_abort < ret_abort) {
151 ret_abort = new_abort;
187 if (player_data != NULL) {
190 player_data =
nullptr;
211 thrai.
ait->start(QThread::NormalPriority);
222 log_debug(
"%s no longer under threaded AI (%d)", pplayer->
name,
254 case TAI_REQ_WORKER_TASK:
257 case TAI_REQ_TURN_DONE:
void dai_data_init(struct ai_type *ait, struct player *pplayer)
Initialize ai data structure.
void dai_data_close(struct ai_type *ait, struct player *pplayer)
Deinitialize ai data structure.
#define city_list_iterate_safe(citylist, _city)
#define city_list_iterate_safe_end
void set_func(void(tfunc)(void *), void *tdata)
void initialize_infrastructure_cache(struct player *pplayer)
Do all tile improvement calculations and cache them for later.
#define log_debug(message,...)
void * player_ai_data(const struct player *pplayer, const struct ai_type *ai)
Return pointer to ai data of given player and ai type.
void player_set_ai_data(struct player *pplayer, const struct ai_type *ai, void *data)
Attach ai data to player.
struct civ_game::@28::@32 server
struct city_list * cities
struct taimsg_list * msglist
struct taireq_list * reqlist
struct tai_reqs reqs_from
void tai_city_worker_requests_create(struct ai_type *ait, struct player *pplayer, struct city *pcity)
Create worker request for the city.
void tai_req_worker_task_rcv(struct tai_req *req)
Receive message from thread to main thread.
void tai_send_req(enum taireqtype type, struct player *pplayer, void *data)
Construct and send request from player thread.
void tai_send_msg(enum taimsgtype type, struct player *pplayer, void *data)
Construct and send message to player thread.
void tai_msg_to_thr(struct tai_msg *msg)
Send message to thread.
bool tai_thread_running(void)
Return whether player thread is running.
void tai_control_gained(struct ai_type *ait, struct player *pplayer)
We actually control the player.
void tai_control_lost(struct ai_type *ait, struct player *pplayer)
We no longer control the player.
void tai_player_alloc(struct ai_type *ait, struct player *pplayer)
Initialize player for use with threaded AI.
void tai_player_free(struct ai_type *ait, struct player *pplayer)
Free player from use with threaded AI.
void tai_init_threading(void)
Initialize ai thread.
void tai_req_from_thr(struct tai_req *req)
Thread sends message.
void tai_refresh(struct ai_type *ait, struct player *pplayer)
Check for messages sent by player thread.
static enum tai_abort_msg_class tai_check_messages(struct ai_type *ait)
Handle messages from message queue.
static void tai_thread_start(void *arg)
This is main function of ai thread.