mirror of https://github.com/OpenTTD/OpenTTD
(svn r16389) -Codechange: use RoadVehicle instead of Vehicle where appropriate
parent
c882248348
commit
d37b840cf3
|
@ -30,6 +30,7 @@
|
||||||
#include "fileio_func.h"
|
#include "fileio_func.h"
|
||||||
#include "fios.h"
|
#include "fios.h"
|
||||||
#include "aircraft.h"
|
#include "aircraft.h"
|
||||||
|
#include "roadveh.h"
|
||||||
#include "console_func.h"
|
#include "console_func.h"
|
||||||
#include "screenshot.h"
|
#include "screenshot.h"
|
||||||
#include "network/network.h"
|
#include "network/network.h"
|
||||||
|
@ -1117,8 +1118,8 @@ void StateGameLoop()
|
||||||
|
|
||||||
switch (v->type) {
|
switch (v->type) {
|
||||||
case VEH_ROAD: {
|
case VEH_ROAD: {
|
||||||
extern byte GetRoadVehLength(const Vehicle *v);
|
extern byte GetRoadVehLength(const RoadVehicle *v);
|
||||||
if (GetRoadVehLength(v) != v->u.road.cached_veh_length) {
|
if (GetRoadVehLength((RoadVehicle *)v) != v->u.road.cached_veh_length) {
|
||||||
DEBUG(desync, 2, "cache mismatch: vehicle %i, company %i, unit number %i\n", v->index, (int)v->owner, v->unitnumber);
|
DEBUG(desync, 2, "cache mismatch: vehicle %i, company %i, unit number %i\n", v->index, (int)v->owner, v->unitnumber);
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
|
@ -734,7 +734,7 @@ CommandCost CmdSkipToOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
v->cur_order_index = sel_ord;
|
v->cur_order_index = sel_ord;
|
||||||
|
|
||||||
if (v->type == VEH_ROAD) ClearSlot(v);
|
if (v->type == VEH_ROAD) ClearSlot((RoadVehicle *)v);
|
||||||
|
|
||||||
if (v->current_order.IsType(OT_LOADING)) v->LeaveStation();
|
if (v->current_order.IsType(OT_LOADING)) v->LeaveStation();
|
||||||
|
|
||||||
|
@ -1360,7 +1360,7 @@ static TileIndex GetStationTileForVehicle(const Vehicle *v, const Station *st)
|
||||||
case VEH_TRAIN: return st->train_tile;
|
case VEH_TRAIN: return st->train_tile;
|
||||||
case VEH_AIRCRAFT: return st->airport_tile;
|
case VEH_AIRCRAFT: return st->airport_tile;
|
||||||
case VEH_SHIP: return st->dock_tile;
|
case VEH_SHIP: return st->dock_tile;
|
||||||
case VEH_ROAD: return st->GetPrimaryRoadStop(v)->xy;
|
case VEH_ROAD: return st->GetPrimaryRoadStop((RoadVehicle *)v)->xy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1739,7 +1739,7 @@ bool ProcessOrders(Vehicle *v)
|
||||||
|
|
||||||
v->current_order.Free();
|
v->current_order.Free();
|
||||||
v->dest_tile = 0;
|
v->dest_tile = 0;
|
||||||
if (v->type == VEH_ROAD) ClearSlot(v);
|
if (v->type == VEH_ROAD) ClearSlot((RoadVehicle *)v);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
#include "engine_base.h"
|
#include "engine_base.h"
|
||||||
#include "economy_func.h"
|
#include "economy_func.h"
|
||||||
|
|
||||||
|
struct RoadVehicle;
|
||||||
|
|
||||||
/** State information about the Road Vehicle controller */
|
/** State information about the Road Vehicle controller */
|
||||||
enum {
|
enum {
|
||||||
RDE_NEXT_TILE = 0x80, ///< We should enter the next tile
|
RDE_NEXT_TILE = 0x80, ///< We should enter the next tile
|
||||||
|
@ -68,9 +70,9 @@ static inline bool RoadVehHasArticPart(const Vehicle *v)
|
||||||
|
|
||||||
void CcBuildRoadVeh(bool success, TileIndex tile, uint32 p1, uint32 p2);
|
void CcBuildRoadVeh(bool success, TileIndex tile, uint32 p1, uint32 p2);
|
||||||
|
|
||||||
byte GetRoadVehLength(const Vehicle *v);
|
byte GetRoadVehLength(const RoadVehicle *v);
|
||||||
|
|
||||||
void RoadVehUpdateCache(Vehicle *v);
|
void RoadVehUpdateCache(RoadVehicle *v);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -104,6 +106,9 @@ struct RoadVehicle : public Vehicle {
|
||||||
Trackdir GetVehicleTrackdir() const;
|
Trackdir GetVehicleTrackdir() const;
|
||||||
TileIndex GetOrderStationLocation(StationID station);
|
TileIndex GetOrderStationLocation(StationID station);
|
||||||
bool FindClosestDepot(TileIndex *location, DestinationID *destination, bool *reverse);
|
bool FindClosestDepot(TileIndex *location, DestinationID *destination, bool *reverse);
|
||||||
|
RoadVehicle *First() { return (RoadVehicle *)this->Vehicle::First(); }
|
||||||
|
RoadVehicle *Next() { return (RoadVehicle *)this->Vehicle::Next(); }
|
||||||
|
const RoadVehicle *Next() const { return (const RoadVehicle *)this->Vehicle::Next(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* ROADVEH_H */
|
#endif /* ROADVEH_H */
|
||||||
|
|
|
@ -120,7 +120,7 @@ void DrawRoadVehEngine(int x, int y, EngineID engine, SpriteID pal)
|
||||||
DrawSprite(GetRoadVehIcon(engine), pal, x, y);
|
DrawSprite(GetRoadVehIcon(engine), pal, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
byte GetRoadVehLength(const Vehicle *v)
|
byte GetRoadVehLength(const RoadVehicle *v)
|
||||||
{
|
{
|
||||||
byte length = 8;
|
byte length = 8;
|
||||||
|
|
||||||
|
@ -132,12 +132,12 @@ byte GetRoadVehLength(const Vehicle *v)
|
||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RoadVehUpdateCache(Vehicle *v)
|
void RoadVehUpdateCache(RoadVehicle *v)
|
||||||
{
|
{
|
||||||
assert(v->type == VEH_ROAD);
|
assert(v->type == VEH_ROAD);
|
||||||
assert(IsRoadVehFront(v));
|
assert(IsRoadVehFront(v));
|
||||||
|
|
||||||
for (Vehicle *u = v; u != NULL; u = u->Next()) {
|
for (RoadVehicle *u = v; u != NULL; u = u->Next()) {
|
||||||
/* Check the v->first cache. */
|
/* Check the v->first cache. */
|
||||||
assert(u->First() == v);
|
assert(u->First() == v);
|
||||||
|
|
||||||
|
@ -192,7 +192,7 @@ CommandCost CmdBuildRoadVeh(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
const RoadVehicleInfo *rvi = RoadVehInfo(p1);
|
const RoadVehicleInfo *rvi = RoadVehInfo(p1);
|
||||||
|
|
||||||
Vehicle *v = new RoadVehicle();
|
RoadVehicle *v = new RoadVehicle();
|
||||||
v->unitnumber = unit_num;
|
v->unitnumber = unit_num;
|
||||||
v->direction = DiagDirToDir(GetRoadDepotDirection(tile));
|
v->direction = DiagDirToDir(GetRoadDepotDirection(tile));
|
||||||
v->owner = _current_company;
|
v->owner = _current_company;
|
||||||
|
@ -254,7 +254,7 @@ CommandCost CmdBuildRoadVeh(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
|
||||||
AddArticulatedParts(v, VEH_ROAD);
|
AddArticulatedParts(v, VEH_ROAD);
|
||||||
|
|
||||||
/* Call various callbacks after the whole consist has been constructed */
|
/* Call various callbacks after the whole consist has been constructed */
|
||||||
for (Vehicle *u = v; u != NULL; u = u->Next()) {
|
for (RoadVehicle *u = v; u != NULL; u = u->Next()) {
|
||||||
u->u.road.cached_veh_length = GetRoadVehLength(u);
|
u->u.road.cached_veh_length = GetRoadVehLength(u);
|
||||||
/* Cargo capacity is zero if and only if the vehicle cannot carry anything */
|
/* Cargo capacity is zero if and only if the vehicle cannot carry anything */
|
||||||
if (u->cargo_cap != 0) u->cargo_cap = GetVehicleProperty(u, 0x0F, u->cargo_cap);
|
if (u->cargo_cap != 0) u->cargo_cap = GetVehicleProperty(u, 0x0F, u->cargo_cap);
|
||||||
|
@ -277,7 +277,7 @@ CommandCost CmdBuildRoadVeh(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
|
||||||
return cost;
|
return cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClearSlot(Vehicle *v)
|
void ClearSlot(RoadVehicle *v)
|
||||||
{
|
{
|
||||||
RoadStop *rs = v->u.road.slot;
|
RoadStop *rs = v->u.road.slot;
|
||||||
if (v->u.road.slot == NULL) return;
|
if (v->u.road.slot == NULL) return;
|
||||||
|
@ -298,7 +298,7 @@ bool RoadVehicle::IsStoppedInDepot() const
|
||||||
if (!IsRoadDepotTile(tile)) return false;
|
if (!IsRoadDepotTile(tile)) return false;
|
||||||
if (IsRoadVehFront(this) && !(this->vehstatus & VS_STOPPED)) return false;
|
if (IsRoadVehFront(this) && !(this->vehstatus & VS_STOPPED)) return false;
|
||||||
|
|
||||||
for (const Vehicle *v = this; v != NULL; v = v->Next()) {
|
for (const RoadVehicle *v = this; v != NULL; v = v->Next()) {
|
||||||
if (v->u.road.state != RVSB_IN_DEPOT || v->tile != tile) return false;
|
if (v->u.road.state != RVSB_IN_DEPOT || v->tile != tile) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -356,7 +356,7 @@ static bool EnumRoadSignalFindDepot(TileIndex tile, void *data, Trackdir trackdi
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const Depot *FindClosestRoadDepot(const Vehicle *v)
|
static const Depot *FindClosestRoadDepot(const RoadVehicle *v)
|
||||||
{
|
{
|
||||||
switch (_settings_game.pf.pathfinder_for_roadvehs) {
|
switch (_settings_game.pf.pathfinder_for_roadvehs) {
|
||||||
case VPF_YAPF: // YAPF
|
case VPF_YAPF: // YAPF
|
||||||
|
@ -486,7 +486,7 @@ void RoadVehicle::UpdateDeltaXY(Direction direction)
|
||||||
this->z_extent = 6;
|
this->z_extent = 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ClearCrashedStation(Vehicle *v)
|
static void ClearCrashedStation(RoadVehicle *v)
|
||||||
{
|
{
|
||||||
RoadStop *rs = GetRoadStopByTile(v->tile, GetRoadStopType(v->tile));
|
RoadStop *rs = GetRoadStopByTile(v->tile, GetRoadStopType(v->tile));
|
||||||
|
|
||||||
|
@ -497,7 +497,7 @@ static void ClearCrashedStation(Vehicle *v)
|
||||||
rs->FreeBay(HasBit(v->u.road.state, RVS_USING_SECOND_BAY));
|
rs->FreeBay(HasBit(v->u.road.state, RVS_USING_SECOND_BAY));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DeleteLastRoadVeh(Vehicle *v)
|
static void DeleteLastRoadVeh(RoadVehicle *v)
|
||||||
{
|
{
|
||||||
Vehicle *u = v;
|
Vehicle *u = v;
|
||||||
for (; v->Next() != NULL; v = v->Next()) u = v;
|
for (; v->Next() != NULL; v = v->Next()) u = v;
|
||||||
|
@ -508,7 +508,7 @@ static void DeleteLastRoadVeh(Vehicle *v)
|
||||||
delete v;
|
delete v;
|
||||||
}
|
}
|
||||||
|
|
||||||
static byte SetRoadVehPosition(Vehicle *v, int x, int y)
|
static byte SetRoadVehPosition(RoadVehicle *v, int x, int y)
|
||||||
{
|
{
|
||||||
byte new_z, old_z;
|
byte new_z, old_z;
|
||||||
|
|
||||||
|
@ -524,7 +524,7 @@ static byte SetRoadVehPosition(Vehicle *v, int x, int y)
|
||||||
return old_z;
|
return old_z;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void RoadVehSetRandomDirection(Vehicle *v)
|
static void RoadVehSetRandomDirection(RoadVehicle *v)
|
||||||
{
|
{
|
||||||
static const DirDiff delta[] = {
|
static const DirDiff delta[] = {
|
||||||
DIRDIFF_45LEFT, DIRDIFF_SAME, DIRDIFF_SAME, DIRDIFF_45RIGHT
|
DIRDIFF_45LEFT, DIRDIFF_SAME, DIRDIFF_SAME, DIRDIFF_45RIGHT
|
||||||
|
@ -540,7 +540,7 @@ static void RoadVehSetRandomDirection(Vehicle *v)
|
||||||
} while ((v = v->Next()) != NULL);
|
} while ((v = v->Next()) != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool RoadVehIsCrashed(Vehicle *v)
|
static bool RoadVehIsCrashed(RoadVehicle *v)
|
||||||
{
|
{
|
||||||
v->u.road.crashed_ctr++;
|
v->u.road.crashed_ctr++;
|
||||||
if (v->u.road.crashed_ctr == 2) {
|
if (v->u.road.crashed_ctr == 2) {
|
||||||
|
@ -568,7 +568,7 @@ static Vehicle *EnumCheckRoadVehCrashTrain(Vehicle *v, void *data)
|
||||||
v : NULL;
|
v : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void RoadVehCrash(Vehicle *v)
|
static void RoadVehCrash(RoadVehicle *v)
|
||||||
{
|
{
|
||||||
uint16 pass = 1;
|
uint16 pass = 1;
|
||||||
|
|
||||||
|
@ -601,9 +601,9 @@ static void RoadVehCrash(Vehicle *v)
|
||||||
SndPlayVehicleFx(SND_12_EXPLOSION, v);
|
SndPlayVehicleFx(SND_12_EXPLOSION, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool RoadVehCheckTrainCrash(Vehicle *v)
|
static bool RoadVehCheckTrainCrash(RoadVehicle *v)
|
||||||
{
|
{
|
||||||
for (Vehicle *u = v; u != NULL; u = u->Next()) {
|
for (RoadVehicle *u = v; u != NULL; u = u->Next()) {
|
||||||
if (u->u.road.state == RVSB_WORMHOLE) continue;
|
if (u->u.road.state == RVSB_WORMHOLE) continue;
|
||||||
|
|
||||||
TileIndex tile = u->tile;
|
TileIndex tile = u->tile;
|
||||||
|
@ -619,7 +619,7 @@ static bool RoadVehCheckTrainCrash(Vehicle *v)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void HandleBrokenRoadVeh(Vehicle *v)
|
static void HandleBrokenRoadVeh(RoadVehicle *v)
|
||||||
{
|
{
|
||||||
if (v->breakdown_ctr != 1) {
|
if (v->breakdown_ctr != 1) {
|
||||||
v->breakdown_ctr = 1;
|
v->breakdown_ctr = 1;
|
||||||
|
@ -678,7 +678,7 @@ TileIndex RoadVehicle::GetOrderStationLocation(StationID station)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void StartRoadVehSound(const Vehicle *v)
|
static void StartRoadVehSound(const RoadVehicle *v)
|
||||||
{
|
{
|
||||||
if (!PlayVehicleSound(v, VSE_START)) {
|
if (!PlayVehicleSound(v, VSE_START)) {
|
||||||
SoundID s = RoadVehInfo(v->engine_type)->sfx;
|
SoundID s = RoadVehInfo(v->engine_type)->sfx;
|
||||||
|
@ -727,10 +727,10 @@ static Vehicle *EnumCheckRoadVehClose(Vehicle *v, void *data)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Vehicle *RoadVehFindCloseTo(Vehicle *v, int x, int y, Direction dir)
|
static RoadVehicle *RoadVehFindCloseTo(RoadVehicle *v, int x, int y, Direction dir)
|
||||||
{
|
{
|
||||||
RoadVehFindData rvf;
|
RoadVehFindData rvf;
|
||||||
Vehicle *front = v->First();
|
RoadVehicle *front = v->First();
|
||||||
|
|
||||||
if (front->u.road.reverse_ctr != 0) return NULL;
|
if (front->u.road.reverse_ctr != 0) return NULL;
|
||||||
|
|
||||||
|
@ -758,10 +758,10 @@ static Vehicle *RoadVehFindCloseTo(Vehicle *v, int x, int y, Direction dir)
|
||||||
|
|
||||||
if (++front->u.road.blocked_ctr > 1480) return NULL;
|
if (++front->u.road.blocked_ctr > 1480) return NULL;
|
||||||
|
|
||||||
return rvf.best;
|
return (RoadVehicle *)rvf.best;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void RoadVehArrivesAt(const Vehicle *v, Station *st)
|
static void RoadVehArrivesAt(const RoadVehicle *v, Station *st)
|
||||||
{
|
{
|
||||||
if (IsCargoInClass(v->cargo_type, CC_PASSENGERS)) {
|
if (IsCargoInClass(v->cargo_type, CC_PASSENGERS)) {
|
||||||
/* Check if station was ever visited before */
|
/* Check if station was ever visited before */
|
||||||
|
@ -792,7 +792,7 @@ static void RoadVehArrivesAt(const Vehicle *v, Station *st)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int RoadVehAccelerate(Vehicle *v)
|
static int RoadVehAccelerate(RoadVehicle *v)
|
||||||
{
|
{
|
||||||
uint oldspeed = v->cur_speed;
|
uint oldspeed = v->cur_speed;
|
||||||
uint accel = 256 + (v->u.road.overtaking != 0 ? 256 : 0);
|
uint accel = 256 + (v->u.road.overtaking != 0 ? 256 : 0);
|
||||||
|
@ -827,7 +827,7 @@ static int RoadVehAccelerate(Vehicle *v)
|
||||||
return scaled_spd;
|
return scaled_spd;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Direction RoadVehGetNewDirection(const Vehicle *v, int x, int y)
|
static Direction RoadVehGetNewDirection(const RoadVehicle *v, int x, int y)
|
||||||
{
|
{
|
||||||
static const Direction _roadveh_new_dir[] = {
|
static const Direction _roadveh_new_dir[] = {
|
||||||
DIR_N , DIR_NW, DIR_W , INVALID_DIR,
|
DIR_N , DIR_NW, DIR_W , INVALID_DIR,
|
||||||
|
@ -842,7 +842,7 @@ static Direction RoadVehGetNewDirection(const Vehicle *v, int x, int y)
|
||||||
return _roadveh_new_dir[y * 4 + x];
|
return _roadveh_new_dir[y * 4 + x];
|
||||||
}
|
}
|
||||||
|
|
||||||
static Direction RoadVehGetSlidingDirection(const Vehicle *v, int x, int y)
|
static Direction RoadVehGetSlidingDirection(const RoadVehicle *v, int x, int y)
|
||||||
{
|
{
|
||||||
Direction new_dir = RoadVehGetNewDirection(v, x, y);
|
Direction new_dir = RoadVehGetNewDirection(v, x, y);
|
||||||
Direction old_dir = v->direction;
|
Direction old_dir = v->direction;
|
||||||
|
@ -854,8 +854,8 @@ static Direction RoadVehGetSlidingDirection(const Vehicle *v, int x, int y)
|
||||||
}
|
}
|
||||||
|
|
||||||
struct OvertakeData {
|
struct OvertakeData {
|
||||||
const Vehicle *u;
|
const RoadVehicle *u;
|
||||||
const Vehicle *v;
|
const RoadVehicle *v;
|
||||||
TileIndex tile;
|
TileIndex tile;
|
||||||
Trackdir trackdir;
|
Trackdir trackdir;
|
||||||
};
|
};
|
||||||
|
@ -889,7 +889,7 @@ static bool CheckRoadBlockedForOvertaking(OvertakeData *od)
|
||||||
return HasVehicleOnPos(od->tile, od, EnumFindVehBlockingOvertake);
|
return HasVehicleOnPos(od->tile, od, EnumFindVehBlockingOvertake);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void RoadVehCheckOvertake(Vehicle *v, Vehicle *u)
|
static void RoadVehCheckOvertake(RoadVehicle *v, RoadVehicle *u)
|
||||||
{
|
{
|
||||||
OvertakeData od;
|
OvertakeData od;
|
||||||
|
|
||||||
|
@ -941,7 +941,7 @@ static void RoadVehCheckOvertake(Vehicle *v, Vehicle *u)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void RoadZPosAffectSpeed(Vehicle *v, byte old_z)
|
static void RoadZPosAffectSpeed(RoadVehicle *v, byte old_z)
|
||||||
{
|
{
|
||||||
if (old_z == v->z_pos) return;
|
if (old_z == v->z_pos) return;
|
||||||
|
|
||||||
|
@ -1000,7 +1000,7 @@ static inline NPFFoundTargetData PerfNPFRouteToStationOrTile(TileIndex tile, Tra
|
||||||
* @param enterdir the direction the vehicle enters the tile from
|
* @param enterdir the direction the vehicle enters the tile from
|
||||||
* @return the Trackdir to take
|
* @return the Trackdir to take
|
||||||
*/
|
*/
|
||||||
static Trackdir RoadFindPathToDest(Vehicle *v, TileIndex tile, DiagDirection enterdir)
|
static Trackdir RoadFindPathToDest(RoadVehicle *v, TileIndex tile, DiagDirection enterdir)
|
||||||
{
|
{
|
||||||
#define return_track(x) { best_track = (Trackdir)x; goto found_best_track; }
|
#define return_track(x) { best_track = (Trackdir)x; goto found_best_track; }
|
||||||
|
|
||||||
|
@ -1166,7 +1166,7 @@ found_best_track:;
|
||||||
return best_track;
|
return best_track;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint RoadFindPathToStop(const Vehicle *v, TileIndex tile)
|
static uint RoadFindPathToStop(const RoadVehicle *v, TileIndex tile)
|
||||||
{
|
{
|
||||||
if (_settings_game.pf.pathfinder_for_roadvehs == VPF_YAPF) {
|
if (_settings_game.pf.pathfinder_for_roadvehs == VPF_YAPF) {
|
||||||
/* use YAPF */
|
/* use YAPF */
|
||||||
|
@ -1201,10 +1201,10 @@ static const byte _road_veh_data_1[] = {
|
||||||
15, 15, 11, 11
|
15, 15, 11, 11
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool RoadVehLeaveDepot(Vehicle *v, bool first)
|
static bool RoadVehLeaveDepot(RoadVehicle *v, bool first)
|
||||||
{
|
{
|
||||||
/* Don't leave if not all the wagons are in the depot. */
|
/* Don't leave if not all the wagons are in the depot. */
|
||||||
for (const Vehicle *u = v; u != NULL; u = u->Next()) {
|
for (const RoadVehicle *u = v; u != NULL; u = u->Next()) {
|
||||||
if (u->u.road.state != RVSB_IN_DEPOT || u->tile != v->tile) return false;
|
if (u->u.road.state != RVSB_IN_DEPOT || u->tile != v->tile) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1240,7 +1240,7 @@ static bool RoadVehLeaveDepot(Vehicle *v, bool first)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Trackdir FollowPreviousRoadVehicle(const Vehicle *v, const Vehicle *prev, TileIndex tile, DiagDirection entry_dir, bool already_reversed)
|
static Trackdir FollowPreviousRoadVehicle(const RoadVehicle *v, const RoadVehicle *prev, TileIndex tile, DiagDirection entry_dir, bool already_reversed)
|
||||||
{
|
{
|
||||||
if (prev->tile == v->tile && !already_reversed) {
|
if (prev->tile == v->tile && !already_reversed) {
|
||||||
/* If the previous vehicle is on the same tile as this vehicle is
|
/* If the previous vehicle is on the same tile as this vehicle is
|
||||||
|
@ -1325,7 +1325,7 @@ static bool CanBuildTramTrackOnTile(CompanyID c, TileIndex t, RoadBits r)
|
||||||
return CmdSucceeded(ret);
|
return CmdSucceeded(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool IndividualRoadVehicleController(Vehicle *v, const Vehicle *prev)
|
static bool IndividualRoadVehicleController(RoadVehicle *v, const RoadVehicle *prev)
|
||||||
{
|
{
|
||||||
if (v->u.road.overtaking != 0) {
|
if (v->u.road.overtaking != 0) {
|
||||||
if (IsTileType(v->tile, MP_STATION)) {
|
if (IsTileType(v->tile, MP_STATION)) {
|
||||||
|
@ -1594,7 +1594,7 @@ again:
|
||||||
if (IsRoadVehFront(v) && !IsInsideMM(v->u.road.state, RVSB_IN_ROAD_STOP, RVSB_IN_ROAD_STOP_END)) {
|
if (IsRoadVehFront(v) && !IsInsideMM(v->u.road.state, RVSB_IN_ROAD_STOP, RVSB_IN_ROAD_STOP_END)) {
|
||||||
/* Vehicle is not in a road stop.
|
/* Vehicle is not in a road stop.
|
||||||
* Check for another vehicle to overtake */
|
* Check for another vehicle to overtake */
|
||||||
Vehicle *u = RoadVehFindCloseTo(v, x, y, new_dir);
|
RoadVehicle *u = RoadVehFindCloseTo(v, x, y, new_dir);
|
||||||
|
|
||||||
if (u != NULL) {
|
if (u != NULL) {
|
||||||
u = u->First();
|
u = u->First();
|
||||||
|
@ -1739,7 +1739,7 @@ again:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool RoadVehController(Vehicle *v)
|
static bool RoadVehController(RoadVehicle *v)
|
||||||
{
|
{
|
||||||
/* decrease counters */
|
/* decrease counters */
|
||||||
v->tick_counter++;
|
v->tick_counter++;
|
||||||
|
@ -1778,8 +1778,8 @@ static bool RoadVehController(Vehicle *v)
|
||||||
while (j >= adv_spd) {
|
while (j >= adv_spd) {
|
||||||
j -= adv_spd;
|
j -= adv_spd;
|
||||||
|
|
||||||
Vehicle *u = v;
|
RoadVehicle *u = v;
|
||||||
for (Vehicle *prev = NULL; u != NULL; prev = u, u = u->Next()) {
|
for (RoadVehicle *prev = NULL; u != NULL; prev = u, u = u->Next()) {
|
||||||
if (!IndividualRoadVehicleController(u, prev)) break;
|
if (!IndividualRoadVehicleController(u, prev)) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1790,7 +1790,7 @@ static bool RoadVehController(Vehicle *v)
|
||||||
if (j >= adv_spd && RoadVehCheckTrainCrash(v)) break;
|
if (j >= adv_spd && RoadVehCheckTrainCrash(v)) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Vehicle *u = v; u != NULL; u = u->Next()) {
|
for (RoadVehicle *u = v; u != NULL; u = u->Next()) {
|
||||||
if ((u->vehstatus & VS_HIDDEN) != 0) continue;
|
if ((u->vehstatus & VS_HIDDEN) != 0) continue;
|
||||||
|
|
||||||
uint16 old_image = u->cur_image;
|
uint16 old_image = u->cur_image;
|
||||||
|
@ -1803,7 +1803,7 @@ static bool RoadVehController(Vehicle *v)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void AgeRoadVehCargo(Vehicle *v)
|
static void AgeRoadVehCargo(RoadVehicle *v)
|
||||||
{
|
{
|
||||||
if (_age_cargo_skip_counter != 0) return;
|
if (_age_cargo_skip_counter != 0) return;
|
||||||
v->cargo.AgeCargo();
|
v->cargo.AgeCargo();
|
||||||
|
@ -1821,7 +1821,7 @@ bool RoadVehicle::Tick()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CheckIfRoadVehNeedsService(Vehicle *v)
|
static void CheckIfRoadVehNeedsService(RoadVehicle *v)
|
||||||
{
|
{
|
||||||
/* If we already got a slot at a stop, use that FIRST, and go to a depot later */
|
/* If we already got a slot at a stop, use that FIRST, and go to a depot later */
|
||||||
if (v->u.road.slot != NULL || _settings_game.vehicle.servint_roadveh == 0 || !v->NeedsAutomaticServicing()) return;
|
if (v->u.road.slot != NULL || _settings_game.vehicle.servint_roadveh == 0 || !v->NeedsAutomaticServicing()) return;
|
||||||
|
@ -2064,7 +2064,7 @@ CommandCost CmdRefitRoadVeh(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & DC_EXEC) RoadVehUpdateCache(Vehicle::Get(p1)->First());
|
if (flags & DC_EXEC) RoadVehUpdateCache((RoadVehicle *)Vehicle::Get(p1)->First());
|
||||||
|
|
||||||
_returned_refit_capacity = total_capacity;
|
_returned_refit_capacity = total_capacity;
|
||||||
|
|
||||||
|
|
|
@ -321,7 +321,7 @@ void AfterLoadVehicles(bool part_of_load)
|
||||||
if (IsFrontEngine(v)) v->u.rail.last_speed = v->cur_speed; // update displayed train speed
|
if (IsFrontEngine(v)) v->u.rail.last_speed = v->cur_speed; // update displayed train speed
|
||||||
TrainConsistChanged(v, false);
|
TrainConsistChanged(v, false);
|
||||||
} else if (v->type == VEH_ROAD && IsRoadVehFront(v)) {
|
} else if (v->type == VEH_ROAD && IsRoadVehFront(v)) {
|
||||||
RoadVehUpdateCache(v);
|
RoadVehUpdateCache((RoadVehicle *)v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -108,7 +108,7 @@ Station::~Station()
|
||||||
* @param v the vehicle to get the first road stop for
|
* @param v the vehicle to get the first road stop for
|
||||||
* @return the first roadstop that this vehicle can load at
|
* @return the first roadstop that this vehicle can load at
|
||||||
*/
|
*/
|
||||||
RoadStop *Station::GetPrimaryRoadStop(const Vehicle *v) const
|
RoadStop *Station::GetPrimaryRoadStop(const RoadVehicle *v) const
|
||||||
{
|
{
|
||||||
RoadStop *rs = this->GetPrimaryRoadStop(IsCargoInClass(v->cargo_type, CC_PASSENGERS) ? ROADSTOP_BUS : ROADSTOP_TRUCK);
|
RoadStop *rs = this->GetPrimaryRoadStop(IsCargoInClass(v->cargo_type, CC_PASSENGERS) ? ROADSTOP_BUS : ROADSTOP_TRUCK);
|
||||||
|
|
||||||
|
@ -459,7 +459,10 @@ RoadStop::~RoadStop()
|
||||||
Vehicle *v;
|
Vehicle *v;
|
||||||
|
|
||||||
FOR_ALL_VEHICLES(v) {
|
FOR_ALL_VEHICLES(v) {
|
||||||
if (v->type == VEH_ROAD && v->u.road.slot == this) ClearSlot(v);
|
if (v->type != VEH_ROAD) continue;
|
||||||
|
RoadVehicle *rv = (RoadVehicle *)v;
|
||||||
|
|
||||||
|
if (rv->u.road.slot == this) ClearSlot(rv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assert(num_vehicles == 0);
|
assert(num_vehicles == 0);
|
||||||
|
@ -535,7 +538,7 @@ void RoadStop::SetEntranceBusy(bool busy)
|
||||||
* @param v the vehicle to get the next road stop for.
|
* @param v the vehicle to get the next road stop for.
|
||||||
* @return the next road stop accessible.
|
* @return the next road stop accessible.
|
||||||
*/
|
*/
|
||||||
RoadStop *RoadStop::GetNextRoadStop(const Vehicle *v) const
|
RoadStop *RoadStop::GetNextRoadStop(const RoadVehicle *v) const
|
||||||
{
|
{
|
||||||
for (RoadStop *rs = this->next; rs != NULL; rs = rs->next) {
|
for (RoadStop *rs = this->next; rs != NULL; rs = rs->next) {
|
||||||
/* The vehicle cannot go to this roadstop (different roadtype) */
|
/* The vehicle cannot go to this roadstop (different roadtype) */
|
||||||
|
|
|
@ -73,7 +73,7 @@ struct RoadStop : RoadStopPool::PoolItem<&_roadstop_pool> {
|
||||||
bool IsEntranceBusy() const;
|
bool IsEntranceBusy() const;
|
||||||
void SetEntranceBusy(bool busy);
|
void SetEntranceBusy(bool busy);
|
||||||
|
|
||||||
RoadStop *GetNextRoadStop(const Vehicle *v) const;
|
RoadStop *GetNextRoadStop(const struct RoadVehicle *v) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct StationSpecList {
|
struct StationSpecList {
|
||||||
|
@ -113,7 +113,7 @@ public:
|
||||||
return type == ROADSTOP_BUS ? bus_stops : truck_stops;
|
return type == ROADSTOP_BUS ? bus_stops : truck_stops;
|
||||||
}
|
}
|
||||||
|
|
||||||
RoadStop *GetPrimaryRoadStop(const Vehicle *v) const;
|
RoadStop *GetPrimaryRoadStop(const struct RoadVehicle *v) const;
|
||||||
|
|
||||||
const AirportFTAClass *Airport() const
|
const AirportFTAClass *Airport() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -34,7 +34,7 @@ RoadStop * GetRoadStopByTile(TileIndex tile, RoadStopType type);
|
||||||
uint GetNumRoadStops(const Station *st, RoadStopType type);
|
uint GetNumRoadStops(const Station *st, RoadStopType type);
|
||||||
RoadStop * AllocateRoadStop();
|
RoadStop * AllocateRoadStop();
|
||||||
|
|
||||||
void ClearSlot(Vehicle *v);
|
void ClearSlot(struct RoadVehicle *v);
|
||||||
|
|
||||||
void DeleteOilRig(TileIndex t);
|
void DeleteOilRig(TileIndex t);
|
||||||
|
|
||||||
|
|
|
@ -524,7 +524,7 @@ void Vehicle::PreDestructor()
|
||||||
if (this->IsPrimaryVehicle()) DecreaseGroupNumVehicle(this->group_id);
|
if (this->IsPrimaryVehicle()) DecreaseGroupNumVehicle(this->group_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->type == VEH_ROAD) ClearSlot(this);
|
if (this->type == VEH_ROAD) ClearSlot((RoadVehicle *)this);
|
||||||
if (this->type == VEH_AIRCRAFT && this->IsPrimaryVehicle()) {
|
if (this->type == VEH_AIRCRAFT && this->IsPrimaryVehicle()) {
|
||||||
Aircraft *a = (Aircraft *)this;
|
Aircraft *a = (Aircraft *)this;
|
||||||
Station *st = GetTargetAirportIfValid(a);
|
Station *st = GetTargetAirportIfValid(a);
|
||||||
|
@ -1742,7 +1742,7 @@ bool CanVehicleUseStation(EngineID engine_type, const Station *st)
|
||||||
*/
|
*/
|
||||||
bool CanVehicleUseStation(const Vehicle *v, const Station *st)
|
bool CanVehicleUseStation(const Vehicle *v, const Station *st)
|
||||||
{
|
{
|
||||||
if (v->type == VEH_ROAD) return st->GetPrimaryRoadStop(v) != NULL;
|
if (v->type == VEH_ROAD) return st->GetPrimaryRoadStop((RoadVehicle *)v) != NULL;
|
||||||
|
|
||||||
return CanVehicleUseStation(v->engine_type, st);
|
return CanVehicleUseStation(v->engine_type, st);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue