equal
deleted
inserted
replaced
4 #include <limits.h> |
4 #include <limits.h> |
5 #include "openttd.h" |
5 #include "openttd.h" |
6 #include "debug.h" |
6 #include "debug.h" |
7 #include "functions.h" |
7 #include "functions.h" |
8 #include "road_map.h" |
8 #include "road_map.h" |
|
9 #include "roadveh.h" |
9 #include "station_map.h" |
10 #include "station_map.h" |
10 #include "table/strings.h" |
11 #include "table/strings.h" |
11 #include "map.h" |
12 #include "map.h" |
12 #include "tile.h" |
13 #include "tile.h" |
13 #include "vehicle.h" |
14 #include "vehicle.h" |
214 v = GetVehicle(p1); |
215 v = GetVehicle(p1); |
215 |
216 |
216 if (v->type != VEH_Road || !CheckOwnership(v->owner)) return CMD_ERROR; |
217 if (v->type != VEH_Road || !CheckOwnership(v->owner)) return CMD_ERROR; |
217 |
218 |
218 if (flags & DC_EXEC) { |
219 if (flags & DC_EXEC) { |
219 if (v->vehstatus & VS_STOPPED && v->u.road.state == 254) { |
220 if (IsRoadVehInDepotStopped(v)) { |
220 DeleteVehicleNews(p1, STR_9016_ROAD_VEHICLE_IS_WAITING); |
221 DeleteVehicleNews(p1, STR_9016_ROAD_VEHICLE_IS_WAITING); |
221 } |
222 } |
222 |
223 |
223 v->vehstatus ^= VS_STOPPED; |
224 v->vehstatus ^= VS_STOPPED; |
224 InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); |
225 InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); |
257 |
258 |
258 if (v->type != VEH_Road || !CheckOwnership(v->owner)) return CMD_ERROR; |
259 if (v->type != VEH_Road || !CheckOwnership(v->owner)) return CMD_ERROR; |
259 |
260 |
260 SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES); |
261 SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES); |
261 |
262 |
262 if (v->u.road.state != 254 || !(v->vehstatus & VS_STOPPED)) { |
263 if (!IsRoadVehInDepotStopped(v)) { |
263 return_cmd_error(STR_9013_MUST_BE_STOPPED_INSIDE); |
264 return_cmd_error(STR_9013_MUST_BE_STOPPED_INSIDE); |
264 } |
265 } |
265 |
266 |
266 if (flags & DC_EXEC) { |
267 if (flags & DC_EXEC) { |
267 // Invalidate depot |
268 // Invalidate depot |
407 if (v->vehstatus & VS_STOPPED || |
408 if (v->vehstatus & VS_STOPPED || |
408 v->u.road.crashed_ctr != 0 || |
409 v->u.road.crashed_ctr != 0 || |
409 v->breakdown_ctr != 0 || |
410 v->breakdown_ctr != 0 || |
410 v->u.road.overtaking != 0 || |
411 v->u.road.overtaking != 0 || |
411 v->u.road.state == 255 || |
412 v->u.road.state == 255 || |
412 v->u.road.state == 254 || |
413 IsRoadVehInDepot(v) || |
413 v->cur_speed < 5) { |
414 v->cur_speed < 5) { |
414 return CMD_ERROR; |
415 return CMD_ERROR; |
415 } |
416 } |
416 |
417 |
417 if (IsTunnelTile(v->tile) && DirToDiagDir(v->direction) == GetTunnelDirection(v->tile)) return CMD_ERROR; |
418 if (IsTunnelTile(v->tile) && DirToDiagDir(v->direction) == GetTunnelDirection(v->tile)) return CMD_ERROR; |
740 short y_diff = v->y_pos - rvf->y; |
741 short y_diff = v->y_pos - rvf->y; |
741 |
742 |
742 return |
743 return |
743 rvf->veh != v && |
744 rvf->veh != v && |
744 v->type == VEH_Road && |
745 v->type == VEH_Road && |
745 v->u.road.state != 254 && |
746 !IsRoadVehInDepot(v) && |
746 myabs(v->z_pos - rvf->veh->z_pos) < 6 && |
747 myabs(v->z_pos - rvf->veh->z_pos) < 6 && |
747 v->direction == rvf->dir && |
748 v->direction == rvf->dir && |
748 (dist_x[v->direction] >= 0 || (x_diff > dist_x[v->direction] && x_diff <= 0)) && |
749 (dist_x[v->direction] >= 0 || (x_diff > dist_x[v->direction] && x_diff <= 0)) && |
749 (dist_x[v->direction] <= 0 || (x_diff < dist_x[v->direction] && x_diff >= 0)) && |
750 (dist_x[v->direction] <= 0 || (x_diff < dist_x[v->direction] && x_diff >= 0)) && |
750 (dist_y[v->direction] >= 0 || (y_diff > dist_y[v->direction] && y_diff <= 0)) && |
751 (dist_y[v->direction] >= 0 || (y_diff > dist_y[v->direction] && y_diff <= 0)) && |
1224 ProcessRoadVehOrder(v); |
1225 ProcessRoadVehOrder(v); |
1225 HandleRoadVehLoading(v); |
1226 HandleRoadVehLoading(v); |
1226 |
1227 |
1227 if (v->current_order.type == OT_LOADING) return; |
1228 if (v->current_order.type == OT_LOADING) return; |
1228 |
1229 |
1229 if (v->u.road.state == 254) { |
1230 if (IsRoadVehInDepot(v)) { |
1230 DiagDirection dir; |
1231 DiagDirection dir; |
1231 const RoadDriveEntry* rdp; |
1232 const RoadDriveEntry* rdp; |
1232 byte rd2; |
1233 byte rd2; |
1233 |
1234 |
1234 v->cur_speed = 0; |
1235 v->cur_speed = 0; |