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

Freeciv-3.2

Loading...
Searching...
No Matches
Data Structures | Macros | Functions | Variables
research.c File Reference
`#include "iterator.h"`
`#include "log.h"`
`#include "shared.h"`
`#include "string_vector.h"`
`#include "support.h"`
`#include "fc_types.h"`
`#include "game.h"`
`#include "nation.h"`
`#include "player.h"`
`#include "name_translation.h"`
`#include "team.h"`
`#include "tech.h"`
`#include "research.h"`

Go to the source code of this file.

## Data Structures

struct | research_iter
struct | research_player_iter

## Macros

#define | RESEARCH_ITER(p) ((struct research_iter *) p)
#define | RESEARCH_PLAYER_ITER(p) ((struct research_player_iter *) p)
#define | RESEARCH_ARRAY_SIZE MAX(MAX_NUM_PLAYER_SLOTS, MAX_NUM_TEAM_SLOTS)
#define | research_is_allowed(presearch, tech) research_allowed(presearch, tech, are_reqs_active)
#define | research_may_become_allowed(presearch, tech) research_allowed(presearch, tech, reqs_may_activate)

## Functions

void | researches_init (void)
void | researches_free (void)
int | research_number (const struct research *presearch)
struct research * | research_by_number (int number)
struct research * | research_get (const struct player *pplayer)
const char * | research_rule_name (const struct research *presearch)
const char * | research_name_translation (const struct research *presearch)
int | research_pretty_name (const struct research *presearch, char *buf, size_t buf_len)
static const struct name_translation * | research_advance_name (Tech_type_id tech)
static const char * | research_future_set_name (struct strvec *psv, int no, const char *new_name)
const char * | research_advance_rule_name (const struct research *presearch, Tech_type_id tech)
const char * | research_advance_name_translation (const struct research *presearch, Tech_type_id tech)
static bool | reqs_may_activate (const struct req_context *context, const struct player *other_player, const struct requirement_vector *reqs, const enum req_problem_type prob_type)
static bool | research_allowed (const struct research *presearch, Tech_type_id tech, bool(*reqs_eval)(const struct req_context *context, const struct player *oplr, const struct requirement_vector *reqs, const enum req_problem_type ptype))
static bool | research_get_reachable_rreqs (const struct research *presearch, Tech_type_id tech)
static bool | research_get_reachable (const struct research *presearch, Tech_type_id tech)
static bool | research_get_root_reqs_known (const struct research *presearch, Tech_type_id tech)
void | research_update (struct research *presearch)
enum tech_state | research_invention_state (const struct research *presearch, Tech_type_id tech)
enum tech_state | research_invention_set (struct research *presearch, Tech_type_id tech, enum tech_state value)
bool | research_invention_reachable (const struct research *presearch, const Tech_type_id tech)
bool | research_invention_gettable (const struct research *presearch, const Tech_type_id tech, bool allow_holes)
Tech_type_id | research_goal_step (const struct research *presearch, Tech_type_id goal)
int | research_goal_unknown_techs (const struct research *presearch, Tech_type_id goal)
int | research_goal_bulbs_required (const struct research *presearch, Tech_type_id goal)
bool | research_goal_tech_req (const struct research *presearch, Tech_type_id goal, Tech_type_id tech)
int | research_total_bulbs_required (const struct research *presearch, Tech_type_id tech, bool loss_value)
int | player_tech_upkeep (const struct player *pplayer)
size_t | research_iter_sizeof (void)
static void * | research_iter_get (const struct iterator *it)
static void | research_iter_team_next (struct iterator *it)
static bool | research_iter_team_valid (const struct iterator *it)
static void | research_iter_player_next (struct iterator *it)
static bool | research_iter_player_valid (const struct iterator *it)
struct iterator * | research_iter_init (struct research_iter *it)
size_t | research_player_iter_sizeof (void)
static bool | research_player_iter_valid_state (struct iterator *it)
static void * | research_player_iter_pooled_get (const struct iterator *it)
static void | research_player_iter_pooled_next (struct iterator *it)
static bool | research_player_iter_pooled_valid (const struct iterator *it)
static void * | research_player_iter_not_pooled_get (const struct iterator *it)
static void | research_player_iter_not_pooled_next (struct iterator *it)
static bool | research_player_iter_not_pooled_valid (const struct iterator *it)
struct iterator * | research_player_iter_init (struct research_player_iter *it, const struct research *presearch)
int | research_count (void)
int | recalculate_techs_researched (const struct research *presearch)
bool | research_future_next (const struct research *presearch)

