mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r6524) -Code cleanup r6515: cleaned up the command to start/stop all vehicles in a depot.
IsWholeTrainInDepot() is removed as CheckTrainInDepot() could be used instead Cleaned up the check to see if a vehicle is valid for start/stop
This commit is contained in:
parent
f18405dfd0
commit
5dbfb5c272
8
train.h
8
train.h
|
@ -218,12 +218,6 @@ static inline Vehicle *GetNextVehicle(const Vehicle *v)
|
||||||
void ConvertOldMultiheadToNew(void);
|
void ConvertOldMultiheadToNew(void);
|
||||||
void ConnectMultiheadedTrains(void);
|
void ConnectMultiheadedTrains(void);
|
||||||
|
|
||||||
static inline bool IsWholeTrainInDepot(const Vehicle *v)
|
int CheckTrainInDepot(const Vehicle *v, bool needs_to_be_stopped);
|
||||||
{
|
|
||||||
for (; v != NULL; v = v->next) {
|
|
||||||
if (!(v->vehstatus & VS_HIDDEN)) return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* TRAIN_H */
|
#endif /* TRAIN_H */
|
||||||
|
|
|
@ -832,7 +832,7 @@ int32 CmdBuildRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
|
|
||||||
/* Check if all the wagons of the given train are in a depot, returns the
|
/* Check if all the wagons of the given train are in a depot, returns the
|
||||||
* number of cars (including loco) then. If not it returns -1 */
|
* number of cars (including loco) then. If not it returns -1 */
|
||||||
static int CheckTrainInDepot(const Vehicle *v, bool needs_to_be_stopped)
|
int CheckTrainInDepot(const Vehicle *v, bool needs_to_be_stopped)
|
||||||
{
|
{
|
||||||
int count;
|
int count;
|
||||||
TileIndex tile = v->tile;
|
TileIndex tile = v->tile;
|
||||||
|
|
14
vehicle.c
14
vehicle.c
|
@ -1570,8 +1570,8 @@ int32 CmdMassStartStopVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2
|
||||||
int32 return_value = CMD_ERROR;
|
int32 return_value = CMD_ERROR;
|
||||||
uint i;
|
uint i;
|
||||||
uint stop_command;
|
uint stop_command;
|
||||||
byte vehicle_type = p1;
|
byte vehicle_type = GB(p1, 0, 8);
|
||||||
byte start_stop = p2;
|
bool start_stop = HASBIT(p2, 0);
|
||||||
|
|
||||||
switch (vehicle_type) {
|
switch (vehicle_type) {
|
||||||
case VEH_Train: stop_command = CMD_START_STOP_TRAIN; break;
|
case VEH_Train: stop_command = CMD_START_STOP_TRAIN; break;
|
||||||
|
@ -1589,8 +1589,12 @@ int32 CmdMassStartStopVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2
|
||||||
int32 ret;
|
int32 ret;
|
||||||
|
|
||||||
if (!!(v->vehstatus & VS_STOPPED) != start_stop) continue;
|
if (!!(v->vehstatus & VS_STOPPED) != start_stop) continue;
|
||||||
if (!(v->vehstatus & VS_HIDDEN)) continue;
|
if (vehicle_type == VEH_Train) {
|
||||||
if (p1 == VEH_Train && !IsWholeTrainInDepot(v)) continue;
|
if (CheckTrainInDepot(v, false) == -1) continue;
|
||||||
|
} else {
|
||||||
|
if (!(v->vehstatus & VS_HIDDEN)) continue;
|
||||||
|
}
|
||||||
|
|
||||||
ret = DoCommand(tile, v->index, 0, flags, stop_command);
|
ret = DoCommand(tile, v->index, 0, flags, stop_command);
|
||||||
|
|
||||||
if (!CmdFailed(ret)) {
|
if (!CmdFailed(ret)) {
|
||||||
|
@ -1601,7 +1605,7 @@ int32 CmdMassStartStopVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free((void*)vl);
|
free(vl);
|
||||||
return return_value;
|
return return_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue