# ship.h

Go to the documentation of this file.

    00001 /* $Id: ship.h 24839 2012-12-23 01:00:25Z michi_cc $ */
    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 #ifndef SHIP_H
    00013 #define SHIP_H
    00014
    00015 #include "vehicle_base.h"
    00016 #include "water_map.h"
    00017
    00018 void GetShipSpriteSize(EngineID engine, uint &width, uint &height, int &xoffs, int &yoffs, EngineImageType image_type);
    00019 WaterClass GetEffectiveWaterClass(TileIndex tile);
    00020
    00024 struct Ship FINAL : public SpecializedVehicle<Ship, VEH_SHIP> {
    00025   TrackBitsByte state;
    00026
    00028   Ship() : SpecializedVehicleBase() {}
    00030   virtual ~Ship() { this->PreDestructor(); }
    00031
    00032   void MarkDirty();
    00033   void UpdateDeltaXY(Direction direction);
    00034   ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_SHIP_INC : EXPENSES_SHIP_RUN; }
    00035   void PlayLeaveStationSound() const;
    00036   bool IsPrimaryVehicle() const { return true; }
    00037   SpriteID GetImage(Direction direction, EngineImageType image_type) const;
    00038   int GetDisplaySpeed() const { return this->cur_speed / 2; }
    00039   int GetDisplayMaxSpeed() const { return this->vcache.cached_max_speed / 2; }
    00040   int GetCurrentMaxSpeed() const { return min(this->vcache.cached_max_speed, this->current_order.max_speed * 2); }
    00041   Money GetRunningCost() const;
    00042   bool IsInDepot() const { return this->state == TRACK_BIT_DEPOT; }
    00043   bool Tick();
    00044   void OnNewDay();
    00045   Trackdir GetVehicleTrackdir() const;
    00046   TileIndex GetOrderStationLocation(StationID station);
    00047   bool FindClosestDepot(TileIndex *location, DestinationID *destination, bool *reverse);
    00048   void UpdateCache();
    00049 };
    00050
    00055 #define FOR_ALL_SHIPS(var) FOR_ALL_VEHICLES_OF_TYPE(Ship, var)
    00056
    00057 #endif /* SHIP_H */