Freeciv-3.2: /fast/freeciv/nightly/S3_2/common/counters.c File Reference

Freeciv-3.2

Loading...
Searching...
No Matches
Functions | Variables
counters.c File Reference
`#include <stdlib.h>`
`#include "game.h"`
`#include "fcintl.h"`
`#include "counters.h"`

Go to the source code of this file.

## Functions

void | counters_init (void)
void | counters_free (void)
int | counters_get_city_counters_count (void)
struct counter * | counter_by_id (int id)
void | attach_city_counter (struct counter *counter)
int | counter_id (struct counter *pcount)
struct counter * | counter_by_rule_name (const char *name)
struct counter * | counter_by_translated_name (const char *name)
const char * | counter_name_translation (const struct counter *counter)
const char * | counter_rule_name (struct counter *pcount)
int | counter_index (const struct counter *pcount)
struct counter * | counter_by_index (int index, enum counter_target target)

## Variables

static struct counter | counters [MAX_COUNTERS]
static struct counter * | counters_city [MAX_COUNTERS]
static int | number_city_counters

## Function Documentation

## ◆ attach_city_counter()

void attach_city_counter | ( | struct counter * | counter | ) |

Attaching given counter type to array containing counter type related to cities. Counter must be present in array for each counter in game, but we do not check this.

Definition at line 94 of file counters.c.

Referenced by tab_counter::add_now(), handle_ruleset_counter(), and load_ruleset_game().

## ◆ counter_by_id()

struct counter * counter_by_id | ( | int | id | ) |

Return counter by given id

Definition at line 82 of file counters.c.

Referenced by tab_counter::add_now(), api_find_counter(), boot_help_texts(), handle_ruleset_counter(), load_game_names(), load_ruleset_game(), and universal_by_number().

## ◆ counter_by_index()

struct counter * counter_by_index | ( | int | index,
|  | enum counter_target | target
| ) |  |

Return counter by given index

Definition at line 183 of file counters.c.

Referenced by create_city_virtual(), sg_save_counters(), and universal_value_initial().

## ◆ counter_by_rule_name()

struct counter * counter_by_rule_name | ( | const char * | name | ) |

Search for counter by rule name (return matched counter if found or NULL)

Definition at line 115 of file counters.c.

Referenced by api_find_counter_by_name(), tab_counter::select_counter(), sg_load_counters(), and universal_value_from_str().

## ◆ counter_by_translated_name()

struct counter * counter_by_translated_name | ( | const char * | name | ) |

Search for counter by translated name (return matched counter if found or NULL)

Definition at line 136 of file counters.c.

## ◆ counter_id()

int counter_id | ( | struct counter * | pcount | ) |

Return id of a given counter

Definition at line 105 of file counters.c.

Referenced by api_find_counter(), tolua_game_find_counter01(), and universal_number().

## ◆ counter_index()

int counter_index | ( | const struct counter * | pcount | ) |

Return index in global counter's array

Definition at line 174 of file counters.c.

Referenced by api_counter_increase(), api_counter_zero(), api_methods_counter_city_get(), is_counter_req_active(), tab_counter::refresh(), and sg_load_counters().

## ◆ counter_name_translation()

const char * counter_name_translation | ( | const struct counter * | counter | ) |

Returns translated name of given counter

Definition at line 157 of file counters.c.

Referenced by api_methods_counter_name_translation(), boot_help_texts(), counter_by_translated_name(), universal_name_translation(), and worklist_item_postpone_req_vec().

## ◆ counter_rule_name()

const char * counter_rule_name | ( | struct counter * | pcount | ) |

Return rule name of a given counter

Definition at line 165 of file counters.c.

Referenced by api_methods_counter_rule_name(), counter_by_rule_name(), tab_counter::delete_now(), tab_counter::edit_effects(), tab_counter::name_given(), tab_counter::refresh(), req_text_insert(), sg_save_counters(), universal_kind_values(), and universal_rule_name().

## ◆ counters_free()

void counters_free | ( | void |  | ) |

Free resources allocated by counters system

Definition at line 51 of file counters.c.

Referenced by game_ruleset_free().

## ◆ counters_get_city_counters_count()

int counters_get_city_counters_count | ( | void |  | ) |

Return number of city counters.

Definition at line 74 of file counters.c.

Referenced by tab_counter::add_now(), city_counters_refresh(), create_city_virtual(), handle_city_update_counters(), handle_ruleset_counter(), tab_counter::initialize_new_counter(), sg_save_counters(), and universal_value_initial().

## ◆ counters_init()

void counters_init | ( | void |  | ) |

Initialize counters system

Definition at line 40 of file counters.c.

Referenced by game_ruleset_init().

## Variable Documentation

## ◆ counters

struct counter counters[MAX_COUNTERS]

static

Definition at line 31 of file counters.c.

Referenced by counter_by_id(), counter_by_rule_name(), counter_by_translated_name(), counter_id(), counters_free(), and receive_packet_city_update_counters_100().

## ◆ counters_city

struct counter* counters_city[MAX_COUNTERS]

static

Definition at line 34 of file counters.c.

Referenced by attach_city_counter(), and counter_by_index().

## ◆ number_city_counters

int number_city_counters

static

Definition at line 35 of file counters.c.

Referenced by attach_city_counter(), counters_free(), counters_get_city_counters_count(), and counters_init().