(svn r13719) -Codechange: rename IsValidPlayer to IsValidPlayerID in line with all other structs/classes that are in a pool.
authorrubidium
Thu, 17 Jul 2008 20:13:01 +0000
changeset 11161 7d0fac8f14cd
parent 11160 4b963391b435
child 11162 37d01497c935
(svn r13719) -Codechange: rename IsValidPlayer to IsValidPlayerID in line with all other structs/classes that are in a pool.
src/ai/ai.cpp
src/airport_gui.cpp
src/autoslope.h
src/cheat_gui.cpp
src/command.cpp
src/console_cmds.cpp
src/dock_gui.cpp
src/economy.cpp
src/group_gui.cpp
src/industry_gui.cpp
src/main_gui.cpp
src/misc_cmd.cpp
src/misc_gui.cpp
src/network/network.cpp
src/network/network_client.cpp
src/network/network_gui.cpp
src/network/network_server.cpp
src/newgrf_engine.cpp
src/newgrf_house.cpp
src/newgrf_industries.cpp
src/openttd.cpp
src/player_face.h
src/player_func.h
src/player_gui.cpp
src/players.cpp
src/rail_cmd.cpp
src/rail_gui.cpp
src/road.cpp
src/road_cmd.cpp
src/road_gui.cpp
src/signal.cpp
src/station_cmd.cpp
src/station_gui.cpp
src/strings.cpp
src/terraform_gui.cpp
src/town_cmd.cpp
src/town_gui.cpp
src/tree_cmd.cpp
src/tree_gui.cpp
src/tunnelbridge_cmd.cpp
src/vehicle.cpp
src/vehicle_gui.cpp
--- a/src/ai/ai.cpp	Thu Jul 17 16:38:26 2008 +0000
+++ b/src/ai/ai.cpp	Thu Jul 17 20:13:01 2008 +0000
@@ -212,7 +212,7 @@
  */
 void AI_StartNewAI(PlayerID player)
 {
-	assert(IsValidPlayer(player));
+	assert(IsValidPlayerID(player));
 
 	/* Called if a new AI is booted */
 	_ai_player[player].active = true;
--- a/src/airport_gui.cpp	Thu Jul 17 16:38:26 2008 +0000
+++ b/src/airport_gui.cpp	Thu Jul 17 20:13:01 2008 +0000
@@ -145,7 +145,7 @@
 
 void ShowBuildAirToolbar()
 {
-	if (!IsValidPlayer(_current_player)) return;
+	if (!IsValidPlayerID(_current_player)) return;
 
 	DeleteWindowByClass(WC_BUILD_TOOLBAR);
 	AllocateWindowDescFront<BuildAirToolbarWindow>(&_air_toolbar_desc, TRANSPORT_AIR);
--- a/src/autoslope.h	Thu Jul 17 16:38:26 2008 +0000
+++ b/src/autoslope.h	Thu Jul 17 20:13:01 2008 +0000
@@ -39,7 +39,7 @@
 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)));
 }
 
