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)
 
charcmafec_preset_get_descr (int idx)
 
const struct cm_parametercmafec_preset_get_parameter (int idx)
 
int cmafec_preset_get_index_of_parameter (const struct cm_parameter *const parameter)
 
int cmafec_preset_num (void)
 
const charcmafec_get_short_descr_of_city (const struct city *pcity)
 
const charcmafec_get_short_descr (const struct cm_parameter *const parameter)
 
static const charget_city_growth_string (struct city *pcity, int surplus)
 
static const charget_prod_complete_string (struct city *pcity, int surplus)
 
const charcmafec_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 
)

◆ cmafec_preset_get_descr()

char * cmafec_preset_get_descr ( int  idx)

◆ 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)

◆ cmafec_preset_num()

int cmafec_preset_num ( void  )

◆ cmafec_preset_remove()

void cmafec_preset_remove ( int  idx)

◆ cmafec_set_fe_parameter()

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

◆ 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