Fix: Violation of strict weak ordering in engine name sorter
[openttd-github.git] / src / ship.h
blobf3e56c39fe683dbdd5bbce1542e20930fcc7e7d6
1 /*
2 * This file is part of OpenTTD.
3 * 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.
4 * 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.
5 * 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/>.
6 */
8 /** @file ship.h Base for ships. */
10 #ifndef SHIP_H
11 #define SHIP_H
13 #include <deque>
15 #include "vehicle_base.h"
16 #include "water_map.h"
18 void GetShipSpriteSize(EngineID engine, uint &width, uint &height, int &xoffs, int &yoffs, EngineImageType image_type);
19 WaterClass GetEffectiveWaterClass(TileIndex tile);
21 typedef std::deque<Trackdir> ShipPathCache;
23 /**
24 * All ships have this type.
26 struct Ship FINAL : public SpecializedVehicle<Ship, VEH_SHIP> {
27 TrackBits state; ///< The "track" the ship is following.
28 ShipPathCache path; ///< Cached path.
29 Direction rotation; ///< Visible direction.
30 int16 rotation_x_pos; ///< NOSAVE: X Position before rotation.
31 int16 rotation_y_pos; ///< NOSAVE: Y Position before rotation.
33 /** We don't want GCC to zero our struct! It already is zeroed and has an index! */
34 Ship() : SpecializedVehicleBase() {}
35 /** We want to 'destruct' the right class. */
36 virtual ~Ship() { this->PreDestructor(); }
38 void MarkDirty();
39 void UpdateDeltaXY();
40 ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_SHIP_INC : EXPENSES_SHIP_RUN; }
41 void PlayLeaveStationSound() const;
42 bool IsPrimaryVehicle() const { return true; }
43 void GetImage(Direction direction, EngineImageType image_type, VehicleSpriteSeq *result) const;
44 int GetDisplaySpeed() const { return this->cur_speed / 2; }
45 int GetDisplayMaxSpeed() const { return this->vcache.cached_max_speed / 2; }
46 int GetCurrentMaxSpeed() const { return min(this->vcache.cached_max_speed, this->current_order.GetMaxSpeed() * 2); }
47 Money GetRunningCost() const;
48 bool IsInDepot() const { return this->state == TRACK_BIT_DEPOT; }
49 bool Tick();
50 void OnNewDay();
51 Trackdir GetVehicleTrackdir() const;
52 TileIndex GetOrderStationLocation(StationID station);
53 bool FindClosestDepot(TileIndex *location, DestinationID *destination, bool *reverse);
54 void UpdateCache();
55 void SetDestTile(TileIndex tile);
58 bool IsShipDestinationTile(TileIndex tile, StationID station);
60 #endif /* SHIP_H */