equal
deleted
inserted
replaced
197 // p1 = vehicle |
197 // p1 = vehicle |
198 int32 CmdStartStopRoadVeh(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
198 int32 CmdStartStopRoadVeh(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
199 { |
199 { |
200 Vehicle *v; |
200 Vehicle *v; |
201 |
201 |
202 v = &_vehicles[p1]; |
202 v = GetVehicle(p1); |
203 |
203 |
204 if (v->type != VEH_Road || !CheckOwnership(v->owner)) |
204 if (v->type != VEH_Road || !CheckOwnership(v->owner)) |
205 return CMD_ERROR; |
205 return CMD_ERROR; |
206 |
206 |
207 if (flags & DC_EXEC) { |
207 if (flags & DC_EXEC) { |
211 } |
211 } |
212 |
212 |
213 return 0; |
213 return 0; |
214 } |
214 } |
215 |
215 |
216 // p1 = vehicle index in &_vehicles[] |
216 // p1 = vehicle index in GetVehicle() |
217 // p2 not used |
217 // p2 not used |
218 int32 CmdSellRoadVeh(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
218 int32 CmdSellRoadVeh(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
219 { |
219 { |
220 Vehicle *v; |
220 Vehicle *v; |
221 |
221 |
222 SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES); |
222 SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES); |
223 |
223 |
224 v = &_vehicles[p1]; |
224 v = GetVehicle(p1); |
225 |
225 |
226 if (v->type != VEH_Road || !CheckOwnership(v->owner)) |
226 if (v->type != VEH_Road || !CheckOwnership(v->owner)) |
227 return CMD_ERROR; |
227 return CMD_ERROR; |
228 |
228 |
229 if (!IsRoadDepotTile(v->tile) || v->u.road.state != 254 || !(v->vehstatus&VS_STOPPED)) |
229 if (!IsRoadDepotTile(v->tile) || v->u.road.state != 254 || !(v->vehstatus&VS_STOPPED)) |
289 return GetDepotByTile(rfdd.tile); |
289 return GetDepotByTile(rfdd.tile); |
290 } |
290 } |
291 |
291 |
292 int32 CmdSendRoadVehToDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
292 int32 CmdSendRoadVehToDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
293 { |
293 { |
294 Vehicle *v = &_vehicles[p1]; |
294 Vehicle *v = GetVehicle(p1); |
295 int depot; |
295 int depot; |
296 |
296 |
297 if (v->type != VEH_Road || !CheckOwnership(v->owner)) |
297 if (v->type != VEH_Road || !CheckOwnership(v->owner)) |
298 return CMD_ERROR; |
298 return CMD_ERROR; |
299 |
299 |
325 |
325 |
326 int32 CmdTurnRoadVeh(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
326 int32 CmdTurnRoadVeh(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
327 { |
327 { |
328 Vehicle *v; |
328 Vehicle *v; |
329 |
329 |
330 v = &_vehicles[p1]; |
330 v = GetVehicle(p1); |
331 |
331 |
332 if (v->type != VEH_Road || !CheckOwnership(v->owner)) |
332 if (v->type != VEH_Road || !CheckOwnership(v->owner)) |
333 return CMD_ERROR; |
333 return CMD_ERROR; |
334 |
334 |
335 if (v->vehstatus & (VS_HIDDEN|VS_STOPPED) || |
335 if (v->vehstatus & (VS_HIDDEN|VS_STOPPED) || |
350 |
350 |
351 int32 CmdChangeRoadVehServiceInt(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
351 int32 CmdChangeRoadVehServiceInt(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
352 { |
352 { |
353 Vehicle *v; |
353 Vehicle *v; |
354 |
354 |
355 v = &_vehicles[p1]; |
355 v = GetVehicle(p1); |
356 |
356 |
357 if (v->type != VEH_Road || !CheckOwnership(v->owner)) |
357 if (v->type != VEH_Road || !CheckOwnership(v->owner)) |
358 return CMD_ERROR; |
358 return CMD_ERROR; |
359 |
359 |
360 if (flags & DC_EXEC) { |
360 if (flags & DC_EXEC) { |
394 } |
394 } |
395 |
395 |
396 static void ClearCrashedStation(Vehicle *v) |
396 static void ClearCrashedStation(Vehicle *v) |
397 { |
397 { |
398 uint tile = v->tile; |
398 uint tile = v->tile; |
399 Station *st = DEREF_STATION(_map2[tile]); |
399 Station *st = GetStation(_map2[tile]); |
400 byte *b, bb; |
400 byte *b, bb; |
401 |
401 |
402 b = (_map5[tile] >= 0x47) ? &st->bus_stop_status : &st->truck_stop_status; |
402 b = (_map5[tile] >= 0x47) ? &st->bus_stop_status : &st->truck_stop_status; |
403 |
403 |
404 bb = *b; |
404 bb = *b; |
592 v->dest_tile = 0; |
592 v->dest_tile = 0; |
593 |
593 |
594 if (order.type == OT_GOTO_STATION) { |
594 if (order.type == OT_GOTO_STATION) { |
595 if (order.station == v->last_station_visited) |
595 if (order.station == v->last_station_visited) |
596 v->last_station_visited = 0xFFFF; |
596 v->last_station_visited = 0xFFFF; |
597 st = DEREF_STATION(order.station); |
597 st = GetStation(order.station); |
598 v->dest_tile = v->cargo_type==CT_PASSENGERS ? st->bus_tile : st->lorry_tile; |
598 v->dest_tile = v->cargo_type==CT_PASSENGERS ? st->bus_tile : st->lorry_tile; |
599 } else if (order.type == OT_GOTO_DEPOT) { |
599 } else if (order.type == OT_GOTO_DEPOT) { |
600 v->dest_tile = _depots[order.station].xy; |
600 v->dest_tile = _depots[order.station].xy; |
601 } |
601 } |
602 |
602 |
949 /* Road crossing */ |
949 /* Road crossing */ |
950 bitmask |= _road_veh_fp_ax_or[_map5[tile]&3]; |
950 bitmask |= _road_veh_fp_ax_or[_map5[tile]&3]; |
951 } else if (IS_TILETYPE(tile, MP_STATION)) { |
951 } else if (IS_TILETYPE(tile, MP_STATION)) { |
952 if (_map_owner[tile] == OWNER_NONE || _map_owner[tile] == v->owner) { |
952 if (_map_owner[tile] == OWNER_NONE || _map_owner[tile] == v->owner) { |
953 /* Our station */ |
953 /* Our station */ |
954 Station *st = DEREF_STATION(_map2[tile]); |
954 Station *st = GetStation(_map2[tile]); |
955 byte val = _map5[tile]; |
955 byte val = _map5[tile]; |
956 if (v->cargo_type != CT_PASSENGERS) { |
956 if (v->cargo_type != CT_PASSENGERS) { |
957 if (IS_BYTE_INSIDE(val, 0x43, 0x47) && (_patches.roadveh_queue || st->truck_stop_status&3)) |
957 if (IS_BYTE_INSIDE(val, 0x43, 0x47) && (_patches.roadveh_queue || st->truck_stop_status&3)) |
958 bitmask |= _road_veh_fp_ax_or[(val-0x43)&3]; |
958 bitmask |= _road_veh_fp_ax_or[(val-0x43)&3]; |
959 } else { |
959 } else { |
1209 } |
1209 } |
1210 |
1210 |
1211 if (IS_BYTE_INSIDE(v->u.road.state, 0x20, 0x30) && IS_TILETYPE(v->tile, MP_STATION)) { |
1211 if (IS_BYTE_INSIDE(v->u.road.state, 0x20, 0x30) && IS_TILETYPE(v->tile, MP_STATION)) { |
1212 if ((tmp&7) >= 6) { v->cur_speed = 0; return; } |
1212 if ((tmp&7) >= 6) { v->cur_speed = 0; return; } |
1213 if (IS_BYTE_INSIDE(_map5[v->tile], 0x43, 0x4B)) { |
1213 if (IS_BYTE_INSIDE(_map5[v->tile], 0x43, 0x4B)) { |
1214 Station *st = DEREF_STATION(_map2[v->tile]); |
1214 Station *st = GetStation(_map2[v->tile]); |
1215 byte *b; |
1215 byte *b; |
1216 |
1216 |
1217 if (_map5[v->tile] >= 0x47) { |
1217 if (_map5[v->tile] >= 0x47) { |
1218 b = &st->bus_stop_status; |
1218 b = &st->bus_stop_status; |
1219 } else { |
1219 } else { |
1305 |
1305 |
1306 if (v->u.road.state >= 0x20 && |
1306 if (v->u.road.state >= 0x20 && |
1307 _road_veh_data_1[v->u.road.state - 0x20 + (_opt.road_side<<4)] == v->u.road.frame) { |
1307 _road_veh_data_1[v->u.road.state - 0x20 + (_opt.road_side<<4)] == v->u.road.frame) { |
1308 byte *b; |
1308 byte *b; |
1309 |
1309 |
1310 st = DEREF_STATION(_map2[v->tile]); |
1310 st = GetStation(_map2[v->tile]); |
1311 b = IS_BYTE_INSIDE(_map5[v->tile], 0x43, 0x47) ? &st->truck_stop_status : &st->bus_stop_status; |
1311 b = IS_BYTE_INSIDE(_map5[v->tile], 0x43, 0x47) ? &st->truck_stop_status : &st->bus_stop_status; |
1312 |
1312 |
1313 if (v->current_order.type != OT_LEAVESTATION && |
1313 if (v->current_order.type != OT_LEAVESTATION && |
1314 v->current_order.type != OT_GOTO_DEPOT) { |
1314 v->current_order.type != OT_GOTO_DEPOT) { |
1315 Order old_order; |
1315 Order old_order; |
1485 |
1485 |
1486 CheckOrders(v); |
1486 CheckOrders(v); |
1487 |
1487 |
1488 /* update destination */ |
1488 /* update destination */ |
1489 if (v->current_order.type == OT_GOTO_STATION) { |
1489 if (v->current_order.type == OT_GOTO_STATION) { |
1490 st = DEREF_STATION(v->current_order.station); |
1490 st = GetStation(v->current_order.station); |
1491 if ((tile=(v->cargo_type==CT_PASSENGERS ? st->bus_tile : st->lorry_tile)) != 0) |
1491 if ((tile=(v->cargo_type==CT_PASSENGERS ? st->bus_tile : st->lorry_tile)) != 0) |
1492 v->dest_tile = tile; |
1492 v->dest_tile = tile; |
1493 } |
1493 } |
1494 |
1494 |
1495 if (v->vehstatus & VS_STOPPED) |
1495 if (v->vehstatus & VS_STOPPED) |