![]() |
Freeciv21
Develop your civilization from humble roots to a global empire
|
#include "bitvector.h"#include "shared.h"#include "fc_types.h"#include "name_translation.h"#include "requirements.h"#include "specenum_gen.h"
Include dependency graph for tech.h:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Classes | |
| struct | tech_class |
| struct | advance |
Macros | |
| #define | A_NONE 0 |
| #define | A_FIRST 1 |
| #define | A_LAST (MAX_NUM_ADVANCES + 1) |
| #define | A_FUTURE (A_LAST + 1) |
| #define | A_ARRAY_SIZE (A_FUTURE + 1) |
| #define | A_UNSET (A_LAST + 2) |
| #define | A_UNKNOWN (A_LAST + 3) |
| #define | A_NEVER (nullptr) |
| #define | SPECENUM_NAME tech_flag_id |
| #define | SPECENUM_VALUE0 TF_BONUS_TECH |
| #define | SPECENUM_VALUE0NAME N_("Bonus_Tech") |
| #define | SPECENUM_VALUE1 TF_BRIDGE |
| #define | SPECENUM_VALUE1NAME N_("Bridge") |
| #define | SPECENUM_VALUE2 TF_BUILD_AIRBORNE |
| #define | SPECENUM_VALUE2NAME N_("Build_Airborne") |
| #define | SPECENUM_VALUE3 TF_CLAIM_OCEAN |
| #define | SPECENUM_VALUE3NAME N_("Claim_Ocean") |
| #define | SPECENUM_VALUE4 TF_CLAIM_OCEAN_LIMITED |
| #define | SPECENUM_VALUE4NAME N_("Claim_Ocean_Limited") |
| #define | SPECENUM_VALUE5 TECH_USER_1 |
| #define | SPECENUM_VALUE6 TECH_USER_2 |
| #define | SPECENUM_VALUE7 TECH_USER_3 |
| #define | SPECENUM_VALUE8 TECH_USER_4 |
| #define | SPECENUM_VALUE9 TECH_USER_5 |
| #define | SPECENUM_VALUE10 TECH_USER_6 |
| #define | SPECENUM_VALUE11 TECH_USER_7 |
| #define | SPECENUM_VALUE12 TECH_USER_LAST |
| #define | SPECENUM_COUNT TF_COUNT |
| #define | SPECENUM_BITVECTOR bv_tech_flags |
| #define | SPECENUM_NAMEOVERRIDE |
| #define | MAX_NUM_USER_TECH_FLAGS (TECH_USER_LAST - TECH_USER_1 + 1) |
| #define | tech_class_index(_ptclass_) (_ptclass_)->idx |
| #define | tech_class_iterate(_p) |
| #define | tech_class_iterate_end |
| #define | tech_class_re_active_iterate(_p) |
| #define | tech_class_re_active_iterate_end |
| #define | advance_index_iterate(_start, _index) |
| #define | advance_index_iterate_end |
| #define | advance_iterate(_start, _p) |
| #define | advance_iterate_end |
| #define | advance_re_active_iterate(_p) |
| #define | advance_re_active_iterate_end |
| #define | advance_req_iterate(_goal, _padvance) |
| #define | advance_req_iterate_end generic_iterate_end |
| #define | advance_root_req_iterate(_goal, _padvance) |
| #define | advance_root_req_iterate_end generic_iterate_end |
Enumerations | |
| enum | tech_req { AR_ONE = 0 , AR_TWO = 1 , AR_ROOT = 2 , AR_SIZE } |
Functions | |
| BV_DEFINE (bv_techs, A_LAST) | |
| Tech_type_id | advance_count () |
| Return the number of advances/technologies. More... | |
| Tech_type_id | advance_index (const struct advance *padvance) |
| Return the advance index. More... | |
| Tech_type_id | advance_number (const struct advance *padvance) |
| Return the advance index. More... | |
| struct advance * | advance_by_number (const Tech_type_id atype) |
| Return the advance for the given advance index. More... | |
| struct advance * | valid_advance (struct advance *padvance) |
| Returns pointer when the advance "exists" in this game, returns nullptr otherwise. More... | |
| struct advance * | valid_advance_by_number (const Tech_type_id atype) |
| Returns pointer when the advance "exists" in this game, returns nullptr otherwise. More... | |
| struct advance * | advance_by_rule_name (const char *name) |
| Does a linear search of advances[].name.vernacular Returns nullptr when none match. More... | |
| struct advance * | advance_by_translated_name (const char *name) |
| Does a linear search of advances[].name.translated Returns nullptr when none match. More... | |
| const char * | advance_rule_name (const struct advance *padvance) |
| Return the (untranslated) rule name of the advance/technology. More... | |
| const char * | advance_name_translation (const struct advance *padvance) |
| Return the (translated) name of the given advance/technology. More... | |
| void | tech_classes_init () |
| Initialize tech classes. More... | |
| struct tech_class * | tech_class_by_number (const int idx) |
| Return the tech_class for the given index. More... | |
| 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. More... | |
| 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. More... | |
| struct tech_class * | tech_class_by_rule_name (const char *name) |
| Does a linear search of tech_classes[].name.vernacular Returns nullptr when none match. More... | |
| void | user_tech_flags_init () |
| Initialize user tech flags. More... | |
| void | user_tech_flags_free () |
| Frees the memory associated with all user tech flags. More... | |
| void | set_user_tech_flag_name (enum tech_flag_id id, const char *name, const char *helptxt) |
| Sets user defined name for tech flag. More... | |
| const char * | tech_flag_helptxt (enum tech_flag_id id) |
| Return the (untranslated) helptxt of the user tech flag. More... | |
| bool | advance_has_flag (Tech_type_id tech, enum tech_flag_id flag) |
| Return TRUE if the tech has this flag otherwise FALSE. More... | |
| Tech_type_id | advance_required (const Tech_type_id tech, enum tech_req require) |
| Accessor for requirements. More... | |
| struct advance * | advance_requires (const struct advance *padvance, enum tech_req require) |
| Accessor for requirements. More... | |
| bool | techs_have_fixed_costs () |
| Returns true if the costs for the given technology will stay constant during the game. More... | |
| bool | is_future_tech (Tech_type_id tech) |
| Is the given tech a future tech. More... | |
| void | techs_init () |
| Initialize tech structures. More... | |
| void | techs_free () |
| De-allocate resources of all techs. More... | |
| void | techs_precalc_data () |
| Function to precalculate needed data for technologies. More... | |
| const struct advance * | advance_array_last () |
| Return the last item of advances/technologies. More... | |
| size_t | advance_req_iter_sizeof () |
| Return the size of the advance requirements iterator. More... | |
| struct iterator * | advance_req_iter_init (struct advance_req_iter *it, const struct advance *goal) |
| Initialize an advance requirements iterator. More... | |
| size_t | advance_root_req_iter_sizeof () |
| Return the size of the advance root requirements iterator. More... | |
| struct iterator * | advance_root_req_iter_init (struct advance_root_req_iter *it, const struct advance *goal) |
| Initialize a root requirements iterator. More... | |
| #define A_LAST (MAX_NUM_ADVANCES + 1) |
| #define advance_index_iterate | ( | _start, | |
| _index | |||
| ) |
| #define advance_iterate | ( | _start, | |
| _p | |||
| ) |
| #define advance_re_active_iterate | ( | _p | ) |
| #define advance_re_active_iterate_end |
| #define advance_req_iterate | ( | _goal, | |
| _padvance | |||
| ) |
| #define advance_req_iterate_end generic_iterate_end |
| #define advance_root_req_iterate | ( | _goal, | |
| _padvance | |||
| ) |
| #define advance_root_req_iterate_end generic_iterate_end |
| #define MAX_NUM_USER_TECH_FLAGS (TECH_USER_LAST - TECH_USER_1 + 1) |
| #define tech_class_iterate | ( | _p | ) |
| #define tech_class_re_active_iterate | ( | _p | ) |
| #define tech_class_re_active_iterate_end |
| const struct advance* advance_array_last | ( | ) |
| struct advance* advance_by_number | ( | const Tech_type_id | atype | ) |
Return the advance for the given advance index.
Definition at line 94 of file tech.cpp.
Referenced by tab_tech::add_now(), advance_has_flag(), help_widget::anchor_clicked(), api_edit_give_technology(), api_find_tech_type(), boot_help_texts(), client_diplomacy_clause_string(), dai_choose_paratrooper(), dai_goldequiv_clause(), dai_manage_government(), dai_manage_tech(), dai_select_tech(), do_tech_parasite_effect(), found_new_tech(), get_tooltip_unit(), handle_diplomacy_accept_treaty_req(), handle_ruleset_tech(), handle_ruleset_unit(), helptext_advance(), helptext_extra(), helptext_nation(), init_tech(), tab_tech::initialize_new_tech(), load_ruleset_techs(), research_diagram::mouseMoveEvent(), research_advance_name(), research_get_reachable(), research_get_root_reqs_known(), research_invention_set(), research_tech_lost(), sanity_check_ruleset_data(), save_tech_list(), save_techs_ruleset(), help_widget::set_topic_unit(), steal_a_tech(), tech_log_prefix(), tech_researched(), technology_save(), top_bar_right_click_science(), universal_value_initial(), unpack_tech_req(), science_report::update_report(), and valid_advance_by_number().
| struct advance* advance_by_rule_name | ( | const char * | name | ) |
Does a linear search of advances[].name.vernacular Returns nullptr when none match.
Definition at line 180 of file tech.cpp.
Referenced by api_find_tech_type_by_name(), tab_tech::initialize_new_tech(), load_ruleset_terrain(), lookup_tech(), lookup_tech_list(), tab_tech::req1_menu(), tab_tech::req2_menu(), edit_utype::req_menu(), tab_tech::root_req_menu(), tab_tech::select_tech(), sg_load_game(), sg_load_researches(), technology_load(), and universal_by_number().
| struct advance* advance_by_translated_name | ( | const char * | name | ) |
Does a linear search of advances[].name.translated Returns nullptr when none match.
Definition at line 163 of file tech.cpp.
Referenced by help_dialog::make_tree(), and help_widget::set_topic_tech().
| Tech_type_id advance_count | ( | ) |
Return the number of advances/technologies.
Definition at line 68 of file tech.cpp.
Referenced by create_dummy_reqtree(), get_req_source_effects(), get_tech_sprite(), handle_research_info(), package_research_info(), pick_random_tech_to_lose(), research_invention_set(), send_ruleset_techs(), send_ruleset_units(), and suggest_tech_exchange().
| 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 198 of file tech.cpp.
Referenced by found_new_tech(), helptext_advance(), research_invention_set(), and save_techs_ruleset().
| Tech_type_id advance_index | ( | const struct advance * | padvance | ) |
Return the advance index.
Currently same as advance_number(), paired with advance_count() indicates use as an array index.
Definition at line 76 of file tech.cpp.
Referenced by can_player_build_unit_direct(), dai_choose_diplomat_defensive(), dai_choose_paratrooper(), dai_process_defender_want(), dai_tech_effect_values(), dai_wants_defender_against(), dai_wants_role_unit(), find_best_city_placement(), process_attacker_want(), tab_tech::refresh(), save_techs_ruleset(), sg_save_savefile(), tech_log_prefix(), tileset_setup_tech_type(), and want_tech_for_improvement_effect().
| const char* advance_name_translation | ( | const struct advance * | padvance | ) |
Return the (translated) name of the given advance/technology.
You don't have to free the return pointer.
Definition at line 274 of file tech.cpp.
Referenced by advance_by_translated_name(), help_widget::anchor_clicked(), api_methods_tech_type_name_translation(), boot_help_texts(), client_diplomacy_clause_string(), go_act_menu::create(), get_tooltip_improvement(), get_tooltip_unit(), handle_diplomacy_accept_treaty_req(), helptext_advance(), helptext_building(), helptext_extra(), helptext_nation(), manual_command(), research_diagram::mouseMoveEvent(), req_text_insert(), help_widget::set_topic_building(), help_widget::set_topic_unit(), diplo_wdg::show_menu(), top_bar_right_click_science(), universal_name_translation(), science_report::update_report(), worklist_change_build_target(), and worklist_item_postpone_req_vec().
| Tech_type_id advance_number | ( | const struct advance * | padvance | ) |
Return the advance index.
Definition at line 85 of file tech.cpp.
Referenced by adjust_improvement_wants_by_effects(), adv_best_government(), advance_req_iter_next(), advance_required(), advance_root_req_iter_next(), diplo_wdg::all_advances(), api_edit_give_technology(), api_methods_player_knows_tech(), can_player_build_unit_direct(), choose_tech_to_steal(), go_act_menu::create(), dai_gov_value(), dai_process_defender_want(), dai_tech_base_want(), dai_tech_effect_values(), dai_wants_defender_against(), dai_wants_role_unit(), draw_reqtree(), handle_ruleset_tech(), helptext_advance(), is_req_active(), is_tech_needed(), 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(), process_attacker_want(), tab_tech::req1_jump(), tab_tech::req2_jump(), research_get_reachable(), research_get_root_reqs_known(), research_goal_step(), research_invention_set(), tab_tech::root_req_jump(), send_ruleset_techs(), send_ruleset_units(), help_widget::set_topic_tech(), sg_load_game(), sg_load_researches(), diplo_wdg::show_menu(), tech_log_prefix(), technology_load(), universal_number(), and worklist_change_build_target().
| struct iterator* advance_req_iter_init | ( | struct advance_req_iter * | it, |
| const struct advance * | goal | ||
| ) |
| size_t advance_req_iter_sizeof | ( | ) |
| Tech_type_id advance_required | ( | const Tech_type_id | tech, |
| enum tech_req | require | ||
| ) |
Accessor for requirements.
Definition at line 108 of file tech.cpp.
Referenced by advance_root_req_iter_next(), create_dummy_reqtree(), pick_random_tech_to_lose(), research_get_reachable_rreqs(), research_invention_set(), and tech_transfer().
Accessor for requirements.
Definition at line 122 of file tech.cpp.
Referenced by advance_req_iter_next(), advance_root_req_iter_get(), advance_root_req_iter_next(), helptext_advance(), research_get_reachable(), and sanity_check_ruleset_data().
| struct iterator* advance_root_req_iter_init | ( | struct advance_root_req_iter * | it, |
| const struct advance * | goal | ||
| ) |
| size_t advance_root_req_iter_sizeof | ( | ) |
| const char* advance_rule_name | ( | const struct advance * | padvance | ) |
Return the (untranslated) rule name of the advance/technology.
You don't have to free the return pointer.
Definition at line 283 of file tech.cpp.
Referenced by advance_by_rule_name(), api_methods_tech_type_rule_name(), dai_choose_paratrooper(), dai_goldequiv_clause(), dai_select_tech(), tab_tech::delete_now(), tab_tech::edit_effects(), handle_diplomacy_accept_treaty_req(), init_tech(), is_tech_needed(), load_ruleset_techs(), load_ruleset_units(), tab_tech::name_given(), tab_tech::refresh(), research_invention_set(), research_tech_lost(), sanity_check_ruleset_data(), save_tech_list(), save_tech_ref(), sg_save_savefile(), tech_log_prefix(), tab_tech::tech_name(), technology_save(), tileset_setup_tech_type(), universal_kind_values(), and universal_rule_name().
| BV_DEFINE | ( | bv_techs | , |
| A_LAST | |||
| ) |
| bool is_future_tech | ( | Tech_type_id | tech | ) |
Is the given tech a future tech.
Definition at line 268 of file tech.cpp.
Referenced by adv_data_phase_init(), api_edit_give_technology(), choose_tech(), dai_select_tech(), found_new_tech(), help_dialog::make_tree(), research_tech_lost(), research_total_bulbs_required(), help_widget::set_topic_tech(), sg_load_sanitycheck(), steal_a_tech(), update_bulbs(), and science_report::update_report().
| 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 378 of file tech.cpp.
Referenced by handle_ruleset_tech_flag(), and load_tech_names().
| struct tech_class* tech_class_by_number | ( | const int | idx | ) |
Return the tech_class for the given index.
Definition at line 304 of file tech.cpp.
Referenced by handle_ruleset_tech(), handle_ruleset_tech_class(), and 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 nullptr when none match.
Definition at line 335 of file tech.cpp.
Referenced by load_ruleset_techs().
| 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 317 of file tech.cpp.
Referenced by helptext_advance().
| 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 326 of file tech.cpp.
Referenced by save_techs_ruleset(), and tech_class_by_rule_name().
| void tech_classes_init | ( | ) |
Initialize tech classes.
Definition at line 291 of file tech.cpp.
Referenced by game_ruleset_init().
| const char* tech_flag_helptxt | ( | enum tech_flag_id | id | ) |
Return the (untranslated) helptxt of the user tech flag.
Definition at line 413 of file tech.cpp.
Referenced by helptext_advance(), save_techs_ruleset(), and send_ruleset_techs().
| void techs_free | ( | ) |
De-allocate resources of all techs.
Definition at line 481 of file tech.cpp.
Referenced by game_ruleset_free().
| bool techs_have_fixed_costs | ( | ) |
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 428 of file tech.cpp.
Referenced by helptext_advance().
| void techs_init | ( | ) |
Initialize tech structures.
Definition at line 437 of file tech.cpp.
Referenced by game_ruleset_init().
| void techs_precalc_data | ( | ) |
Function to precalculate needed data for technologies.
Definition at line 207 of file tech.cpp.
Referenced by load_rulesetdir().
| void user_tech_flags_free | ( | ) |
Frees the memory associated with all user tech flags.
Definition at line 366 of file tech.cpp.
Referenced by game_ruleset_free().
| void user_tech_flags_init | ( | ) |
Initialize user tech flags.
Definition at line 354 of file tech.cpp.
Referenced by game_ruleset_init().
Returns pointer when the advance "exists" in this game, returns nullptr 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 nullptr if either of req values is A_NEVER, rather than both, to be on the safe side.
Definition at line 138 of file tech.cpp.
Referenced by advance_req_iter_next(), advance_root_req_iter_next(), load_ruleset_techs(), load_ruleset_units(), lookup_tech_list(), manual_command(), research_get_reachable(), send_ruleset_techs(), tech_log_prefix(), tileset_setup_tech_type(), and valid_advance_by_number().
| struct advance* valid_advance_by_number | ( | const Tech_type_id | id | ) |
Returns pointer when the advance "exists" in this game, returns nullptr otherwise.
In addition to valid_advance(), tests for id is out of range.
Definition at line 154 of file tech.cpp.
Referenced by add_clause(), boot_help_texts(), create_dummy_reqtree(), dai_select_tech(), diplomat_get_tech(), found_new_tech(), get_science_goal_text(), handle_player_research(), handle_player_tech_goal(), helptext_advance(), research_allowed(), research_get_reachable(), research_get_reachable_rreqs(), research_goal_bulbs_required(), research_goal_step(), research_goal_tech_req(), research_goal_unknown_techs(), research_invention_gettable(), research_invention_reachable(), research_invention_set(), research_tech_lost(), research_total_bulbs_required(), sanity_check_ruleset_data(), progress_bar::set_pixmap(), sg_load_player_unit(), sg_load_sanitycheck(), steal_a_tech(), and unit_order_list_is_sane().