## Variables

static struct research | research_array [RESEARCH_ARRAY_SIZE]
static struct name_translation | advance_unset_name = NAME_INIT
static struct name_translation | advance_future_name = NAME_INIT
static struct name_translation | advance_unknown_name = NAME_INIT
static struct strvec * | future_rule_name
static struct strvec * | future_name_translation

## Macro Definition Documentation

## ◆ RESEARCH_ARRAY_SIZE

#define RESEARCH_ARRAY_SIZE MAX(MAX_NUM_PLAYER_SLOTS, MAX_NUM_TEAM_SLOTS)

Definition at line 51 of file research.c.

## ◆ research_is_allowed

#define research_is_allowed | ( |  | presearch,
|  |  | tech
| ) |  | research_allowed(presearch, tech, are_reqs_active)

Returns TRUE iff researching the given tech is allowed according to its research_reqs.

Helper for research_update().

Definition at line 366 of file research.c.

## ◆ RESEARCH_ITER

#define RESEARCH_ITER | ( |  | p | ) | ((struct research_iter *) p)

Definition at line 40 of file research.c.

## ◆ research_may_become_allowed

#define research_may_become_allowed | ( |  | presearch,
|  |  | tech
| ) |  | research_allowed(presearch, tech, reqs_may_activate)

Returns TRUE iff researching the given tech may become allowed according to its research_reqs.

Helper for research_get_reachable_rreqs().

Definition at line 375 of file research.c.

## ◆ RESEARCH_PLAYER_ITER

#define RESEARCH_PLAYER_ITER | ( |  | p | ) | ((struct research_player_iter *) p)

Definition at line 49 of file research.c.

## Function Documentation

## ◆ player_tech_upkeep()

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 1050 of file research.c.

Referenced by dai_goldequiv_clause(), dai_manage_taxes(), init_tech(), package_player_info(), and update_national_activities().

## ◆ recalculate_techs_researched()

int recalculate_techs_researched | ( | const struct research * | presearch | ) |

Return recalculated number of techs researched. Useful for sanity checking techs_researched counter.

Definition at line 1345 of file research.c.

Referenced by sg_load_sanitycheck(), and sg_load_sanitycheck().

## ◆ reqs_may_activate()

static bool reqs_may_activate | ( | const struct req_context * | context,
|  | const struct player * | other_player,
|  | const struct requirement_vector * | reqs,
|  | const enum req_problem_type | prob_type
| ) |  |

static

Returns TRUE iff the requirement vector may become active against the given target.

If may become active if all unchangeable requirements are active.

Definition at line 303 of file research.c.

## ◆ research_advance_name()

static const struct name_translation * research_advance_name | ( | Tech_type_id | tech | ) |

inlinestatic

Return the name translation for 'tech'. Utility for research_advance_rule_name() and research_advance_translated_name().

Definition at line 199 of file research.c.

Referenced by research_advance_name_translation(), and research_advance_rule_name().

## ◆ research_advance_name_translation()

const char * 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 NULL. We don't return a static buffer because that would break anything that needed to work with more than one name at a time.

Definition at line 273 of file research.c.

Referenced by api_edit_give_technology(), api_methods_player_researching(), choose_tech_goal(), city_build_building(), cmp_func(), create_advances_list(), create_tech_tree(), research_diagram::create_tooltip_help(), do_tech_parasite_effects(), draw_reqtree(), forget_tech_transferred(), found_new_tech(), get_bulb_tooltip(), get_info_label_text_popup(), get_researching_info(), research_diagram::mousePressEvent(), plr_widget::nation_selected(), node_rectangle_minimum_size(), real_science_report_dialog_update(), research_tech_lost(), science_diagram_button_release_callback(), science_diagram_right_button_up(), science_report_store_set(), set_indicator_icons(), show_new_turn_info(), spy_steal_shared(), steal_a_tech(), tech_researched(), tech_transfer(), update_bulbs(), update_intel_dialog(), and science_report::update_report().

## ◆ research_advance_rule_name()

const char * 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 NULL. We don't return a static buffer because that would break anything that needed to work with more than one name at a time.

Definition at line 240 of file research.c.

Referenced by dai_manage_tech(), dai_select_tech(), player_loot_player(), and update_bulbs().

## ◆ research_allowed()

