~ubuntu-branches/debian/squeeze/openttd/squeeze

« back to all changes in this revision

Viewing changes to src/train.h

  • Committer: Bazaar Package Importer
  • Author(s): Jordi Mallach, Matthijs Kooijman, Jordi Mallach
  • Date: 2009-04-15 18:22:10 UTC
  • mfrom: (1.1.6 upstream) (2.1.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090415182210-22ktb8kdbp2tf3bm
[ Matthijs Kooijman ]
* New upstream release.
* Remove Debian specific desktop file, upstream provides one now. 
* Add debian/watch file.

[ Jordi Mallach ]
* Bump Standards-Version to 3.8.1, with no changes required.
* Move to debhelper compat 7. Bump Build-Depends accordingly.
* Use dh_prep.
* Add "set -e" to config script.
* Remove a few extra doc files that get installed by upstream Makefile.
* Add more complete copyright information.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: train.h 13827 2008-07-25 19:54:14Z rubidium $ */
 
1
/* $Id: train.h 15308 2009-02-01 17:14:39Z frosch $ */
2
2
 
3
 
/** @file train.h */
 
3
/** @file train.h Base for the train class. */
4
4
 
5
5
#ifndef TRAIN_H
6
6
#define TRAIN_H
10
10
#include "vehicle_base.h"
11
11
 
12
12
 
13
 
/*
14
 
 * enum to handle train subtypes
 
13
/** enum to handle train subtypes
15
14
 * Do not access it directly unless you have to. Use the access functions below
16
15
 * This is an enum to tell what bit to access as it is a bitmask
17
16
 */
18
 
 
19
17
enum TrainSubtype {
20
18
        TS_FRONT             = 0, ///< Leading engine of a train
21
19
        TS_ARTICULATED_PART  = 1, ///< Articulated part of an engine
249
247
        return v->Next();
250
248
}
251
249
 
 
250
/** Get the previous real (non-articulated part) vehicle in the consist.
 
251
 * @param w Vehicle.
 
252
 * @return Previous vehicle in the consist.
 
253
 */
 
254
static inline Vehicle *GetPrevVehicle(const Vehicle *w)
 
255
{
 
256
        assert(w->type == VEH_TRAIN);
 
257
 
 
258
        Vehicle *v = w->Previous();
 
259
        while (v != NULL && IsArticulatedPart(v)) v = v->Previous();
 
260
 
 
261
        return v;
 
262
}
 
263
 
252
264
/** Get the next real (non-articulated part and non rear part of dualheaded engine) vehicle in the consist.
253
265
 * @param v Vehicle.
254
266
 * @return Next vehicle in the consist.
255
267
 */
256
 
static inline Vehicle *GetNextUnit(Vehicle *v)
257
 
{
258
 
        assert(v->type == VEH_TRAIN);
259
 
        v = GetNextVehicle(v);
260
 
        if (v != NULL && IsRearDualheaded(v)) v = v->Next();
261
 
 
262
 
        return v;
263
 
}
264
 
 
265
 
void ConvertOldMultiheadToNew();
266
 
void ConnectMultiheadedTrains();
267
 
uint CountArticulatedParts(EngineID engine_type);
268
 
 
269
 
int CheckTrainInDepot(const Vehicle *v, bool needs_to_be_stopped);
 
268
static inline Vehicle *GetNextUnit(const Vehicle *v)
 
269
{
 
270
        assert(v->type == VEH_TRAIN);
 
271
        Vehicle *w = GetNextVehicle(v);
 
272
        if (w != NULL && IsRearDualheaded(w)) w = GetNextVehicle(w);
 
273
 
 
274
        return w;
 
275
}
 
276
 
 
277
/** Get the previous real (non-articulated part and non rear part of dualheaded engine) vehicle in the consist.
 
278
 * @param v Vehicle.
 
279
 * @return Previous vehicle in the consist.
 
280
 */
 
281
static inline Vehicle *GetPrevUnit(const Vehicle *v)
 
282
{
 
283
        assert(v->type == VEH_TRAIN);
 
284
        Vehicle *w = GetPrevVehicle(v);
 
285
        if (w != NULL && IsRearDualheaded(w)) w = GetPrevVehicle(w);
 
286
 
 
287
        return w;
 
288
}
 
289
 
270
290
void CcBuildLoco(bool success, TileIndex tile, uint32 p1, uint32 p2);
271
291
void CcBuildWagon(bool success, TileIndex tile, uint32 p1, uint32 p2);
272
292
 
274
294
 
275
295
int CheckTrainInDepot(const Vehicle *v, bool needs_to_be_stopped);
276
296
int CheckTrainStoppedInDepot(const Vehicle *v);
277
 
void UpdateTrainAcceleration(Vehicle* v);
 
297
void UpdateTrainAcceleration(Vehicle *v);
278
298
void CheckTrainsLengths();
279
299
 
 
300
void FreeTrainTrackReservation(const Vehicle *v, TileIndex origin = INVALID_TILE, Trackdir orig_td = INVALID_TRACKDIR);
 
301
bool TryPathReserve(Vehicle *v, bool mark_as_stuck = false, bool first_tile_okay = false);
 
302
 
280
303
/**
281
304
 * This class 'wraps' Vehicle; you do not actually instantiate this class.
282
305
 * You create a Vehicle using AllocateVehicle, so it is added to the pool
296
319
        void MarkDirty();
297
320
        void UpdateDeltaXY(Direction direction);
298
321
        ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_TRAIN_INC : EXPENSES_TRAIN_RUN; }
299
 
        WindowClass GetVehicleListWindowClass() const { return WC_TRAINS_LIST; }
300
322
        void PlayLeaveStationSound() const;
301
323
        bool IsPrimaryVehicle() const { return IsFrontEngine(this); }
302
 
        int GetImage(Direction direction) const;
303
 
        int GetDisplaySpeed() const { return this->u.rail.last_speed * 10 / 16; }
304
 
        int GetDisplayMaxSpeed() const { return this->u.rail.cached_max_speed * 10 / 16; }
 
324
        SpriteID GetImage(Direction direction) const;
 
325
        int GetDisplaySpeed() const { return this->u.rail.last_speed; }
 
326
        int GetDisplayMaxSpeed() const { return this->u.rail.cached_max_speed; }
305
327
        Money GetRunningCost() const;
306
328
        bool IsInDepot() const { return CheckTrainInDepot(this, false) != -1; }
307
329
        bool IsStoppedInDepot() const { return CheckTrainStoppedInDepot(this) >= 0; }
308
330
        void Tick();
309
331
        void OnNewDay();
 
332
        TileIndex GetOrderStationLocation(StationID station);
 
333
        bool FindClosestDepot(TileIndex *location, DestinationID *destination, bool *reverse);
310
334
};
311
335
 
312
336
#endif /* TRAIN_H */