Freeciv-3.3
Loading...
Searching...
No Matches
Data Structures | Macros | Functions | Variables
tech.c File Reference
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "fcintl.h"
#include "iterator.h"
#include "log.h"
#include "mem.h"
#include "shared.h"
#include "string_vector.h"
#include "support.h"
#include "game.h"
#include "research.h"
#include "tech.h"

Go to the source code of this file.

Data Structures

struct  advance_req_iter
 
struct  advance_root_req_iter
 

Macros

#define ADVANCE_REQ_ITER(it)   ((struct advance_req_iter *) it)
 
#define ADVANCE_ROOT_REQ_ITER(it)   ((struct advance_root_req_iter *) it)
 

Functions

const struct advanceadvance_array_last (void)
 
Tech_type_id advance_count_real (void)
 
Tech_type_id advance_index (const struct advance *padvance)
 
Tech_type_id advance_number (const struct advance *padvance)
 
struct advanceadvance_by_number (const Tech_type_id atype)
 
Tech_type_id advance_required (const Tech_type_id tech, enum tech_req require)
 
struct advanceadvance_requires (const struct advance *padvance, enum tech_req require)
 
struct advancevalid_advance (struct advance *padvance)
 
struct advancevalid_advance_by_number (const Tech_type_id id)
 
struct advanceadvance_by_translated_name (const char *name)
 
struct advanceadvance_by_rule_name (const char *name)
 
bool advance_has_flag (Tech_type_id tech, enum tech_flag_id flag)
 
void techs_precalc_data (void)
 
bool is_future_tech (Tech_type_id tech)
 
bool is_regular_advance (struct advance *padvance)
 
const charadvance_name_translation (const struct advance *padvance)
 
const charadvance_rule_name (const struct advance *padvance)
 
void tech_classes_init (void)
 
struct tech_classtech_class_by_number (const int idx)
 
const chartech_class_name_translation (const struct tech_class *ptclass)
 
const chartech_class_rule_name (const struct tech_class *ptclass)
 
struct tech_classtech_class_by_rule_name (const char *name)
 
void user_tech_flags_init (void)
 
void user_tech_flags_free (void)
 
void set_user_tech_flag_name (enum tech_flag_id id, const char *name, const char *helptxt)
 
const chartech_flag_id_name_cb (enum tech_flag_id flag)
 
const chartech_flag_helptxt (enum tech_flag_id id)
 
bool techs_have_fixed_costs (void)
 
void techs_init (void)
 
static void tech_free (Tech_type_id tech)
 
void techs_free (void)
 
size_t advance_req_iter_sizeof (void)
 
static voidadvance_req_iter_get (const struct iterator *it)
 
static void advance_req_iter_next (struct iterator *it)
 
static bool advance_req_iter_valid (const struct iterator *it)
 
struct iteratoradvance_req_iter_init (struct advance_req_iter *it, const struct advance *goal)
 
size_t advance_root_req_iter_sizeof (void)
 
static voidadvance_root_req_iter_get (const struct iterator *it)
 
static bool advance_root_req_iter_valid (const struct iterator *it)
 
static void advance_root_req_iter_next (struct iterator *it)
 
struct iteratoradvance_root_req_iter_init (struct advance_root_req_iter *it, const struct advance *goal)
 

Variables

struct advance advances [A_ARRAY_SIZE]
 
struct tech_class tech_classes [MAX_NUM_TECH_CLASSES]
 
static struct user_flag user_tech_flags [MAX_NUM_USER_TECH_FLAGS]
 

Macro Definition Documentation

◆ ADVANCE_REQ_ITER

#define ADVANCE_REQ_ITER (   it)    ((struct advance_req_iter *) it)

Definition at line 44 of file tech.c.

◆ ADVANCE_ROOT_REQ_ITER

#define ADVANCE_ROOT_REQ_ITER (   it)    ((struct advance_root_req_iter *) it)

Definition at line 52 of file tech.c.

Function Documentation

◆ advance_array_last()

const struct advance * advance_array_last ( void  )

Return the last item of advances/technologies.

Definition at line 67 of file tech.c.

◆ advance_by_number()

