Merge branch 'development' into master_joker
[openttd-joker.git] / src / ship.h
blob15e11f674db2b8390615a263af8b93f9b8fa7c18
1 /* $Id: ship.h 24839 2012-12-23 01:00:25Z michi_cc $ */
3 /*
4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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/>.
8 */
10 /** @file ship.h Base for ships. */
12 #ifndef SHIP_H
13 #define SHIP_H
15 #include "vehicle_base.h"
16 #include "water_map.h"
18 extern const DiagDirection _ship_search_directions[TRACK_END][DIAGDIR_END];
20 void GetShipSpriteSize(EngineID engine, uint &width, uint &height, int &xoffs, int &yoffs, EngineImageType image_type);
21 WaterClass GetEffectiveWaterClass(TileIndex tile);
23 /**
24 * All ships have this type.
26 struct Ship FINAL : public SpecializedVehicle<Ship, VEH_SHIP> {
27 TrackBitsByte state; ///< The "track" the ship is following.
29 /** We don't want GCC to zero our struct! It already is zeroed and has an index! */
30 Ship() : SpecializedVehicleBase() {}
31 /** We want to 'destruct' the right class. */
32 virtual ~Ship() { this->PreDestructor(); }
34 void MarkDirty();
35 void UpdateDeltaXY(Direction direction);
36 ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_SHIP_INC : EXPENSES_SHIP_RUN; }
37 void PlayLeaveStationSound() const;
38 bool IsPrimaryVehicle() const { return true; }
39 void GetImage(Direction direction, EngineImageType image_type, VehicleSpriteSeq *result) const;
40 int GetDisplaySpeed() const { return this->cur_speed / 2; }
41 int GetDisplayMaxSpeed() const { return this->vcache.cached_max_speed / 2; }
42 int GetCurrentMaxSpeed() const { return min(this->vcache.cached_max_speed, this->current_order.GetMaxSpeed() * 2); }
43 Money GetRunningCost() const;
44 bool IsInDepot() const { return this->state == TRACK_BIT_DEPOT; }
45 bool Tick();
46 void OnNewDay();
47 Trackdir GetVehicleTrackdir() const;
48 TileIndex GetOrderStationLocation(StationID station);
49 bool FindClosestDepot(TileIndex *location, DestinationID *destination, bool *reverse);
50 void UpdateCache();
53 /**
54 * Iterate over all ships.
55 * @param var The variable used for iteration.
57 #define FOR_ALL_SHIPS(var) FOR_ALL_VEHICLES_OF_TYPE(Ship, var)
59 #endif /* SHIP_H */