(svn r6774) -Codechange: Rename the badly named OWNER_SPECTATOR to PLAYER_SPECTATOR and

put it into player.h where it belongs (instead of map.h)
This commit is contained in:
Darkvater 2006-10-14 15:49:43 +00:00
parent 94339a884d
commit a85d679f54
30 changed files with 86 additions and 82 deletions

View File

@ -225,7 +225,7 @@ void AI_StartNewAI(PlayerID player)
void AI_PlayerDied(PlayerID player)
{
if (_ai.network_client && _ai.network_playas == player) {
_ai.network_playas = OWNER_SPECTATOR;
_ai.network_playas = PLAYER_SPECTATOR;
}
/* Called if this AI died */
@ -246,7 +246,7 @@ void AI_Initialize(void)
memset(&_ai_player, 0, sizeof(_ai_player));
_ai.network_client = ai_network_client;
_ai.network_playas = OWNER_SPECTATOR;
_ai.network_playas = PLAYER_SPECTATOR;
_ai.enabled = true;
}

View File

@ -133,7 +133,7 @@ static const WindowDesc _air_toolbar_desc = {
void ShowBuildAirToolbar(void)
{
if (_current_player == OWNER_SPECTATOR) return;
if (_current_player == PLAYER_SPECTATOR) return;
DeleteWindowById(WC_BUILD_TOOLBAR, 0);
AllocateWindowDescFront(&_air_toolbar_desc, 0);
if (_patches.link_terraform_toolbar) ShowTerraformToolbar();

View File

@ -426,7 +426,7 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
/** Spectator has no rights except for the dedicated server which
* is a spectator but is the server, so can do anything */
if (_current_player == OWNER_SPECTATOR && !_network_dedicated) {
if (_current_player == PLAYER_SPECTATOR && !_network_dedicated) {
ShowErrorMessage(_error_message, error_part1, x, y);
_cmd_text = NULL;
return false;
@ -500,7 +500,7 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
if (_networking && !(cmd & CMD_NETWORK_COMMAND)) {
if (_network_dedicated) _local_player = 0;
NetworkSend_Command(tile, p1, p2, cmd, callback);
if (_network_dedicated) _local_player = OWNER_SPECTATOR;
if (_network_dedicated) _local_player = PLAYER_SPECTATOR;
_docommand_recursive = 0;
_cmd_text = NULL;
return true;

View File

@ -214,7 +214,7 @@ static const WindowDesc _build_docks_toolbar_desc = {
void ShowBuildDocksToolbar(void)
{
if (_current_player == OWNER_SPECTATOR) return;
if (_current_player == PLAYER_SPECTATOR) return;
DeleteWindowById(WC_BUILD_TOOLBAR, 0);
AllocateWindowDesc(&_build_docks_toolbar_desc);
if (_patches.link_terraform_toolbar) ShowTerraformToolbar();

View File

@ -240,7 +240,7 @@ int UpdateCompanyRatingAndValue(Player *p, bool update)
return score;
}
// use OWNER_SPECTATOR as new_player to delete the player.
// use PLAYER_SPECTATOR as new_player to delete the player.
void ChangeOwnershipOfPlayerItems(PlayerID old_player, PlayerID new_player)
{
PlayerID old = _current_player;
@ -249,12 +249,12 @@ void ChangeOwnershipOfPlayerItems(PlayerID old_player, PlayerID new_player)
/* Temporarily increase the player's money, to be sure that
* removing his/her property doesn't fail because of lack of money.
* Not too drastically though, because it could overflow */
if (new_player == OWNER_SPECTATOR) {
if (new_player == PLAYER_SPECTATOR) {
GetPlayer(old_player)->money64 = MAX_UVALUE(uint64) >>2; // jackpot ;p
UpdatePlayerMoney32(GetPlayer(old_player));
}
if (new_player == OWNER_SPECTATOR) {
if (new_player == PLAYER_SPECTATOR) {
Subsidy *s;
for (s = _subsidies; s != endof(_subsidies); s++) {
@ -265,7 +265,7 @@ void ChangeOwnershipOfPlayerItems(PlayerID old_player, PlayerID new_player)
}
/* Take care of rating in towns */
if (new_player != OWNER_SPECTATOR) {
if (new_player != PLAYER_SPECTATOR) {
Town *t;
FOR_ALL_TOWNS(t) {
/* If a player takes over, give the ratings to that player. */
@ -306,7 +306,7 @@ void ChangeOwnershipOfPlayerItems(PlayerID old_player, PlayerID new_player)
FOR_ALL_VEHICLES(v) {
if (v->owner == old_player && IS_BYTE_INSIDE(v->type, VEH_Train, VEH_Aircraft + 1)) {
if (new_player == OWNER_SPECTATOR) {
if (new_player == PLAYER_SPECTATOR) {
DeleteWindowById(WC_VEHICLE_VIEW, v->index);
DeleteWindowById(WC_VEHICLE_DETAILS, v->index);
DeleteWindowById(WC_VEHICLE_ORDERS, v->index);
@ -334,7 +334,7 @@ void ChangeOwnershipOfPlayerItems(PlayerID old_player, PlayerID new_player)
}
// Change color of existing windows
if (new_player != OWNER_SPECTATOR) {
if (new_player != PLAYER_SPECTATOR) {
Window *w;
for (w = _windows; w != _last_window; w++) {
if (w->caption_color == old_player) w->caption_color = new_player;
@ -350,14 +350,14 @@ void ChangeOwnershipOfPlayerItems(PlayerID old_player, PlayerID new_player)
for (i = 0; i < 4; i++) {
/* 'Sell' the share if this player has any */
if (p->share_owners[i] == _current_player) {
p->share_owners[i] = OWNER_SPECTATOR;
p->share_owners[i] = PLAYER_SPECTATOR;
}
}
}
p = GetPlayer(_current_player);
/* Sell all the shares that people have on this company */
for (i = 0; i < 4; i++)
p->share_owners[i] = OWNER_SPECTATOR;
p->share_owners[i] = PLAYER_SPECTATOR;
}
_current_player = old;
@ -429,7 +429,7 @@ static void PlayersCheckBankrupt(Player *p)
FOR_ALL_CLIENTS(cs) {
ci = DEREF_CLIENT_INFO(cs);
if ((ci->client_playas-1) == owner) {
ci->client_playas = OWNER_SPECTATOR;
ci->client_playas = PLAYER_SPECTATOR;
// Send the new info to all the clients
NetworkUpdateClientInfo(_network_own_client_index);
}
@ -438,12 +438,12 @@ static void PlayersCheckBankrupt(Player *p)
// Make sure the player no longer controls the company
if (IsHumanPlayer(owner) && owner == _local_player) {
// Switch the player to spectator..
_local_player = OWNER_SPECTATOR;
_local_player = PLAYER_SPECTATOR;
}
#endif /* ENABLE_NETWORK */
/* Remove the player */
ChangeOwnershipOfPlayerItems(owner, OWNER_SPECTATOR);
ChangeOwnershipOfPlayerItems(owner, PLAYER_SPECTATOR);
// Register the player as not-active
p->is_active = false;
@ -1516,7 +1516,7 @@ static void DoAcquireCompany(Player *p)
value = CalculateCompanyValue(p) >> 2;
for (i = 0; i != 4; i++) {
if (p->share_owners[i] != OWNER_SPECTATOR) {
if (p->share_owners[i] != PLAYER_SPECTATOR) {
owner = GetPlayer(p->share_owners[i]);
owner->money64 += value;
owner->yearly_expenses[0][EXPENSES_OTHER] += value;
@ -1552,17 +1552,17 @@ int32 CmdBuyShareInCompany(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
if (_cur_year - p->inaugurated_year < 6) return_cmd_error(STR_7080_PROTECTED);
/* Those lines are here for network-protection (clients can be slow) */
if (GetAmountOwnedBy(p, OWNER_SPECTATOR) == 0) return 0;
if (GetAmountOwnedBy(p, PLAYER_SPECTATOR) == 0) return 0;
/* We can not buy out a real player (temporarily). TODO: well, enable it obviously */
if (GetAmountOwnedBy(p, OWNER_SPECTATOR) == 1 && !p->is_ai) return 0;
if (GetAmountOwnedBy(p, PLAYER_SPECTATOR) == 1 && !p->is_ai) return 0;
cost = CalculateCompanyValue(p) >> 2;
if (flags & DC_EXEC) {
PlayerID* b = p->share_owners;
int i;
while (*b != OWNER_SPECTATOR) b++; /* share owners is guaranteed to contain at least one OWNER_SPECTATOR */
while (*b != PLAYER_SPECTATOR) b++; /* share owners is guaranteed to contain at least one PLAYER_SPECTATOR */
*b = _current_player;
for (i = 0; p->share_owners[i] == _current_player;) {
@ -1603,7 +1603,7 @@ int32 CmdSellShareInCompany(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
if (flags & DC_EXEC) {
PlayerID* b = p->share_owners;
while (*b != _current_player) b++; /* share owners is guaranteed to contain player */
*b = OWNER_SPECTATOR;
*b = PLAYER_SPECTATOR;
InvalidateWindow(WC_COMPANY, p1);
}
return cost;

View File

@ -227,7 +227,7 @@ static PlayerID GetBestPlayer(PlayerID pp)
do {
best_hist = -1;
best_player = OWNER_SPECTATOR;
best_player = PLAYER_SPECTATOR;
FOR_ALL_PLAYERS(p) {
if (p->is_active && p->block_preview == 0 && !HASBIT(mask, p->index) &&
p->old_economy[0].performance_history > best_hist) {
@ -236,7 +236,7 @@ static PlayerID GetBestPlayer(PlayerID pp)
}
}
if (best_player == OWNER_SPECTATOR) return OWNER_SPECTATOR;
if (best_player == PLAYER_SPECTATOR) return PLAYER_SPECTATOR;
SETBIT(mask, best_player);
} while (--pp != 0);
@ -263,7 +263,7 @@ void EnginesDailyLoop(void)
} else if (e->preview_player != 0xFF) {
PlayerID best_player = GetBestPlayer(e->preview_player);
if (best_player == OWNER_SPECTATOR) {
if (best_player == PLAYER_SPECTATOR) {
e->preview_player = 0xFF;
continue;
}

View File

@ -235,7 +235,7 @@ void GenerateWorld(int mode, uint size_x, uint size_y)
_gw.threaded = true;
/* This disables some commands and stuff */
_local_player = OWNER_SPECTATOR;
_local_player = PLAYER_SPECTATOR;
/* Make sure everything is done via OWNER_NONE */
_current_player = OWNER_NONE;

View File

@ -265,7 +265,7 @@ static const WindowDesc * const _industry_window_desc[2][4] = {
void ShowBuildIndustryWindow(void)
{
if (_current_player == OWNER_SPECTATOR) return;
if (_current_player == PLAYER_SPECTATOR) return;
AllocateWindowDescFront(_industry_window_desc[_patches.build_rawmaterial_ind][_opt_ptr->landscape],0);
}

View File

@ -736,9 +736,9 @@ static Window *PopupMainPlayerToolbMenu(Window *w, int x, int main_button, int g
w = AllocateWindow(x, 0x16, 0xF1, 0x52, PlayerMenuWndProc, WC_TOOLBAR_MENU, _player_menu_widgets);
w->flags4 &= ~WF_WHITE_BORDER_MASK;
WP(w,menu_d).item_count = 0;
WP(w,menu_d).sel_index = (_local_player != OWNER_SPECTATOR) ? _local_player : GetPlayerIndexFromMenu(0);
WP(w,menu_d).sel_index = (_local_player != PLAYER_SPECTATOR) ? _local_player : GetPlayerIndexFromMenu(0);
if (_networking && main_button == 9) {
if (_local_player != OWNER_SPECTATOR) {
if (_local_player != PLAYER_SPECTATOR) {
WP(w,menu_d).sel_index++;
} else {
/* Select client list by default for spectators */
@ -802,7 +802,7 @@ static void ToolbarLeagueClick(Window *w)
static void ToolbarIndustryClick(Window *w)
{
/* Disable build-industry menu if we are a spectator */
PopupMainToolbMenu(w, 12, STR_INDUSTRY_DIR, 2, (_current_player == OWNER_SPECTATOR) ? (1 << 1) : 0);
PopupMainToolbMenu(w, 12, STR_INDUSTRY_DIR, 2, (_current_player == PLAYER_SPECTATOR) ? (1 << 1) : 0);
}
static void ToolbarTrainClick(Window *w)
@ -1807,7 +1807,7 @@ static void MainToolbarWndProc(Window *w, WindowEvent *e)
/* If spectator, disable all construction buttons
* ie : Build road, rail, ships, airports and landscaping
* Since enabled state is the default, just disable when needed */
SetWindowWidgetsDisabledState(w, _current_player == OWNER_SPECTATOR, 19, 20, 21, 22, 23, WIDGET_LIST_END);
SetWindowWidgetsDisabledState(w, _current_player == PLAYER_SPECTATOR, 19, 20, 21, 22, 23, WIDGET_LIST_END);
/* disable company list drop downs, if there are no companies */
SetWindowWidgetsDisabledState(w, ActivePlayerCount() == 0, 7, 8, 13, 14, 15, 16, WIDGET_LIST_END);
@ -1820,7 +1820,7 @@ static void MainToolbarWndProc(Window *w, WindowEvent *e)
} break;
case WE_KEYPRESS: {
PlayerID local = (_local_player != OWNER_SPECTATOR) ? _local_player : 0;
PlayerID local = (_local_player != PLAYER_SPECTATOR) ? _local_player : 0;
switch (e->we.keypress.keycode) {
case WKC_F1: case WKC_PAUSE:
@ -2140,7 +2140,7 @@ static void StatusBarWndProc(Window *w, WindowEvent *e)
{
switch (e->event) {
case WE_PAINT: {
const Player *p = (_local_player == OWNER_SPECTATOR) ? NULL : GetPlayer(_local_player);
const Player *p = (_local_player == PLAYER_SPECTATOR) ? NULL : GetPlayer(_local_player);
DrawWindowWidgets(w);
SetDParam(0, _date);
@ -2185,7 +2185,7 @@ static void StatusBarWndProc(Window *w, WindowEvent *e)
case WE_CLICK:
switch (e->we.click.widget) {
case 1: ShowLastNewsMessage(); break;
case 2: if (_local_player != OWNER_SPECTATOR) ShowPlayerFinances(_local_player); break;
case 2: if (_local_player != PLAYER_SPECTATOR) ShowPlayerFinances(_local_player); break;
default: ResetObjectToPlace();
}
break;

2
map.h
View File

@ -72,8 +72,6 @@ typedef enum Owner {
OWNER_NONE = 0x10, // nobody owns the tile
OWNER_WATER = 0x11, // "water" owns the tile
OWNER_END = 0x12,
OWNER_SPECTATOR = 0xFF, // spectator in MP or in scenario editor
} Owner;
enum {

View File

@ -108,7 +108,7 @@ byte NetworkSpectatorCount(void)
byte count = 0;
FOR_ALL_CLIENTS(cs) {
if (DEREF_CLIENT_INFO(cs)->client_playas == OWNER_SPECTATOR) count++;
if (DEREF_CLIENT_INFO(cs)->client_playas == PLAYER_SPECTATOR) count++;
}
return count;
@ -1035,7 +1035,7 @@ static void NetworkInitGameInfo(void)
ci->client_index = NETWORK_SERVER_INDEX;
if (_network_dedicated) {
ci->client_playas = OWNER_SPECTATOR;
ci->client_playas = PLAYER_SPECTATOR;
} else {
ci->client_playas = _local_player + 1;
}

View File

@ -342,7 +342,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_CLIENT_INFO)
/* Are we a ai-network-client? Are we not joining as a SPECTATOR (playas == 0, means SPECTATOR) */
if (_ai.network_client && playas != 0) {
if (_ai.network_playas == OWNER_SPECTATOR)
if (_ai.network_playas == PLAYER_SPECTATOR)
AI_StartNewAI(playas - 1);
_ai.network_playas = playas - 1;
@ -521,16 +521,16 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_MAP)
if (_network_playas == 0 || _network_playas > MAX_PLAYERS ||
!GetPlayer(_network_playas - 1)->is_active) {
if (_network_playas == OWNER_SPECTATOR) {
if (_network_playas == PLAYER_SPECTATOR) {
// The client wants to be a spectator..
_local_player = OWNER_SPECTATOR;
_local_player = PLAYER_SPECTATOR;
DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
} else {
/* We have arrived and ready to start playing; send a command to make a new player;
* the server will give us a client-id and let us in */
_local_player = 0;
NetworkSend_Command(0, 0, 0, CMD_PLAYER_CTRL, NULL);
_local_player = OWNER_SPECTATOR;
_local_player = PLAYER_SPECTATOR;
}
} else {
// take control over an existing company
@ -544,9 +544,9 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_MAP)
/* Check if we are an ai-network-client, and if so, disable GUI */
if (_ai.network_client) {
_ai.network_playas = _local_player;
_local_player = OWNER_SPECTATOR;
_local_player = PLAYER_SPECTATOR;
if (_ai.network_playas != OWNER_SPECTATOR) {
if (_ai.network_playas != PLAYER_SPECTATOR) {
/* If we didn't join the game as a spectator, activate the AI */
AI_StartNewAI(_ai.network_playas);
}
@ -745,7 +745,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_NEWGAME)
{
// To trottle the reconnects a bit, every clients waits
// his _local_player value before reconnecting
// OWNER_SPECTATOR is currently 255, so to avoid long wait periods
// PLAYER_SPECTATOR is currently 255, so to avoid long wait periods
// set the max to 10.
_network_reconnect = min(_local_player + 1, 10);
_switch_mode_errorstr = STR_NETWORK_SERVER_REBOOT;

View File

@ -933,7 +933,7 @@ static void NetworkLobbyWindowWndProc(Window *w, WindowEvent *e)
NetworkClientConnectGame(_network_last_host, _network_last_port);
break;
case 9: /* Spectate game */
_network_playas = OWNER_SPECTATOR;
_network_playas = PLAYER_SPECTATOR;
NetworkClientConnectGame(_network_last_host, _network_last_port);
break;
case 10: /* Refresh */

View File

@ -602,7 +602,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_JOIN)
return;
}
break;
case OWNER_SPECTATOR: /* Spectator */
case PLAYER_SPECTATOR: /* Spectator */
if (NetworkSpectatorCount() >= _network_game_info.spectators_max) {
SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_FULL);
return;

View File

@ -586,7 +586,7 @@ static void MakeNewGameDone(void)
{
/* In a dedicated server, the server does not play */
if (_network_dedicated) {
_local_player = OWNER_SPECTATOR;
_local_player = PLAYER_SPECTATOR;
return;
}
@ -794,7 +794,7 @@ void SwitchMode(int new_mode)
/* Delete all players */
FOR_ALL_PLAYERS(p) {
if (p->is_active) {
ChangeOwnershipOfPlayerItems(p->index, OWNER_SPECTATOR);
ChangeOwnershipOfPlayerItems(p->index, PLAYER_SPECTATOR);
p->is_active = false;
}
}
@ -874,7 +874,7 @@ static void DoAutosave(void)
{
char buf[200];
if (_patches.keep_all_autosave && _local_player != OWNER_SPECTATOR) {
if (_patches.keep_all_autosave && _local_player != PLAYER_SPECTATOR) {
const Player *p = GetPlayer(_local_player);
char *s;
sprintf(buf, "%s%s", _path.autosave_dir, PATHSEP);

View File

@ -211,7 +211,13 @@ void UpdatePlayerMoney32(Player *p);
VARDEF PlayerID _local_player;
VARDEF PlayerID _current_player;
#define MAX_PLAYERS 8
/* Player identifiers All players below MAX_PLAYERS are playable
* players, above, they are special, computer controlled players */
enum {
PLAYER_SPECTATOR = 255, ///< Spectator in Multiplayer or the player in the scenario editor
MAX_PLAYERS = 8,
};
VARDEF Player _players[MAX_PLAYERS];
// NOSAVE: can be determined from player structs
VARDEF byte _player_colors[MAX_PLAYERS];

View File

@ -693,16 +693,16 @@ static void PlayerCompanyWndProc(Window *w, WindowEvent *e)
if (!local) {
if (_patches.allow_shares) { // Shares are allowed
/* If all shares are owned by someone (none by nobody), disable buy button */
SetWindowWidgetDisabledState(w, PCW_WIDGET_BUY_SHARE, GetAmountOwnedBy(p, OWNER_SPECTATOR) == 0 ||
SetWindowWidgetDisabledState(w, PCW_WIDGET_BUY_SHARE, GetAmountOwnedBy(p, PLAYER_SPECTATOR) == 0 ||
/* Only 25% left to buy. If the player is human, disable buying it up.. TODO issues! */
(GetAmountOwnedBy(p, OWNER_SPECTATOR) == 1 && !p->is_ai) ||
(GetAmountOwnedBy(p, PLAYER_SPECTATOR) == 1 && !p->is_ai) ||
/* Spectators cannot do anything of course */
_local_player == OWNER_SPECTATOR);
_local_player == PLAYER_SPECTATOR);
/* If the player doesn't own any shares, disable sell button */
SetWindowWidgetDisabledState(w, PCW_WIDGET_SELL_SHARE, (GetAmountOwnedBy(p, _local_player) == 0) ||
/* Spectators cannot do anything of course */
_local_player == OWNER_SPECTATOR);
_local_player == PLAYER_SPECTATOR);
} else { // Shares are not allowed, disable buy/sell buttons
DisableWindowWidget(w, PCW_WIDGET_BUY_SHARE);
DisableWindowWidget(w, PCW_WIDGET_SELL_SHARE);
@ -1105,7 +1105,7 @@ void ShowEndGameChart(void)
WP(w, highscore_d).background_img = SPR_TYCOON_IMG1_BEGIN;
if (_local_player != OWNER_SPECTATOR) {
if (_local_player != PLAYER_SPECTATOR) {
const Player *p = GetPlayer(_local_player);
if (p->old_economy[0].performance_history == SCORE_MAX)
WP(w, highscore_d).background_img = SPR_TYCOON_IMG2_BEGIN;

View File

@ -33,7 +33,7 @@ uint16 GetDrawStringPlayerColor(PlayerID player)
/* Get the color for DrawString-subroutines which matches the color of the
* player
*/
if (player == OWNER_SPECTATOR || player == OWNER_SPECTATOR - 1) return 1;
if (player == PLAYER_SPECTATOR || player == PLAYER_SPECTATOR - 1) return 1;
return (_colour_gradient[_player_colors[player]][4]) | IS_PALETTE_COLOR;
}
@ -498,7 +498,7 @@ Player *DoStartupNewPlayer(bool is_ai)
p->is_ai = is_ai;
p->ai.state = 5; /* AIS_WANT_NEW_ROUTE */
p->share_owners[0] = p->share_owners[1] = p->share_owners[2] = p->share_owners[3] = OWNER_SPECTATOR;
p->share_owners[0] = p->share_owners[1] = p->share_owners[2] = p->share_owners[3] = PLAYER_SPECTATOR;
p->avail_railtypes = GetPlayerRailtypes(p->index);
p->inaugurated_year = _cur_year;
@ -606,7 +606,7 @@ void PlayersYearlyLoop(void)
}
}
if (_patches.show_finances && _local_player != OWNER_SPECTATOR) {
if (_patches.show_finances && _local_player != PLAYER_SPECTATOR) {
ShowPlayerFinances(_local_player);
p = GetPlayer(_local_player);
if (p->num_valid_stat_ent > 5 && p->old_economy[0].performance_history < p->old_economy[4].performance_history) {
@ -829,25 +829,25 @@ int32 CmdPlayerCtrl(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
p = DoStartupNewPlayer(false);
#ifdef ENABLE_NETWORK
if (_networking && !_network_server && _local_player == OWNER_SPECTATOR) {
if (_networking && !_network_server && _local_player == PLAYER_SPECTATOR) {
/* In case we are a client joining a server... */
DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
}
#endif /* ENABLE_NETWORK */
if (p != NULL) {
if (_local_player == OWNER_SPECTATOR &&
(!_ai.network_client || _ai.network_playas == OWNER_SPECTATOR)) {
if (_local_player == PLAYER_SPECTATOR &&
(!_ai.network_client || _ai.network_playas == PLAYER_SPECTATOR)) {
/* Check if we do not want to be a spectator in network */
if (!_networking ||
(_network_server && !_network_dedicated) ||
_network_playas != OWNER_SPECTATOR ||
_network_playas != PLAYER_SPECTATOR ||
_ai.network_client) {
if (_ai.network_client) {
/* As ai-network-client, we have our own rulez (disable GUI and stuff) */
_ai.network_playas = p->index;
_local_player = OWNER_SPECTATOR;
if (_ai.network_playas != OWNER_SPECTATOR) {
_local_player = PLAYER_SPECTATOR;
if (_ai.network_playas != PLAYER_SPECTATOR) {
/* If we didn't join the game as a spectator, activate the AI */
AI_StartNewAI(_ai.network_playas);
}
@ -895,7 +895,7 @@ int32 CmdPlayerCtrl(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
* server-side in network_server.c:838, function
* DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_COMMAND) */
NetworkClientInfo *ci = &_network_client_info[pid];
ci->client_playas = OWNER_SPECTATOR;
ci->client_playas = PLAYER_SPECTATOR;
NetworkUpdateClientInfo(ci->client_index);
#endif /* ENABLE_NETWORK */
}
@ -927,7 +927,7 @@ int32 CmdPlayerCtrl(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
AddNewsItem( (StringID)(p->index + 16*3), NEWS_FLAGS(NM_CALLBACK, 0, NT_COMPANY_INFO, DNC_BANKRUPCY),0,0);
/* Remove the company */
ChangeOwnershipOfPlayerItems(p->index, OWNER_SPECTATOR);
ChangeOwnershipOfPlayerItems(p->index, PLAYER_SPECTATOR);
p->is_active = false;
}
RemoveAllEngineReplacementForPlayer(p);

View File

@ -1952,7 +1952,7 @@ static void ChangeTileOwner_Track(TileIndex tile, PlayerID old_player, PlayerID
{
if (!IsTileOwner(tile, old_player)) return;
if (new_player != OWNER_SPECTATOR) {
if (new_player != PLAYER_SPECTATOR) {
SetTileOwner(tile, new_player);
} else {
DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);

View File

@ -589,7 +589,7 @@ void ShowBuildRailToolbar(RailType railtype, int button)
{
Window *w;
if (_current_player == OWNER_SPECTATOR) return;
if (_current_player == PLAYER_SPECTATOR) return;
if (!ValParamRailtype(railtype)) return;
// don't recreate the window if we're clicking on a button and the window exists.

View File

@ -1069,12 +1069,12 @@ static uint32 VehicleEnter_Road(Vehicle *v, TileIndex tile, int x, int y)
static void ChangeTileOwner_Road(TileIndex tile, PlayerID old_player, PlayerID new_player)
{
if (IsLevelCrossing(tile) && GetCrossingRoadOwner(tile) == old_player) {
SetCrossingRoadOwner(tile, new_player == OWNER_SPECTATOR ? OWNER_NONE : new_player);
SetCrossingRoadOwner(tile, new_player == PLAYER_SPECTATOR ? OWNER_NONE : new_player);
}
if (!IsTileOwner(tile, old_player)) return;
if (new_player != OWNER_SPECTATOR) {
if (new_player != PLAYER_SPECTATOR) {
SetTileOwner(tile, new_player);
} else {
switch (GetRoadTileType(tile)) {

View File

@ -318,7 +318,7 @@ static const WindowDesc _build_road_desc = {
void ShowBuildRoadToolbar(void)
{
if (_current_player == OWNER_SPECTATOR) return;
if (_current_player == PLAYER_SPECTATOR) return;
DeleteWindowById(WC_BUILD_TOOLBAR, 0);
AllocateWindowDesc(&_build_road_desc);
if (_patches.link_terraform_toolbar) ShowTerraformToolbar();

View File

@ -497,7 +497,7 @@ static char *MakeScreenshotName(const char *ext)
char *base;
int serial;
if (_game_mode == GM_EDITOR || _game_mode == GM_MENU || _local_player == OWNER_SPECTATOR) {
if (_game_mode == GM_EDITOR || _game_mode == GM_MENU || _local_player == PLAYER_SPECTATOR) {
sprintf(_screenshot_name, "screenshot");
} else {
const Player* p = GetPlayer(_local_player);

View File

@ -444,7 +444,7 @@ static Station* GetClosestStationFromTile(TileIndex tile, uint threshold, Player
Station* st;
FOR_ALL_STATIONS(st) {
if ((owner == OWNER_SPECTATOR || st->owner == owner)) {
if ((owner == PLAYER_SPECTATOR || st->owner == owner)) {
uint cur_dist = DistanceManhattan(tile, st->xy);
if (cur_dist < threshold) {
@ -2814,7 +2814,7 @@ static void ChangeTileOwner_Station(TileIndex tile, PlayerID old_player, PlayerI
{
if (!IsTileOwner(tile, old_player)) return;
if (new_player != OWNER_SPECTATOR) {
if (new_player != PLAYER_SPECTATOR) {
Station* st = GetStationByTile(tile);
SetTileOwner(tile, new_player);

View File

@ -274,6 +274,6 @@ static const WindowDesc _terraform_desc = {
void ShowTerraformToolbar(void)
{
if (_current_player == OWNER_SPECTATOR) return;
if (_current_player == PLAYER_SPECTATOR) return;
AllocateWindowDescFront(&_terraform_desc, 0);
}

View File

@ -44,7 +44,7 @@ uint GetMaskOfTownActions(int *nump, PlayerID pid, const Town *t)
uint avail_buttons = 0x7F; // by default all buttons except bribe are enabled.
uint buttons = 0;
if (pid != OWNER_SPECTATOR) {
if (pid != PLAYER_SPECTATOR) {
uint i;
// bribe option enabled?

View File

@ -1314,7 +1314,7 @@ static void ChangeTileOwner_TunnelBridge(TileIndex tile, PlayerID old_player, Pl
{
if (!IsTileOwner(tile, old_player)) return;
if (new_player != OWNER_SPECTATOR) {
if (new_player != PLAYER_SPECTATOR) {
SetTileOwner(tile, new_player);
} else {
if (IsBridge(tile) && IsBridgeMiddle(tile) && IsTransportUnderBridge(tile)) {

View File

@ -388,7 +388,7 @@ static void ChangeTileOwner_Unmovable(TileIndex tile, PlayerID old_player, Playe
{
if (!IsTileOwner(tile, old_player)) return;
if (IsOwnedLand(tile) && new_player != OWNER_SPECTATOR) {
if (IsOwnedLand(tile) && new_player != PLAYER_SPECTATOR) {
SetTileOwner(tile, new_player);
} else {
DoClearSquare(tile);

View File

@ -238,8 +238,8 @@ static void DedicatedVideoMainLoop(void)
// Load the dedicated server stuff
_is_network_server = true;
_network_dedicated = true;
_network_playas = OWNER_SPECTATOR;
_local_player = OWNER_SPECTATOR;
_network_playas = PLAYER_SPECTATOR;
_local_player = PLAYER_SPECTATOR;
/* If SwitchMode is SM_LOAD, it means that the user used the '-g' options */
if (_switch_mode != SM_LOAD) {

View File

@ -729,7 +729,7 @@ static void ChangeTileOwner_Water(TileIndex tile, PlayerID old_player, PlayerID
{
if (!IsTileOwner(tile, old_player)) return;
if (new_player != OWNER_SPECTATOR) {
if (new_player != PLAYER_SPECTATOR) {
SetTileOwner(tile, new_player);
} else {
DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);