Changeset - r9652:8dc9b501f076
[Not reviewed]
src/ai/ai.cpp
Show inline comments
 
@@ -212,7 +212,7 @@ void AI_RunGameLoop()
 
 */
 
void AI_StartNewAI(PlayerID player)
 
{
 
	assert(IsValidPlayer(player));
 
	assert(IsValidPlayerID(player));
 

	
 
	/* Called if a new AI is booted */
 
	_ai_player[player].active = true;
src/airport_gui.cpp
Show inline comments
 
@@ -145,7 +145,7 @@ static const WindowDesc _air_toolbar_des
 

	
 
void ShowBuildAirToolbar()
 
{
 
	if (!IsValidPlayer(_current_player)) return;
 
	if (!IsValidPlayerID(_current_player)) return;
 

	
 
	DeleteWindowByClass(WC_BUILD_TOOLBAR);
 
	AllocateWindowDescFront<BuildAirToolbarWindow>(&_air_toolbar_desc, TRANSPORT_AIR);
src/autoslope.h
Show inline comments
 
@@ -39,7 +39,7 @@ static inline bool AutoslopeCheckForEntr
 
static inline bool AutoslopeEnabled()
 
{
 
	return (_settings_game.construction.autoslope &&
 
	        ((IsValidPlayer(_current_player) && !_is_old_ai_player) ||
 
	        ((IsValidPlayerID(_current_player) && !_is_old_ai_player) ||
 
	         (_current_player == OWNER_NONE && _game_mode == GM_EDITOR)));
 
}
 

	
src/cheat_gui.cpp
Show inline comments
 
@@ -44,7 +44,7 @@ static int32 ClickMoneyCheat(int32 p1, i
 
 */
 
static int32 ClickChangePlayerCheat(int32 p1, int32 p2)
 
{
 
	while (IsValidPlayer((PlayerID)p1)) {
 
	while (IsValidPlayerID((PlayerID)p1)) {
 
		if (_players[p1].is_active) {
 
			SetLocalPlayer((PlayerID)p1);
 

	
src/command.cpp
Show inline comments
 
@@ -448,7 +448,7 @@ error:
 
	if (--_docommand_recursive == 0 && !(flags & DC_BANKRUPT)) {
 
		SubtractMoneyFromPlayer(res);
 
		/* XXX - Old AI hack which doesn't use DoCommandDP; update last build coord of player */
 
		if (tile != 0 && IsValidPlayer(_current_player)) {
 
		if (tile != 0 && IsValidPlayerID(_current_player)) {
 
			GetPlayer(_current_player)->last_build_coordinate = tile;
 
		}
 
	}
 
@@ -467,7 +467,7 @@ error:
 
Money GetAvailableMoneyForCommand()
 
{
 
	PlayerID pid = _current_player;
 
	if (!IsValidPlayer(pid)) return INT64_MAX;
 
	if (!IsValidPlayerID(pid)) return INT64_MAX;
 
	return GetPlayer(pid)->player_money;
 
}
 

	
 
@@ -608,7 +608,7 @@ bool DoCommandP(TileIndex tile, uint32 p
 
	DebugDumpCommands("ddc:cmd:%d;%d;%d;%d;%d;%d;%d;%s\n", _date, _date_fract, (int)_current_player, tile, p1, p2, cmd, _cmd_text);
 

	
 
	/* update last build coordinate of player. */
 
	if (tile != 0 && IsValidPlayer(_current_player)) {
 
	if (tile != 0 && IsValidPlayerID(_current_player)) {
 
		GetPlayer(_current_player)->last_build_coordinate = tile;
 
	}
 

	
src/console_cmds.cpp
Show inline comments
 
@@ -608,7 +608,7 @@ DEF_CONSOLE_CMD(ConResetCompany)
 
	index = (PlayerID)(atoi(argv[1]) - 1);
 

	
 
	/* Check valid range */
 
	if (!IsValidPlayer(index)) {
 
	if (!IsValidPlayerID(index)) {
 
		IConsolePrintF(CC_ERROR, "Company does not exist. Company-id must be between 1 and %d.", MAX_PLAYERS);
 
		return true;
 
	}
 
@@ -654,7 +654,7 @@ DEF_CONSOLE_CMD(ConNetworkClients)
 
	FOR_ALL_ACTIVE_CLIENT_INFOS(ci) {
 
		IConsolePrintF(CC_INFO, "Client #%1d  name: '%s'  company: %1d  IP: %s",
 
		               ci->client_index, ci->client_name,
 
		               ci->client_playas + (IsValidPlayer(ci->client_playas) ? 1 : 0),
 
		               ci->client_playas + (IsValidPlayerID(ci->client_playas) ? 1 : 0),
 
		               GetPlayerIP(ci));
 
	}
 

	
 
@@ -694,7 +694,7 @@ DEF_CONSOLE_CMD(ConNetworkConnect)
 
		 * players are offset by one to ease up on users (eg players 1-8 not 0-7) */
 
		if (_network_playas != PLAYER_SPECTATOR) {
 
			_network_playas--;
 
			if (!IsValidPlayer(_network_playas)) return false;
 
			if (!IsValidPlayerID(_network_playas)) return false;
 
		}
 
	}
 
	if (port != NULL) {
 
@@ -1185,7 +1185,7 @@ DEF_CONSOLE_CMD(ConSayPlayer)
 
	if (argc != 3) return false;
 

	
 
	PlayerID player_id = (PlayerID)(atoi(argv[1]) - 1);
 
	if (!IsValidPlayer(player_id) || !GetPlayer(player_id)->is_active) {
 
	if (!IsValidPlayerID(player_id) || !GetPlayer(player_id)->is_active) {
 
		IConsolePrintF(CC_DEFAULT, "Unknown player. Player range is between 1 and %d.", MAX_PLAYERS);
 
		return true;
 
	}
 
@@ -1224,12 +1224,12 @@ extern void HashCurrentCompanyPassword()
 
bool NetworkChangeCompanyPassword(byte argc, char *argv[])
 
{
 
	if (argc == 0) {
 
		if (!IsValidPlayer(_local_player)) return true; // dedicated server
 
		if (!IsValidPlayerID(_local_player)) return true; // dedicated server
 
		IConsolePrintF(CC_WARNING, "Current value for 'company_pw': %s", _network_player_info[_local_player].password);
 
		return true;
 
	}
 

	
 
	if (!IsValidPlayer(_local_player)) {
 
	if (!IsValidPlayerID(_local_player)) {
 
		IConsoleError("You have to own a company to make use of this command.");
 
		return false;
 
	}
src/dock_gui.cpp
Show inline comments
 
@@ -277,7 +277,7 @@ static const WindowDesc _build_docks_too
 

	
 
void ShowBuildDocksToolbar()
 
{
 
	if (!IsValidPlayer(_current_player)) return;
 
	if (!IsValidPlayerID(_current_player)) return;
 

	
 
	DeleteWindowByClass(WC_BUILD_TOOLBAR);
 
	AllocateWindowDescFront<BuildDocksToolbarWindow>(&_build_docks_toolbar_desc, TRANSPORT_WATER);
src/economy.cpp
Show inline comments
 
@@ -1784,7 +1784,7 @@ CommandCost CmdBuyShareInCompany(TileInd
 

	
 
	/* Check if buying shares is allowed (protection against modified clients) */
 
	/* Cannot buy own shares */
 
	if (!IsValidPlayer((PlayerID)p1) || !_settings_game.economy.allow_shares || _current_player == (PlayerID)p1) return CMD_ERROR;
 
	if (!IsValidPlayerID((PlayerID)p1) || !_settings_game.economy.allow_shares || _current_player == (PlayerID)p1) return CMD_ERROR;
 

	
 
	p = GetPlayer((PlayerID)p1);
 

	
 
@@ -1833,7 +1833,7 @@ CommandCost CmdSellShareInCompany(TileIn
 

	
 
	/* Check if selling shares is allowed (protection against modified clients) */
 
	/* Cannot sell own shares */
 
	if (!IsValidPlayer((PlayerID)p1) || !_settings_game.economy.allow_shares || _current_player == (PlayerID)p1) return CMD_ERROR;
 
	if (!IsValidPlayerID((PlayerID)p1) || !_settings_game.economy.allow_shares || _current_player == (PlayerID)p1) return CMD_ERROR;
 

	
 
	p = GetPlayer((PlayerID)p1);
 

	
 
@@ -1871,7 +1871,7 @@ CommandCost CmdBuyCompany(TileIndex tile
 
	PlayerID pid = (PlayerID)p1;
 

	
 
	/* Disable takeovers in multiplayer games */
 
	if (!IsValidPlayer(pid) || _networking) return CMD_ERROR;
 
	if (!IsValidPlayerID(pid) || _networking) return CMD_ERROR;
 

	
 
	/* Do not allow players to take over themselves */
 
	if (pid == _current_player) return CMD_ERROR;
src/group_gui.cpp
Show inline comments
 
@@ -732,7 +732,7 @@ static const WindowDesc _group_desc = {
 

	
 
void ShowPlayerGroup(PlayerID player, VehicleType vehicle_type)
 
{
 
	if (!IsValidPlayer(player)) return;
 
	if (!IsValidPlayerID(player)) return;
 

	
 
	WindowClass wc;
 

	
src/industry_gui.cpp
Show inline comments
 
@@ -419,7 +419,7 @@ public:
 

	
 
void ShowBuildIndustryWindow()
 
{
 
	if (_game_mode != GM_EDITOR && !IsValidPlayer(_current_player)) return;
 
	if (_game_mode != GM_EDITOR && !IsValidPlayerID(_current_player)) return;
 
	if (BringWindowToFrontById(WC_BUILD_INDUSTRY, 0)) return;
 
	new BuildIndustryWindow();
 
}
src/main_gui.cpp
Show inline comments
 
@@ -342,7 +342,7 @@ struct MainWindow : Window
 
					if (cio == NULL) break;
 

	
 
					/* Only players actually playing can speak to team. Eg spectators cannot */
 
					if (_settings_client.gui.prefer_teamchat && IsValidPlayer(cio->client_playas)) {
 
					if (_settings_client.gui.prefer_teamchat && IsValidPlayerID(cio->client_playas)) {
 
						const NetworkClientInfo *ci;
 
						FOR_ALL_ACTIVE_CLIENT_INFOS(ci) {
 
							if (ci->client_playas == cio->client_playas && ci != cio) {
src/misc_cmd.cpp
Show inline comments
 
@@ -35,7 +35,7 @@ CommandCost CmdSetPlayerFace(TileIndex t
 
{
 
	PlayerFace pf = (PlayerFace)p2;
 

	
 
	if (!IsValidPlayerFace(pf)) return CMD_ERROR;
 
	if (!IsValidPlayerIDFace(pf)) return CMD_ERROR;
 

	
 
	if (flags & DC_EXEC) {
 
		GetPlayer(_current_player)->face = pf;
 
@@ -366,7 +366,7 @@ CommandCost CmdGiveMoney(TileIndex tile,
 

	
 
	/* You can only transfer funds that is in excess of your loan */
 
	if (p->player_money - p->current_loan < amount.GetCost() || amount.GetCost() <= 0) return CMD_ERROR;
 
	if (!_networking || !IsValidPlayer((PlayerID)p2)) return CMD_ERROR;
 
	if (!_networking || !IsValidPlayerID((PlayerID)p2)) return CMD_ERROR;
 

	
 
	if (flags & DC_EXEC) {
 
		/* Add money to player */
src/misc_gui.cpp
Show inline comments
 
@@ -103,7 +103,7 @@ public:
 
	}
 

	
 
	LandInfoWindow(TileIndex tile) : Window(&_land_info_desc) {
 
		Player *p = GetPlayer(IsValidPlayer(_local_player) ? _local_player : PLAYER_FIRST);
 
		Player *p = GetPlayer(IsValidPlayerID(_local_player) ? _local_player : PLAYER_FIRST);
 
		Town *t = ClosestTownFromTile(tile, _settings_game.economy.dist_local_authority);
 

	
 
		Money old_money = p->player_money;
 
@@ -1364,7 +1364,7 @@ struct SaveLoadWindow : public QueryStri
 
	{
 
		/* Check if we are not a spectator who wants to generate a name..
 
				Let's use the name of player #0 for now. */
 
		const Player *p = GetPlayer(IsValidPlayer(_local_player) ? _local_player : PLAYER_FIRST);
 
		const Player *p = GetPlayer(IsValidPlayerID(_local_player) ? _local_player : PLAYER_FIRST);
 

	
 
		SetDParam(0, p->index);
 
		SetDParam(1, _date);
src/network/network.cpp
Show inline comments
 
@@ -341,7 +341,7 @@ static uint NetworkCountPlayers()
 

	
 
	FOR_ALL_CLIENTS(cs) {
 
		const NetworkClientInfo *ci = DEREF_CLIENT_INFO(cs);
 
		if (IsValidPlayer(ci->client_playas)) count++;
 
		if (IsValidPlayerID(ci->client_playas)) count++;
 
	}
 

	
 
	return count;
src/network/network_client.cpp
Show inline comments
 
@@ -367,7 +367,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER
 
		if (total == 0) return NETWORK_RECV_STATUS_CLOSE_QUERY;
 

	
 
		current = (Owner)p->Recv_uint8();
 
		if (!IsValidPlayer(current)) return NETWORK_RECV_STATUS_CLOSE_QUERY;
 
		if (!IsValidPlayerID(current)) return NETWORK_RECV_STATUS_CLOSE_QUERY;
 

	
 
		p->Recv_string(_network_player_info[current].company_name, sizeof(_network_player_info[current].company_name));
 
		_network_player_info[current].inaugurated_year = p->Recv_uint32();
 
@@ -624,7 +624,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER
 

	
 
		/* New company/spectator (invalid player) or company we want to join is not active
 
		 * Switch local player to spectator and await the server's judgement */
 
		if (_network_playas == PLAYER_NEW_COMPANY || !IsValidPlayer(_network_playas) ||
 
		if (_network_playas == PLAYER_NEW_COMPANY || !IsValidPlayerID(_network_playas) ||
 
				!GetPlayer(_network_playas)->is_active) {
 

	
 
			SetLocalPlayer(PLAYER_SPECTATOR);
 
@@ -737,10 +737,10 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER
 

	
 
			/* For speaking to company or giving money, we need the player-name */
 
			case NETWORK_ACTION_GIVE_MONEY:
 
				if (!IsValidPlayer(ci_to->client_playas)) return NETWORK_RECV_STATUS_OKAY;
 
				if (!IsValidPlayerID(ci_to->client_playas)) return NETWORK_RECV_STATUS_OKAY;
 
				/* fallthrough */
 
			case NETWORK_ACTION_CHAT_COMPANY: {
 
				StringID str = IsValidPlayer(ci_to->client_playas) ? STR_COMPANY_NAME : STR_NETWORK_SPECTATORS;
 
				StringID str = IsValidPlayerID(ci_to->client_playas) ? STR_COMPANY_NAME : STR_NETWORK_SPECTATORS;
 
				SetDParam(0, ci_to->client_playas);
 

	
 
				GetString(name, str, lastof(name));
src/network/network_gui.cpp
Show inline comments
 
@@ -1296,7 +1296,7 @@ struct NetworkClientListPopupWindow : Wi
 
			this->proc[i++] = &ClientList_SpeakToClient;
 
		}
 

	
 
		if (IsValidPlayer(ci->client_playas) || ci->client_playas == PLAYER_SPECTATOR) {
 
		if (IsValidPlayerID(ci->client_playas) || ci->client_playas == PLAYER_SPECTATOR) {
 
			GetString(this->action[i], STR_NETWORK_CLIENTLIST_SPEAK_TO_COMPANY, lastof(this->action[i]));
 
			this->proc[i++] = &ClientList_SpeakToCompany;
 
		}
 
@@ -1305,7 +1305,7 @@ struct NetworkClientListPopupWindow : Wi
 

	
 
		if (_network_own_client_index != ci->client_index) {
 
			/* We are no spectator and the player we want to give money to is no spectator and money gifts are allowed */
 
			if (IsValidPlayer(_network_playas) && IsValidPlayer(ci->client_playas) && _settings_game.economy.give_money) {
 
			if (IsValidPlayerID(_network_playas) && IsValidPlayerID(ci->client_playas) && _settings_game.economy.give_money) {
 
				GetString(this->action[i], STR_NETWORK_CLIENTLIST_GIVE_MONEY, lastof(this->action[i]));
 
				this->proc[i++] = &ClientList_GiveMoney;
 
			}
 
@@ -1494,7 +1494,7 @@ struct NetworkClientListWindow : Window
 
			}
 

	
 
			/* Filter out spectators */
 
			if (IsValidPlayer(ci->client_playas)) DrawPlayerIcon(ci->client_playas, 64, y + 1);
 
			if (IsValidPlayerID(ci->client_playas)) DrawPlayerIcon(ci->client_playas, 64, y + 1);
 

	
 
			DoDrawString(ci->client_name, 81, y, colour);
 

	
src/network/network_server.cpp
Show inline comments
 
@@ -621,7 +621,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT
 
	if (!StrEmpty(_settings_client.network.server_password)) {
 
		SEND_COMMAND(PACKET_SERVER_NEED_PASSWORD)(cs, NETWORK_GAME_PASSWORD);
 
	} else {
 
		if (IsValidPlayer(ci->client_playas) && _network_player_info[ci->client_playas].password[0] != '\0') {
 
		if (IsValidPlayerID(ci->client_playas) && _network_player_info[ci->client_playas].password[0] != '\0') {
 
			SEND_COMMAND(PACKET_SERVER_NEED_PASSWORD)(cs, NETWORK_COMPANY_PASSWORD);
 
		} else {
 
			SEND_COMMAND(PACKET_SERVER_WELCOME)(cs);
 
@@ -677,7 +677,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT
 
			}
 
			break;
 
		default: /* Join another company (companies 1-8 (index 0-7)) */
 
			if (!IsValidPlayer(playas)) {
 
			if (!IsValidPlayerID(playas)) {
 
				SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_PLAYER_MISMATCH);
 
				return;
 
			}
 
@@ -701,7 +701,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT
 
	ci->client_lang = client_lang;
 

	
 
	/* Make sure companies to which people try to join are not autocleaned */
 
	if (IsValidPlayer(playas)) _network_player_info[playas].months_empty = 0;
 
	if (IsValidPlayerID(playas)) _network_player_info[playas].months_empty = 0;
 

	
 
	if (_grfconfig == NULL) {
 
		RECEIVE_COMMAND(PACKET_CLIENT_NEWGRFS_CHECKED)(cs, NULL);
 
@@ -729,7 +729,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT
 

	
 
		ci = DEREF_CLIENT_INFO(cs);
 

	
 
		if (IsValidPlayer(ci->client_playas) && _network_player_info[ci->client_playas].password[0] != '\0') {
 
		if (IsValidPlayerID(ci->client_playas) && _network_player_info[ci->client_playas].password[0] != '\0') {
 
			SEND_COMMAND(PACKET_SERVER_NEED_PASSWORD)(cs, NETWORK_COMPANY_PASSWORD);
 
			return;
 
		}
 
@@ -841,7 +841,7 @@ static bool CheckCommandFlags(const Comm
 
		return false;
 
	}
 

	
 
	if (cp->cmd != CMD_PLAYER_CTRL && !IsValidPlayer(cp->player) && ci->client_index != NETWORK_SERVER_INDEX) {
 
	if (cp->cmd != CMD_PLAYER_CTRL && !IsValidPlayerID(cp->player) && ci->client_index != NETWORK_SERVER_INDEX) {
 
		IConsolePrintF(CC_ERROR, "WARNING: spectator issueing command from client %d (IP: %s), kicking...", ci->client_index, GetPlayerIP(ci));
 
		return false;
 
	}
 
@@ -1125,7 +1125,7 @@ void NetworkServerSendChat(NetworkAction
 
		if (ci != NULL && show_local) {
 
			if (from_index == NETWORK_SERVER_INDEX) {
 
				char name[NETWORK_NAME_LENGTH];
 
				StringID str = IsValidPlayer(ci_to->client_playas) ? STR_COMPANY_NAME : STR_NETWORK_SPECTATORS;
 
				StringID str = IsValidPlayerID(ci_to->client_playas) ? STR_COMPANY_NAME : STR_NETWORK_SPECTATORS;
 
				SetDParam(0, ci_to->client_playas);
 
				GetString(name, str, lastof(name));
 
				NetworkTextMessage(action, (ConsoleColour)GetDrawStringPlayerColor(ci_own->client_playas), true, name, "%s", msg);
 
@@ -1185,7 +1185,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT
 
	p->Recv_string(password, sizeof(password));
 
	ci = DEREF_CLIENT_INFO(cs);
 

	
 
	if (IsValidPlayer(ci->client_playas)) {
 
	if (IsValidPlayerID(ci->client_playas)) {
 
		ttd_strlcpy(_network_player_info[ci->client_playas].password, password, sizeof(_network_player_info[0].password));
 
	}
 
}
 
@@ -1337,7 +1337,7 @@ void NetworkPopulateCompanyInfo()
 

	
 
	// Go through all vehicles and count the type of vehicles
 
	FOR_ALL_VEHICLES(v) {
 
		if (!IsValidPlayer(v->owner) || !v->IsPrimaryVehicle()) continue;
 
		if (!IsValidPlayerID(v->owner) || !v->IsPrimaryVehicle()) continue;
 
		byte type = 0;
 
		switch (v->type) {
 
			case VEH_TRAIN: type = 0; break;
 
@@ -1351,7 +1351,7 @@ void NetworkPopulateCompanyInfo()
 

	
 
	// Go through all stations and count the types of stations
 
	FOR_ALL_STATIONS(s) {
 
		if (IsValidPlayer(s->owner)) {
 
		if (IsValidPlayerID(s->owner)) {
 
			NetworkPlayerInfo *npi = &_network_player_info[s->owner];
 

	
 
			if (s->facilities & FACIL_TRAIN)      npi->num_station[0]++;
 
@@ -1364,7 +1364,7 @@ void NetworkPopulateCompanyInfo()
 

	
 
	ci = NetworkFindClientInfoFromIndex(NETWORK_SERVER_INDEX);
 
	// Register local player (if not dedicated)
 
	if (ci != NULL && IsValidPlayer(ci->client_playas))
 
	if (ci != NULL && IsValidPlayerID(ci->client_playas))
 
		ttd_strlcpy(_network_player_info[ci->client_playas].players, ci->client_name, sizeof(_network_player_info[0].players));
 

	
 
	FOR_ALL_CLIENTS(cs) {
 
@@ -1373,7 +1373,7 @@ void NetworkPopulateCompanyInfo()
 
		NetworkGetClientName(client_name, sizeof(client_name), cs);
 

	
 
		ci = DEREF_CLIENT_INFO(cs);
 
		if (ci != NULL && IsValidPlayer(ci->client_playas)) {
 
		if (ci != NULL && IsValidPlayerID(ci->client_playas)) {
 
			if (!StrEmpty(_network_player_info[ci->client_playas].players)) {
 
				ttd_strlcat(_network_player_info[ci->client_playas].players, ", ", lengthof(_network_player_info[0].players));
 
			}
 
@@ -1425,12 +1425,12 @@ static void NetworkAutoCleanCompanies()
 
	/* Detect the active companies */
 
	FOR_ALL_CLIENTS(cs) {
 
		ci = DEREF_CLIENT_INFO(cs);
 
		if (IsValidPlayer(ci->client_playas)) clients_in_company[ci->client_playas] = true;
 
		if (IsValidPlayerID(ci->client_playas)) clients_in_company[ci->client_playas] = true;
 
	}
 

	
 
	if (!_network_dedicated) {
 
		ci = NetworkFindClientInfoFromIndex(NETWORK_SERVER_INDEX);
 
		if (IsValidPlayer(ci->client_playas)) clients_in_company[ci->client_playas] = true;
 
		if (IsValidPlayerID(ci->client_playas)) clients_in_company[ci->client_playas] = true;
 
	}
 

	
 
	/* Go through all the comapnies */
 
@@ -1669,7 +1669,7 @@ void NetworkServerShowStatusToConsole()
 
		status = (cs->status < (ptrdiff_t)lengthof(stat_str) ? stat_str[cs->status] : "unknown");
 
		IConsolePrintF(CC_INFO, "Client #%1d  name: '%s'  status: '%s'  frame-lag: %3d  company: %1d  IP: %s  unique-id: '%s'",
 
			cs->index, ci->client_name, status, lag,
 
			ci->client_playas + (IsValidPlayer(ci->client_playas) ? 1 : 0),
 
			ci->client_playas + (IsValidPlayerID(ci->client_playas) ? 1 : 0),
 
			GetPlayerIP(ci), ci->unique_id);
 
	}
 
}
src/newgrf_engine.cpp
Show inline comments
 
@@ -454,7 +454,7 @@ static uint8 LiveryHelper(EngineID engin
 
	const Livery *l;
 

	
 
	if (v == NULL) {
 
		if (!IsValidPlayer(_current_player)) return 0;
 
		if (!IsValidPlayerID(_current_player)) return 0;
 
		l = GetEngineLivery(engine, _current_player, INVALID_ENGINE, NULL);
 
	} else if (v->type == VEH_TRAIN) {
 
		l = GetEngineLivery((v->u.rail.first_engine != INVALID_ENGINE && (IsArticulatedPart(v) || UsesWagonOverride(v))) ? v->u.rail.first_engine : v->engine_type, v->owner, v->u.rail.first_engine, v);
src/newgrf_house.cpp
Show inline comments
 
@@ -591,7 +591,7 @@ bool CanDeleteHouse(TileIndex tile)
 

	
 
	/* Human players are always allowed to remove buildings, as is water and
 
	 * anyone using the scenario editor. */
 
	if ((IsValidPlayer(_current_player) && IsHumanPlayer(_current_player))
 
	if ((IsValidPlayerID(_current_player) && IsHumanPlayer(_current_player))
 
			|| _current_player == OWNER_WATER || _current_player == OWNER_NONE) return true;
 

	
 
	if (HasBit(hs->callback_mask, CBM_HOUSE_DENY_DESTRUCTION)) {
src/newgrf_industries.cpp
Show inline comments
 
@@ -252,7 +252,7 @@ uint32 IndustryGetVariable(const Resolve
 
			byte colours;
 
			bool is_ai = false;
 

	
 
			if (IsValidPlayer(industry->founder)) {
 
			if (IsValidPlayerID(industry->founder)) {
 
				const Player *p = GetPlayer(industry->founder);
 
				const Livery *l = &p->livery[LS_DEFAULT];
 

	
src/openttd.cpp
Show inline comments
 
@@ -630,7 +630,7 @@ int ttd_main(int argc, char *argv[])
 

	
 
				if (_network_playas != PLAYER_SPECTATOR) {
 
					_network_playas--;
 
					if (!IsValidPlayer(_network_playas)) return false;
 
					if (!IsValidPlayerID(_network_playas)) return false;
 
				}
 
			}
 
			if (port != NULL) rport = atoi(port);
 
@@ -1573,7 +1573,7 @@ bool AfterLoadGame()
 
		 * becomes player 0, unless we are in the scenario editor where all the
 
		 * players are 'invalid'.
 
		 */
 
		if (!_network_dedicated && IsValidPlayer(PLAYER_FIRST)) {
 
		if (!_network_dedicated && IsValidPlayerID(PLAYER_FIRST)) {
 
			p = GetPlayer(PLAYER_FIRST);
 
			p->engine_renew        = _settings_client.gui.autorenew;
 
			p->engine_renew_months = _settings_client.gui.autorenew_months;
 
@@ -2322,7 +2322,7 @@ bool AfterLoadGame()
 
				for (uint i = 0; i < 4; i++) {
 
					PlayerID o = p->share_owners[i];
 
					if (o == PLAYER_SPECTATOR) continue;
 
					if (!IsValidPlayer(o) || o == p->index || !GetPlayer(o)->is_active) p->share_owners[i] = PLAYER_SPECTATOR;
 
					if (!IsValidPlayerID(o) || o == p->index || !GetPlayer(o)->is_active) p->share_owners[i] = PLAYER_SPECTATOR;
 
				}
 
			}
 
		}
 
@@ -2374,7 +2374,7 @@ bool AfterLoadGame()
 

	
 
			if (IsBuoyTile(t) || IsDriveThroughStopTile(t) || IsTileType(t, MP_WATER)) {
 
				Owner o = GetTileOwner(t);
 
				if (IsValidPlayer(o) && !GetPlayer(o)->is_active) {
 
				if (IsValidPlayerID(o) && !GetPlayer(o)->is_active) {
 
					_current_player = o;
 
					ChangeTileOwner(t, o, PLAYER_SPECTATOR);
 
				}
 
@@ -2388,7 +2388,7 @@ bool AfterLoadGame()
 
				for (RoadType rt = ROADTYPE_ROAD; rt < ROADTYPE_END; rt++) {
 
					/* update even non-existing road types to update tile owner too */
 
					Owner o = GetRoadOwner(t, rt);
 
					if (IsValidPlayer(o) && !GetPlayer(o)->is_active) SetRoadOwner(t, rt, OWNER_NONE);
 
					if (IsValidPlayerID(o) && !GetPlayer(o)->is_active) SetRoadOwner(t, rt, OWNER_NONE);
 
				}
 
				if (IsLevelCrossing(t)) {
 
					Owner o = GetTileOwner(t);
src/player_face.h
Show inline comments
 
@@ -229,6 +229,6 @@ static inline SpriteID GetPlayerFaceSpri
 

	
 
void DrawPlayerFace(PlayerFace face, int color, int x, int y);
 
PlayerFace ConvertFromOldPlayerFace(uint32 face);
 
bool IsValidPlayerFace(PlayerFace pf);
 
bool IsValidPlayerIDFace(PlayerFace pf);
 

	
 
#endif /* PLAYER_FACE_H */
src/player_func.h
Show inline comments
 
@@ -27,7 +27,7 @@ static inline bool IsLocalPlayer()
 
	return _local_player == _current_player;
 
}
 

	
 
static inline bool IsValidPlayer(PlayerID pi)
 
static inline bool IsValidPlayerID(PlayerID pi)
 
{
 
	return IsInsideBS(pi, PLAYER_FIRST, MAX_PLAYERS);
 
}
src/player_gui.cpp
Show inline comments
 
@@ -252,7 +252,7 @@ static const WindowDesc _player_finances
 
 */
 
static void DoShowPlayerFinances(PlayerID player, bool show_small, bool show_stickied, int top, int left)
 
{
 
	if (!IsValidPlayer(player)) return;
 
	if (!IsValidPlayerID(player)) return;
 

	
 
	if (BringWindowToFrontById(WC_FINANCES, player)) return;
 
	new PlayerFinancesWindow(show_small ? &_player_finances_small_desc : &_player_finances_desc, player, show_small, show_stickied, top, left);
 
@@ -1030,7 +1030,7 @@ static const WindowDesc _select_player_f
 
 */
 
static void DoSelectPlayerFace(Window *parent, bool adv, int top, int left)
 
{
 
	if (!IsValidPlayer((PlayerID)parent->window_number)) return;
 
	if (!IsValidPlayerID((PlayerID)parent->window_number)) return;
 

	
 
	if (BringWindowToFrontById(WC_PLAYER_FACE, parent->window_number)) return;
 
	new SelectPlayerFaceWindow(adv ? &_select_player_face_adv_desc : &_select_player_face_desc, parent, adv, top, left); // simple or advanced window
 
@@ -1349,7 +1349,7 @@ static const WindowDesc _player_company_
 

	
 
void ShowPlayerCompany(PlayerID player)
 
{
 
	if (!IsValidPlayer(player)) return;
 
	if (!IsValidPlayerID(player)) return;
 

	
 
	AllocateWindowDescFront<PlayerCompanyWindow>(&_player_company_desc, player);
 
}
 
@@ -1495,7 +1495,7 @@ struct EndGameWindow : EndGameHighScoreB
 

	
 
		this->SetupHighScoreEndWindow(&x, &y);
 

	
 
		if (!IsValidPlayer(_local_player)) return;
 
		if (!IsValidPlayerID(_local_player)) return;
 

	
 
		p = GetPlayer(_local_player);
 
		/* We need to get performance from last year because the image is shown
src/players.cpp
Show inline comments
 
@@ -54,17 +54,17 @@ HighScore _highscore_table[5][5]; // 4 d
 
 * 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
 
 * @pre IsValidPlayerID(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);
 
	assert(IsValidPlayerID(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) {
 
	if (IsValidPlayerID(new_player) && _game_mode != GM_MENU) {
 
		const Player *p = GetPlayer(new_player);
 
		_settings_client.gui.autorenew        = p->engine_renew;
 
		_settings_client.gui.autorenew_months = p->engine_renew_months;
 
@@ -83,7 +83,7 @@ uint16 GetDrawStringPlayerColor(PlayerID
 
{
 
	/* 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;
 
	if (!IsValidPlayerID(player)) return _colour_gradient[COLOUR_WHITE][4] | IS_PALETTE_COLOR;
 
	return (_colour_gradient[_player_colors[player]][4]) | IS_PALETTE_COLOR;
 
}
 

	
 
@@ -166,7 +166,7 @@ PlayerFace ConvertFromOldPlayerFace(uint
 
 * @param pf the fact to check
 
 * @return true if and only if the face is valid
 
 */
 
bool IsValidPlayerFace(PlayerFace pf)
 
bool IsValidPlayerIDFace(PlayerFace pf)
 
{
 
	if (!ArePlayerFaceBitsValid(pf, PFV_GEN_ETHN, GE_WM)) return false;
 

	
 
@@ -203,7 +203,7 @@ bool CheckPlayerHasMoney(CommandCost cos
 
{
 
	if (cost.GetCost() > 0) {
 
		PlayerID pid = _current_player;
 
		if (IsValidPlayer(pid) && cost.GetCost() > GetPlayer(pid)->player_money) {
 
		if (IsValidPlayerID(pid) && cost.GetCost() > GetPlayer(pid)->player_money) {
 
			SetDParam(0, cost.GetCost());
 
			_error_message = STR_0003_NOT_ENOUGH_CASH_REQUIRES;
 
			return false;
 
@@ -259,7 +259,7 @@ void SubtractMoneyFromPlayer(CommandCost
 
{
 
	PlayerID pid = _current_player;
 

	
 
	if (IsValidPlayer(pid)) SubtractMoneyFromAnyPlayer(GetPlayer(pid), cost);
 
	if (IsValidPlayerID(pid)) SubtractMoneyFromAnyPlayer(GetPlayer(pid), cost);
 
}
 

	
 
void SubtractMoneyFromPlayerFract(PlayerID player, CommandCost cst)
 
@@ -279,7 +279,7 @@ void GetNameOfOwner(Owner owner, TileInd
 
	SetDParam(2, owner);
 

	
 
	if (owner != OWNER_TOWN) {
 
		if (!IsValidPlayer(owner)) {
 
		if (!IsValidPlayerID(owner)) {
 
			SetDParam(0, STR_0150_SOMEONE);
 
		} else {
 
			const Player* p = GetPlayer(owner);
 
@@ -686,7 +686,7 @@ static void DeletePlayerStuff(PlayerID p
 
 */
 
CommandCost CmdSetAutoReplace(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	if (!IsValidPlayer(_current_player)) return CMD_ERROR;
 
	if (!IsValidPlayerID(_current_player)) return CMD_ERROR;
 

	
 
	Player *p = GetPlayer(_current_player);
 
	switch (GB(p1, 0, 3)) {
 
@@ -889,7 +889,7 @@ CommandCost CmdPlayerCtrl(TileIndex tile
 
			ci->client_playas = p->index;
 
			NetworkUpdateClientInfo(ci->client_index);
 

	
 
			if (IsValidPlayer(ci->client_playas)) {
 
			if (IsValidPlayerID(ci->client_playas)) {
 
				PlayerID player_backup = _local_player;
 
				_network_player_info[p->index].months_empty = 0;
 

	
 
@@ -922,7 +922,7 @@ CommandCost CmdPlayerCtrl(TileIndex tile
 
	case 2: { /* Delete a player */
 
		Player *p;
 

	
 
		if (!IsValidPlayer((PlayerID)p2)) return CMD_ERROR;
 
		if (!IsValidPlayerID((PlayerID)p2)) return CMD_ERROR;
 

	
 
		if (!(flags & DC_EXEC)) return CommandCost();
 

	
 
@@ -949,7 +949,7 @@ CommandCost CmdPlayerCtrl(TileIndex tile
 
		PlayerID pid_old = (PlayerID)GB(p2,  0, 16);
 
		PlayerID pid_new = (PlayerID)GB(p2, 16, 16);
 

	
 
		if (!IsValidPlayer(pid_old) || !IsValidPlayer(pid_new)) return CMD_ERROR;
 
		if (!IsValidPlayerID(pid_old) || !IsValidPlayerID(pid_new)) return CMD_ERROR;
 

	
 
		if (!(flags & DC_EXEC)) return CMD_ERROR;
 

	
src/rail_cmd.cpp
Show inline comments
 
@@ -514,7 +514,7 @@ CommandCost CmdRemoveSingleRail(TileInde
 

	
 
	if (flags & DC_EXEC) {
 
		/* if we got that far, 'owner' variable is set correctly */
 
		assert(IsValidPlayer(owner));
 
		assert(IsValidPlayerID(owner));
 

	
 
		MarkTileDirtyByTile(tile);
 
		if (crossing) {
src/rail_gui.cpp
Show inline comments
 
@@ -839,7 +839,7 @@ void ShowBuildRailToolbar(RailType railt
 
{
 
	BuildRailToolbarWindow *w;
 

	
 
	if (!IsValidPlayer(_current_player)) return;
 
	if (!IsValidPlayerID(_current_player)) return;
 
	if (!ValParamRailtype(railtype)) return;
 

	
 
	// don't recreate the window if we're clicking on a button and the window exists.
 
@@ -1698,7 +1698,7 @@ void ReinitGuiAfterToggleElrail(bool dis
 
/** Set the initial (default) railtype to use */
 
static void SetDefaultRailGui()
 
{
 
	if (_local_player == PLAYER_SPECTATOR || !IsValidPlayer(_local_player)) return;
 
	if (_local_player == PLAYER_SPECTATOR || !IsValidPlayerID(_local_player)) return;
 

	
 
	extern RailType _last_built_railtype;
 
	RailType rt = (RailType)_settings_client.gui.default_rail_type;
src/road.cpp
Show inline comments
 
@@ -84,7 +84,7 @@ bool HasRoadTypesAvail(const PlayerID p,
 
	if (p == OWNER_TOWN || _game_mode == GM_EDITOR || IsGeneratingWorld()) {
 
		avail_roadtypes = ROADTYPES_ROAD;
 
	} else {
 
		if (!IsValidPlayer(p)) return false;
 
		if (!IsValidPlayerID(p)) return false;
 
		avail_roadtypes = (RoadTypes)GetPlayer(p)->avail_roadtypes | ROADTYPES_ROAD; // road is available for always for everybody
 
	}
 
	return (rts & ~avail_roadtypes) == 0;
src/road_cmd.cpp
Show inline comments
 
@@ -152,7 +152,7 @@ bool CheckAllowRemoveRoad(TileIndex tile
 
	 * Towns are not be allowed to remove non "normal" road pieces, like tram
 
	 * tracks as that would result in trams that cannot turn. */
 
	if (_current_player == OWNER_WATER ||
 
			(rt == ROADTYPE_ROAD && !IsValidPlayer(_current_player))) return true;
 
			(rt == ROADTYPE_ROAD && !IsValidPlayerID(_current_player))) return true;
 

	
 
	/* Only do the special processing if the road is owned
 
	 * by a town */
 
@@ -471,7 +471,7 @@ CommandCost CmdBuildRoad(TileIndex tile,
 

	
 
	/* Road pieces are max 4 bitset values (NE, NW, SE, SW) and town can only be non-zero
 
	 * if a non-player is building the road */
 
	if ((IsValidPlayer(_current_player) && p2 != 0) || (_current_player == OWNER_TOWN && !IsValidTownID(p2))) return CMD_ERROR;
 
	if ((IsValidPlayerID(_current_player) && p2 != 0) || (_current_player == OWNER_TOWN && !IsValidTownID(p2))) return CMD_ERROR;
 

	
 
	RoadBits pieces = Extract<RoadBits, 0>(p1);
 

	
src/road_gui.cpp
Show inline comments
 
@@ -675,7 +675,7 @@ static const WindowDesc _build_tramway_d
 

	
 
void ShowBuildRoadToolbar(RoadType roadtype)
 
{
 
	if (!IsValidPlayer(_current_player)) return;
 
	if (!IsValidPlayerID(_current_player)) return;
 
	_cur_roadtype = roadtype;
 

	
 
	DeleteWindowByClass(WC_BUILD_TOOLBAR);
src/signal.cpp
Show inline comments
 
@@ -467,11 +467,11 @@ static inline void ResetSets()
 
 *
 
 * @param owner player whose signals we are updating
 
 * @return state of the first block from _globset
 
 * @pre IsValidPlayer(owner)
 
 * @pre IsValidPlayerID(owner)
 
 */
 
static SigSegState UpdateSignalsInBuffer(Owner owner)
 
{
 
	assert(IsValidPlayer(owner));
 
	assert(IsValidPlayerID(owner));
 

	
 
	bool first = true;  // first block?
 
	SigSegState state = SIGSEG_FREE; // value to return
src/station_cmd.cpp
Show inline comments
 
@@ -956,7 +956,7 @@ CommandCost CmdBuildRailroadStation(Tile
 
			st->town = ClosestTownFromTile(tile_org, UINT_MAX);
 
			st->string_id = GenerateStationName(st, tile_org, STATIONNAMING_RAIL);
 

	
 
			if (IsValidPlayer(_current_player)) {
 
			if (IsValidPlayerID(_current_player)) {
 
				SetBit(st->town->have_ratings, _current_player);
 
			}
 
		}
 
@@ -1382,7 +1382,7 @@ CommandCost CmdBuildRoadStop(TileIndex t
 
			st->town = ClosestTownFromTile(tile, UINT_MAX);
 
			st->string_id = GenerateStationName(st, tile, STATIONNAMING_ROAD);
 

	
 
			if (IsValidPlayer(_current_player)) {
 
			if (IsValidPlayerID(_current_player)) {
 
				SetBit(st->town->have_ratings, _current_player);
 
			}
 
			st->sign.width_1 = 0;
 
@@ -1778,7 +1778,7 @@ CommandCost CmdBuildAirport(TileIndex ti
 
			st->town = t;
 
			st->string_id = GenerateStationName(st, tile, !(afc->flags & AirportFTAClass::AIRPLANES) ? STATIONNAMING_HELIPORT : STATIONNAMING_AIRPORT);
 

	
 
			if (IsValidPlayer(_current_player)) {
 
			if (IsValidPlayerID(_current_player)) {
 
				SetBit(st->town->have_ratings, _current_player);
 
			}
 
			st->sign.width_1 = 0;
 
@@ -1911,7 +1911,7 @@ CommandCost CmdBuildBuoy(TileIndex tile,
 
		st->town = ClosestTownFromTile(tile, UINT_MAX);
 
		st->string_id = GenerateStationName(st, tile, STATIONNAMING_BUOY);
 

	
 
		if (IsValidPlayer(_current_player)) {
 
		if (IsValidPlayerID(_current_player)) {
 
			SetBit(st->town->have_ratings, _current_player);
 
		}
 
		st->sign.width_1 = 0;
 
@@ -1960,7 +1960,7 @@ bool HasStationInUse(StationID station, 
 
static CommandCost RemoveBuoy(Station *st, uint32 flags)
 
{
 
	/* XXX: strange stuff */
 
	if (!IsValidPlayer(_current_player)) return_cmd_error(INVALID_STRING_ID);
 
	if (!IsValidPlayerID(_current_player)) return_cmd_error(INVALID_STRING_ID);
 

	
 
	TileIndex tile = st->dock_tile;
 

	
 
@@ -2070,7 +2070,7 @@ CommandCost CmdBuildDock(TileIndex tile,
 
			st->town = ClosestTownFromTile(tile, UINT_MAX);
 
			st->string_id = GenerateStationName(st, tile, STATIONNAMING_DOCK);
 

	
 
			if (IsValidPlayer(_current_player)) {
 
			if (IsValidPlayerID(_current_player)) {
 
				SetBit(st->town->have_ratings, _current_player);
 
			}
 
		}
 
@@ -2153,7 +2153,7 @@ static void DrawTile_Station(TileInfo *t
 
	PlayerID owner = GetTileOwner(ti->tile);
 

	
 
	SpriteID palette;
 
	if (IsValidPlayer(owner)) {
 
	if (IsValidPlayerID(owner)) {
 
		palette = PLAYER_SPRITE_COLOR(owner);
 
	} else {
 
		/* Some stations are not owner by a player, namely oil rigs */
 
@@ -2573,7 +2573,7 @@ static void UpdateStationRating(Station 
 
				(rating += 13, true);
 
			}
 

	
 
			if (IsValidPlayer(st->owner) && HasBit(st->town->statues, st->owner)) rating += 26;
 
			if (IsValidPlayerID(st->owner) && HasBit(st->town->statues, st->owner)) rating += 26;
 

	
 
			{
 
				byte days = ge->days_since_pickup;
src/station_gui.cpp
Show inline comments
 
@@ -601,7 +601,7 @@ static const WindowDesc _player_stations
 
 */
 
void ShowPlayerStations(PlayerID player)
 
{
 
	if (!IsValidPlayer(player)) return;
 
	if (!IsValidPlayerID(player)) return;
 

	
 
	AllocateWindowDescFront<PlayerStationsWindow>(&_player_stations_desc, player);
 
}
src/strings.cpp
Show inline comments
 
@@ -959,7 +959,7 @@ static char* FormatString(char* buff, co
 
				PlayerID player = (PlayerID)GetInt32(&argv);
 

	
 
				/* Nothing is added for AI or inactive players */
 
				if (IsHumanPlayer(player) && IsValidPlayer(player)) {
 
				if (IsHumanPlayer(player) && IsValidPlayerID(player)) {
 
					int64 args[1];
 
					args[0] = player + 1;
 
					buff = GetStringWithArgs(buff, STR_7002_PLAYER, args, last);
src/terraform_gui.cpp
Show inline comments
 
@@ -327,7 +327,7 @@ static const WindowDesc _terraform_desc 
 

	
 
void ShowTerraformToolbar(Window *link)
 
{
 
	if (!IsValidPlayer(_current_player)) return;
 
	if (!IsValidPlayerID(_current_player)) return;
 
	Window *w = AllocateWindowDescFront<TerraformToolbarWindow>(&_terraform_desc, 0);
 
	if (w != NULL && link != NULL) {
 
		/* Align the terraform toolbar under the main toolbar and put the linked
 
@@ -574,7 +574,7 @@ static void ResetLandscapeConfirmationCa
 
		/* Delete all stations owned by a player */
 
		Station *st;
 
		FOR_ALL_STATIONS(st) {
 
			if (IsValidPlayer(st->owner)) delete st;
 
			if (IsValidPlayerID(st->owner)) delete st;
 
		}
 
	}
 
}
src/town_cmd.cpp
Show inline comments
 
@@ -529,7 +529,7 @@ static CommandCost ClearTile_Town(TileIn
 
	_cleared_town_rating += rating;
 
	Town *t = _cleared_town = GetTownByTile(tile);
 

	
 
	if (IsValidPlayer(_current_player)) {
 
	if (IsValidPlayerID(_current_player)) {
 
		if (rating > t->ratings[_current_player] && !(flags & DC_NO_TOWN_RATING) && !_cheats.magic_bulldozer.value) {
 
			SetDParam(0, t->index);
 
			return_cmd_error(STR_2009_LOCAL_AUTHORITY_REFUSES);
 
@@ -2314,12 +2314,12 @@ static void UpdateTownGrowRate(Town *t)
 
		if (DistanceSquare(st->xy, t->xy) <= t->squared_town_zone_radius[0]) {
 
			if (st->time_since_load <= 20 || st->time_since_unload <= 20) {
 
				n++;
 
				if (IsValidPlayer(st->owner)) {
 
				if (IsValidPlayerID(st->owner)) {
 
					int new_rating = t->ratings[st->owner] + RATING_STATION_UP_STEP;
 
					t->ratings[st->owner] = min(new_rating, INT16_MAX); // do not let it overflow
 
				}
 
			} else {
 
				if (IsValidPlayer(st->owner)) {
 
				if (IsValidPlayerID(st->owner)) {
 
					int new_rating = t->ratings[st->owner] + RATING_STATION_DOWN_STEP;
 
					t->ratings[st->owner] = max(new_rating, INT16_MIN);
 
				}
 
@@ -2405,7 +2405,7 @@ static void UpdateTownUnwanted(Town *t)
 

	
 
bool CheckIfAuthorityAllows(TileIndex tile)
 
{
 
	if (!IsValidPlayer(_current_player)) return true;
 
	if (!IsValidPlayerID(_current_player)) return true;
 

	
 
	Town *t = ClosestTownFromTile(tile, _settings_game.economy.dist_local_authority);
 
	if (t == NULL) return true;
 
@@ -2482,7 +2482,7 @@ void ChangeTownRating(Town *t, int add, 
 
{
 
	/* if magic_bulldozer cheat is active, town doesn't penaltize for removing stuff */
 
	if (t == NULL ||
 
			!IsValidPlayer(_current_player) ||
 
			!IsValidPlayerID(_current_player) ||
 
			(_cheats.magic_bulldozer.value && add < 0)) {
 
		return;
 
	}
 
@@ -2520,7 +2520,7 @@ static const int _default_rating_setting
 
bool CheckforTownRating(uint32 flags, Town *t, byte type)
 
{
 
	/* if magic_bulldozer cheat is active, town doesn't restrict your destructive actions */
 
	if (t == NULL || !IsValidPlayer(_current_player) || _cheats.magic_bulldozer.value)
 
	if (t == NULL || !IsValidPlayerID(_current_player) || _cheats.magic_bulldozer.value)
 
		return true;
 

	
 
	/* check if you're allowed to remove the street/bridge/tunnel/industry
src/town_gui.cpp
Show inline comments
 
@@ -781,7 +781,7 @@ static const WindowDesc _scen_edit_town_
 

	
 
void ShowBuildTownWindow()
 
{
 
	if (_game_mode != GM_EDITOR && !IsValidPlayer(_current_player)) return;
 
	if (_game_mode != GM_EDITOR && !IsValidPlayerID(_current_player)) return;
 
	AllocateWindowDescFront<ScenarioEditorTownGenerationWindow>(&_scen_edit_town_gen_desc, 0);
 
}
 

	
src/tree_cmd.cpp
Show inline comments
 
@@ -389,7 +389,7 @@ CommandCost CmdPlantTree(TileIndex tile,
 
						}
 
					}
 

	
 
					if (_game_mode != GM_EDITOR && IsValidPlayer(_current_player)) {
 
					if (_game_mode != GM_EDITOR && IsValidPlayerID(_current_player)) {
 
						Town *t = ClosestTownFromTile(tile, _settings_game.economy.dist_local_authority);
 
						if (t != NULL) ChangeTownRating(t, RATING_TREE_UP_STEP, RATING_TREE_MAXIMUM);
 
					}
 
@@ -532,7 +532,7 @@ static CommandCost ClearTile_Trees(TileI
 
{
 
	uint num;
 

	
 
	if (IsValidPlayer(_current_player)) {
 
	if (IsValidPlayerID(_current_player)) {
 
		Town *t = ClosestTownFromTile(tile, _settings_game.economy.dist_local_authority);
 
		if (t != NULL) ChangeTownRating(t, RATING_TREE_DOWN_STEP, RATING_TREE_MINIMUM);
 
	}
src/tree_gui.cpp
Show inline comments
 
@@ -179,6 +179,6 @@ static const WindowDesc _build_trees_des
 

	
 
void ShowBuildTreesToolbar()
 
{
 
	if (_game_mode != GM_EDITOR && !IsValidPlayer(_current_player)) return;
 
	if (_game_mode != GM_EDITOR && !IsValidPlayerID(_current_player)) return;
 
	AllocateWindowDescFront<BuildTreesWindow>(&_build_trees_desc, 0);
 
}
src/tunnelbridge_cmd.cpp
Show inline comments
 
@@ -452,10 +452,10 @@ not_valid_below:;
 
	 * It's unnecessary to execute this command every time for every bridge. So it is done only
 
	 * and cost is computed in "bridge_gui.c". For AI, Towns this has to be of course calculated
 
	 */
 
	if (!(flags & DC_QUERY_COST) || (IsValidPlayer(_current_player) && GetPlayer(_current_player)->is_ai)) {
 
	if (!(flags & DC_QUERY_COST) || (IsValidPlayerID(_current_player) && GetPlayer(_current_player)->is_ai)) {
 
		bridge_len += 2; // begin and end tiles/ramps
 

	
 
		if (IsValidPlayer(_current_player) && !_is_old_ai_player)
 
		if (IsValidPlayerID(_current_player) && !_is_old_ai_player)
 
			bridge_len = CalcBridgeLenCostFactor(bridge_len);
 

	
 
		cost.AddCost((int64)bridge_len * _price.build_bridge * GetBridgeSpec(bridge_type)->price >> 8);
src/vehicle.cpp
Show inline comments
 
@@ -1750,7 +1750,7 @@ bool CanBuildVehicleInfrastructure(Vehic
 
{
 
	assert(IsPlayerBuildableVehicleType(type));
 

	
 
	if (!IsValidPlayer(_current_player)) return false;
 
	if (!IsValidPlayerID(_current_player)) return false;
 
	if (_settings_client.gui.always_build_infrastructure) return true;
 

	
 
	UnitID max;
src/vehicle_gui.cpp
Show inline comments
 
@@ -1122,7 +1122,7 @@ static void ShowVehicleListWindowLocal(P
 
	VehicleListWindow *w;
 
	WindowNumber num;
 

	
 
	if (!IsValidPlayer(player)) return;
 
	if (!IsValidPlayerID(player)) return;
 

	
 
	num = (unique_number << 16) | (vehicle_type << 11) | VLW_flag | player;
 

	
0 comments (0 inline, 0 general)