static bool research_allowed | ( | const struct research * | presearch,
|  | Tech_type_id | tech,
|  | bool(*)(const struct req_context *context, const struct player *oplr, const struct requirement_vector *reqs, const enum req_problem_type ptype) | reqs_eval
| ) |  |

static

Evaluates the legality of starting to research this tech according to reqs_eval() and the tech's research_reqs. Returns TRUE iff legal.

The reqs_eval() argument evaluates the requirements. One variant may check the current situation while another may check potential future situations.

Helper for research_update().

Definition at line 327 of file research.c.

## ◆ research_by_number()

struct research * research_by_number | ( | int | number | ) |

Returns the research for the given index.

Definition at line 118 of file research.c.

Referenced by handle_research_info(), handle_unknown_research(), sg_load_researches(), and sg_load_researches().

## ◆ research_count()

int research_count | ( | void |  | ) |

Return number of researches, i.e., either number of players or teams depending on settings.

Definition at line 1328 of file research.c.

Referenced by dai_effect_value(), and do_tech_parasite_effects().

## ◆ research_future_next()

bool research_future_next | ( | const struct research * | presearch | ) |

Is this research group going to research some Future Tech next?

Definition at line 1362 of file research.c.

Referenced by science_report_update().

## ◆ research_future_set_name()

static const char * research_future_set_name | ( | struct strvec * | psv,
|  | int | no,
|  | const char * | new_name
| ) |  |

static

Set a new future tech name in the string vector, and return the string duplicate stored inside the vector.

Definition at line 219 of file research.c.

Referenced by research_advance_name_translation(), and research_advance_rule_name().

## ◆ research_get()

struct research * research_get | ( | const struct player * | pplayer | ) |

Returns the research structure associated with the player.

Definition at line 128 of file research.c.

Referenced by adjust_improvement_wants_by_effects(), adv_best_government(), adv_data_phase_init(), diplo_wdg::all_advances(), api_edit_give_technology(), api_edit_player_give_bulbs(), api_method_player_can_research(), api_methods_player_bulbs(), api_methods_player_free_bulbs(), api_methods_player_future(), api_methods_player_knows_tech(), api_methods_player_research_cost(), api_methods_player_researching(), api_methods_player_shares_research(), api_methods_player_tech_bulbs(), api_methods_player_tech_cost(), api_methods_research_name_translation(), api_methods_research_rule_name(), api_notify_research_embassies_msg(), api_notify_research_msg(), calc_civ_score(), choose_tech_to_steal(), city_build_building(), client_research_sprite(), cmp_func(), compute_tech_sell_price(), count_stealable_techs(), create_advances_list(), create_animals(), create_barbarian_player(), create_clause_menu(), create_command_newcomer(), create_dummy_reqtree(), create_select_tech_icon(), create_tech_tree(), research_diagram::create_tooltip_help(), 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(), diplomacy_dialog_tech_callback(), diplomacy_dialog_tech_callback(), diplomat_get_tech(), do_tech_parasite_effects(), do_unit_establish_trade(), draw_reqtree(), end_phase(), establish_embassy(), find_city_to_diplomat(), forget_tech_transferred(), found_new_tech(), get_bulb_tooltip(), get_bulbs_per_turn(), get_edge_type(), get_info_label_text_popup(), get_researching_info(), get_science_goal_text(), get_science_target_text(), get_tech_color(), 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_mintechs_req_active(), is_tech_req_active(), research_diagram::mousePressEvent(), plr_widget::nation_selected(), node_color(), node_rectangle_minimum_size(), notify_research_embassies(), num_known_tech_with_flag(), objbind_get_value_from_object(), objbind_pack_current_values(), player_has_really_useful_tech_parasite(), player_knows_extra_exist(), player_loot_player(), player_tech_upkeep(), popup_add_menu(), popup_change_research_dialog(), popup_change_research_goal_dialog(), popup_diplomatic_objects(), process_attacker_want(), real_science_report_dialog_update(), real_tech_log(), research_total_bulbs_required(), science_diagram_button_release_callback(), science_diagram_left_button_up(), science_diagram_right_button_up(), science_dialog_text(), science_report_current_callback(), science_report_dialog_popup(), science_report_goal_callback(), science_report_redraw(), science_report_store_set(), science_report_update(), script_tech_learned(), send_city_info(), send_research_info(), set_client_state(), set_indicator_icons(), diplo_wdg::show_menu(), show_new_turn_info(), side_right_click_science(), split_player(), spy_steal_popup_shared(), spy_steal_shared(), steal_a_tech(), suggest_tech_exchange(), tech_can_be_stolen(), tech_transfer(), update_bulbs(), update_intel_dialog(), update_national_activities(), science_report::update_report(), and worklist_change_build_target().

