Freeciv-3.2: /fast/freeciv/nightly/S3_2/server/advisors/infracache.c File Reference

Freeciv-3.2

Loading...
Searching...
No Matches
Data Structures | Functions
infracache.c File Reference
`#include "city.h"`
`#include "game.h"`
`#include "map.h"`
`#include "player.h"`
`#include "tile.h"`
`#include "maphand.h"`
`#include "advbuilding.h"`
`#include "autosettlers.h"`
`#include "infracache.h"`

Go to the source code of this file.

## Data Structures

struct | worker_activity_cache

## Functions

static adv_want | adv_calc_cultivate (const struct city *pcity, const struct tile *ptile)
static adv_want | adv_calc_plant (const struct city *pcity, const struct tile *ptile)
static adv_want | adv_calc_transform (const struct city *pcity, const struct tile *ptile)
static adv_want | adv_calc_extra (const struct city *pcity, const struct tile *ptile, const struct extra_type *pextra)
static adv_want | adv_calc_rmextra (const struct city *pcity, const struct tile *ptile, const struct extra_type *pextra)
void | initialize_infrastructure_cache (struct player *pplayer)
adv_want | city_tile_value (const struct city *pcity, const struct tile *ptile, int foodneed, int prodneed)
void | adv_city_worker_act_set (struct city *pcity, int city_tile_index, enum unit_activity act_id, adv_want value)
adv_want | adv_city_worker_act_get (const struct city *pcity, int city_tile_index, enum unit_activity act_id)
void | adv_city_worker_extra_set (struct city *pcity, int city_tile_index, const struct extra_type *pextra, int value)
void | adv_city_worker_rmextra_set (struct city *pcity, int city_tile_index, const struct extra_type *pextra, int value)
int | adv_city_worker_extra_get (const struct city *pcity, int city_tile_index, const struct extra_type *pextra)
int | adv_city_worker_rmextra_get (const struct city *pcity, int city_tile_index, const struct extra_type *pextra)
void | adv_city_update (struct city *pcity)
void | adv_city_alloc (struct city *pcity)
void | adv_city_free (struct city *pcity)

## Function Documentation

## ◆ adv_calc_cultivate()

static adv_want adv_calc_cultivate | ( | const struct city * | pcity,
|  | const struct tile * | ptile
| ) |  |

static

Calculate the benefit of cultivating the given tile.

