45 #undef TECH_UPKEEP_DEBUGGING
78 struct player *originating_plr,
79 struct advance *tech,
const char *reason)
83 if (originating_plr) {
92 if (member != originating_plr) {
113 _(
"The %s have researched %s."), research_name,
141 struct effect_list *plist = effect_list_new();
153 effect_list_destroy(plist);
166 game.
info.tech_parasite_allow_holes)
175 if (mod <= ++num_teams) {
176 if (0 ==
fc_rand(++num_techs)) {
189 effect_list_destroy(plist);
201 Q_(
"?fromeffect:%s acquired from %s!"),
202 qUtf8Printable(advance_name), qUtf8Printable(
effects));
206 Q_(
"?fromeffect:%s acquired from %s's %s!"),
207 qUtf8Printable(advance_name),
player_name(pplayer),
210 plr_research,
nullptr, E_TECH_EMBASSY,
ftc_server,
213 Q_(
"?fromeffect:The %s have acquired %s from %s."), research_name,
214 qUtf8Printable(advance_name), qUtf8Printable(
effects));
216 effect_list_destroy(plist);
240 packet->researching_cost =
245 packet->tech_goal = presearch->
tech_goal;
246 packet->total_bulbs_prod = 0;
251 packet->total_bulbs_prod += pcity->surplus[
O_SCIENCE];
262 packet->tech_goal = presearch->
tech_goal;
274 const struct conn_list *dest)
276 struct packet_research_info full_info, restricted_info;
277 const struct player *pplayer;
280 if (
nullptr == dest) {
286 restricted_info = full_info;
287 restricted_info.tech_goal =
A_UNSET;
288 restricted_info.total_bulbs_prod = 0;
293 if (
nullptr != pplayer) {
310 EFT_NATION_INTELLIGENCE)
324 send_packet_research_info(pconn, &full_info);
326 send_packet_research_info(pconn, &restricted_info);
328 }
else if (pconn->observer) {
330 send_packet_research_info(pconn, &full_info);
342 bool was_discovery,
bool saving_bulbs)
346 bool was_first =
false;
347 bool bonus_tech_hack =
false;
349 QString advance_name;
357 was_first = (!
game.
info.global_advances[tech_found]);
363 if (was_first && vap) {
369 if (pobs->source.kind == VUT_ADVANCE
370 && pobs->source.value.advance == vap
371 && pobs->range >= REQ_RANGE_WORLD && pobs->survives
375 ftc_server,
_(
"Discovery of %s OBSOLETES %s in %s!"),
389 bonus_tech_hack =
true;
477 _(
"Discovery of %s makes the government form %s"
478 " available. You may want to start a revolution."),
479 qUtf8Printable(advance_name),
500 if (0 < had_embassies[i]
505 if (aplayer != pother_player) {
515 if (tech_found == presearch->
tech_goal) {
528 _(
"Learned %s. Our scientists focus on %s; "
530 qUtf8Printable(advance_name),
532 presearch, next_tech)),
544 if (
is_ai(aplayer)) {
554 _(
"Learned %s. Scientists "
555 "do not know what to research next."),
556 qUtf8Printable(advance_name));
559 _(
"Learned %s. Scientists choose to research %s."),
560 qUtf8Printable(advance_name),
562 presearch, next_tech)));
580 if (bonus_tech_hack) {
593 && additional_tech !=
A_UNSET) {
596 qUtf8Printable(radv_name));
597 }
else if (additional_tech !=
A_UNSET) {
601 _(
"Great scientists from all the "
602 "world join your civilization: you learn "
604 qUtf8Printable(radv_name));
608 _(
"%s acquire %s as a result of learning %s."),
609 research_name, qUtf8Printable(radv_name),
610 qUtf8Printable(advance_name));
619 if (
game.
info.techloss_forgiveness < 0) {
637 *
game.
info.techloss_forgiveness / 100);
660 pplayer->
server.bulbs_last_turn += bulbs;
701 _(
"Insufficient science output. We lost %s."),
724 bv_techs eligible_techs;
736 BV_CLR(eligible_techs, i);
745 BV_CLR(eligible_techs, root);
747 if (!
game.
info.tech_loss_allow_holes) {
754 BV_CLR(eligible_techs, prereq);
759 BV_CLR(eligible_techs, prereq);
771 chosen =
fc_rand(eligible) + 1;
785 fc_assert_msg(chosen == 0,
"internal error (eligible=%d, chosen=%d)",
807 presearch,
nullptr, E_TECH_EMBASSY,
ftc_server,
808 _(
"The %s have lost %s."), research_name,
817 presearch,
nullptr, E_TECH_EMBASSY,
ftc_server,
819 _(
"The %s have lost %s."), research_name,
839 pplayer,
nullptr, E_NEW_GOVERNMENT,
ftc_server,
840 _(
"The required technology for our government '%s' "
841 "was lost. The country has fallen into %s."),
846 }
else if (
nullptr != pplayer->target_government
848 pplayer->target_government)) {
853 _(
"The required technology for our new government "
854 "'%s' was lost. The country has fallen into %s."),
857 pplayer->target_government = pgov;
865 log_debug(
"lost technology for activity of unit %s of %s (%d, %d)",
879 if (pcity->production.kind == VUT_UTYPE
881 pcity->production.value.utype)) {
884 _(
"%s can't build %s. The required technology was "
892 if (pcity->production.kind == VUT_IMPROVEMENT
894 pcity, pcity->production.value.building)) {
897 _(
"%s can't build %s. The required technology was "
926 if (
fc_rand(++num_techs) == 0) {
940 int cheapest_cost = -1;
941 int cheapest_amount = 0;
949 if (cost < cheapest_cost || cheapest_cost == -1) {
950 cheapest_cost = cost;
953 }
else if (cost == cheapest_cost &&
fc_rand(++cheapest_amount) == 0) {
1068 _(
"Technology goal is %s."),
1085 #ifdef TECH_UPKEEP_DEBUGGING
1089 bool global_state[
A_LAST];
1095 global_state[i] =
game.
info.global_advances[i];
1106 "[research %d] %-25s (ID: %3d) cost: %6d - reachable: %-3s "
1107 "(now) / %-3s (ever)",
1137 log_debug(
"[player %d] researched: %-25s (ID: %4d) techs: %3d "
1151 game.
info.global_advances[i] = global_state[i];
1215 for (i = 0; i < num_random_techs; i++) {
1230 struct research *presearch, *vresearch;
1232 QString advance_name;
1289 stolen_tech = preferred;
1295 _(
"You steal %s from the %s."), qUtf8Printable(advance_name),
1298 _(
"The %s stole %s from the %s and shared it with you."),
1300 qUtf8Printable(advance_name),
1304 _(
"The %s stole %s from you!"),
1306 qUtf8Printable(advance_name));
1309 _(
"The %s have stolen %s from the %s."),
1310 research_name, qUtf8Printable(advance_name),
1384 if (
game.
info.free_tech_method == FTM_CHEAPEST) {
1387 ||
game.
info.free_tech_method == FTM_RANDOM) {
1417 _(
"Too bad! You made a mistake transferring the tech %s and "
1422 _(
"Too bad! The %s made a mistake transferring the tech "
1437 bool donor_can_lose =
true;
1445 || (!
game.
info.tech_trade_loss_allow_holes
1448 donor_can_lose =
false;
bool BV_ISSET(const BV &bv, int bit)
struct player * city_owner(const struct city *pcity)
Return the owner of the city.
struct tile * city_tile(const struct city *pcity)
Return the tile location of the city.
bool can_city_build_improvement_now(const struct city *pcity, const struct impr_type *pimprove)
Return whether given city can build given building; returns FALSE if the building is obsolete.
bool can_city_build_unit_now(const struct city *pcity, const struct unit_type *punittype)
Return whether given city can build given unit; returns FALSE if unit is obsolete.
#define city_list_iterate(citylist, pcity)
#define city_list_iterate_end
void remove_obsolete_buildings(struct player *pplayer)
Sell obsolete buildings from all cities of the player.
void choose_build_target(struct player *pplayer, struct city *pcity)
Assuming we just finished building something, find something new to build.
bool city_refresh(struct city *pcity)
Updates unit upkeeps and city internal cached data.
struct player * conn_get_player(const struct connection *pconn)
Returns the player that this connection is attached to, or nullptr.
#define conn_list_iterate(connlist, pconn)
#define conn_list_iterate_end
struct effect_list * effects[EFT_COUNT]
int get_player_bonus_effects(struct effect_list *plist, const struct player *pplayer, enum effect_type effect_type)
Returns the effect sources of this type currently active at the player.
int get_player_intel_bonus(const struct player *pplayer, const struct player *pother, enum national_intelligence nintel, enum effect_type effect_type)
Gets the player effect bonus of a national intelligence.
QString get_effect_list_req_text(const struct effect_list *plist)
Make user-friendly text for an effect list.
int get_player_bonus(const struct player *pplayer, enum effect_type effect_type)
Returns the effect bonus for a player.
#define MAX_NUM_PLAYER_SLOTS
#define MAX_NUM_TECH_LIST
const struct ft_color ftc_server
const char * city_link(const struct city *pcity)
Get a text link to a city.
void send_game_info(struct conn_list *dest)
Send game_info packet; some server options and various stuff...
struct government * government_of_player(const struct player *pplayer)
Return the government of a player.
Government_type_id government_count()
Return the number of governments.
std::vector< government > governments
bool can_change_to_government(struct player *pplayer, const struct government *gov)
Can change to government if appropriate tech exists, and one of:
Government_type_id government_number(const struct government *pgovern)
Return the government index.
Government_type_id government_index(const struct government *pgovern)
Return the government index.
const char * government_name_translation(const struct government *pgovern)
Return the (translated) name of the given government.
struct city * city_from_great_wonder(const struct impr_type *pimprove)
Get the world city with this great wonder.
bool is_great_wonder(const struct impr_type *pimprove)
Is this building a great wonder?
const char * improvement_name_translation(const struct impr_type *pimprove)
Return the (translated) name of the given improvement.
#define improvement_iterate_end
#define improvement_iterate(_p)
#define fc_assert_msg(condition, message,...)
#define fc_assert_ret(condition)
#define fc_assert(condition)
#define log_debug(message,...)
#define whole_map_iterate(_map, _tile)
#define whole_map_iterate_end
void send_tile_info(struct conn_list *dest, struct tile *ptile, bool send_unknown)
Send tile information to all the clients in dest which know and see the tile.
bool update_player_tile_knowledge(struct player *pplayer, struct tile *ptile)
Give pplayer the correct knowledge about tile; return TRUE iff knowledge changed.
void upgrade_all_city_extras(struct player *pplayer, bool discovery)
To be called when a player gains some better extra building tech for the first time.
bool map_is_known_and_seen(const struct tile *ptile, const struct player *pplayer, enum vision_layer vlayer)
Returns whether the layer 'vlayer' of the tile 'ptile' is known and seen by the player 'pplayer'.
const char * nation_plural_for_player(const struct player *pplayer)
Return the (translated) plural noun of the given nation of a player.
struct nation_type * nation_of_player(const struct player *pplayer)
Return the nation of a player.
void notify_research(const struct research *presearch, const struct player *exclude, enum event_type event, const struct ft_color color, const char *format,...)
Sends a message to all players that share research.
void notify_player(const struct player *pplayer, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...)
Similar to notify_conn_packet (see also), but takes player as "destination".
void notify_research_embassies(const struct research *presearch, const struct player *exclude, enum event_type event, const struct ft_color color, const char *format,...)
Sends a message to all players that have embassies with someone who shares research.
bool player_slots_initialised()
Return whether player slots are already initialized.
int player_index(const struct player *pplayer)
Return the player index.
const char * player_name(const struct player *pplayer)
Return the leader name of the player.
#define players_iterate_end
#define players_iterate(_pplayer)
#define player_list_iterate(playerlist, pplayer)
#define player_list_iterate_end
void send_player_all_c(struct player *src, struct conn_list *dest)
Send all information about a player (player_info and all player_diplstates) to the given connections.
void send_player_info_c(struct player *src, struct conn_list *dest)
Send information about player slot 'src', or all valid (i.e.
void handle_player_change_government(struct player *pplayer, Government_type_id government)
Called by the client or AI to change government.
#define shuffled_players_iterate_end
#define shuffled_players_iterate(NAME_pplayer)
#define requirement_vector_iterate_end
#define requirement_vector_iterate(req_vec, preq)
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...
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.
int player_tech_upkeep(const struct player *pplayer)
Calculate the bulb upkeep needed for all techs of a player.
struct research * research_get(const struct player *pplayer)
Returns the research structure associated with the player.
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'.
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'.
int research_number(const research *presearch)
Returns the index of the research in the array.
int research_total_bulbs_required(const struct research *presearch, Tech_type_id tech, bool loss_value)
Function to determine cost for technology.
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Returns state of the tech for current research.
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.
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.
bool research_is_valid(const struct research &presearch)
Checks whether the research object is valid in the current game.
void research_update(struct research *presearch)
Mark as TECH_PREREQS_KNOWN each tech which is available, not known and which has all requirements ful...
const char * research_rule_name(const struct research *presearch)
Returns the name of the research owner: a player name or a team name.
int research_pretty_name(const struct research *presearch, char *buf, size_t buf_len)
Set in 'buf' the name of the research owner.
#define research_players_iterate(_presearch, _pplayer)
#define research_players_iterate_end
std::vector< research > research_array
void script_server_signal_emit(const char *signal_name,...)
Invoke all the callback functions attached to a given signal.
struct civ_game::@28::@32 server
struct conn_list * est_connections
int global_init_techs[MAX_NUM_TECH_LIST]
struct packet_game_info info
struct civ_game::@27 rgame
struct government * government_during_revolution
int init_techs[MAX_NUM_TECH_LIST]
struct player::@65::@67 server
int bulbs_researched_saved
int bulbs_researching_saved
Tech_type_id researching_saved
struct research::research_invention inventions[A_LAST]
const struct player_list * team_members(const struct team *pteam)
Returns the member list of the team.
bool is_future_tech(Tech_type_id tech)
Is the given tech a future tech.
bool advance_has_flag(Tech_type_id tech, enum tech_flag_id flag)
Return TRUE if the tech has this flag otherwise FALSE.
const char * advance_rule_name(const struct advance *padvance)
Return the (untranslated) rule name of the advance/technology.
struct advance * advance_by_number(const Tech_type_id atype)
Return the advance for the given advance index.
Tech_type_id advance_required(const Tech_type_id tech, enum tech_req require)
Accessor for requirements.
struct advance * valid_advance_by_number(const Tech_type_id id)
Returns pointer when the advance "exists" in this game, returns nullptr otherwise.
Tech_type_id advance_count()
Return the number of advances/technologies.
#define advance_index_iterate_end
#define advance_index_iterate(_start, _index)
void set_unit_activity(struct unit *punit, enum unit_activity new_activity)
Assign a new untargeted task to a unit.
bool can_unit_continue_current_activity(struct unit *punit)
Check if the unit's current activity is actually legal.
#define unit_list_iterate(unitlist, punit)
#define unit_list_iterate_end
const char * utype_name_translation(const struct unit_type *punittype)
Return the (translated) name of the unit type.
const char * unit_name_translation(const struct unit *punit)
Return the (translated) name of the unit.