## ◆ research_get_reachable()

static bool research_get_reachable | ( | const struct research * | presearch,
|  | Tech_type_id | tech
| ) |  |

static

Returns TRUE iff the given tech is ever reachable by the players sharing the research by checking tech tree limitations.

Helper for research_update().

Definition at line 440 of file research.c.

Referenced by research_update().

## ◆ research_get_reachable_rreqs()

static bool research_get_reachable_rreqs | ( | const struct research * | presearch,
|  | Tech_type_id | tech
| ) |  |

static

Returns TRUE iff the given tech is ever reachable by the players sharing the research as far as research_reqs are concerned.

Helper for research_get_reachable().

Definition at line 384 of file research.c.

Referenced by research_get_reachable().

## ◆ research_get_root_reqs_known()

static bool research_get_root_reqs_known | ( | const struct research * | presearch,
|  | Tech_type_id | tech
| ) |  |

static

Returns TRUE iff the players sharing 'presearch' already have got the knowledge of all root requirement technologies for 'tech' (without which it's impossible to gain 'tech').

Helper for research_update().

Definition at line 482 of file research.c.

Referenced by research_update().

## ◆ research_goal_bulbs_required()

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 NULL in which case it will returns the total number of bulbs needed for reaching the goal.

Definition at line 772 of file research.c.

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().

## ◆ research_goal_step()

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 720 of file research.c.

Referenced by end_phase(), found_new_tech(), and init_tech().

## ◆ research_goal_tech_req()

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 NULL.

Definition at line 807 of file research.c.

Referenced by dai_choose_paratrooper(), dai_select_tech(), dai_treaty_evaluate(), get_edge_type(), get_science_goal_text(), and node_color().

## ◆ research_goal_unknown_techs()

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 NULL in which case it will returns the total number of technologies needed for reaching the goal.

Definition at line 750 of file research.c.

Referenced by adjust_improvement_wants_by_effects(), adv_best_government(), create_tech_tree(), dai_effect_value(), dai_gov_value(), dai_select_tech(), get_science_goal_text(), helptext_advance(), popup_change_research_goal_dialog(), process_attacker_want(), real_tech_log(), and science_report_store_set().

## ◆ research_invention_gettable()

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 693 of file research.c.

Referenced by diplo_wdg::all_advances(), choose_tech_to_steal(), create_advances_list(), create_clause_menu(), dai_goldequiv_tech(), dai_select_tech(), dai_share(), diplomacy_dialog_tech_callback(), diplomacy_dialog_tech_callback(), diplomat_get_tech(), do_tech_parasite_effects(), get_tech_color(), handle_diplomacy_accept_treaty_req(), init_tech(), node_color(), player_has_really_useful_tech_parasite(), popup_add_menu(), popup_change_research_dialog(), popup_diplomatic_objects(), diplo_wdg::show_menu(), spy_steal_popup_shared(), spy_steal_shared(), steal_a_tech(), suggest_tech_exchange(), and tech_can_be_stolen().

## ◆ research_invention_reachable()

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 NULL in which case a simplified result is returned (used by the client).

Definition at line 668 of file research.c.

Referenced by create_dummy_reqtree(), dai_select_tech(), dai_wants_defender_against(), dai_wants_role_unit(), handle_player_tech_goal(), helptext_advance(), init_tech(), node_color(), popup_change_research_goal_dialog(), research_goal_step(), science_report_dialog_popup(), science_report_update(), sg_load_sanitycheck(), sg_load_sanitycheck(), update_intel_dialog(), and science_report::update_report().

## ◆ research_invention_set()

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 637 of file research.c.

Referenced by dai_tech_base_want(), found_new_tech(), handle_edit_player(), handle_research_info(), handle_unknown_research(), init_tech(), research_tech_lost(), sg_load_researches(), sg_load_researches(), and split_player().

## ◆ research_invention_state()

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 NULL this checks whether any player knows the tech (used by the client).

Definition at line 619 of file research.c.

Referenced by diplo_wdg::all_advances(), api_edit_give_technology(), api_method_player_can_research(), api_methods_player_knows_tech(), calc_civ_score(), choose_tech(), choose_tech_to_steal(), compute_tech_sell_price(), count_stealable_techs(), create_advances_list(), create_clause_menu(), create_tech_tree(), dai_choose_paratrooper(), 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(), diplomacy_dialog_tech_callback(), diplomacy_dialog_tech_callback(), diplomat_get_tech(), do_tech_parasite_effects(), found_new_tech(), get_edge_type(), get_tech_color(), give_initial_techs(), handle_diplomacy_accept_treaty_req(), handle_edit_player(), handle_player_research(), handle_player_tech_goal(), helptext_advance(), init_tech(), is_tech_req_active(), research_diagram::mousePressEvent(), plr_widget::nation_selected(), node_color(), objbind_get_value_from_object(), objbind_pack_current_values(), pick_cheapest_tech(), pick_random_tech(), pick_random_tech_to_lose(), player_has_really_useful_tech_parasite(), player_knows_extra_exist(), player_tech_upkeep(), popup_add_menu(), popup_change_research_goal_dialog(), popup_diplomatic_objects(), recalculate_techs_researched(), research_future_next(), research_goal_step(), research_total_bulbs_required(), research_update(), science_diagram_button_release_callback(), science_diagram_left_button_up(), science_report_dialog_popup(), sg_load_sanitycheck(), sg_load_sanitycheck(), sg_save_researches(), diplo_wdg::show_menu(), split_player(), spy_steal_popup_shared(), spy_steal_shared(), steal_a_tech(), suggest_tech_exchange(), tech_can_be_stolen(), tech_transfer(), update_intel_dialog(), and worklist_change_build_target().

## ◆ research_iter_get()

static void * research_iter_get | ( | const struct iterator * | it | ) |

static

Returns the research structure pointed by the iterator.

Definition at line 1145 of file research.c.

Referenced by research_iter_init().

## ◆ research_iter_init()

struct iterator * research_iter_init | ( | struct research_iter * | it | ) |

Initializes a player research iterator.

Definition at line 1205 of file research.c.

## ◆ research_iter_player_next()

static void research_iter_player_next | ( | struct iterator * | it | ) |

static

Jump to next player research structure.

Definition at line 1179 of file research.c.

Referenced by research_iter_init().

## ◆ research_iter_player_valid()

static bool research_iter_player_valid | ( | const struct iterator * | it | ) |

static

Returns FALSE if there is no valid player at current index.

Definition at line 1193 of file research.c.

Referenced by research_iter_init().

## ◆ research_iter_sizeof()

size_t research_iter_sizeof | ( | void |  | ) |

Returns the real size of the player research iterator.

Definition at line 1137 of file research.c.

## ◆ research_iter_team_next()

static void research_iter_team_next | ( | struct iterator * | it | ) |

static

Jump to next team research structure.

Definition at line 1153 of file research.c.

Referenced by research_iter_init().

## ◆ research_iter_team_valid()

static bool research_iter_team_valid | ( | const struct iterator * | it | ) |

static

Returns FALSE if there is no valid team at current index.

Definition at line 1167 of file research.c.

Referenced by research_iter_init().

## ◆ research_name_translation()

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 156 of file research.c.

Referenced by sg_load_sanitycheck(), and sg_load_sanitycheck().

## ◆ research_number()

int research_number | ( | const struct research * | presearch | ) |

Returns the index of the research in the array.

Definition at line 109 of file research.c.

Referenced by init_tech(), package_research_info(), research_name_translation(), research_player_iter_init(), research_pretty_name(), research_rule_name(), send_research_info(), and sg_save_researches().

## ◆ research_player_iter_init()

struct iterator * research_player_iter_init | ( | struct research_player_iter * | it,
|  | const struct research * | presearch
| ) |  |

Initializes a research player iterator.

Definition at line 1297 of file research.c.

## ◆ research_player_iter_not_pooled_get()

static void * research_player_iter_not_pooled_get | ( | const struct iterator * | it | ) |

static

Returns player of the iterator.

Definition at line 1273 of file research.c.

Referenced by research_player_iter_init().

## ◆ research_player_iter_not_pooled_next()

static void research_player_iter_not_pooled_next | ( | struct iterator * | it | ) |

static

Invalidate the iterator.

Definition at line 1281 of file research.c.

Referenced by research_player_iter_init().

## ◆ research_player_iter_not_pooled_valid()

static bool research_player_iter_not_pooled_valid | ( | const struct iterator * | it | ) |

static

Returns whether the iterate is valid.

Definition at line 1289 of file research.c.

Referenced by research_player_iter_init().

## ◆ research_player_iter_pooled_get()

static void * research_player_iter_pooled_get | ( | const struct iterator * | it | ) |

static

Returns player of the iterator.

Definition at line 1245 of file research.c.

Referenced by research_player_iter_init().

## ◆ research_player_iter_pooled_next()

static void research_player_iter_pooled_next | ( | struct iterator * | it | ) |

static

Returns the next player sharing the research.

Definition at line 1253 of file research.c.

Referenced by research_player_iter_init().

## ◆ research_player_iter_pooled_valid()

static bool research_player_iter_pooled_valid | ( | const struct iterator * | it | ) |

static

Returns whether the iterate is valid.

Definition at line 1265 of file research.c.

Referenced by research_player_iter_init().

## ◆ research_player_iter_sizeof()

size_t research_player_iter_sizeof | ( | void |  | ) |

Returns the real size of the research player iterator.

Definition at line 1227 of file research.c.

## ◆ research_player_iter_valid_state()

static bool research_player_iter_valid_state | ( | struct iterator * | it | ) |

inlinestatic

Returns whether the iterator is currently at a valid state.

Definition at line 1235 of file research.c.

Referenced by research_player_iter_init(), and research_player_iter_pooled_next().

## ◆ research_pretty_name()

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 169 of file research.c.

Referenced by api_edit_give_technology(), api_methods_research_name_translation(), city_build_building(), do_tech_parasite_effects(), found_new_tech(), handle_diplomacy_accept_treaty_req(), research_tech_lost(), steal_a_tech(), and tech_researched().

## ◆ research_rule_name()

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 143 of file research.c.

Referenced by api_methods_research_rule_name(), research_tech_lost(), research_update(), and update_bulbs().

## ◆ research_total_bulbs_required()

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

- 0.5) where reqs == number of requirement for tech, counted recursively. TECH_COST_EXPERIMENTAL_PRESET: Cost are read from tech.ruleset. Missing costs are generated by style "Experimental".

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 NULL in which case a simplified result is returned (used by client and manual code).

