File diff r5375:772a1c1f8fa4 → r5376:226f4edfd4b1
players.c
Show inline comments
 
@@ -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, uint
 
			} 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, uint
 
		/* 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();
 
		}