struct advance * advance_by_number ( const Tech_type_id  atype)

Return the advance for the given advance index.

Definition at line 107 of file tech.c.

Referenced by tab_tech::add_now(), advance_has_flag(), help_widget::anchor_clicked(), api_edit_give_technology(), api_find_tech_type(), api_methods_player_researching(), boot_help_texts(), client_diplomacy_clause_string(), create_select_tech_icon(), create_tech_info(), create_tech_tree(), research_diagram::create_tooltip_help(), dai_goldequiv_clause(), dai_manage_government(), dai_manage_tech(), dai_select_tech(), do_tech_parasite_effects(), draw_reqtree(), found_new_tech(), get_tooltip_unit(), handle_diplomacy_accept_treaty_req(), handle_ruleset_tech(), help_hyperlink_callback(), help_tech_tree_activated_callback(), help_update_tech(), helptext_advance(), helptext_extra(), helptext_nation(), init_tech(), tab_tech::initialize_new_tech(), load_ruleset_techs(), research_diagram::mouseMoveEvent(), node_rectangle_minimum_size(), popup_change_research_dialog(), popup_change_research_goal_dialog(), popup_diplomatic_objects(), real_science_report_dialog_update(), real_tech_log(), research_advance_name(), research_get_reachable(), research_get_root_reqs_known(), research_tech_lost(), research_update(), sanity_check_ruleset_data(), save_tech_list(), save_techs_ruleset(), side_right_click_science(), spy_steal_popup_shared(), steal_a_tech(), tech_researched(), technology_save(), universal_by_number(), universal_value_initial(), unpack_tech_req(), update_intel_dialog(), science_report::update_report(), utype_primary_tech_req(), and valid_advance_by_number().

◆ advance_by_rule_name()

struct advance * advance_by_rule_name ( const char name)

◆ advance_by_translated_name()

struct advance * advance_by_translated_name ( const char name)

Does a linear search of advances[].name.translated Returns NULL when none match.

Definition at line 185 of file tech.c.

Referenced by help_update_tech(), help_dialog::make_tree(), and help_widget::set_topic_tech().

◆ advance_count_real()

Tech_type_id advance_count_real ( void  )

Return the number of advances/technologies.

Definition at line 78 of file tech.c.

Referenced by advance_count().

◆ advance_has_flag()

bool advance_has_flag ( Tech_type_id  tech,
enum tech_flag_id  flag 
)

Return TRUE if the tech has this flag otherwise FALSE

Definition at line 216 of file tech.c.

Referenced by found_new_tech(), helptext_advance(), is_techflag_req_active(), research_update(), and save_techs_ruleset().

◆ advance_index()

Tech_type_id advance_index ( const struct advance padvance)

◆ advance_name_translation()

const char * advance_name_translation ( const struct advance padvance)

◆ advance_number()

Tech_type_id advance_number ( const struct advance padvance)

Return the advance index.

Definition at line 98 of file tech.c.

Referenced by adjust_improvement_wants_by_effects(), adv_best_government(), advance_req_iter_next(), advance_required(), advance_root_req_iter_init(), advance_root_req_iter_next(), diplo_wdg::all_advances(), api_edit_give_technology(), api_edit_player_give_bulbs(), api_method_player_can_research(), api_methods_player_knows_tech(), api_methods_player_tech_bulbs(), choose_tech_to_steal(), go_act_menu::create(), create_clause_menu(), create_select_tech_icon(), create_tech_info(), research_diagram::create_tooltip_help(), dai_gov_value(), dai_process_defender_want(), dai_tech_base_want(), dai_tech_effect_values(), dai_wants_defender_against(), dai_wants_role_unit(), diplomacy_dialog_tech_callback(), diplomacy_dialog_tech_callback(), draw_reqtree(), handle_ruleset_tech(), help_update_tech(), help_update_unit_type(), helptext_advance(), is_tech_needed(), is_tech_req_active(), load_ruleset_terrain(), lookup_tech_list(), help_dialog::make_tree(), nation_has_initial_tech(), plr_widget::nation_selected(), node_rectangle_minimum_size(), player_tech_upkeep(), popup_add_menu(), popup_impr_info(), popup_unit_info(), process_attacker_want(), real_science_report_dialog_update(), real_tech_log(), recalculate_techs_researched(), tab_tech::req1_jump(), tab_tech::req2_jump(), research_get_reachable(), research_get_root_reqs_known(), research_goal_step(), research_update(), tab_tech::root_req_jump(), send_ruleset_techs(), help_widget::set_topic_tech(), help_widget::set_topic_unit(), sg_load_game(), sg_load_game(), sg_load_researches(), sg_load_researches(), diplo_wdg::show_menu(), spy_steal_popup_shared(), tech_can_be_stolen(), technology_load(), technology_load(), unit_goto_and_callback(), unit_goto_and_callback(), universal_number(), and worklist_change_build_target().

