ai_waypoint.cpp

Go to the documentation of this file.
00001 /* $Id: ai_waypoint.cpp 19019 2010-02-05 17:05:58Z smatz $ */
00002 
00003 /*
00004  * This file is part of OpenTTD.
00005  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
00006  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00007  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
00008  */
00009 
00012 #include "ai_waypoint.hpp"
00013 #include "ai_rail.hpp"
00014 #include "ai_marine.hpp"
00015 #include "../../company_func.h"
00016 #include "../../waypoint_base.h"
00017 
00018 /* static */ bool AIWaypoint::IsValidWaypoint(StationID waypoint_id)
00019 {
00020   const Waypoint *wp = ::Waypoint::GetIfValid(waypoint_id);
00021   return wp != NULL && (wp->owner == _current_company || wp->owner == OWNER_NONE);
00022 }
00023 
00024 /* static */ StationID AIWaypoint::GetWaypointID(TileIndex tile)
00025 {
00026   if (!AIRail::IsRailWaypointTile(tile) && !AIMarine::IsBuoyTile(tile)) return STATION_INVALID;
00027 
00028   return ::GetStationIndex(tile);
00029 }
00030 
00031 /* static */ bool AIWaypoint::HasWaypointType(StationID waypoint_id, WaypointType waypoint_type)
00032 {
00033   if (!IsValidWaypoint(waypoint_id)) return false;
00034   if (!HasExactlyOneBit(waypoint_type)) return false;
00035 
00036   return (::Waypoint::Get(waypoint_id)->facilities & waypoint_type) != 0;
00037 }

Generated on Fri Apr 30 21:55:18 2010 for OpenTTD by  doxygen 1.6.1