waypoint.cpp

Go to the documentation of this file.
00001 /* $Id: waypoint.cpp 19995 2010-06-19 16:35:37Z rubidium $ */
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 "stdafx.h"
00013 
00014 #include "order_func.h"
00015 #include "window_func.h"
00016 #include "newgrf_station.h"
00017 #include "waypoint_base.h"
00018 #include "vehicle_gui.h"
00019 #include "company_func.h"
00020 #include "company_base.h"
00021 
00029 void DrawWaypointSprite(int x, int y, int stat_id, RailType railtype)
00030 {
00031   if (!DrawStationTile(x, y, railtype, AXIS_X, STAT_CLASS_WAYP, stat_id)) {
00032     StationPickerDrawSprite(x, y, STATION_WAYPOINT, railtype, INVALID_ROADTYPE, AXIS_X);
00033   }
00034 }
00035 
00036 void Waypoint::GetTileArea(TileArea *ta, StationType type) const
00037 {
00038   switch (type) {
00039     case STATION_WAYPOINT:
00040       *ta = this->train_station;
00041       return;
00042 
00043     case STATION_BUOY:
00044       ta->tile = this->xy;
00045       ta->w    = 1;
00046       ta->h    = 1;
00047       break;
00048 
00049     default: NOT_REACHED();
00050   }
00051 }
00052 
00053 Waypoint::~Waypoint()
00054 {
00055   if (CleaningPool()) return;
00056   DeleteWindowById(WC_WAYPOINT_VIEW, this->index);
00057   RemoveOrderFromAllVehicles(OT_GOTO_WAYPOINT, this->index);
00058 
00059   Owner owner = this->owner;
00060   if (!Company::IsValidID(owner)) owner = _local_company;
00061   WindowNumber wno = (this->index << 16) | VLW_WAYPOINT_LIST | owner;
00062   DeleteWindowById(WC_TRAINS_LIST, wno | (VEH_TRAIN << 11));
00063   DeleteWindowById(WC_SHIPS_LIST, wno | (VEH_SHIP << 11));
00064 
00065   this->sign.MarkDirty();
00066 }

Generated on Sat Jun 19 17:14:57 2010 for OpenTTD by  doxygen 1.6.1