|
@@ -19,24 +19,47 @@
|
|
|
#include "gfx.h"
|
|
|
#include "news.h"
|
|
|
#include "saveload.h"
|
|
|
#include "command.h"
|
|
|
#include "sound.h"
|
|
|
#include "network.h"
|
|
|
#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;
|
|
|
return (_colour_gradient[_player_colors[player]][4]) | IS_PALETTE_COLOR;
|
|
|
}
|
|
|
|
|
|
|
|
|
static const SpriteID cheeks_table[4] = {
|
|
|
0x325, 0x326,
|
|
@@ -829,33 +852,34 @@ int32 CmdPlayerCtrl(TileIndex tile, uint
|
|
|
p = DoStartupNewPlayer(false);
|
|
|
|
|
|
/* A new player could not be created, revert to being a spectator */
|
|
|
if (p == NULL) {
|
|
|
#ifdef ENABLE_NETWORK
|
|
|
if (_network_server) {
|
|
|
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,
|
|
|
(_patches.autorenew << 15 ) | (_patches.autorenew_months << 16) | 4,
|
|
|
_patches.autorenew_money,
|
|
|
DC_EXEC,
|
|
|
CMD_SET_AUTOREPLACE
|
|
|
);
|
|
|
|