The return value is the goodness of the tile after the cultivating. This should be compared to the goodness of the tile currently. (see city_tile_value(); note that this depends on the AI's weighting values).

Definition at line 62 of file infracache.c.

Referenced by initialize_infrastructure_cache().

## ◆ adv_calc_extra()

static adv_want adv_calc_extra | ( | const struct city * | pcity,
|  | const struct tile * | ptile,
|  | const struct extra_type * | pextra
| ) |  |

static

Calculate the benefit of building an extra at the given tile.

The return value is the goodness of the tile after the extra is built. This should be compared to the goodness of the tile currently. (see city_tile_value(); note that this depends on the AI's weighting values).

This function does not calculate the benefit of being able to quickly move units (i.e., of connecting the civilization). See road_bonus() for that calculation.

Definition at line 188 of file infracache.c.

Referenced by initialize_infrastructure_cache().

## ◆ adv_calc_plant()

static adv_want adv_calc_plant | ( | const struct city * | pcity,
|  | const struct tile * | ptile
| ) |  |

static

Calculate the benefit of planting to the given tile.

The return value is the goodness of the tile after the planting. This should be compared to the goodness of the tile currently. (see city_tile_value(); note that this depends on the AI's weighting values).

Definition at line 102 of file infracache.c.

Referenced by initialize_infrastructure_cache().

## ◆ adv_calc_rmextra()

static adv_want adv_calc_rmextra | ( | const struct city * | pcity,
|  | const struct tile * | ptile,
|  | const struct extra_type * | pextra
| ) |  |

static

Calculate the benefit of removing an extra from the given tile.

The return value is the goodness of the tile after the extra is removed. This should be compared to the goodness of the tile currently. (see city_tile_value(); note that this depends on the AI's weighting values).

Definition at line 223 of file infracache.c.

Referenced by initialize_infrastructure_cache().

## ◆ adv_calc_transform()

static adv_want adv_calc_transform | ( | const struct city * | pcity,
|  | const struct tile * | ptile
| ) |  |

static

Calculate the benefit of transforming the given tile.

The return value is the goodness of the tile after the transform. This should be compared to the goodness of the tile currently. (see city_tile_value(); note that this depends on the AI's weighting values).

Definition at line 142 of file infracache.c.

Referenced by initialize_infrastructure_cache().

## ◆ adv_city_alloc()

void adv_city_alloc | ( | struct city * | pcity | ) |

Allocate advisors related city data

Definition at line 488 of file infracache.c.

Referenced by create_city(), sg_load_player_cities(), sg_load_player_cities(), and texai_city_info_recv().

## ◆ adv_city_free()

void adv_city_free | ( | struct city * | pcity | ) |

Free advisors related city data

Definition at line 501 of file infracache.c.

Referenced by remove_city(), server_game_free(), sg_load_player_cities(), sg_load_player_cities(), and texai_city_destruction_recv().

## ◆ adv_city_update()

void adv_city_update | ( | struct city * | pcity | ) |

Update the memory allocated for AI city handling.

Definition at line 462 of file infracache.c.

Referenced by adv_city_alloc(), adv_city_worker_act_set(), adv_city_worker_extra_set(), adv_city_worker_rmextra_set(), and city_map_update_radius_sq().

## ◆ adv_city_worker_act_get()

adv_want adv_city_worker_act_get | ( | const struct city * | pcity,
|  | int | city_tile_index,
|  | enum unit_activity | act_id
| ) |  |

Return the value for activity 'doing' on tile 'city_tile_index' of city 'pcity'.

Definition at line 359 of file infracache.c.

Referenced by settler_evaluate_improvements(), and texai_tile_worker_task_select().

## ◆ adv_city_worker_act_set()

void adv_city_worker_act_set | ( | struct city * | pcity,
|  | int | city_tile_index,
|  | enum unit_activity | act_id,
|  | adv_want | value
| ) |  |

Set the value for activity 'doing' on tile 'city_tile_index' of city 'pcity'.

Definition at line 333 of file infracache.c.

Referenced by initialize_infrastructure_cache().

## ◆ adv_city_worker_extra_get()

int adv_city_worker_extra_get | ( | const struct city * | pcity,
|  | int | city_tile_index,
|  | const struct extra_type * | pextra
| ) |  |

Return the value for extra on tile 'city_tile_index' of city 'pcity'.

Definition at line 429 of file infracache.c.

Referenced by settler_evaluate_improvements(), and texai_tile_worker_task_select().

## ◆ adv_city_worker_extra_set()

void adv_city_worker_extra_set | ( | struct city * | pcity,
|  | int | city_tile_index,
|  | const struct extra_type * | pextra,
|  | int | value
| ) |  |

Set the value for extra on tile 'city_tile_index' of city 'pcity'.

Definition at line 377 of file infracache.c.

Referenced by initialize_infrastructure_cache().

## ◆ adv_city_worker_rmextra_get()

int adv_city_worker_rmextra_get | ( | const struct city * | pcity,
|  | int | city_tile_index,
|  | const struct extra_type * | pextra
| ) |  |

Return the value for extra removal on tile 'city_tile_index' of city 'pcity'.

Definition at line 446 of file infracache.c.

Referenced by settler_evaluate_improvements(), and texai_tile_worker_task_select().

## ◆ adv_city_worker_rmextra_set()

void adv_city_worker_rmextra_set | ( | struct city * | pcity,
|  | int | city_tile_index,
|  | const struct extra_type * | pextra,
|  | int | value
| ) |  |

Set the value for extra removal on tile 'city_tile_index' of city 'pcity'.

Definition at line 403 of file infracache.c.

Referenced by initialize_infrastructure_cache().

## ◆ city_tile_value()

adv_want city_tile_value | ( | const struct city * | pcity,
|  | const struct tile * | ptile,
|  | int | foodneed,
|  | int | prodneed
| ) |  |

Returns a measure of goodness of a tile to pcity.

FIXME: foodneed and prodneed are always 0.

Definition at line 302 of file infracache.c.

Referenced by adv_calc_cultivate(), adv_calc_extra(), adv_calc_plant(), adv_calc_rmextra(), adv_calc_transform(), settler_evaluate_improvements(), and texai_tile_worker_task_select().

## ◆ initialize_infrastructure_cache()

void initialize_infrastructure_cache | ( | struct player * | pplayer | ) |

Do all tile improvement calculations and cache them for later.

These values are used in settler_evaluate_improvements() so this function must be called before doing that. Currently this is only done when handling auto-settlers or when the AI contemplates building worker units.

Definition at line 250 of file infracache.c.

Referenced by auto_settlers_player(), dai_do_build_city(), dai_manage_cities(), and texai_check_messages().