Definition at line 868 of file research.c.

Referenced by api_methods_player_research_cost(), api_methods_player_tech_cost(), 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_update(), tech_researched(), and update_bulbs().

## ◆ research_update()

void research_update | ( | struct research * | presearch | ) |

Mark as TECH_PREREQS_KNOWN each tech which is available, not known and which has all requirements fulfilled.

Recalculate presearch->num_known_tech_with_flag Should always be called after research_invention_set().

Definition at line 501 of file research.c.

Referenced by found_new_tech(), government_change(), handle_edit_player(), handle_research_info(), init_tech(), research_tech_lost(), set_client_state(), sg_load_researches(), sg_load_researches(), and split_player().

## ◆ researches_free()

void researches_free | ( | void |  | ) |

Free all resources allocated for the research system

Definition at line 100 of file research.c.

Referenced by game_free().

## ◆ researches_init()

void researches_init | ( | void |  | ) |

Initializes all player research structure.

Definition at line 64 of file research.c.

Referenced by game_init(), and game_reset().

## Variable Documentation

## ◆ advance_future_name

struct name_translation advance_future_name = NAME_INIT

static

Definition at line 55 of file research.c.

Referenced by research_advance_name(), research_advance_rule_name(), and researches_init().

## ◆ advance_unknown_name

struct name_translation advance_unknown_name = NAME_INIT

static

Definition at line 56 of file research.c.

Referenced by research_advance_name(), and researches_init().

## ◆ advance_unset_name

struct name_translation advance_unset_name = NAME_INIT

static

Definition at line 54 of file research.c.

Referenced by research_advance_name(), and researches_init().

## ◆ future_name_translation

struct strvec* future_name_translation

static

Definition at line 59 of file research.c.

Referenced by research_advance_name_translation(), researches_free(), and researches_init().

## ◆ future_rule_name

struct strvec* future_rule_name

static

Definition at line 58 of file research.c.

Referenced by research_advance_rule_name(), researches_free(), and researches_init().

## ◆ research_array

struct research research_array[RESEARCH_ARRAY_SIZE]

static

Definition at line 52 of file research.c.

Referenced by research_by_number(), research_get(), research_iter_get(), research_iter_player_next(), research_iter_player_valid(), research_iter_team_next(), research_iter_team_valid(), research_number(), and researches_init().