depot.cpp

Go to the documentation of this file.
00001 /* $Id: depot.cpp 21939 2011-02-02 14:50:57Z 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 "stdafx.h"
00013 #include "depot_base.h"
00014 #include "order_backup.h"
00015 #include "order_func.h"
00016 #include "window_func.h"
00017 #include "core/pool_func.hpp"
00018 #include "vehicle_gui.h"
00019 #include "vehiclelist.h"
00020 
00021 DepotPool _depot_pool("Depot");
00022 INSTANTIATE_POOL_METHODS(Depot)
00023 
00024 
00027 Depot::~Depot()
00028 {
00029   if (CleaningPool()) return;
00030 
00031   if (!IsDepotTile(this->xy) || GetDepotIndex(this->xy) != this->index) {
00032     /* It can happen there is no depot here anymore (TTO/TTD savegames) */
00033     return;
00034   }
00035 
00036   /* Clear the order backup. */
00037   OrderBackup::Reset(this->xy, false);
00038 
00039   /* Clear the depot from all order-lists */
00040   RemoveOrderFromAllVehicles(OT_GOTO_DEPOT, this->index);
00041 
00042   /* Delete the depot-window */
00043   DeleteWindowById(WC_VEHICLE_DEPOT, this->xy);
00044 
00045   /* Delete the depot list */
00046   VehicleType vt;
00047   switch (GetTileType(this->xy)) {
00048     default: NOT_REACHED();
00049     case MP_RAILWAY: vt = VEH_TRAIN; break;
00050     case MP_ROAD:    vt = VEH_ROAD;  break;
00051     case MP_WATER:   vt = VEH_SHIP;  break;
00052   }
00053   DeleteWindowById(GetWindowClassForVehicleType(vt), VehicleListIdentifier(VL_DEPOT_LIST, vt, GetTileOwner(this->xy), this->index).Pack());
00054 }
00055 
00056 void InitializeDepots()
00057 {
00058   _depot_pool.CleanPool();
00059 }

Generated on Fri Mar 4 21:36:58 2011 for OpenTTD by  doxygen 1.6.1