mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r11068) -Codechange: remove Vehicle::HasFront as all vehicles have the Vehicle::first pointer correctly set.
This commit is contained in:
parent
efea7622ac
commit
40b871410b
|
@ -474,7 +474,7 @@ static void HandleCloneVehClick(const Vehicle *v, const Window *w)
|
||||||
|
|
||||||
if (v == NULL) return;
|
if (v == NULL) return;
|
||||||
|
|
||||||
if (v->HasFront() && !v->IsPrimaryVehicle()) {
|
if (!v->IsPrimaryVehicle()) {
|
||||||
v = v->First();
|
v = v->First();
|
||||||
/* Do nothing when clicking on a train in depot with no loc attached */
|
/* Do nothing when clicking on a train in depot with no loc attached */
|
||||||
if (v->type == VEH_TRAIN && !IsFrontEngine(v)) return;
|
if (v->type == VEH_TRAIN && !IsFrontEngine(v)) return;
|
||||||
|
|
|
@ -354,7 +354,7 @@ CommandCost CmdSetGroupReplaceProtection(TileIndex tile, uint32 flags, uint32 p1
|
||||||
*/
|
*/
|
||||||
void RemoveVehicleFromGroup(const Vehicle *v)
|
void RemoveVehicleFromGroup(const Vehicle *v)
|
||||||
{
|
{
|
||||||
if (!v->IsValid() || !(v->HasFront() && v->IsPrimaryVehicle())) return;
|
if (!v->IsValid() || !v->IsPrimaryVehicle()) return;
|
||||||
|
|
||||||
if (!IsDefaultGroupID(v->group_id)) DecreaseGroupNumVehicle(v->group_id);
|
if (!IsDefaultGroupID(v->group_id)) DecreaseGroupNumVehicle(v->group_id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -509,8 +509,6 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by
|
||||||
switch (variable) {
|
switch (variable) {
|
||||||
case 0x40: // Get length of consist
|
case 0x40: // Get length of consist
|
||||||
case 0x41: // Get length of same consecutive wagons
|
case 0x41: // Get length of same consecutive wagons
|
||||||
if (!v->HasFront()) return 1;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
const Vehicle* u;
|
const Vehicle* u;
|
||||||
byte chain_before = 0;
|
byte chain_before = 0;
|
||||||
|
@ -832,7 +830,7 @@ static inline void NewVehicleResolver(ResolverObject *res, EngineID engine_type,
|
||||||
res->ResolveReal = &VehicleResolveReal;
|
res->ResolveReal = &VehicleResolveReal;
|
||||||
|
|
||||||
res->u.vehicle.self = v;
|
res->u.vehicle.self = v;
|
||||||
res->u.vehicle.parent = (v != NULL && v->HasFront()) ? v->First() : v;
|
res->u.vehicle.parent = (v != NULL) ? v->First() : v;
|
||||||
|
|
||||||
res->u.vehicle.self_type = engine_type;
|
res->u.vehicle.self_type = engine_type;
|
||||||
|
|
||||||
|
|
|
@ -355,7 +355,7 @@ static bool HandleOrderVehClick(const Vehicle *v, const Vehicle *u, Window *w)
|
||||||
{
|
{
|
||||||
if (u->type != v->type) return false;
|
if (u->type != v->type) return false;
|
||||||
|
|
||||||
if (u->HasFront() && !u->IsPrimaryVehicle()) {
|
if (!u->IsPrimaryVehicle()) {
|
||||||
u = u->First();
|
u = u->First();
|
||||||
if (!u->IsPrimaryVehicle()) return false;
|
if (!u->IsPrimaryVehicle()) return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,6 @@ struct RoadVehicle : public Vehicle {
|
||||||
ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_ROADVEH_INC : EXPENSES_ROADVEH_RUN; }
|
ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_ROADVEH_INC : EXPENSES_ROADVEH_RUN; }
|
||||||
WindowClass GetVehicleListWindowClass() const { return WC_ROADVEH_LIST; }
|
WindowClass GetVehicleListWindowClass() const { return WC_ROADVEH_LIST; }
|
||||||
bool IsPrimaryVehicle() const { return IsRoadVehFront(this); }
|
bool IsPrimaryVehicle() const { return IsRoadVehFront(this); }
|
||||||
bool HasFront() const { return true; }
|
|
||||||
int GetImage(Direction direction) const;
|
int GetImage(Direction direction) const;
|
||||||
int GetDisplaySpeed() const { return this->cur_speed * 10 / 32; }
|
int GetDisplaySpeed() const { return this->cur_speed * 10 / 32; }
|
||||||
int GetDisplayMaxSpeed() const { return this->max_speed * 10 / 32; }
|
int GetDisplayMaxSpeed() const { return this->max_speed * 10 / 32; }
|
||||||
|
|
|
@ -296,7 +296,6 @@ struct Train : public Vehicle {
|
||||||
WindowClass GetVehicleListWindowClass() const { return WC_TRAINS_LIST; }
|
WindowClass GetVehicleListWindowClass() const { return WC_TRAINS_LIST; }
|
||||||
void PlayLeaveStationSound() const;
|
void PlayLeaveStationSound() const;
|
||||||
bool IsPrimaryVehicle() const { return IsFrontEngine(this); }
|
bool IsPrimaryVehicle() const { return IsFrontEngine(this); }
|
||||||
bool HasFront() const { return true; }
|
|
||||||
int GetImage(Direction direction) const;
|
int GetImage(Direction direction) const;
|
||||||
int GetDisplaySpeed() const { return this->u.rail.last_speed * 10 / 16; }
|
int GetDisplaySpeed() const { return this->u.rail.last_speed * 10 / 16; }
|
||||||
int GetDisplayMaxSpeed() const { return this->u.rail.cached_max_speed * 10 / 16; }
|
int GetDisplayMaxSpeed() const { return this->u.rail.cached_max_speed * 10 / 16; }
|
||||||
|
|
|
@ -1369,7 +1369,7 @@ static uint32 VehicleEnter_TunnelBridge(Vehicle *v, TileIndex tile, int x, int y
|
||||||
} else if (IsBridge(tile)) { // XXX is this necessary?
|
} else if (IsBridge(tile)) { // XXX is this necessary?
|
||||||
DiagDirection dir;
|
DiagDirection dir;
|
||||||
|
|
||||||
if (v->HasFront() && v->IsPrimaryVehicle()) {
|
if (v->IsPrimaryVehicle()) {
|
||||||
/* modify speed of vehicle */
|
/* modify speed of vehicle */
|
||||||
uint16 spd = _bridge[GetBridgeType(tile)].speed;
|
uint16 spd = _bridge[GetBridgeType(tile)].speed;
|
||||||
|
|
||||||
|
|
|
@ -420,12 +420,6 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual bool IsPrimaryVehicle() const { return false; }
|
virtual bool IsPrimaryVehicle() const { return false; }
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether this vehicle understands the concept of a front engine, so
|
|
||||||
* basically, if GetFirstVehicleInChain() can be called for it.
|
|
||||||
*/
|
|
||||||
virtual bool HasFront() const { return false; }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the sprite to show for the given direction
|
* Gets the sprite to show for the given direction
|
||||||
* @param direction the direction the vehicle is facing
|
* @param direction the direction the vehicle is facing
|
||||||
|
|
Loading…
Reference in New Issue