◆ advance_req_iter_get()

static void * advance_req_iter_get ( const struct iterator it)
static

Return the current advance.

Definition at line 544 of file tech.c.

Referenced by advance_req_iter_init().

◆ advance_req_iter_init()

struct iterator * advance_req_iter_init ( struct advance_req_iter it,
const struct advance goal 
)

Initialize an advance requirements iterator.

Definition at line 592 of file tech.c.

◆ advance_req_iter_next()

static void advance_req_iter_next ( struct iterator it)
static

Jump to next advance requirement.

Definition at line 552 of file tech.c.

Referenced by advance_req_iter_init().

◆ advance_req_iter_sizeof()

size_t advance_req_iter_sizeof ( void  )

Return the size of the advance requirements iterator.

Definition at line 536 of file tech.c.

◆ advance_req_iter_valid()

static bool advance_req_iter_valid ( const struct iterator it)
static

Return whether we finished to iterate or not.

Definition at line 582 of file tech.c.

Referenced by advance_req_iter_init().

◆ advance_required()

Tech_type_id advance_required ( const Tech_type_id  tech,
enum tech_req  require 
)

◆ advance_requires()

struct advance * advance_requires ( const struct advance padvance,
enum tech_req  require 
)

◆ advance_root_req_iter_get()

static void * advance_root_req_iter_get ( const struct iterator it)
static

Return the current root_req.

Definition at line 620 of file tech.c.

Referenced by advance_root_req_iter_init().

◆ advance_root_req_iter_init()

struct iterator * advance_root_req_iter_init ( struct advance_root_req_iter it,
const struct advance goal 
)

Initialize a root requirements iterator.

Definition at line 695 of file tech.c.

◆ advance_root_req_iter_next()

static void advance_root_req_iter_next ( struct iterator it)
static

Jump to next advance which has a previously unseen root_req.

Definition at line 639 of file tech.c.

Referenced by advance_root_req_iter_init().

◆ advance_root_req_iter_sizeof()

size_t advance_root_req_iter_sizeof ( void  )

Return the size of the advance root requirements iterator.

Definition at line 612 of file tech.c.

◆ advance_root_req_iter_valid()

static bool advance_root_req_iter_valid ( const struct iterator it)
static

Return whether we finished to iterate or not.

Definition at line 629 of file tech.c.

Referenced by advance_root_req_iter_init(), and advance_root_req_iter_next().

◆ advance_rule_name()

const char * advance_rule_name ( const struct advance padvance)

◆ is_future_tech()

bool is_future_tech ( Tech_type_id  tech)

◆ is_regular_advance()

bool is_regular_advance ( struct advance padvance)

Is the given tech an regular advance. "None" counts as regular advance, Future Tech does not.

Definition at line 290 of file tech.c.

Referenced by help_update_tech(), help_dialog::make_tree(), and help_widget::set_topic_tech().

◆ set_user_tech_flag_name()

void set_user_tech_flag_name ( enum tech_flag_id  id,
const char name,
const char helptxt 
)

Sets user defined name for tech flag.

Definition at line 404 of file tech.c.

Referenced by handle_ruleset_tech_flag(), load_tech_names(), and rscompat_names().

◆ tech_class_by_number()

struct tech_class * tech_class_by_number ( const int  idx)

Return the tech_class for the given index.

Definition at line 330 of file tech.c.

Referenced by handle_ruleset_tech(), handle_ruleset_tech_class(), and tech_class_by_rule_name().

