Freeciv-3.2: /fast/freeciv/nightly/S3_2/client/agents/cma_fec.c File Reference

Freeciv-3.2

Loading...
Searching...
No Matches
Data Structures | Macros | Functions | Variables
cma_fec.c File Reference
`#include <string.h>`
`#include "fciconv.h"`
`#include "fcintl.h"`
`#include "log.h"`
`#include "mem.h"`
`#include "support.h"`
`#include "game.h"`
`#include "specialist.h"`
`#include "attribute.h"`
`#include "agents.h"`
`#include "cma_fec.h"`
`#include "speclist.h"`

Go to the source code of this file.

## Data Structures

struct | cma_preset

## Macros

#define | RESULT_COLUMNS 10
#define | BUFFER_SIZE 100
#define | MAX_LEN_PRESET_NAME 80
#define | SPECLIST_TAG preset
#define | SPECLIST_TYPE struct cma_preset
#define | preset_list_iterate(presetlist, ppreset) TYPED_LIST_ITERATE(struct cma_preset, presetlist, ppreset)
#define | preset_list_iterate_end LIST_ITERATE_END

## Functions

static void | city_remove (int city_id)
void | cmafec_init (void)
void | cmafec_free (void)
void | cmafec_set_fe_parameter (struct city *pcity, const struct cm_parameter *const parameter)
void | cmafec_get_fe_parameter (struct city *pcity, struct cm_parameter *dest)
void | cmafec_preset_add (const char *descr_name, struct cm_parameter *pparam)
void | cmafec_preset_remove (int idx)
char * | cmafec_preset_get_descr (int idx)
const struct cm_parameter * | cmafec_preset_get_parameter (int idx)
int | cmafec_preset_get_index_of_parameter (const struct cm_parameter *const parameter)
int | cmafec_preset_num (void)
const char * | cmafec_get_short_descr_of_city (const struct city *pcity)
const char * | cmafec_get_short_descr (const struct cm_parameter *const parameter)
static const char * | get_city_growth_string (struct city *pcity, int surplus)
static const char * | get_prod_complete_string (struct city *pcity, int surplus)
const char * | cmafec_get_result_descr (struct city *pcity, const struct cm_result *result, const struct cm_parameter *const parameter)
void | create_default_cma_presets (void)

## Variables

static struct preset_list * | preset_list = NULL

## Macro Definition Documentation

## ◆ BUFFER_SIZE

#define BUFFER_SIZE 100

Definition at line 46 of file cma_fec.c.

## ◆ MAX_LEN_PRESET_NAME

#define MAX_LEN_PRESET_NAME 80

Definition at line 47 of file cma_fec.c.

## ◆ preset_list_iterate

#define preset_list_iterate | ( |  | presetlist,
|  |  | ppreset
| ) |  | TYPED_LIST_ITERATE(struct cma_preset, presetlist, ppreset)

Definition at line 58 of file cma_fec.c.

## ◆ preset_list_iterate_end

#define preset_list_iterate_end LIST_ITERATE_END

Definition at line 60 of file cma_fec.c.

## ◆ RESULT_COLUMNS

#define RESULT_COLUMNS 10

Definition at line 45 of file cma_fec.c.

## ◆ SPECLIST_TAG

#define SPECLIST_TAG preset

Definition at line 54 of file cma_fec.c.

## ◆ SPECLIST_TYPE

#define SPECLIST_TYPE struct cma_preset

Definition at line 55 of file cma_fec.c.

## Function Documentation

## ◆ city_remove()

static void city_remove | ( | int | city_id | ) |

static

Is called if the game removes a city. It will clear the "fe parameter" attribute to reduce the size of the savegame.

Definition at line 68 of file cma_fec.c.

Referenced by cmafec_init().

## ◆ cmafec_free()

void cmafec_free | ( | void |  | ) |

Free resources allocated for presets system.

Definition at line 94 of file cma_fec.c.

## ◆ cmafec_get_fe_parameter()

void cmafec_get_fe_parameter | ( | struct city * | pcity,
|  | struct cm_parameter * | dest
| ) |  |

Return the front-end parameter for the given city. Returns a dummy parameter if no parameter was set.

Definition at line 115 of file cma_fec.c.

Referenced by button_press_callback(), button_press_callback(), cell_data_func(), cma_active_callback(), cma_preset_add_popup_callback(), create_cma_dialog(), hscale_changed(), popup_city_cma_dialog(), refresh_cma_dialog(), and city_dialog::update_cma_tab().

## ◆ cmafec_get_result_descr()

const char * cmafec_get_result_descr | ( | struct city * | pcity,
|  | const struct cm_result * | result,
|  | const struct cm_parameter *const | parameter
| ) |  |

Return string describing result

Definition at line 322 of file cma_fec.c.

Referenced by refresh_cma_dialog(), and update_city_cma_dialog().

## ◆ cmafec_get_short_descr()

const char * cmafec_get_short_descr | ( | const struct cm_parameter *const | parameter | ) |

Returns the description of the matching preset or "custom" if no preset could be found.

Definition at line 236 of file cma_fec.c.

Referenced by cell_data_func(), cmafec_get_result_descr(), and cmafec_get_short_descr_of_city().