--- a/src/cheat_gui.cpp	Thu Jul 17 16:38:26 2008 +0000
+++ b/src/cheat_gui.cpp	Thu Jul 17 20:13:01 2008 +0000
@@ -44,7 +44,7 @@
  */
 static int32 ClickChangePlayerCheat(int32 p1, int32 p2)
 {
-	while (IsValidPlayer((PlayerID)p1)) {
+	while (IsValidPlayerID((PlayerID)p1)) {
 		if (_players[p1].is_active) {
 			SetLocalPlayer((PlayerID)p1);
 
--- a/src/command.cpp	Thu Jul 17 16:38:26 2008 +0000
+++ b/src/command.cpp	Thu Jul 17 20:13:01 2008 +0000
@@ -448,7 +448,7 @@
 	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 @@
 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 @@
 	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;
 	}
 
--- a/src/console_cmds.cpp	Thu Jul 17 16:38:26 2008 +0000
+++ b/src/console_cmds.cpp	Thu Jul 17 20:13:01 2008 +0000
@@ -608,7 +608,7 @@
 	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 @@
 	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 @@
 		 * 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 @@
 	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 @@
 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;
 	}
--- a/src/dock_gui.cpp	Thu Jul 17 16:38:26 2008 +0000
+++ b/src/dock_gui.cpp	Thu Jul 17 20:13:01 2008 +0000
@@ -277,7 +277,7 @@
 
 void ShowBuildDocksToolbar()
 {
-	if (!IsValidPlayer(_current_player)) return;
+	if (!IsValidPlayerID(_current_player)) return;
 
 	DeleteWindowByClass(WC_BUILD_TOOLBAR);
 	AllocateWindowDescFront<BuildDocksToolbarWindow>(&_build_docks_toolbar_desc, TRANSPORT_WATER);
--- a/src/economy.cpp	Thu Jul 17 16:38:26 2008 +0000
+++ b/src/economy.cpp	Thu Jul 17 20:13:01 2008 +0000
@@ -1784,7 +1784,7 @@
 
 	/* 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 @@
 
 	/* 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 @@
 	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;
--- a/src/group_gui.cpp	Thu Jul 17 16:38:26 2008 +0000
+++ b/src/group_gui.cpp	Thu Jul 17 20:13:01 2008 +0000
@@ -732,7 +732,7 @@
 
 void ShowPlayerGroup(PlayerID player, VehicleType vehicle_type)
 {
-	if (!IsValidPlayer(player)) return;
+	if (!IsValidPlayerID(player)) return;
 
 	WindowClass wc;
 
--- a/src/industry_gui.cpp	Thu Jul 17 16:38:26 2008 +0000
+++ b/src/industry_gui.cpp	Thu Jul 17 20:13:01 2008 +0000
@@ -419,7 +419,7 @@
 
 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();
 }
--- a/src/main_gui.cpp	Thu Jul 17 16:38:26 2008 +0000
+++ b/src/main_gui.cpp	Thu Jul 17 20:13:01 2008 +0000
@@ -342,7 +342,7 @@
 					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) {
--- a/src/misc_cmd.cpp	Thu Jul 17 16:38:26 2008 +0000
+++ b/src/misc_cmd.cpp	Thu Jul 17 20:13:01 2008 +0000
@@ -35,7 +35,7 @@
 {
 	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 @@
 
 	/* 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 */
--- a/src/misc_gui.cpp	Thu Jul 17 16:38:26 2008 +0000
+++ b/src/misc_gui.cpp	Thu Jul 17 20:13:01 2008 +0000
@@ -103,7 +103,7 @@
 	}
 
 	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 @@
 	{
 		/* 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);
--- a/src/network/network.cpp	Thu Jul 17 16:38:26 2008 +0000
+++ b/src/network/network.cpp	Thu Jul 17 20:13:01 2008 +0000
@@ -341,7 +341,7 @@
 
 	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;
--- a/src/network/network_client.cpp	Thu Jul 17 16:38:26 2008 +0000
+++ b/src/network/network_client.cpp	Thu Jul 17 20:13:01 2008 +0000
@@ -367,7 +367,7 @@
 		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 @@
 
 		/* 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 @@
 
 			/* 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));
--- a/src/network/network_gui.cpp	Thu Jul 17 16:38:26 2008 +0000
+++ b/src/network/network_gui.cpp	Thu Jul 17 20:13:01 2008 +0000
@@ -1296,7 +1296,7 @@
 			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 @@
 
 		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 @@
 			}
 
 			/* 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);
 
--- a/src/network/network_server.cpp	Thu Jul 17 16:38:26 2008 +0000
+++ b/src/network/network_server.cpp	Thu Jul 17 20:13:01 2008 +0000
@@ -621,7 +621,7 @@
 	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 @@
 			}
 			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 @@
 	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 @@
 
 		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 @@
 		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 @@
 		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 @@
 	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 @@
 
 	// 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 @@
 
 	// 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 @@
 
 	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 @@
 		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 @@
 	/* 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 @@
 		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);
 	}
 }
--- a/src/newgrf_engine.cpp	Thu Jul 17 16:38:26 2008 +0000
+++ b/src/newgrf_engine.cpp	Thu Jul 17 20:13:01 2008 +0000
@@ -454,7 +454,7 @@
 	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);
--- a/src/newgrf_house.cpp	Thu Jul 17 16:38:26 2008 +0000
+++ b/src/newgrf_house.cpp	Thu Jul 17 20:13:01 2008 +0000
@@ -591,7 +591,7 @@
 
 	/* 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)) {
--- a/src/newgrf_industries.cpp	Thu Jul 17 16:38:26 2008 +0000
+++ b/src/newgrf_industries.cpp	Thu Jul 17 20:13:01 2008 +0000
@@ -252,7 +252,7 @@
 			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];
 
--- a/src/openttd.cpp	Thu Jul 17 16:38:26 2008 +0000
+++ b/src/openttd.cpp	Thu Jul 17 20:13:01 2008 +0000
@@ -630,7 +630,7 @@
 
 				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 @@
 		 * 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 @@
 				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 @@
 
 			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 @@
 				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);
--- a/src/player_face.h	Thu Jul 17 16:38:26 2008 +0000
+++ b/src/player_face.h	Thu Jul 17 20:13:01 2008 +0000
@@ -229,6 +229,6 @@
 
 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 */
--- a/src/player_func.h	Thu Jul 17 16:38:26 2008 +0000
+++ b/src/player_func.h	Thu Jul 17 20:13:01 2008 +0000
@@ -27,7 +27,7 @@
 	return _local_player == _current_player;
 }
 
-static inline bool IsValidPlayer(PlayerID pi)
+static inline bool IsValidPlayerID(PlayerID pi)
 {
 	return IsInsideBS(pi, PLAYER_FIRST, MAX_PLAYERS);
 }
--- a/src/player_gui.cpp	Thu Jul 17 16:38:26 2008 +0000
+++ b/src/player_gui.cpp	Thu Jul 17 20:13:01 2008 +0000
@@ -252,7 +252,7 @@
  */
 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 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 @@
 
 void ShowPlayerCompany(PlayerID player)
 {
-	if (!IsValidPlayer(player)) return;
+	if (!IsValidPlayerID(player)) return;
 
 	AllocateWindowDescFront<PlayerCompanyWindow>(&_player_company_desc, player);
 }
@@ -1495,7 +1495,7 @@
 
 		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
--- a/src/players.cpp	Thu Jul 17 16:38:26 2008 +0000
+++ b/src/players.cpp	Thu Jul 17 20:13:01 2008 +0000
@@ -54,17 +54,17 @@
  * 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 @@
 {
 	/* 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 @@
  * @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 @@
 {
 	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 @@
 {
 	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 @@
 	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 @@
  */
 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 @@
 			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 @@
 	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 @@
 		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;
 
--- a/src/rail_cmd.cpp	Thu Jul 17 16:38:26 2008 +0000
+++ b/src/rail_cmd.cpp	Thu Jul 17 20:13:01 2008 +0000
@@ -514,7 +514,7 @@
 
 	if (flags & DC_EXEC) {
 		/* if we got that far, 'owner' variable is set correctly */
-		assert(IsValidPlayer(owner));
+		assert(IsValidPlayerID(owner));
 
 		MarkTileDirtyByTile(tile);
 		if (crossing) {
--- a/src/rail_gui.cpp	Thu Jul 17 16:38:26 2008 +0000
+++ b/src/rail_gui.cpp	Thu Jul 17 20:13:01 2008 +0000
@@ -839,7 +839,7 @@
 {
 	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 @@
 /** 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;
--- a/src/road.cpp	Thu Jul 17 16:38:26 2008 +0000
+++ b/src/road.cpp	Thu Jul 17 20:13:01 2008 +0000
@@ -84,7 +84,7 @@
 	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;
--- a/src/road_cmd.cpp	Thu Jul 17 16:38:26 2008 +0000
+++ b/src/road_cmd.cpp	Thu Jul 17 20:13:01 2008 +0000
@@ -152,7 +152,7 @@
 	 * 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 @@
 
 	/* 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);
 
--- a/src/road_gui.cpp	Thu Jul 17 16:38:26 2008 +0000
+++ b/src/road_gui.cpp	Thu Jul 17 20:13:01 2008 +0000
@@ -675,7 +675,7 @@
 
 void ShowBuildRoadToolbar(RoadType roadtype)
 {
-	if (!IsValidPlayer(_current_player)) return;
+	if (!IsValidPlayerID(_current_player)) return;
 	_cur_roadtype = roadtype;
 
 	DeleteWindowByClass(WC_BUILD_TOOLBAR);
--- a/src/signal.cpp	Thu Jul 17 16:38:26 2008 +0000
+++ b/src/signal.cpp	Thu Jul 17 20:13:01 2008 +0000
@@ -467,11 +467,11 @@
  *
  * @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
--- a/src/station_cmd.cpp	Thu Jul 17 16:38:26 2008 +0000
+++ b/src/station_cmd.cpp	Thu Jul 17 20:13:01 2008 +0000
@@ -956,7 +956,7 @@
 			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 @@
 			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 @@
 			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 @@
 		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 @@
 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 @@
 			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 @@
 	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 @@
 				(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;
--- a/src/station_gui.cpp	Thu Jul 17 16:38:26 2008 +0000
+++ b/src/station_gui.cpp	Thu Jul 17 20:13:01 2008 +0000
@@ -601,7 +601,7 @@
  */
 void ShowPlayerStations(PlayerID player)
 {
-	if (!IsValidPlayer(player)) return;
+	if (!IsValidPlayerID(player)) return;
 
 	AllocateWindowDescFront<PlayerStationsWindow>(&_player_stations_desc, player);
 }
--- a/src/strings.cpp	Thu Jul 17 16:38:26 2008 +0000
+++ b/src/strings.cpp	Thu Jul 17 20:13:01 2008 +0000
@@ -959,7 +959,7 @@
 				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);
--- a/src/terraform_gui.cpp	Thu Jul 17 16:38:26 2008 +0000
+++ b/src/terraform_gui.cpp	Thu Jul 17 20:13:01 2008 +0000
@@ -327,7 +327,7 @@
 
 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 @@
 		/* 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;
 		}
 	}
 }
--- a/src/town_cmd.cpp	Thu Jul 17 16:38:26 2008 +0000
+++ b/src/town_cmd.cpp	Thu Jul 17 20:13:01 2008 +0000
@@ -529,7 +529,7 @@
 	_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 @@
 		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 @@
 
 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 @@
 {
 	/* 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 @@
 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
--- a/src/town_gui.cpp	Thu Jul 17 16:38:26 2008 +0000
+++ b/src/town_gui.cpp	Thu Jul 17 20:13:01 2008 +0000
@@ -781,7 +781,7 @@
 
 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);
 }
 
--- a/src/tree_cmd.cpp	Thu Jul 17 16:38:26 2008 +0000
+++ b/src/tree_cmd.cpp	Thu Jul 17 20:13:01 2008 +0000
@@ -389,7 +389,7 @@
 						}
 					}
 
-					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 @@
 {
 	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);
 	}
--- a/src/tree_gui.cpp	Thu Jul 17 16:38:26 2008 +0000
+++ b/src/tree_gui.cpp	Thu Jul 17 20:13:01 2008 +0000
@@ -179,6 +179,6 @@
 
 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);
 }
--- a/src/tunnelbridge_cmd.cpp	Thu Jul 17 16:38:26 2008 +0000
+++ b/src/tunnelbridge_cmd.cpp	Thu Jul 17 20:13:01 2008 +0000
@@ -452,10 +452,10 @@
 	 * 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);
--- a/src/vehicle.cpp	Thu Jul 17 16:38:26 2008 +0000
+++ b/src/vehicle.cpp	Thu Jul 17 20:13:01 2008 +0000
@@ -1750,7 +1750,7 @@
 {
 	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;
--- a/src/vehicle_gui.cpp	Thu Jul 17 16:38:26 2008 +0000
+++ b/src/vehicle_gui.cpp	Thu Jul 17 20:13:01 2008 +0000
@@ -1122,7 +1122,7 @@
 	VehicleListWindow *w;
 	WindowNumber num;
 
-	if (!IsValidPlayer(player)) return;
+	if (!IsValidPlayerID(player)) return;
 
 	num = (unique_number << 16) | (vehicle_type << 11) | VLW_flag | player;