|
@@ -25,12 +25,35 @@
|
|
|
#include "variables.h"
|
|
|
#include "engine.h"
|
|
|
#include "ai/ai.h"
|
|
|
#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)
|
|
|
{
|
|
|
/* Get the color for DrawString-subroutines which matches the color
|
|
|
* of the player */
|
|
|
if (!IsValidPlayer(player)) return _colour_gradient[COLOUR_WHITE][4] | IS_PALETTE_COLOR;
|
|
@@ -835,21 +858,22 @@ int32 CmdPlayerCtrl(TileIndex tile, uint
|
|
|
NetworkClientInfo *ci = &_network_client_info[cid];
|
|
|
ci->client_playas = PLAYER_SPECTATOR;
|
|
|
NetworkUpdateClientInfo(ci->client_index);
|
|
|
} else
|
|
|
#endif /* ENABLE_NETWORK */
|
|
|
{
|
|
|
_local_player = _network_playas = PLAYER_SPECTATOR;
|
|
|
_network_playas = PLAYER_SPECTATOR;
|
|
|
SetLocalPlayer(PLAYER_SPECTATOR);
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
/* 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();
|
|
|
}
|
|
|
|
|
|
/* Now that we have a new player, broadcast its autorenew settings to
|
|
|
* all clients so everything is in sync */
|
|
|
DoCommand(0,
|