14 #include <fc_config.h>
132 info->
id = pcity->
id;
165 if (msgtype == TEXAI_MSG_CITY_CREATED) {
170 pcity->
id = info->
id;
178 pcity->
owner = pplayer;
180 qCritical(
"Tex: requested change on city id %d that's not known.",
202 info->
id = pcity->
id;
222 qCritical(
"Tex: requested removal of city id %d that's not known.",
236 info->
id = punit->
id;
272 if (msgtype == TEXAI_MSG_UNIT_CREATED) {
276 punit->
id = info->
id;
279 unit_list_prepend(ptile->
units, punit);
280 unit_list_prepend(plr_data->
units, punit);
281 }
else if (msgtype == TEXAI_MSG_UNIT_MOVED) {
282 struct tile *old_tile;
286 old_tile = punit->
tile;
287 if (old_tile != ptile) {
288 unit_list_remove(old_tile->
units, punit);
289 unit_list_prepend(ptile->
units, punit);
292 fc_assert(msgtype == TEXAI_MSG_UNIT_CHANGED);
310 info->
id = punit->
id;
328 unit_list_remove(punit->
tile->
units, punit);
329 unit_list_remove(plr_data->
units, punit);
333 qCritical(
"Tex: requested removal of unit id %d that's not known.",
347 info->
id = punit->
id;
364 unit_list_remove(punit->
tile->
units, punit);
365 unit_list_prepend(ptile->
units, punit);
369 qCritical(
"Tex: requested moving of unit id %d that's not known.",
struct player * city_owner(const struct city *pcity)
Return the owner of the city.
struct tile * city_tile(const struct city *pcity)
Return the tile location of the city.
void destroy_city_virtual(struct city *pcity)
Removes the virtual skeleton of a city.
struct city * create_city_virtual(struct player *pplayer, struct tile *ptile, const char *name)
Create virtual skeleton for a city.
void idex_free(struct world *iworld)
Free the hashs.
void idex_register_unit(struct world *iworld, struct unit *punit)
Register a unit into idex, with current punit->id.
struct unit * idex_lookup_unit(struct world *iworld, int id)
Lookup unit with given id.
void idex_unregister_city(struct world *iworld, struct city *pcity)
Remove a city from idex, with current pcity->id.
void idex_init(struct world *iworld)
idex = ident index: a lookup table for quick mapping of unit and city id values to unit and city poin...
struct city * idex_lookup_city(struct world *iworld, int id)
Lookup city with given id.
void idex_unregister_unit(struct world *iworld, struct unit *punit)
Remove a unit from idex, with current punit->id.
void idex_register_city(struct world *iworld, struct city *pcity)
Register a city into idex, with current pcity->id.
void adv_city_free(struct city *pcity)
Free advisors related city data.
void adv_city_alloc(struct city *pcity)
Allocate advisors related city data.
#define fc_assert(condition)
void map_free(struct civ_map *fmap)
Frees the allocated memory of the map.
void map_allocate(struct civ_map *amap)
Allocate space for map, and initialise the tiles.
struct tile * index_to_tile(const struct civ_map *imap, int mindex)
Return the tile for the given index position.
void map_init(struct civ_map *imap, bool server_side)
Put some sensible values into the map structure.
void * player_ai_data(const struct player *pplayer, const struct ai_type *ai)
Return pointer to ai data of given player and ai type.
struct player * player_by_number(const int player_id)
Return struct player pointer for the given player index.
int player_number(const struct player *pplayer)
Return the player index/number/id.
const struct unit_type * utype
struct ai_type * texai_get_self(void)
Get pointer to ai type of the tex ai.
void texai_send_msg(enum texaimsgtype type, struct player *pplayer, void *data)
Construct and send message to player thread.
bool texai_thread_running(void)
Return whether player thread is running.
static void texai_city_update(struct city *pcity, enum texaimsgtype msgtype)
Send city information to the thread.
void texai_city_info_recv(void *data, enum texaimsgtype msgtype)
Receive city update to the thread.
void texai_city_created(struct city *pcity)
New city has been added to the main map.
void texai_city_destruction_recv(void *data)
Receive city destruction to the thread.
void texai_city_destroyed(struct city *pcity)
City has been removed from the main map.
void texai_unit_destroyed(struct unit *punit)
Unit has been removed from the main map.
static void texai_unit_update(struct unit *punit, enum texaimsgtype msgtype)
Send unit information to the thread.
struct civ_map * texai_map_get(void)
Return tex worldmap.
void texai_tile_info_recv(void *data)
Receive tile update to the thread.
void texai_map_close(void)
Free resources allocated for texai world map.
void texai_unit_changed(struct unit *punit)
Unit (potentially) changed in main map.
void texai_world_init(void)
Initialize world object for texai.
void texai_tile_info(struct tile *ptile)
Tile info updated on main map.
void texai_city_changed(struct city *pcity)
City on main map has (potentially) changed.
void texai_unit_move_seen(struct unit *punit)
Unit has moved in the main map.
void texai_unit_info_recv(void *data, enum texaimsgtype msgtype)
Receive unit update to the thread.
void texai_unit_created(struct unit *punit)
New unit has been added to the main map.
void texai_unit_moved_recv(void *data)
Receive unit move to the thread.
void texai_map_init(void)
Initialize world map for texai.
static struct world texai_world
void texai_world_close(void)
Free resources allocated for texai world object.
void texai_unit_destruction_recv(void *data)
Receive unit destruction to the thread.
struct city * texai_map_city(int city_id)
Get city from the tex map.
void tile_set_worked(struct tile *ptile, struct city *pcity)
Set the city/worker on the tile (may be nullptr).
void unit_virtual_destroy(struct unit *punit)
Free the memory used by virtual unit.
struct unit * unit_virtual_create(struct player *pplayer, struct city *pcity, const struct unit_type *punittype, int veteran_level)
Create a virtual unit skeleton.
void unit_tile_set(struct unit *punit, struct tile *ptile)
Set the tile location of the unit.
const struct unit_type * unit_type_get(const struct unit *punit)
Return the unit type for this unit.
struct unit_type * utype_by_number(const Unit_type_id id)
Return a pointer for the unit type struct for the given unit type id.
Unit_type_id utype_number(const struct unit_type *punittype)
Return the unit type index.