◆ tech_class_by_rule_name()

struct tech_class * tech_class_by_rule_name ( const char name)

Does a linear search of tech_classes[].name.vernacular Returns NULL when none match.

Definition at line 361 of file tech.c.

Referenced by load_ruleset_techs().

◆ tech_class_name_translation()

const char * tech_class_name_translation ( const struct tech_class ptclass)

Return the (translated) name of the given tech_class You must not free the return pointer.

Definition at line 343 of file tech.c.

Referenced by helptext_advance().

◆ tech_class_rule_name()

const char * tech_class_rule_name ( const struct tech_class ptclass)

Return the (untranslated) rule name of tech_class You must not free the return pointer.

Definition at line 352 of file tech.c.

Referenced by save_techs_ruleset(), and tech_class_by_rule_name().

◆ tech_classes_init()

void tech_classes_init ( void  )

Initialize tech classes

Definition at line 317 of file tech.c.

Referenced by game_ruleset_init().

◆ tech_flag_helptxt()

const char * tech_flag_helptxt ( enum tech_flag_id  id)

Return the (untranslated) helptxt of the user tech flag.

Definition at line 445 of file tech.c.

Referenced by helptext_advance(), save_techs_ruleset(), and send_ruleset_techs().

◆ tech_flag_id_name_cb()

const char * tech_flag_id_name_cb ( enum tech_flag_id  flag)

Tech flag name callback, called from specenum code.

Definition at line 433 of file tech.c.

Referenced by first_free_tech_user_flag(), save_techs_ruleset(), and send_ruleset_techs().

◆ tech_free()

static void tech_free ( Tech_type_id  tech)
static

De-allocate resources associated with the given tech.

Definition at line 502 of file tech.c.

Referenced by techs_free().

◆ techs_free()

void techs_free ( void  )

De-allocate resources of all techs.

Definition at line 520 of file tech.c.

Referenced by game_ruleset_free().

◆ techs_have_fixed_costs()

bool techs_have_fixed_costs ( void  )

Returns true if the costs for the given technology will stay constant during the game. False otherwise.

Checking every tech_cost_style with fixed costs seems a waste of system resources, when we can check that it is not the one style without fixed costs.

Definition at line 460 of file tech.c.

Referenced by helptext_advance().

◆ techs_init()

void techs_init ( void  )

Initialize tech structures.

Definition at line 469 of file tech.c.

Referenced by game_ruleset_init().

◆ techs_precalc_data()

void techs_precalc_data ( void  )

Function to precalculate needed data for technologies.

Definition at line 225 of file tech.c.

Referenced by load_rulesetdir().

◆ user_tech_flags_free()

void user_tech_flags_free ( void  )

Frees the memory associated with all user tech flags

Definition at line 392 of file tech.c.

Referenced by game_ruleset_free().

◆ user_tech_flags_init()

void user_tech_flags_init ( void  )

Initialize user tech flags.

Definition at line 380 of file tech.c.

Referenced by game_ruleset_init().

◆ valid_advance()

struct advance * valid_advance ( struct advance padvance)

Returns pointer when the advance "exists" in this game, returns NULL otherwise.

A tech doesn't exist if it has been flagged as removed by setting its require values to A_NEVER. Note that this function returns NULL if either of req values is A_NEVER, rather than both, to be on the safe side.

Definition at line 152 of file tech.c.

Referenced by advance_req_iter_next(), advance_root_req_iter_next(), is_regular_advance(), load_ruleset_techs(), load_ruleset_units(), lookup_tech_list(), manual_techs(), real_tech_log(), recalculate_techs_researched(), research_get_reachable(), send_ruleset_techs(), tileset_setup_tech_type(), and valid_advance_by_number().

◆ valid_advance_by_number()

struct advance * valid_advance_by_number ( const Tech_type_id  id)

Variable Documentation

◆ advances

◆ tech_classes

Definition at line 60 of file tech.c.

Referenced by tech_class_by_number(), and tech_classes_init().

◆ user_tech_flags

struct user_flag user_tech_flags[MAX_NUM_USER_TECH_FLAGS]
static