39#define RESEARCH_ITER(p) ((struct research_iter *) p)
48#define RESEARCH_PLAYER_ITER(p) ((struct research_player_iter *) p)
128 if (NULL == pplayer) {
170 const struct player *pplayer;
181 return fc_snprintf(buf, buf_len,
_(
"members of %s"), buf2);
209 return &padvance->
name;
218 const char *new_name)
241 if (
A_FUTURE == tech && NULL != presearch) {
274 if (
A_FUTURE == tech && NULL != presearch) {
283 fc_snprintf(buffer,
sizeof(buffer),
_(
"Future Tech. %d"), no + 1);
302 const struct player *other_player,
303 const struct requirement_vector *
reqs,
327 bool (*reqs_eval)(
const struct req_context *context,
328 const struct player *oplr,
329 const struct requirement_vector *
reqs,
342 if (reqs_eval(&(
const struct req_context) { .player = pplayer },
364#define research_is_allowed(presearch, tech) \
365 research_allowed(presearch, tech, are_reqs_active)
373#define research_may_become_allowed(presearch, tech) \
374 research_allowed(presearch, tech, reqs_may_activate)
399 for (i = 0; i < techs_num; i++) {
414 for (req = 0; req <
AR_SIZE; req++) {
419 }
else if (!
BV_ISSET(done, req_tech)) {
421 techs[techs_num] = req_tech;
456 for (req = 0; req <
AR_SIZE; req++) {
501 enum tech_flag_id flag;
502 int techs_researched;
506 bool root_reqs_known =
TRUE;
516 if (state != TECH_KNOWN) {
518 state = (root_reqs_known
524 ? TECH_PREREQS_KNOWN : TECH_UNKNOWN);
535 state = TECH_UNKNOWN;
546 if (!reachable || state == TECH_KNOWN) {
590 ?
"" :
" [root reqs aren't known]");
595 for (flag = 0; flag <= tech_flag_id_max(); flag++) {
620 tech_state_invalid());
622 if (NULL != presearch) {
636 enum tech_state value)
648 if (value == TECH_KNOWN) {
670 }
else if (presearch != NULL) {
696 }
else if (presearch != NULL) {
704 :
research_iter->inventions[tech].state == TECH_PREREQS_KNOWN) {
729 case TECH_PREREQS_KNOWN:
754 }
else if (NULL != presearch) {
776 }
else if (NULL != presearch) {
782 int bulbs_required = 0;
785 bulbs_required += preq->cost;
787 return bulbs_required;
800 const struct advance *pgoal, *ptech;
806 }
else if (NULL != presearch) {
863 double base_cost, total_cost;
880 tech_cost_style = TECH_COST_CIV1CIV2;
884 "Invalid tech_cost_style %d", tech_cost_style);
886 switch (tech_cost_style) {
887 case TECH_COST_CIV1CIV2:
888 if (NULL != presearch) {
895 case TECH_COST_CLASSIC:
896 case TECH_COST_CLASSIC_PRESET:
897 case TECH_COST_EXPERIMENTAL:
898 case TECH_COST_EXPERIMENTAL_PRESET:
899 case TECH_COST_LINEAR:
903 if (NULL != padvance) {
904 base_cost = padvance->
cost;
916 total_cost += (base_cost
924 base_cost = total_cost / members;
929 case TECH_LEAKAGE_NONE:
933 case TECH_LEAKAGE_EMBASSIES:
935 int players = 0, players_with_tech_and_embassy = 0;
941 if (aresearch == presearch
950 players_with_tech_and_embassy++;
957 fc_assert(players >= players_with_tech_and_embassy);
958 leak = base_cost * players_with_tech_and_embassy
963 case TECH_LEAKAGE_PLAYERS:
965 int players = 0, players_with_tech = 0;
984 case TECH_LEAKAGE_NO_BARBS:
986 int players = 0, players_with_tech = 0;
1002 fc_assert(players >= players_with_tech);
1009 if (leak > base_cost) {
1021 if (
is_ai(pplayer)) {
1022 fc_assert(0 < pplayer->ai_common.science_cost);
1023 total_cost += base_cost * pplayer->ai_common.science_cost / 100.0;
1025 total_cost += base_cost;
1028 base_cost = total_cost / members;
1032 return MAX(base_cost, 1);
1044 double tech_upkeep = 0.0;
1045 double total_research_factor;
1052 total_research_factor = 0.0;
1055 total_research_factor += (
get_player_bonus(contributor, EFT_TECH_COST_FACTOR)
1056 + (
is_ai(contributor)
1057 ? contributor->ai_common.science_cost / 100.0
1070 case TECH_COST_CIV1CIV2:
1074 case TECH_COST_CLASSIC:
1075 case TECH_COST_CLASSIC_PRESET:
1076 case TECH_COST_EXPERIMENTAL:
1077 case TECH_COST_EXPERIMENTAL_PRESET:
1078 case TECH_COST_LINEAR:
1082 tech_upkeep += padvance->cost;
1089 * (f * (2 * t + f + 1) + 2 * t) / 2);
1094 tech_upkeep *= total_research_factor / members;
1098 tech_upkeep /= members;
1102 case TECH_UPKEEP_BASIC:
1105 case TECH_UPKEEP_PER_CITY:
1107 tech_upkeep *= city_list_size(pplayer->
cities);
1109 case TECH_UPKEEP_NONE:
1114 if (0.0 > tech_upkeep) {
1120 return (
int) tech_upkeep;
1161 return (0 <= rit->
index
1187 return (0 <= rit->
index
1229 return (NULL == pplayer || pplayer->
is_alive);
1248 rpit->
plink = player_list_link_next(rpit->
plink);
1302 it->
pplayer = (NULL != presearch
#define BV_ISSET(bv, bit)
static void base(QVariant data1, QVariant data2)
int get_player_bonus(const struct player *pplayer, enum effect_type effect_type)
#define MAX_NUM_PLAYER_SLOTS
static void * iterator_get(const struct iterator *it)
static void iterator_next(struct iterator *it)
#define fc_assert_msg(condition, message,...)
#define fc_assert(condition)
#define fc_assert_ret_val(condition, val)
#define log_debug(message,...)
static void name_set(struct name_translation *ptrans, const char *domain, const char *vernacular_name)
static const char * rule_name_get(const struct name_translation *ptrans)
static const char * name_translation_get(const struct name_translation *ptrans)
const char * nation_plural_for_player(const struct player *pplayer)
struct player * player_by_number(const int player_id)
int player_slot_count(void)
int player_number(const struct player *pplayer)
const char * player_name(const struct player *pplayer)
bool player_slots_initialised(void)
bool player_has_embassy(const struct player *pplayer, const struct player *pplayer2)
static bool is_barbarian(const struct player *pplayer)
#define players_iterate_alive_end
#define players_iterate_alive(_pplayer)
enum req_unchanging_status is_req_preventing(const struct req_context *context, const struct player *other_player, const struct requirement *req, enum req_problem_type prob_type)
#define requirement_vector_iterate_end
#define requirement_vector_iterate(req_vec, preq)
static struct research research_array[MAX_NUM_PLAYER_SLOTS]
int research_goal_unknown_techs(const struct research *presearch, Tech_type_id goal)
bool research_invention_reachable(const struct research *presearch, const Tech_type_id tech)
bool research_goal_tech_req(const struct research *presearch, Tech_type_id goal, Tech_type_id tech)
const char * research_name_translation(const struct research *presearch)
#define research_may_become_allowed(presearch, tech)
enum tech_state research_invention_set(struct research *presearch, Tech_type_id tech, enum tech_state value)
static struct name_translation advance_unknown_name
struct research * research_by_number(int number)
const char * research_advance_rule_name(const struct research *presearch, Tech_type_id tech)
int player_tech_upkeep(const struct player *pplayer)
bool research_future_next(const struct research *presearch)
static void * research_player_iter_not_pooled_get(const struct iterator *it)
static void * research_iter_get(const struct iterator *it)
static bool research_iter_player_valid(const struct iterator *it)
static void * research_player_iter_pooled_get(const struct iterator *it)
static struct name_translation advance_unset_name
static void research_player_iter_not_pooled_next(struct iterator *it)
size_t research_iter_sizeof(void)
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)
#define research_is_allowed(presearch, tech)
void researches_init(void)
static void research_player_iter_pooled_next(struct iterator *it)
static void research_iter_player_next(struct iterator *it)
static struct name_translation advance_future_name
static bool research_get_root_reqs_known(const struct research *presearch, Tech_type_id tech)
int research_number(const struct research *presearch)
static bool research_player_iter_valid_state(struct iterator *it)
int research_goal_bulbs_required(const struct research *presearch, Tech_type_id goal)
const char * research_advance_name_translation(const struct research *presearch, Tech_type_id tech)
int research_total_bulbs_required(const struct research *presearch, Tech_type_id tech, bool loss_value)
static const struct name_translation * research_advance_name(Tech_type_id tech)
struct iterator * research_iter_init(struct research_iter *it)
int recalculate_techs_researched(const struct research *presearch)
const char * research_rule_name(const struct research *presearch)
static struct strvec * future_rule_name
static bool research_get_reachable_rreqs(const struct research *presearch, Tech_type_id tech)
struct research * research_get(const struct player *pplayer)
void researches_free(void)
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
static bool research_get_reachable(const struct research *presearch, Tech_type_id tech)
static bool research_player_iter_not_pooled_valid(const struct iterator *it)
static bool research_iter_team_valid(const struct iterator *it)
Tech_type_id research_goal_step(const struct research *presearch, Tech_type_id goal)
bool research_invention_gettable(const struct research *presearch, const Tech_type_id tech, bool allow_holes)
static bool research_player_iter_pooled_valid(const struct iterator *it)
#define RESEARCH_PLAYER_ITER(p)
size_t research_player_iter_sizeof(void)
static const char * research_future_set_name(struct strvec *psv, int no, const char *new_name)
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))
struct iterator * research_player_iter_init(struct research_player_iter *it, const struct research *presearch)
static struct strvec * future_name_translation
void research_update(struct research *presearch)
static void research_iter_team_next(struct iterator *it)
int research_pretty_name(const struct research *presearch, char *buf, size_t buf_len)
#define research_players_iterate(_presearch, _pplayer)
#define researches_iterate(_presearch)
#define research_players_iterate_end
#define researches_iterate_end
void strvec_destroy(struct strvec *psv)
bool strvec_set(struct strvec *psv, size_t svindex, const char *string)
void strvec_reserve(struct strvec *psv, size_t reserve)
const char * strvec_get(const struct strvec *psv, size_t svindex)
struct strvec * strvec_new(void)
size_t strvec_size(const struct strvec *psv)
struct requirement_vector research_reqs
struct name_translation name
struct packet_ruleset_control control
struct packet_game_info info
bool(* valid)(const struct iterator *it)
bool team_pooled_research
enum tech_upkeep_style tech_upkeep_style
bool global_advances[A_LAST]
enum tech_leakage_style tech_leakage
enum tech_cost_style tech_cost_style
struct city_list * cities
int bulbs_researched_saved
struct player_list_link * plink
struct research::research_invention inventions[A_ARRAY_SIZE]
Tech_type_id researching_saved
int num_known_tech_with_flag[TF_COUNT]
int fc_snprintf(char *str, size_t n, const char *format,...)
size_t fc_strlcpy(char *dest, const char *src, size_t n)
struct team * team_by_number(const int team_id)
const char * team_name_translation(const struct team *pteam)
const char * team_rule_name(const struct team *pteam)
int team_number(const struct team *pteam)
bool team_slots_initialised(void)
int team_pretty_name(const struct team *pteam, char *buf, size_t buf_len)
const struct player_list * team_members(const struct team *pteam)
int team_slot_count(void)
struct advance * advance_by_number(const Tech_type_id atype)
bool is_future_tech(Tech_type_id tech)
struct advance * valid_advance(struct advance *padvance)
bool advance_has_flag(Tech_type_id tech, enum tech_flag_id flag)
struct advance * advance_requires(const struct advance *padvance, enum tech_req require)
struct advance * valid_advance_by_number(const Tech_type_id id)
Tech_type_id advance_required(const Tech_type_id tech, enum tech_req require)
const char * advance_rule_name(const struct advance *padvance)
Tech_type_id advance_number(const struct advance *padvance)
#define advance_index_iterate_end
#define advance_req_iterate(_goal, _padvance)
#define advance_iterate(_start, _p)
#define advance_req_iterate_end
static Tech_type_id advance_count(void)
#define advance_root_req_iterate_end
#define advance_iterate_end
#define advance_index_iterate(_start, _index)
#define advance_root_req_iterate(_goal, _padvance)