mirror of https://github.com/OpenTTD/OpenTTD
(svn r3208) Don't explicitly pass the engine type to look for to GetRearEngine(), because it's the engine type of the vehicle which gets passed as first parameter
parent
1bffec2c27
commit
89cfe202b8
|
@ -1080,13 +1080,13 @@ int32 CmdStartStopTrain(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||||
* engine is 'started', first 'close' that before 'closing' our
|
* engine is 'started', first 'close' that before 'closing' our
|
||||||
* searched engine
|
* searched engine
|
||||||
*/
|
*/
|
||||||
Vehicle *GetRearEngine(const Vehicle *v, EngineID engine)
|
Vehicle* GetRearEngine(const Vehicle* v)
|
||||||
{
|
{
|
||||||
Vehicle *u;
|
Vehicle *u;
|
||||||
int en_count = 1;
|
int en_count = 1;
|
||||||
|
|
||||||
for (u = v->next; u != NULL; u = u->next) {
|
for (u = v->next; u != NULL; u = u->next) {
|
||||||
if (u->engine_type == engine) { // find matching engine
|
if (u->engine_type == v->engine_type) { // find matching engine
|
||||||
en_count += (IS_FIRSTHEAD_SPRITE(u->spritenum)) ? +1 : -1;
|
en_count += (IS_FIRSTHEAD_SPRITE(u->spritenum)) ? +1 : -1;
|
||||||
|
|
||||||
if (en_count == 0) return (Vehicle *)u;
|
if (en_count == 0) return (Vehicle *)u;
|
||||||
|
@ -1142,7 +1142,7 @@ int32 CmdSellRailWagon(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||||
|
|
||||||
/* 1. Delete the engine, if it is dualheaded also delete the matching
|
/* 1. Delete the engine, if it is dualheaded also delete the matching
|
||||||
* rear engine of the loco (from the point of deletion onwards) */
|
* rear engine of the loco (from the point of deletion onwards) */
|
||||||
Vehicle *rear = (RailVehInfo(v->engine_type)->flags & RVI_MULTIHEAD) ? GetRearEngine(v, v->engine_type) : NULL;
|
Vehicle* rear = (RailVehInfo(v->engine_type)->flags & RVI_MULTIHEAD) ? GetRearEngine(v) : NULL;
|
||||||
if (rear != NULL) {
|
if (rear != NULL) {
|
||||||
cost -= v->value;
|
cost -= v->value;
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
|
|
|
@ -1491,7 +1491,7 @@ static Vehicle *GetNextEnginePart(Vehicle *v)
|
||||||
switch (v->type) {
|
switch (v->type) {
|
||||||
case VEH_Train:
|
case VEH_Train:
|
||||||
if (RailVehInfo(v->engine_type)->flags & RVI_MULTIHEAD) {
|
if (RailVehInfo(v->engine_type)->flags & RVI_MULTIHEAD) {
|
||||||
return GetRearEngine(v, v->engine_type);
|
return GetRearEngine(v);
|
||||||
}
|
}
|
||||||
if (v->next != NULL && v->next->subtype == TS_Artic_Part) return v->next;
|
if (v->next != NULL && v->next->subtype == TS_Artic_Part) return v->next;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -311,7 +311,7 @@ void DecreaseVehicleValue(Vehicle *v);
|
||||||
void CheckVehicleBreakdown(Vehicle *v);
|
void CheckVehicleBreakdown(Vehicle *v);
|
||||||
void AgeVehicle(Vehicle *v);
|
void AgeVehicle(Vehicle *v);
|
||||||
void VehicleEnteredDepotThisTick(Vehicle *v);
|
void VehicleEnteredDepotThisTick(Vehicle *v);
|
||||||
Vehicle *GetRearEngine(const Vehicle *v, EngineID engine);
|
Vehicle* GetRearEngine(const Vehicle* v);
|
||||||
|
|
||||||
void BeginVehicleMove(Vehicle *v);
|
void BeginVehicleMove(Vehicle *v);
|
||||||
void EndVehicleMove(Vehicle *v);
|
void EndVehicleMove(Vehicle *v);
|
||||||
|
|
Loading…
Reference in New Issue