Freeciv-3.2: /fast/freeciv/nightly/S3_2/server/techtools.h File Reference

Freeciv-3.2

Loading...
Searching...
No Matches
Data Structures | Functions
techtools.h File Reference
`#include "government.h"`
`#include "player.h"`
`#include "tech.h"`

Go to the source code of this file.

## Data Structures

struct | cur_govs_data

## Functions

void | research_apply_penalty (struct research *presearch, Tech_type_id tech, int penalty_percent)
void | do_tech_parasite_effects (struct player *pplayer)
void | send_research_info (const struct research *presearch, const struct conn_list *dest)
void | script_tech_learned (struct research *presearch, struct player *originating_plr, struct advance *tech, const char *reason)
void | found_new_tech (struct research *presearch, Tech_type_id tech_found, bool was_discovery, bool saving_bulbs)
void | update_bulbs (struct player *pplayer, int bulbs, bool check_tech, bool free_bulbs)
void | init_tech (struct research *presearch, bool update)
void | choose_tech (struct research *presearch, Tech_type_id tech)
void | choose_random_tech (struct research *presearch)
void | choose_tech_goal (struct research *presearch, Tech_type_id tech)
Tech_type_id | steal_a_tech (struct player *pplayer, struct player *target, Tech_type_id preferred)
Tech_type_id | pick_free_tech (struct research *presearch)
void | give_immediate_free_tech (struct research *presearch, Tech_type_id tech)
void | give_initial_techs (struct research *presearch, int num_random_techs)
bool | tech_transfer (struct player *plr_recv, struct player *plr_donor, Tech_type_id tech)
struct cur_govs_data * | create_current_governments_data (struct research *presearch)
struct cur_govs_data * | create_current_governments_data_all (void)
void | free_current_governments_data (struct cur_govs_data *data)
void | notify_new_government_options (struct player *pplayer, struct cur_govs_data *data, const char *reason)

## Function Documentation

## ◆ choose_random_tech()

void choose_random_tech | ( | struct research * | research | ) |

Finds and chooses (sets) a random research target from among all those available until presearch->researching != A_UNSET. Players may research more than one tech in this function. Possible reasons:

- techpenalty < 100;
- research.got_tech = TRUE and enough bulbs was saved;
- research.researching = A_UNSET and enough bulbs was saved.

Definition at line 989 of file techtools.c.

Referenced by end_phase(), and init_tech().

## ◆ choose_tech()

void choose_tech | ( | struct research * | research,
|  | Tech_type_id | tech
| ) |  |

Called when a player chooses the tech they want to research (or when the server chooses it for them automatically).

This takes care of all side effects so the research target probably shouldn't be changed outside of this function (doing so has been the cause of several bugs).

Definition at line 1004 of file techtools.c.

Referenced by choose_random_tech(), dai_manage_tech(), end_phase(), found_new_tech(), handle_player_research(), and init_tech().

## ◆ choose_tech_goal()

void choose_tech_goal | ( | struct research * | presearch,
|  | Tech_type_id | tech
| ) |  |

Called when a player chooses the tech goal they want to research (or when the server chooses it for them automatically).

Definition at line 1074 of file techtools.c.

Referenced by dai_manage_tech(), and handle_player_tech_goal().

## ◆ create_current_governments_data()

struct cur_govs_data * create_current_governments_data | ( | struct research * | presearch | ) |

Create data block listing what are the current government options of the players participating in the research.

Use free_current_governments_data() to free the returned data.

Definition at line 1489 of file techtools.c.

Referenced by found_new_tech().

## ◆ create_current_governments_data_all()

struct cur_govs_data * create_current_governments_data_all | ( | void |  | ) |

Create data block listing what are the current government options of the all players.

Use free_current_governments_data() to free the returned data.

Definition at line 1517 of file techtools.c.

Referenced by city_add_improvement_with_gov_notice().

## ◆ do_tech_parasite_effects()

void do_tech_parasite_effects | ( | struct player * | pplayer | ) |

Give technologies to players with EFT_TECH_PARASITE and the like (traditionally from the Great Library).

Definition at line 143 of file techtools.c.

Referenced by end_phase().

## ◆ found_new_tech()

void found_new_tech | ( | struct research * | presearch,
|  | Tech_type_id | tech_found,
|  | bool | was_discovery,
|  | bool | saving_bulbs
| ) |  |

Players sharing the research have got a new technology (from somewhere). 'was_discovery' is passed on to upgrade_city_extras. Logging and notification is not done here as it depends on how the tech came.

Definition at line 347 of file techtools.c.

Referenced by api_edit_give_technology(), do_tech_parasite_effects(), give_immediate_free_tech(), give_initial_techs(), handle_diplomacy_accept_treaty_req(), steal_a_tech(), and tech_researched().

## ◆ free_current_governments_data()

void free_current_governments_data | ( | struct cur_govs_data * | data | ) |

Free the data block returned from the create_current_governments_data()

Definition at line 1537 of file techtools.c.

Referenced by city_add_improvement_with_gov_notice(), and found_new_tech().

## ◆ give_immediate_free_tech()

