summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2004-12-12 14:00:25 +0000
committertruelight <truelight@openttd.org>2004-12-12 14:00:25 +0000
commit397bd915a3dd5d606f5ae7f66125ef5e86e481fb (patch)
treee4e7650b01674332130afe59c7295958de9ad60f
parente027fa76b1a9b5ff48e645f640dac323fcdeff2c (diff)
downloadopenttd-397bd915a3dd5d606f5ae7f66125ef5e86e481fb.tar.xz
(svn r1023) -Fix: [Network] [ 1083692 ] You can no longer buy out a company in MP
because of the lag between commands (anyway, I hope)
-rw-r--r--economy.c9
-rw-r--r--player_gui.c6
2 files changed, 12 insertions, 3 deletions
diff --git a/economy.c b/economy.c
index 9fa35e5c4..804763d1d 100644
--- a/economy.c
+++ b/economy.c
@@ -1466,6 +1466,8 @@ static void DoAcquireCompany(Player *p)
DeletePlayerWindows(pi);
}
+extern int GetAmountOwnedBy(Player *p, byte owner);
+
int32 CmdBuyShareInCompany(int x, int y, uint32 flags, uint32 p1, uint32 p2)
{
Player *p;
@@ -1476,6 +1478,13 @@ int32 CmdBuyShareInCompany(int x, int y, uint32 flags, uint32 p1, uint32 p2)
SET_EXPENSES_TYPE(EXPENSES_OTHER);
p = DEREF_PLAYER(p1);
+ /* Those lines are here for network-protection (clients can be slow) */
+ if (GetAmountOwnedBy(p, OWNER_SPECTATOR) == 0)
+ return 0;
+ /* We can not buy out a real player in networking */
+ if (GetAmountOwnedBy(p, OWNER_SPECTATOR) == 1 && !p->is_ai)
+ return 0;
+
cost = CalculateCompanyValue(p) >> 2;
if (flags & DC_EXEC) {
b = p->share_owners;
diff --git a/player_gui.c b/player_gui.c
index 541429ac7..c0990a27e 100644
--- a/player_gui.c
+++ b/player_gui.c
@@ -443,7 +443,7 @@ static void DrawPlayerVehiclesAmount(int player)
}
}
-static int GetAmountOwnedBy(Player *p, byte owner)
+int GetAmountOwnedBy(Player *p, byte owner)
{
return (p->share_owners[0] == owner) +
(p->share_owners[1] == owner) +
@@ -489,10 +489,10 @@ static void PlayerCompanyWndProc(Window *w, WindowEvent *e)
SetDParam(2, GetPlayerNameString((byte)w->window_number, 3));
dis = 0;
- if (GetAmountOwnedBy(p, 0xFF) == 0) dis |= 1 << 9;
+ if (GetAmountOwnedBy(p, OWNER_SPECTATOR) == 0) dis |= 1 << 9;
// Also disable the buy button if 25% is not-owned by someone
// and the player is not an AI
- if (GetAmountOwnedBy(p, 0xFF) == 1 && !p->is_ai) dis |= 1 << 9;
+ if (GetAmountOwnedBy(p, OWNER_SPECTATOR) == 1 && !p->is_ai) dis |= 1 << 9;
if (GetAmountOwnedBy(p, _local_player) == 0) dis |= 1 << 10;
w->disabled_state = dis;