Freeciv-3.1
Loading...
Searching...
No Matches
taimsg.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18/* ai/threaded */
19#include "taiplayer.h"
20
21#include "taimsg.h"
22
23/**********************************************************************/
26void tai_send_msg(enum taimsgtype type, struct player *pplayer,
27 void *data)
28{
29 struct tai_msg *msg;
30
31 if (!tai_thread_running()) {
32 /* No player thread to send messages to */
33 return;
34 }
35
36 msg = fc_malloc(sizeof(*msg));
37
38 msg->type = type;
39 msg->plr = pplayer;
40 msg->data = data;
41
42 tai_msg_to_thr(msg);
43}
44
45/**********************************************************************/
48void tai_send_req(enum taireqtype type, struct player *pplayer,
49 void *data)
50{
51 struct tai_req *req = fc_malloc(sizeof(*req));
52
53 req->type = type;
54 req->plr = pplayer;
55 req->data = data;
56
58}
59
60/**********************************************************************/
63void tai_first_activities(struct ai_type *ait, struct player *pplayer)
64{
65 tai_send_msg(TAI_MSG_FIRST_ACTIVITIES, pplayer, NULL);
66}
67
68/**********************************************************************/
71void tai_phase_finished(struct ai_type *ait, struct player *pplayer)
72{
73 tai_send_msg(TAI_MSG_PHASE_FINISHED, pplayer, NULL);
74}
GType type
Definition repodlgs.c:1312
#define fc_malloc(sz)
Definition mem.h:34
Definition ai.h:50
struct player * plr
Definition taimsg.h:35
enum taimsgtype type
Definition taimsg.h:34
void * data
Definition taimsg.h:36
struct player * plr
Definition taimsg.h:42
enum taireqtype type
Definition taimsg.h:41
void * data
Definition taimsg.h:43
void tai_send_req(enum taireqtype type, struct player *pplayer, void *data)
Definition taimsg.c:48
void tai_send_msg(enum taimsgtype type, struct player *pplayer, void *data)
Definition taimsg.c:26
void tai_phase_finished(struct ai_type *ait, struct player *pplayer)
Definition taimsg.c:71
void tai_first_activities(struct ai_type *ait, struct player *pplayer)
Definition taimsg.c:63
void tai_msg_to_thr(struct tai_msg *msg)
Definition taiplayer.c:274
bool tai_thread_running(void)
Definition taiplayer.c:295
void tai_req_from_thr(struct tai_req *req)
Definition taiplayer.c:285