void give_immediate_free_tech | ( | struct research * | presearch,
|  | Tech_type_id | tech
| ) |  |

Give an immediate free tech (probably chosen with pick_free_tech()). Applies freecost.

Definition at line 1406 of file techtools.c.

Referenced by city_build_building(), and found_new_tech().

## ◆ give_initial_techs()

void give_initial_techs | ( | struct research * | presearch,
|  | int | num_random_techs
| ) |  |

Gives global (read from the game.ruleset file) and nation (read from the nation ruleset files) initial techs as specified in the ruleset, and random free technologies thanks to the techlevel setting.

Definition at line 1187 of file techtools.c.

Referenced by create_animals(), create_barbarian_player(), create_command_newcomer(), handle_edit_player_create(), and srv_ready().

## ◆ init_tech()

void init_tech | ( | struct research * | research,
|  | bool | update
| ) |  |

Initializes tech data for the research.

Definition at line 1093 of file techtools.c.

Referenced by create_animals(), create_barbarian_player(), create_command_newcomer(), handle_edit_player_create(), sg_load_researches(), sg_load_researches(), and srv_ready().

## ◆ notify_new_government_options()

void notify_new_government_options | ( | struct player * | pplayer,
|  | struct cur_govs_data * | data,
|  | const char * | reason
| ) |  |

Notify player about any new government options they have compared to the data block provided.

Definition at line 1551 of file techtools.c.

Referenced by city_add_improvement_with_gov_notice(), and found_new_tech().

## ◆ pick_free_tech()

Tech_type_id pick_free_tech | ( | struct research * | presearch | ) |

Choose a free tech.

Definition at line 1387 of file techtools.c.

Referenced by api_edit_give_technology(), city_build_building(), and found_new_tech().

## ◆ research_apply_penalty()

void research_apply_penalty | ( | struct research * | presearch,
|  | Tech_type_id | tech,
|  | int | penalty_percent
| ) |  |

Apply a penalty to the research.

Definition at line 67 of file techtools.c.

Referenced by api_edit_give_technology(), do_tech_parasite_effects(), give_immediate_free_tech(), handle_diplomacy_accept_treaty_req(), and steal_a_tech().

## ◆ script_tech_learned()

void script_tech_learned | ( | struct research * | presearch,
|  | struct player * | originating_plr,
|  | struct advance * | tech,
|  | const char * | reason
| ) |  |

Emit script signal(s) for player/team learning new tech. originating_plr is the player whose action caused this; may be NULL, and is only used to order the emission of the signals.

Definition at line 84 of file techtools.c.

Referenced by api_edit_give_technology(), handle_diplomacy_accept_treaty_req(), steal_a_tech(), and tech_researched().

## ◆ send_research_info()

void send_research_info | ( | const struct research * | presearch,
|  | const struct conn_list * | dest
| ) |  |

Send research info for 'presearch' to 'dest'. 'dest' can be NULL to send to all established connections.

Definition at line 293 of file techtools.c.

Referenced by api_edit_player_give_bulbs(), create_animals(), create_barbarian_player(), create_command_newcomer(), do_unit_establish_trade(), end_turn(), establish_embassy(), found_new_tech(), government_change(), handle_edit_player(), handle_edit_player_create(), handle_player_research(), handle_player_tech_goal(), research_tech_lost(), send_all_info(), and send_city_info().

## ◆ steal_a_tech()

Tech_type_id steal_a_tech | ( | struct player * | pplayer,
|  | struct player * | victim,
|  | Tech_type_id | preferred
| ) |  |

If victim has a tech which pplayer doesn't have, pplayer will get it. The clients will both be notified and the conquer cost penalty applied. Used for diplomats and city conquest. If preferred is A_UNSET one random tech will be chosen. Returns the stolen tech or A_NONE if no tech was found.

Definition at line 1233 of file techtools.c.

Referenced by diplomat_get_tech(), diplomat_incite(), player_loot_player(), and unit_conquer_city().

## ◆ tech_transfer()

bool tech_transfer | ( | struct player * | plr_recv,
|  | struct player * | plr_donor,
|  | Tech_type_id | tech
| ) |  |

Check if the tech is lost by the donor or receiver. Returns if the receiver gets a new tech.

Definition at line 1437 of file techtools.c.

Referenced by handle_diplomacy_accept_treaty_req(), and steal_a_tech().

## ◆ update_bulbs()

void update_bulbs | ( | struct player * | pplayer,
|  | int | bulbs,
|  | bool | check_tech,
|  | bool | free_bulbs
| ) |  |

Adds the given number of bulbs into the player's tech and (if necessary and 'check_tech' is TRUE) completes the research. If the total number of bulbs is negative due to tech upkeep, one (randomly chosen) tech may be lost. free_bulbs allows to set the bulbs free for player to invest into any tech (in multiresearch mode it happens iff the tech is not selected).

The caller is responsible for sending updated player information.

This is called from each city every turn, from caravan revenue, at the end of the phase, and from Lua API.

Definition at line 654 of file techtools.c.

Referenced by api_edit_player_give_bulbs(), do_unit_establish_trade(), end_phase(), srv_ready(), update_city_activity(), and update_national_activities().