![]() |
Freeciv21
Develop your civilization from humble roots to a global empire
|
#include "iterator.h"#include "support.h"#include "fc_types.h"#include "tech.h"#include "specenum_gen.h"
Include dependency graph for research.h:Go to the source code of this file.
Classes | |
| struct | research |
| struct | research::research_invention |
Macros | |
| #define | SPECENUM_NAME tech_state |
| #define | SPECENUM_VALUE0 TECH_UNKNOWN |
| #define | SPECENUM_VALUE1 TECH_PREREQS_KNOWN |
| #define | SPECENUM_VALUE2 TECH_KNOWN |
| #define | research_players_iterate(_presearch, _pplayer) |
| #define | research_players_iterate_end generic_iterate_end |
Functions | |
| void | researches_init () |
| Initializes all player research structure. More... | |
| void | researches_free () |
| Free all resources allocated for the research system. More... | |
| int | research_number (const struct research *presearch) |
| const char * | research_rule_name (const struct research *presearch) |
| Returns the name of the research owner: a player name or a team name. More... | |
| const char * | research_name_translation (const struct research *presearch) |
| Returns the name of the research owner: a player name or a team name. More... | |
| int | research_pretty_name (const struct research *presearch, char *buf, size_t buf_len) |
| Set in 'buf' the name of the research owner. More... | |
| struct research * | research_by_number (int number) |
| Returns the research for the given index. More... | |
| struct research * | research_get (const struct player *pplayer) |
| Returns the research structure associated with the player. More... | |
| bool | research_is_valid (const struct research &presearch) |
| Checks whether the research object is valid in the current game. More... | |
| QString | research_advance_rule_name (const struct research *presearch, Tech_type_id tech) |
| Store the rule name of the given tech (including A_FUTURE) in 'buf'. More... | |
| QString | research_advance_name_translation (const struct research *presearch, Tech_type_id tech) |
| Store the translated name of the given tech (including A_FUTURE) in 'buf'. More... | |
| void | research_update (struct research *presearch) |
| Mark as TECH_PREREQS_KNOWN each tech which is available, not known and which has all requirements fullfiled. More... | |
| enum tech_state | research_invention_state (const struct research *presearch, Tech_type_id tech) |
| Returns state of the tech for current research. More... | |
| enum tech_state | research_invention_set (struct research *presearch, Tech_type_id tech, enum tech_state value) |
| Set research knowledge about tech to given state. More... | |
| bool | research_invention_reachable (const struct research *presearch, const Tech_type_id tech) |
| Returns TRUE iff the given tech is ever reachable via research by the players sharing the research by checking tech tree limitations. More... | |
| bool | research_invention_gettable (const struct research *presearch, const Tech_type_id tech, bool allow_holes) |
| Returns TRUE iff the given tech can be given to the players sharing the research immediately. More... | |
| Tech_type_id | research_goal_step (const struct research *presearch, Tech_type_id goal) |
| Return the next tech we should research to advance towards our goal. More... | |
| int | research_goal_unknown_techs (const struct research *presearch, Tech_type_id goal) |
| Returns the number of technologies the player need to research to get the goal technology. More... | |
| int | research_goal_bulbs_required (const struct research *presearch, Tech_type_id goal) |
| Function to determine cost (in bulbs) of reaching goal technology. More... | |
| bool | research_goal_tech_req (const struct research *presearch, Tech_type_id goal, Tech_type_id tech) |
| Returns if the given tech has to be researched to reach the goal. More... | |
| int | research_total_bulbs_required (const struct research *presearch, Tech_type_id tech, bool loss_value) |
| Function to determine cost for technology. More... | |
| int | player_tech_upkeep (const struct player *pplayer) |
| Calculate the bulb upkeep needed for all techs of a player. More... | |
| size_t | research_player_iter_sizeof () |
| Returns the real size of the research player iterator. More... | |
| struct iterator * | research_player_iter_init (struct research_player_iter *it, const struct research *presearch) |
| Initializes a research player iterator. More... | |
Variables | |
| std::vector< research > | research_array |
| #define research_players_iterate | ( | _presearch, | |
| _pplayer | |||
| ) |
Definition at line 151 of file research.h.
| #define research_players_iterate_end generic_iterate_end |
Definition at line 155 of file research.h.
| #define SPECENUM_NAME tech_state |
Definition at line 24 of file research.h.
| #define SPECENUM_VALUE0 TECH_UNKNOWN |
Definition at line 27 of file research.h.
| #define SPECENUM_VALUE1 TECH_PREREQS_KNOWN |
Definition at line 28 of file research.h.
| #define SPECENUM_VALUE2 TECH_KNOWN |
Definition at line 29 of file research.h.
| int player_tech_upkeep | ( | const struct player * | pplayer | ) |
Calculate the bulb upkeep needed for all techs of a player.
See also research_total_bulbs_required().
Definition at line 1037 of file research.cpp.
Referenced by dai_goldequiv_clause(), dai_manage_taxes(), end_phase(), init_tech(), and package_player_info().
| QString research_advance_name_translation | ( | const struct research * | presearch, |
| Tech_type_id | tech | ||
| ) |
Store the translated name of the given tech (including A_FUTURE) in 'buf'.
'presearch' may be nullptr.
Definition at line 257 of file research.cpp.
Referenced by api_edit_give_technology(), choose_tech_goal(), city_build_building(), col_research(), do_tech_parasite_effect(), draw_reqtree(), forget_tech_transfered(), found_new_tech(), get_info_label_text_popup(), research_diagram::mousePressEvent(), plr_widget::nation_selected(), node_rectangle_minimum_size(), real_science_report_dialog_update(), research_tech_lost(), show_new_turn_info(), spy_steal_shared(), steal_a_tech(), tech_researched(), update_bulbs(), and science_report::update_report().
| QString research_advance_rule_name | ( | const struct research * | presearch, |
| Tech_type_id | tech | ||
| ) |
Store the rule name of the given tech (including A_FUTURE) in 'buf'.
'presearch' may be nullptr.
Definition at line 233 of file research.cpp.
Referenced by dai_manage_tech(), dai_select_tech(), kill_unit(), and update_bulbs().
| struct research* research_by_number | ( | int | number | ) |
Returns the research for the given index.
Definition at line 100 of file research.cpp.
Referenced by handle_research_info(), and sg_load_researches().
Returns the research structure associated with the player.
Definition at line 110 of file research.cpp.
Referenced by adjust_improvement_wants_by_effects(), adv_best_government(), adv_data_phase_init(), diplo_wdg::all_advances(), api_edit_give_technology(), api_methods_player_knows_tech(), api_methods_player_shares_research(), api_methods_research_name_translation(), api_methods_research_rule_name(), api_notify_research_embassies_msg(), api_notify_research_msg(), calc_civ_score(), can_player_build_unit_direct(), choose_tech_to_steal(), city_build_building(), client_research_sprite(), client_state(), col_research(), compute_tech_sell_price(), count_stealable_techs(), create_animals(), create_barbarian_player(), create_dummy_reqtree(), dai_choose_diplomat_offensive(), dai_choose_paratrooper(), dai_effect_value(), dai_goldequiv_clause(), dai_goldequiv_tech(), dai_gov_value(), dai_manage_government(), dai_manage_taxes(), dai_manage_tech(), dai_process_defender_want(), dai_select_tech(), dai_share(), dai_tech_base_want(), dai_tech_effect_values(), dai_treaty_evaluate(), dai_wants_defender_against(), dai_wants_role_unit(), dai_war_desire(), diplomat_get_tech(), do_tech_parasite_effect(), do_unit_establish_trade(), draw_reqtree(), end_phase(), establish_embassy(), find_city_to_diplomat(), forget_tech_transfered(), found_new_tech(), get_bulbs_per_turn(), get_edge_type(), get_info_label_text_popup(), get_science_goal_text(), get_science_target_text(), government_change(), handle_diplomacy_accept_treaty_req(), handle_edit_player(), handle_edit_player_create(), handle_player_research(), handle_player_tech_goal(), handle_research_info(), helptext_advance(), historian_generic(), is_req_active(), kill_unit(), science_report::locate_goal(), science_report::locate_researching(), research_diagram::mousePressEvent(), plr_widget::nation_selected(), node_rectangle_minimum_size(), notify_research_embassies(), num_known_tech_with_flag(), player_has_really_useful_tech_parasite(), player_knows_extra_exist(), player_tech_upkeep(), process_attacker_want(), science_report::push_research(), real_science_report_dialog_update(), research_total_bulbs_required(), science_dialog_text(), script_tech_learned(), send_city_info(), send_research_info(), diplo_wdg::show_menu(), show_new_turn_info(), split_player(), spy_steal_shared(), steal_a_tech(), suggest_tech_exchange(), tech_log_prefix(), tech_transfer(), top_bar_right_click_science(), update_bulbs(), science_report::update_report(), and worklist_change_build_target().
| int research_goal_bulbs_required | ( | const struct research * | presearch, |
| Tech_type_id | goal | ||
| ) |
Function to determine cost (in bulbs) of reaching goal technology.
These costs include the cost for researching the goal technology itself.
'presearch' may be nullptr in which case it will returns the total number of bulbs needed for reaching the goal.
Definition at line 767 of file research.cpp.
Referenced by adjust_improvement_wants_by_effects(), dai_goldequiv_tech(), dai_process_defender_want(), dai_wants_defender_against(), dai_wants_role_unit(), get_science_goal_text(), helptext_advance(), and process_attacker_want().
| Tech_type_id research_goal_step | ( | const struct research * | presearch, |
| Tech_type_id | goal | ||
| ) |
Return the next tech we should research to advance towards our goal.
Returns A_UNSET if nothing is available or the goal is already known.
Definition at line 714 of file research.cpp.
Referenced by end_phase(), found_new_tech(), and init_tech().
| bool research_goal_tech_req | ( | const struct research * | presearch, |
| Tech_type_id | goal, | ||
| Tech_type_id | tech | ||
| ) |
Returns if the given tech has to be researched to reach the goal.
The goal itself isn't a requirement of itself.
'presearch' may be nullptr.
Definition at line 794 of file research.cpp.
Referenced by dai_choose_paratrooper(), dai_select_tech(), dai_treaty_evaluate(), get_edge_type(), and get_science_goal_text().
| int research_goal_unknown_techs | ( | const struct research * | presearch, |
| Tech_type_id | goal | ||
| ) |
Returns the number of technologies the player need to research to get the goal technology.
This includes the goal technology. Technologies are only counted once.
'presearch' may be nullptr in which case it will returns the total number of technologies needed for reaching the goal.
Definition at line 745 of file research.cpp.
Referenced by adjust_improvement_wants_by_effects(), adv_best_government(), dai_effect_value(), dai_gov_value(), dai_select_tech(), get_science_goal_text(), helptext_advance(), process_attacker_want(), and tech_log_prefix().
| bool research_invention_gettable | ( | const struct research * | presearch, |
| const Tech_type_id | tech, | ||
| bool | allow_holes | ||
| ) |
Returns TRUE iff the given tech can be given to the players sharing the research immediately.
If allow_holes is TRUE, any tech with known root reqs is ok. If it's FALSE, getting the tech must not leave holes to the known techs tree.
Definition at line 686 of file research.cpp.
Referenced by diplo_wdg::all_advances(), choose_tech_to_steal(), dai_goldequiv_tech(), dai_select_tech(), dai_share(), diplomat_get_tech(), do_tech_parasite_effect(), get_edge_type(), handle_diplomacy_accept_treaty_req(), init_tech(), player_has_really_useful_tech_parasite(), diplo_wdg::show_menu(), spy_steal_shared(), steal_a_tech(), and suggest_tech_exchange().
| bool research_invention_reachable | ( | const struct research * | presearch, |
| const Tech_type_id | tech | ||
| ) |
Returns TRUE iff the given tech is ever reachable via research by the players sharing the research by checking tech tree limitations.
'presearch' may be nullptr in which case a simplified result is returned (used by the client).
Definition at line 659 of file research.cpp.
Referenced by create_dummy_reqtree(), dai_select_tech(), dai_wants_defender_against(), dai_wants_role_unit(), get_edge_type(), handle_player_tech_goal(), helptext_advance(), init_tech(), research_goal_step(), sg_load_sanitycheck(), and science_report::update_report().
| enum tech_state research_invention_set | ( | struct research * | presearch, |
| Tech_type_id | tech, | ||
| enum tech_state | value | ||
| ) |
Set research knowledge about tech to given state.
Definition at line 486 of file research.cpp.
Referenced by dai_tech_base_want(), found_new_tech(), handle_edit_player(), handle_research_info(), init_tech(), research_tech_lost(), sg_load_researches(), and split_player().
| enum tech_state research_invention_state | ( | const struct research * | presearch, |
| Tech_type_id | tech | ||
| ) |
Returns state of the tech for current research.
This can be: TECH_KNOWN, TECH_UNKNOWN, or TECH_PREREQS_KNOWN Should be called with existing techs.
If 'presearch' is nullptr this checks whether any player knows the tech (used by the client).
Definition at line 486 of file research.cpp.
Referenced by diplo_wdg::all_advances(), api_edit_give_technology(), api_methods_player_knows_tech(), calc_civ_score(), can_player_build_unit_direct(), choose_tech(), choose_tech_to_steal(), compute_tech_sell_price(), count_stealable_techs(), dai_goldequiv_clause(), dai_goldequiv_tech(), dai_manage_government(), dai_select_tech(), dai_share(), dai_tech_base_want(), dai_tech_effect_values(), dai_wants_defender_against(), dai_wants_role_unit(), diplomat_get_tech(), do_tech_parasite_effect(), found_new_tech(), get_edge_type(), give_initial_techs(), handle_diplomacy_accept_treaty_req(), handle_edit_player(), handle_player_research(), handle_player_tech_goal(), helptext_advance(), init_tech(), research_diagram::mousePressEvent(), plr_widget::nation_selected(), pick_cheapest_tech(), pick_random_tech(), pick_random_tech_to_lose(), player_has_really_useful_tech_parasite(), player_knows_extra_exist(), player_tech_upkeep(), research_goal_step(), research_invention_set(), research_total_bulbs_required(), sg_load_sanitycheck(), sg_save_researches(), diplo_wdg::show_menu(), split_player(), spy_steal_shared(), steal_a_tech(), suggest_tech_exchange(), tech_transfer(), and worklist_change_build_target().
| bool research_is_valid | ( | const struct research & | presearch | ) |
Checks whether the research object is valid in the current game.
Definition at line 125 of file research.cpp.
Referenced by do_tech_parasite_effect(), end_turn(), research_invention_gettable(), research_invention_reachable(), send_all_info(), sg_load_researches(), sg_load_sanitycheck(), sg_save_researches(), and srv_ready().
| const char* research_name_translation | ( | const struct research * | presearch | ) |
Returns the name of the research owner: a player name or a team name.
For most uses you probably want research_pretty_name() instead.
Definition at line 150 of file research.cpp.
Referenced by sg_load_sanitycheck().
| int research_number | ( | const struct research * | presearch | ) |
| struct iterator* research_player_iter_init | ( | struct research_player_iter * | it, |
| const struct research * | presearch | ||
| ) |
Initializes a research player iterator.
Definition at line 1197 of file research.cpp.
| size_t research_player_iter_sizeof | ( | ) |
Returns the real size of the research player iterator.
Definition at line 1127 of file research.cpp.
| int research_pretty_name | ( | const struct research * | presearch, |
| char * | buf, | ||
| size_t | buf_len | ||
| ) |
Set in 'buf' the name of the research owner.
It may be either a nation plural name, or something like "members of team Red".
Definition at line 163 of file research.cpp.
Referenced by api_edit_give_technology(), api_methods_research_name_translation(), city_build_building(), do_tech_parasite_effect(), found_new_tech(), handle_diplomacy_accept_treaty_req(), research_tech_lost(), steal_a_tech(), and tech_researched().
| const char* research_rule_name | ( | const struct research * | presearch | ) |
Returns the name of the research owner: a player name or a team name.
Definition at line 137 of file research.cpp.
Referenced by api_methods_research_rule_name(), research_invention_set(), research_tech_lost(), and update_bulbs().
| int research_total_bulbs_required | ( | const struct research * | presearch, |
| Tech_type_id | tech, | ||
| bool | loss_value | ||
| ) |
Function to determine cost for technology.
The equation is determined from game.info.tech_cost_style and game.info.tech_leakage.
tech_cost_style: TECH_COST_CIV1CIV2: Civ (I|II) style. Every new tech add base_tech_cost to cost of next tech. TECH_COST_CLASSIC: Cost of technology is: base_tech_cost * (1 + reqs) * sqrt(1 + reqs) / 2 where reqs == number of requirement for tech, counted recursively. TECH_COST_CLASSIC_PRESET: Cost are read from tech.ruleset. Missing costs are generated by style "Classic". TECH_COST_EXPERIMENTAL: Cost of technology is: base_tech_cost * (reqs^2 / (1 + sqrt(sqrt(reqs + 1)))
tech_leakage: TECH_LEAKAGE_NONE: No reduction of the technology cost. TECH_LEAKAGE_EMBASSIES: Technology cost is reduced depending on the number of players which already know the tech and you have an embassy with. TECH_LEAKAGE_PLAYERS: Technology cost is reduced depending on the number of all players (human, AI and barbarians) which already know the tech. TECH_LEAKAGE_NO_BARBS: Technology cost is reduced depending on the number of normal players (human and AI) which already know the tech.
At the end we multiply by the sciencebox value, as a percentage. The cost can never be less than 1.
'presearch' may be nullptr in which case a simplified result is returned (used by client and manual code).
Definition at line 855 of file research.cpp.
Referenced by choose_tech(), dai_choose_diplomat_offensive(), dai_manage_tech(), helptext_advance(), init_tech(), lose_tech(), package_research_info(), pick_cheapest_tech(), research_apply_penalty(), research_invention_set(), tech_researched(), and update_bulbs().
| void research_update | ( | struct research * | presearch | ) |
Mark as TECH_PREREQS_KNOWN each tech which is available, not known and which has all requirements fullfiled.
Recalculate presearch->num_known_tech_with_flag Should always be called after research_invention_set().
Definition at line 486 of file research.cpp.
Referenced by client_state(), found_new_tech(), government_change(), handle_edit_player(), handle_research_info(), init_tech(), research_tech_lost(), sg_load_researches(), and split_player().
| void researches_free | ( | ) |
Free all resources allocated for the research system.
Definition at line 82 of file research.cpp.
Referenced by game_free().
| void researches_init | ( | ) |
Initializes all player research structure.
Definition at line 50 of file research.cpp.
Referenced by game_init(), and game_reset().
|
extern |
Referenced by do_tech_parasite_effect(), end_turn(), send_all_info(), sg_load_researches(), sg_load_sanitycheck(), sg_save_researches(), and srv_ready().