summaryrefslogtreecommitdiff
path: root/players.c
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2006-12-26 12:56:48 +0000
committerrubidium <rubidium@openttd.org>2006-12-26 12:56:48 +0000
commit9560a1d9ec28080ab2fd49f760591da5fe85a08d (patch)
treeb5bcd33d161b6f6ae2e80e6b0e7ad2f3badc52ff /players.c
parent80c3be09fce9f7c1ae41fa9f4984dd0941073feb (diff)
downloadopenttd-9560a1d9ec28080ab2fd49f760591da5fe85a08d.tar.xz
(svn r7561) -Fix (FS#431): core and (patches) GUI were not in-sync with respect to autorenew settings. This is only a temporary fix, as the definite fix needs to move the autorenew settings to a per-company settings window.
Diffstat (limited to 'players.c')
-rw-r--r--players.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/players.c b/players.c
index 1dc2b5601..c6652b7a3 100644
--- a/players.c
+++ b/players.c
@@ -28,6 +28,29 @@
#include "date.h"
#include "window.h"
+/**
+ * Sets the local player and updates the patch settings that are set on a
+ * per-company (player) basis to reflect the core's state in the GUI.
+ * @param new_player the new player
+ * @pre IsValidPlayer(new_player) || new_player == PLAYER_SPECTATOR || new_player == OWNER_NONE
+ */
+void SetLocalPlayer(PlayerID new_player)
+{
+ /* Player could also be PLAYER_SPECTATOR or OWNER_NONE */
+ assert(IsValidPlayer(new_player) || new_player == PLAYER_SPECTATOR || new_player == OWNER_NONE);
+
+ _local_player = new_player;
+
+ /* Do not update the patches if we are in the intro GUI */
+ if (IsValidPlayer(new_player) && _game_mode != GM_MENU) {
+ const Player *p = GetPlayer(new_player);
+ _patches.autorenew = p->engine_renew;
+ _patches.autorenew_months = p->engine_renew_months;
+ _patches.autorenew_money = p->engine_renew_money;
+ InvalidateWindow(WC_GAME_OPTIONS, 0);
+ }
+}
+
uint16 GetDrawStringPlayerColor(PlayerID player)
{
@@ -838,7 +861,8 @@ int32 CmdPlayerCtrl(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
} else
#endif /* ENABLE_NETWORK */
{
- _local_player = _network_playas = PLAYER_SPECTATOR;
+ _network_playas = PLAYER_SPECTATOR;
+ SetLocalPlayer(PLAYER_SPECTATOR);
}
break;
}
@@ -846,7 +870,7 @@ int32 CmdPlayerCtrl(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
/* This is the joining client who wants a new company */
if (_local_player != _network_playas) {
assert(_local_player == PLAYER_SPECTATOR && _network_playas == p->index);
- _local_player = p->index;
+ SetLocalPlayer(p->index);
MarkWholeScreenDirty();
}