![]() |
Freeciv21
Develop your civilization from humble roots to a global empire
|
#include "fcintl.h"#include "log.h"#include "rand.h"#include "support.h"#include "game.h"#include "government.h"#include "movement.h"#include "player.h"#include "research.h"#include "tech.h"#include "unit.h"#include "luascript_types.h"#include "citytools.h"#include "cityturn.h"#include "connecthand.h"#include "gamehand.h"#include "maphand.h"#include "notify.h"#include "plrhand.h"#include "unittools.h"#include "script_server.h"#include "techtools.h"
Include dependency graph for techtools.cpp:Go to the source code of this file.
Functions | |
| static Tech_type_id | pick_random_tech_to_lose (const struct research *presearch) |
| Choose a random tech for player to lose. More... | |
| static Tech_type_id | pick_random_tech (const struct research *presearch) |
| Returns random researchable tech or A_FUTURE. More... | |
| static Tech_type_id | pick_cheapest_tech (const struct research *presearch) |
| Returns cheapest researchable tech, random among equal cost ones. More... | |
| static void | research_tech_lost (struct research *presearch, Tech_type_id tech) |
| Remove one tech from the research. More... | |
| static void | forget_tech_transfered (struct player *pplayer, Tech_type_id tech) |
| Let the player forget one tech. More... | |
| void | research_apply_penalty (struct research *presearch, Tech_type_id tech, int penalty_percent) |
| Apply a penalty to the research. More... | |
| 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. More... | |
| static void | tech_researched (struct research *research) |
| Players have researched a new technology. More... | |
| void | do_tech_parasite_effect (struct player *pplayer) |
| Give technologies to players with EFT_TECH_PARASITE (traditionally from the Great Library). More... | |
| static void | package_research_info (struct packet_research_info *packet, const struct research *presearch) |
| Fill packet fields. More... | |
| void | send_research_info (const struct research *presearch, const struct conn_list *dest) |
| Send research info for 'presearch' to 'dest'. More... | |
| 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). More... | |
| static bool | lose_tech (struct research *research) |
| Is player about to lose tech? More... | |
| void | update_bulbs (struct player *pplayer, int bulbs, bool check_tech) |
| Adds the given number of bulbs into the player's tech and (if necessary and 'check_tech' is TRUE) completes the research. More... | |
| 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. More... | |
| void | choose_tech (struct research *research, Tech_type_id tech) |
| Called when a player chooses the tech he wants to research (or when the server chooses it for him automatically). More... | |
| void | choose_tech_goal (struct research *presearch, Tech_type_id tech) |
| Called when a player chooses the tech goal he wants to research (or when the server chooses it for him automatically). More... | |
| void | init_tech (struct research *research, bool update) |
| Initializes tech data for the research. More... | |
| 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. More... | |
| 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. More... | |
| void | handle_player_research (struct player *pplayer, int tech) |
| Handle incoming research packet. More... | |
| void | handle_player_tech_goal (struct player *pplayer, int tech_goal) |
| Handle incoming player_tech_goal packet Called from the network or AI code to set the player's tech goal. More... | |
| Tech_type_id | pick_free_tech (struct research *presearch) |
| Choose a free tech. More... | |
| void | give_immediate_free_tech (struct research *presearch, Tech_type_id tech) |
| Give an immediate free tech (probably chosen with pick_free_tech()). More... | |
| 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. More... | |
| 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:
Definition at line 972 of file techtools.cpp.
Referenced by end_phase(), and init_tech().
| void choose_tech | ( | struct research * | research, |
| Tech_type_id | tech | ||
| ) |
Called when a player chooses the tech he wants to research (or when the server chooses it for him 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 987 of file techtools.cpp.
Referenced by choose_random_tech(), dai_manage_tech(), end_phase(), found_new_tech(), handle_player_research(), and init_tech().
| void choose_tech_goal | ( | struct research * | presearch, |
| Tech_type_id | tech | ||
| ) |
Called when a player chooses the tech goal he wants to research (or when the server chooses it for him automatically).
Definition at line 1055 of file techtools.cpp.
Referenced by dai_manage_tech(), and handle_player_tech_goal().
| void do_tech_parasite_effect | ( | struct player * | pplayer | ) |
Give technologies to players with EFT_TECH_PARASITE (traditionally from the Great Library).
Definition at line 139 of file techtools.cpp.
Referenced by end_phase().
|
static |
Let the player forget one tech.
Definition at line 1408 of file techtools.cpp.
Referenced by tech_transfer().
| 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 341 of file techtools.cpp.
Referenced by api_edit_give_technology(), do_tech_parasite_effect(), give_immediate_free_tech(), give_initial_techs(), handle_diplomacy_accept_treaty_req(), steal_a_tech(), and tech_researched().
| 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 1399 of file techtools.cpp.
Referenced by city_build_building(), and found_new_tech().
| 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 1179 of file techtools.cpp.
Referenced by create_animals(), create_barbarian_player(), handle_edit_player_create(), and srv_ready().
| void handle_player_research | ( | struct player * | pplayer, |
| int | tech | ||
| ) |
Handle incoming research packet.
Need to check correctness Set the player to be researching the given tech.
If there are enough accumulated research points, the tech may be acquired immediately.
Definition at line 1331 of file techtools.cpp.
| void handle_player_tech_goal | ( | struct player * | pplayer, |
| int | tech_goal | ||
| ) |
Handle incoming player_tech_goal packet Called from the network or AI code to set the player's tech goal.
Definition at line 1354 of file techtools.cpp.
| void init_tech | ( | struct research * | research, |
| bool | update | ||
| ) |
Initializes tech data for the research.
Definition at line 1075 of file techtools.cpp.
Referenced by create_animals(), create_barbarian_player(), handle_edit_player_create(), helptext_nation(), sg_load_researches(), and srv_ready().
|
static |
Is player about to lose tech?
Definition at line 617 of file techtools.cpp.
Referenced by update_bulbs().
|
inlinestatic |
Fill packet fields.
Helper for following functions.
Definition at line 233 of file techtools.cpp.
Referenced by send_research_info().
|
static |
Returns cheapest researchable tech, random among equal cost ones.
Definition at line 938 of file techtools.cpp.
Referenced by pick_free_tech().
| Tech_type_id pick_free_tech | ( | struct research * | presearch | ) |
Choose a free tech.
Definition at line 1380 of file techtools.cpp.
Referenced by api_edit_give_technology(), city_build_building(), and found_new_tech().
|
static |
Returns random researchable tech or A_FUTURE.
No side effects.
Definition at line 918 of file techtools.cpp.
Referenced by choose_random_tech(), found_new_tech(), give_initial_techs(), and pick_free_tech().
|
static |
Choose a random tech for player to lose.
Definition at line 722 of file techtools.cpp.
Referenced by update_bulbs().
| void research_apply_penalty | ( | struct research * | presearch, |
| Tech_type_id | tech, | ||
| int | penalty_percent | ||
| ) |
Apply a penalty to the research.
Definition at line 59 of file techtools.cpp.
Referenced by api_edit_give_technology(), do_tech_parasite_effect(), give_immediate_free_tech(), handle_diplomacy_accept_treaty_req(), and steal_a_tech().
|
static |
Remove one tech from the research.
Definition at line 793 of file techtools.cpp.
Referenced by forget_tech_transfered(), and update_bulbs().
| 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 nullptr, and is only used to order the emission of the signals.
Definition at line 77 of file techtools.cpp.
Referenced by api_edit_give_technology(), handle_diplomacy_accept_treaty_req(), steal_a_tech(), and tech_researched().
| void send_research_info | ( | const struct research * | presearch, |
| const struct conn_list * | dest | ||
| ) |
Send research info for 'presearch' to 'dest'.
'dest' can be nullptr to send to all established connections.
Definition at line 273 of file techtools.cpp.
Referenced by create_animals(), create_barbarian_player(), 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().
| 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 1227 of file techtools.cpp.
Referenced by diplomat_get_tech(), kill_unit(), and unit_conquer_city().
|
static |
Players have researched a new technology.
Definition at line 102 of file techtools.cpp.
Referenced by choose_tech(), and update_bulbs().
| 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 1432 of file techtools.cpp.
Referenced by handle_diplomacy_accept_treaty_req(), and steal_a_tech().
| void update_bulbs | ( | struct player * | pplayer, |
| int | bulbs, | ||
| bool | check_tech | ||
| ) |
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 is lost.
The caller is responsible for sending updated player information.
This is called from each city every turn, from caravan revenue, and at the end of the phase.
Definition at line 650 of file techtools.cpp.
Referenced by do_unit_establish_trade(), end_phase(), srv_ready(), and update_city_activity().