summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack Baron <jackmbaron@gmail.com>2019-10-18 01:47:29 +0100
committerCharles Pigott <charlespigott@googlemail.com>2019-10-19 20:31:44 +0100
commit7c9dedb94f3b3ebca222f544f7d7502f22d03bb7 (patch)
tree774c0a7e71ef1db71f3618987d5ccede2c810e28
parent53f8d0b815a7be57fb6489d95e67b9002ade14d7 (diff)
downloadopenttd-7c9dedb94f3b3ebca222f544f7d7502f22d03bb7.tar.xz
Feature: Configure minimum share trading years
-rw-r--r--src/economy.cpp2
-rw-r--r--src/lang/english.txt2
-rw-r--r--src/settings_gui.cpp1
-rw-r--r--src/settings_type.h1
-rw-r--r--src/table/settings.ini13
5 files changed, 18 insertions, 1 deletions
diff --git a/src/economy.cpp b/src/economy.cpp
index e8fbea094..6fd795b35 100644
--- a/src/economy.cpp
+++ b/src/economy.cpp
@@ -2030,7 +2030,7 @@ CommandCost CmdBuyShareInCompany(TileIndex tile, DoCommandFlag flags, uint32 p1,
if (c == nullptr || !_settings_game.economy.allow_shares || _current_company == target_company) return CMD_ERROR;
/* Protect new companies from hostile takeovers */
- if (_cur_year - c->inaugurated_year < 6) return_cmd_error(STR_ERROR_PROTECTED);
+ if (_cur_year - c->inaugurated_year < _settings_game.economy.min_years_for_shares) return_cmd_error(STR_ERROR_PROTECTED);
/* Those lines are here for network-protection (clients can be slow) */
if (GetAmountOwnedBy(c, COMPANY_SPECTATOR) == 0) return cost;
diff --git a/src/lang/english.txt b/src/lang/english.txt
index 8651639fd..bb3da82cc 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -1556,6 +1556,8 @@ STR_CONFIG_SETTING_SMOOTH_ECONOMY :Enable smooth e
STR_CONFIG_SETTING_SMOOTH_ECONOMY_HELPTEXT :When enabled, industry production changes more often, and in smaller steps. This setting has usually no effect, if industry types are provided by a NewGRF
STR_CONFIG_SETTING_ALLOW_SHARES :Allow buying shares from other companies: {STRING2}
STR_CONFIG_SETTING_ALLOW_SHARES_HELPTEXT :When enabled, allow buying and selling of company shares. Shares will only be available for companies reaching a certain age
+STR_CONFIG_SETTING_MIN_YEARS_FOR_SHARES :Minimum company age to trade shares: {STRING2}
+STR_CONFIG_SETTING_MIN_YEARS_FOR_SHARES_HELPTEXT :Set the minimum age of a company for others to be able to buy and sell shares from them.
STR_CONFIG_SETTING_FEEDER_PAYMENT_SHARE :Percentage of leg profit to pay in feeder systems: {STRING2}
STR_CONFIG_SETTING_FEEDER_PAYMENT_SHARE_HELPTEXT :Percentage of income given to the intermediate legs in feeder systems, giving more control over the income
STR_CONFIG_SETTING_DRAG_SIGNALS_DENSITY :When dragging, place signals every: {STRING2}
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp
index bde6e0557..e93da22d0 100644
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -1768,6 +1768,7 @@ static SettingsContainer &GetSettingsTree()
ai->Add(new SettingEntry("economy.give_money"));
ai->Add(new SettingEntry("economy.allow_shares"));
+ ai->Add(new SettingEntry("economy.min_years_for_shares"));
}
main->Init();
diff --git a/src/settings_type.h b/src/settings_type.h
index 45d32105b..0033aaf1c 100644
--- a/src/settings_type.h
+++ b/src/settings_type.h
@@ -472,6 +472,7 @@ struct EconomySettings {
bool bribe; ///< enable bribing the local authority
bool smooth_economy; ///< smooth economy
bool allow_shares; ///< allow the buying/selling of shares
+ uint8 min_years_for_shares; ///< minimum age of a company for it to trade shares
uint8 feeder_payment_share; ///< percentage of leg payment to virtually pay in feeder systems
byte dist_local_authority; ///< distance for town local authority, default 20
bool exclusive_rights; ///< allow buying exclusive rights
diff --git a/src/table/settings.ini b/src/table/settings.ini
index 714a8c86c..6e39f239b 100644
--- a/src/table/settings.ini
+++ b/src/table/settings.ini
@@ -1426,6 +1426,19 @@ proc = InvalidateCompanyWindow
[SDT_VAR]
base = GameSettings
+var = economy.min_years_for_shares
+type = SLE_UINT8
+def = 6
+min = 0
+max = 255
+interval = 1
+str = STR_CONFIG_SETTING_MIN_YEARS_FOR_SHARES
+strhelp = STR_CONFIG_SETTING_MIN_YEARS_FOR_SHARES_HELPTEXT
+strval = STR_JUST_INT
+cat = SC_EXPERT
+
+[SDT_VAR]
+base = GameSettings
var = economy.feeder_payment_share
type = SLE_UINT8
from = SLV_134