summaryrefslogtreecommitdiff
path: root/src/economy.cpp
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2010-08-06 20:28:16 +0000
committeralberth <alberth@openttd.org>2010-08-06 20:28:16 +0000
commit3536357cc6b1b80f8b578314142b7ed2fa276592 (patch)
tree9547e8e9024c1a2c44ed204481094939783c64d0 /src/economy.cpp
parent422a1ad24286594285ec6dc14182dd29a92ea21a (diff)
downloadopenttd-3536357cc6b1b80f8b578314142b7ed2fa276592.tar.xz
(svn r20393) -Fix [FS#3993]: Prevent taking over competitors when you'd get too many vehicles.
Diffstat (limited to 'src/economy.cpp')
-rw-r--r--src/economy.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/economy.cpp b/src/economy.cpp
index a9a61850d..dcf7d3990 100644
--- a/src/economy.cpp
+++ b/src/economy.cpp
@@ -1517,8 +1517,12 @@ CommandCost CmdBuyShareInCompany(TileIndex tile, DoCommandFlag flags, uint32 p1,
/* Those lines are here for network-protection (clients can be slow) */
if (GetAmountOwnedBy(c, COMPANY_SPECTATOR) == 0) return cost;
- /* We can not buy out a real company (temporarily). TODO: well, enable it obviously */
- if (GetAmountOwnedBy(c, COMPANY_SPECTATOR) == 1 && !c->is_ai) return cost;
+ if (GetAmountOwnedBy(c, COMPANY_SPECTATOR) == 1) {
+ if (!c->is_ai) return cost; // We can not buy out a real company (temporarily). TODO: well, enable it obviously.
+
+ if (GetAmountOwnedBy(c, _current_company) == 3 && !MayCompanyTakeOver(_current_company, target_company)) return_cmd_error(STR_ERROR_TOO_MANY_VEHICLES_IN_GAME);
+ }
+
cost.AddCost(CalculateCompanyValue(c) >> 2);
if (flags & DC_EXEC) {