## ◆ cmafec_get_short_descr_of_city()

const char * cmafec_get_short_descr_of_city | ( | const struct city * | pcity | ) |

Return short description of city governor preset

Definition at line 221 of file cma_fec.c.

Referenced by cr_entry_cma(), city_map::paintEvent(), and city_dialog::update_cma_tab().

## ◆ cmafec_init()

void cmafec_init | ( | void |  | ) |

Initialize the presets if there are no presets loaded on startup.

Definition at line 76 of file cma_fec.c.

Referenced by agents_init().

## ◆ cmafec_preset_add()

void cmafec_preset_add | ( | const char * | descr_name,
|  | struct cm_parameter * | pparam
| ) |  |

Adds a preset.

Definition at line 136 of file cma_fec.c.

Referenced by cma_preset_add_popup_callback(), create_default_cma_presets(), ok_save_cma_callback(), and city_dialog::save_cma().

## ◆ cmafec_preset_get_descr()

char * cmafec_preset_get_descr | ( | int | idx | ) |

Returns the indexed preset's description.

Definition at line 169 of file cma_fec.c.

Referenced by append_cma_to_menu_item(), cma_add_preset_callback(), cma_preset_remove(), city_dialog::cma_remove(), cmafec_get_short_descr(), create_governor_menu(), city_widget::gen_cma_labels(), popup_load_del_presets_dialog(), update_cma_preset_list(), and city_dialog::update_cma_tab().

## ◆ cmafec_preset_get_index_of_parameter()

int cmafec_preset_get_index_of_parameter | ( | const struct cm_parameter *const | parameter | ) |

Returns the index of the preset which matches the given parameter. Returns -1 if no preset could be found.

Definition at line 196 of file cma_fec.c.

Referenced by append_cma_to_menu_item(), cell_data_func(), cmafec_get_short_descr(), create_governor_menu(), select_cma_callback(), select_governor_callback(), and city_dialog::update_cma_tab().

## ◆ cmafec_preset_get_parameter()

const struct cm_parameter * cmafec_preset_get_parameter | ( | int | idx | ) |

Returns the indexed preset's parameter.

Definition at line 182 of file cma_fec.c.

Referenced by append_cma_to_menu_item(), cma_activate_preset_callback(), city_dialog::cma_double_clicked(), cma_iterate(), city_dialog::cma_selected(), create_governor_menu(), city_widget::display_list_menu(), governors_iterate(), ld_cma_callback(), popup_load_del_presets_dialog(), select_cma_callback(), select_governor_callback(), and city_dialog::update_sliders().

## ◆ cmafec_preset_num()

int cmafec_preset_num | ( | void |  | ) |

Returns the total number of presets.

Definition at line 213 of file cma_fec.c.

Referenced by append_cma_to_menu_item(), city_dialog::cma_remove(), city_dialog::cma_selected(), cmafec_free(), cmafec_preset_get_descr(), cmafec_preset_get_parameter(), cmafec_preset_remove(), create_governor_menu(), city_widget::gen_cma_labels(), popup_load_del_presets_dialog(), update_city_cma_dialog(), update_cma_preset_list(), city_dialog::update_cma_tab(), and city_dialog::update_sliders().

## ◆ cmafec_preset_remove()

void cmafec_preset_remove | ( | int | idx | ) |

Removes a preset.

Definition at line 153 of file cma_fec.c.

Referenced by cma_preset_remove_response(), city_dialog::cma_remove(), cmafec_free(), ld_cma_callback(), and popup_load_del_presets_dialog().

## ◆ cmafec_set_fe_parameter()

void cmafec_set_fe_parameter | ( | struct city * | pcity,
|  | const struct cm_parameter *const | parameter
| ) |  |

Sets the front-end parameter.

Definition at line 105 of file cma_fec.c.

Referenced by cma_activate_preset_callback(), cmafec_get_fe_parameter(), factor_horiz_cma_callback(), hscale_changed(), ld_cma_callback(), min_horiz_cma_callback(), popup_load_del_presets_dialog(), and toggle_cma_celebrating_callback().

## ◆ create_default_cma_presets()

void create_default_cma_presets | ( | void |  | ) |

Create default cma presets for a new user (or without configuration file)

Definition at line 384 of file cma_fec.c.

## ◆ get_city_growth_string()

static const char * get_city_growth_string | ( | struct city * | pcity,
|  | int | surplus
| ) |  |

static

Return string describing when city is assumed to grow.

Definition at line 251 of file cma_fec.c.

Referenced by cmafec_get_result_descr().

## ◆ get_prod_complete_string()

static const char * get_prod_complete_string | ( | struct city * | pcity,
|  | int | surplus
| ) |  |

static

Return string describing when city is assumed to finish current production

Definition at line 285 of file cma_fec.c.

Referenced by cmafec_get_result_descr().

## Variable Documentation

## ◆ preset_list

struct preset_list* preset_list = NULL

static

Definition at line 62 of file cma_fec.c.

Referenced by cmafec_free(), cmafec_init(), cmafec_preset_add(), cmafec_preset_get_descr(), cmafec_preset_get_index_of_parameter(), cmafec_preset_get_parameter(), cmafec_preset_num(), and cmafec_preset_remove().