Codefix: Documentation comment in IndustryDirectoryWindow (#13059)
[openttd-github.git] / src / ship.h
blobc47be05436a4e56699fe57c7e115fb9e21cca405
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 "vehicle_base.h"
14 #include "water_map.h"
16 void GetShipSpriteSize(EngineID engine, uint &width, uint &height, int &xoffs, int &yoffs, EngineImageType image_type);
17 WaterClass GetEffectiveWaterClass(TileIndex tile);
19 typedef std::deque<Trackdir> ShipPathCache;
21 /**
22 * All ships have this type.
24 struct Ship final : public SpecializedVehicle<Ship, VEH_SHIP> {
25 ShipPathCache path; ///< Cached path.
26 TrackBits state; ///< The "track" the ship is following.
27 Direction rotation; ///< Visible direction.
28 int16_t rotation_x_pos; ///< NOSAVE: X Position before rotation.
29 int16_t rotation_y_pos; ///< NOSAVE: Y Position before rotation.
31 /** We don't want GCC to zero our struct! It already is zeroed and has an index! */
32 Ship() : SpecializedVehicleBase() {}
33 /** We want to 'destruct' the right class. */
34 virtual ~Ship() { this->PreDestructor(); }
36 void MarkDirty() override;
37 void UpdateDeltaXY() override;
38 ExpensesType GetExpenseType(bool income) const override { return income ? EXPENSES_SHIP_REVENUE : EXPENSES_SHIP_RUN; }
39 void PlayLeaveStationSound(bool force = false) const override;
40 bool IsPrimaryVehicle() const override { return true; }
41 void GetImage(Direction direction, EngineImageType image_type, VehicleSpriteSeq *result) const override;
42 int GetDisplaySpeed() const override { return this->cur_speed / 2; }
43 int GetDisplayMaxSpeed() const override { return this->vcache.cached_max_speed / 2; }
44 int GetCurrentMaxSpeed() const override { return std::min<int>(this->vcache.cached_max_speed, this->current_order.GetMaxSpeed() * 2); }
45 Money GetRunningCost() const override;
46 bool IsInDepot() const override { return this->state == TRACK_BIT_DEPOT; }
47 bool Tick() override;
48 void OnNewCalendarDay() override;
49 void OnNewEconomyDay() override;
50 Trackdir GetVehicleTrackdir() const override;
51 TileIndex GetOrderStationLocation(StationID station) override;
52 ClosestDepot FindClosestDepot() override;
53 void UpdateCache();
54 void SetDestTile(TileIndex tile) override;
57 bool IsShipDestinationTile(TileIndex tile, StationID station);
59 #endif /* SHIP_H */