2009-08-21 21:21:05 +01:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* 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.
|
|
|
|
* 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.
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2008-05-06 16:11:33 +01:00
|
|
|
/** @file ship.h Base for ships. */
|
2007-04-04 02:35:16 +01:00
|
|
|
|
2006-09-28 19:42:35 +01:00
|
|
|
#ifndef SHIP_H
|
|
|
|
#define SHIP_H
|
|
|
|
|
2007-12-27 13:35:39 +00:00
|
|
|
#include "vehicle_base.h"
|
2011-08-21 15:13:22 +01:00
|
|
|
#include "water_map.h"
|
2006-06-05 12:28:31 +01:00
|
|
|
|
2012-12-23 01:00:25 +00:00
|
|
|
void GetShipSpriteSize(EngineID engine, uint &width, uint &height, int &xoffs, int &yoffs, EngineImageType image_type);
|
2011-08-21 15:13:22 +01:00
|
|
|
WaterClass GetEffectiveWaterClass(TileIndex tile);
|
2006-06-05 12:28:31 +01:00
|
|
|
|
2019-04-22 08:03:04 +01:00
|
|
|
typedef std::deque<Trackdir> ShipPathCache;
|
2019-01-14 23:33:42 +00:00
|
|
|
|
2007-04-29 22:24:08 +01:00
|
|
|
/**
|
2009-05-27 00:24:34 +01:00
|
|
|
* All ships have this type.
|
2007-04-29 22:24:08 +01:00
|
|
|
*/
|
2011-12-18 17:17:18 +00:00
|
|
|
struct Ship FINAL : public SpecializedVehicle<Ship, VEH_SHIP> {
|
2019-04-22 08:11:28 +01:00
|
|
|
TrackBits state; ///< The "track" the ship is following.
|
|
|
|
ShipPathCache path; ///< Cached path.
|
|
|
|
Direction rotation; ///< Visible direction.
|
|
|
|
int16 rotation_x_pos; ///< NOSAVE: X Position before rotation.
|
|
|
|
int16 rotation_y_pos; ///< NOSAVE: Y Position before rotation.
|
2009-05-22 19:17:20 +01:00
|
|
|
|
2009-06-02 20:12:28 +01:00
|
|
|
/** We don't want GCC to zero our struct! It already is zeroed and has an index! */
|
2011-01-21 14:43:38 +00:00
|
|
|
Ship() : SpecializedVehicleBase() {}
|
2007-04-29 22:24:08 +01:00
|
|
|
/** We want to 'destruct' the right class. */
|
2007-08-05 18:43:04 +01:00
|
|
|
virtual ~Ship() { this->PreDestructor(); }
|
2007-04-29 22:24:08 +01:00
|
|
|
|
2023-01-03 21:33:09 +00:00
|
|
|
void MarkDirty() override;
|
|
|
|
void UpdateDeltaXY() override;
|
|
|
|
ExpensesType GetExpenseType(bool income) const override { return income ? EXPENSES_SHIP_REVENUE : EXPENSES_SHIP_RUN; }
|
|
|
|
void PlayLeaveStationSound(bool force = false) const override;
|
|
|
|
bool IsPrimaryVehicle() const override { return true; }
|
|
|
|
void GetImage(Direction direction, EngineImageType image_type, VehicleSpriteSeq *result) const override;
|
|
|
|
int GetDisplaySpeed() const override { return this->cur_speed / 2; }
|
|
|
|
int GetDisplayMaxSpeed() const override { return this->vcache.cached_max_speed / 2; }
|
|
|
|
int GetCurrentMaxSpeed() const override { return std::min<int>(this->vcache.cached_max_speed, this->current_order.GetMaxSpeed() * 2); }
|
|
|
|
Money GetRunningCost() const override;
|
|
|
|
bool IsInDepot() const override { return this->state == TRACK_BIT_DEPOT; }
|
|
|
|
bool Tick() override;
|
|
|
|
void OnNewDay() override;
|
|
|
|
Trackdir GetVehicleTrackdir() const override;
|
|
|
|
TileIndex GetOrderStationLocation(StationID station) override;
|
|
|
|
ClosestDepot FindClosestDepot() override;
|
2010-11-06 13:03:17 +00:00
|
|
|
void UpdateCache();
|
2023-01-03 21:33:09 +00:00
|
|
|
void SetDestTile(TileIndex tile) override;
|
2007-04-29 22:24:08 +01:00
|
|
|
};
|
|
|
|
|
2019-03-11 10:37:47 +00:00
|
|
|
bool IsShipDestinationTile(TileIndex tile, StationID station);
|
|
|
|
|
2006-09-28 19:42:35 +01:00
|
|
|
#endif /* SHIP_H */
|