OpenTTD

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

ship.h
Go to the documentation of this file.
1 /* $Id: ship.h 27666 2016-10-16 14:57:56Z frosch $ */
2
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 */
9
12 #ifndef SHIP_H
13 #define SHIP_H
14
15 #include "vehicle_base.h"
16 #include "water_map.h"
17
18 void GetShipSpriteSize(EngineID engine, uint &width, uint &height, int &xoffs, int &yoffs, EngineImageType image_type);
19 WaterClass GetEffectiveWaterClass(TileIndex tile);
20
24 struct Ship FINAL : public SpecializedVehicle<Ship, VEH_SHIP> {
25 TrackBitsByte state;
26
28 Ship() : SpecializedVehicleBase() {}
30 virtual ~Ship() { this->PreDestructor(); }
31
32 void MarkDirty();
33 void UpdateDeltaXY(Direction direction);
34 ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_SHIP_INC : EXPENSES_SHIP_RUN; }
35 void PlayLeaveStationSound() const;
36 bool IsPrimaryVehicle() const { return true; }
37 void GetImage(Direction direction, EngineImageType image_type, VehicleSpriteSeq *result) const;
38 int GetDisplaySpeed() const { return this->cur_speed / 2; }
39 int GetDisplayMaxSpeed() const { return this->vcache.cached_max_speed / 2; }
40 int GetCurrentMaxSpeed() const { return min(this->vcache.cached_max_speed, this->current_order.GetMaxSpeed() * 2); }
41 Money GetRunningCost() const;
42 bool IsInDepot() const { return this->state == TRACK_BIT_DEPOT; }
43 bool Tick();
44 void OnNewDay();
45 Trackdir GetVehicleTrackdir() const;
46 TileIndex GetOrderStationLocation(StationID station);
47 bool FindClosestDepot(TileIndex *location, DestinationID *destination, bool *reverse);
48 void UpdateCache();
49 };
50
55 #define FOR_ALL_SHIPS(var) FOR_ALL_VEHICLES_OF_TYPE(Ship, var)
56
57 #endif /* SHIP_H */