2006-06-05 11:28:31 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2009-08-21 20:21:05 +00: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 15:11:33 +00:00
|
|
|
/** @file ship.h Base for ships. */
|
2007-04-04 01:35:16 +00:00
|
|
|
|
2006-09-28 18:42:35 +00:00
|
|
|
#ifndef SHIP_H
|
|
|
|
#define SHIP_H
|
|
|
|
|
2019-01-14 23:33:42 +00:00
|
|
|
#include <deque>
|
|
|
|
|
2007-12-27 13:35:39 +00:00
|
|
|
#include "vehicle_base.h"
|
2011-08-21 14:13:22 +00:00
|
|
|
#include "water_map.h"
|
2006-06-05 11:28:31 +00: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 14:13:22 +00:00
|
|
|
WaterClass GetEffectiveWaterClass(TileIndex tile);
|
2006-06-05 11:28:31 +00:00
|
|
|
|
2019-01-14 23:33:42 +00:00
|
|
|
typedef std::deque<TrackdirByte> ShipPathCache;
|
|
|
|
|
2007-04-29 21:24:08 +00:00
|
|
|
/**
|
2009-05-26 23:24:34 +00:00
|
|
|
* All ships have this type.
|
2007-04-29 21:24:08 +00:00
|
|
|
*/
|
2011-12-18 17:17:18 +00:00
|
|
|
struct Ship FINAL : public SpecializedVehicle<Ship, VEH_SHIP> {
|
2018-05-20 10:03:14 +00:00
|
|
|
TrackBitsByte state; ///< The "track" the ship is following.
|
|
|
|
ShipPathCache path; ///< Cached path.
|
|
|
|
DirectionByte rotation; ///< Visible direction.
|
2019-01-31 20:54:15 +00:00
|
|
|
int16 rotation_x_pos; ///< NOSAVE: X Position before rotation.
|
|
|
|
int16 rotation_y_pos; ///< NOSAVE: Y Position before rotation.
|
2009-05-22 18:17:20 +00:00
|
|
|
|
2009-06-02 19:12:28 +00: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 21:24:08 +00:00
|
|
|
/** We want to 'destruct' the right class. */
|
2007-08-05 17:43:04 +00:00
|
|
|
virtual ~Ship() { this->PreDestructor(); }
|
2007-04-29 21:24:08 +00:00
|
|
|
|
2007-04-29 22:33:51 +00:00
|
|
|
void MarkDirty();
|
2018-05-22 17:43:34 +00:00
|
|
|
void UpdateDeltaXY();
|
2007-05-02 09:39:11 +00:00
|
|
|
ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_SHIP_INC : EXPENSES_SHIP_RUN; }
|
2007-05-07 15:58:05 +00:00
|
|
|
void PlayLeaveStationSound() const;
|
2007-06-01 12:03:10 +00:00
|
|
|
bool IsPrimaryVehicle() const { return true; }
|
2016-10-16 14:57:56 +00:00
|
|
|
void GetImage(Direction direction, EngineImageType image_type, VehicleSpriteSeq *result) const;
|
2009-02-01 17:14:39 +00:00
|
|
|
int GetDisplaySpeed() const { return this->cur_speed / 2; }
|
2010-11-06 13:03:17 +00:00
|
|
|
int GetDisplayMaxSpeed() const { return this->vcache.cached_max_speed / 2; }
|
2014-05-01 14:48:44 +00:00
|
|
|
int GetCurrentMaxSpeed() const { return min(this->vcache.cached_max_speed, this->current_order.GetMaxSpeed() * 2); }
|
2009-01-22 21:33:08 +00:00
|
|
|
Money GetRunningCost() const;
|
2009-05-22 18:17:20 +00:00
|
|
|
bool IsInDepot() const { return this->state == TRACK_BIT_DEPOT; }
|
2009-05-22 13:53:14 +00:00
|
|
|
bool Tick();
|
2008-02-01 22:02:14 +00:00
|
|
|
void OnNewDay();
|
2009-05-22 18:17:20 +00:00
|
|
|
Trackdir GetVehicleTrackdir() const;
|
2008-04-05 10:55:50 +00:00
|
|
|
TileIndex GetOrderStationLocation(StationID station);
|
2008-04-11 08:14:43 +00:00
|
|
|
bool FindClosestDepot(TileIndex *location, DestinationID *destination, bool *reverse);
|
2010-11-06 13:03:17 +00:00
|
|
|
void UpdateCache();
|
2019-01-14 23:33:42 +00:00
|
|
|
void SetDestTile(TileIndex tile);
|
2007-04-29 21:24:08 +00:00
|
|
|
};
|
|
|
|
|
2018-05-20 11:01:17 +00:00
|
|
|
static const uint SHIP_MAX_ORDER_DISTANCE = 130;
|
|
|
|
|
2011-05-01 19:51:52 +00:00
|
|
|
/**
|
|
|
|
* Iterate over all ships.
|
|
|
|
* @param var The variable used for iteration.
|
|
|
|
*/
|
2009-05-26 22:45:48 +00:00
|
|
|
#define FOR_ALL_SHIPS(var) FOR_ALL_VEHICLES_OF_TYPE(Ship, var)
|
|
|
|
|
2006-09-28 18:42:35 +00:00
|
|
|
#endif /* SHIP_H */
|