src/station_cmd.cpp
changeset 8832 6d8cc04d39a4
parent 8806 4fe163e0b52a
child 8836 f6f1ea3d7e93
equal deleted inserted replaced
8831:d598d3d0380a 8832:6d8cc04d39a4
  2397 	215, 195, 175, 155, 135, 115, 95, 75, 55, 35, 15, 0
  2397 	215, 195, 175, 155, 135, 115, 95, 75, 55, 35, 15, 0
  2398 };
  2398 };
  2399 
  2399 
  2400 static VehicleEnterTileStatus VehicleEnter_Station(Vehicle *v, TileIndex tile, int x, int y)
  2400 static VehicleEnterTileStatus VehicleEnter_Station(Vehicle *v, TileIndex tile, int x, int y)
  2401 {
  2401 {
       
  2402 	StationID station_id = GetStationIndex(tile);
       
  2403 	if (!v->current_order.ShouldStopAtStation(v, station_id)) return VETSB_CONTINUE;
       
  2404 
  2402 	if (v->type == VEH_TRAIN) {
  2405 	if (v->type == VEH_TRAIN) {
  2403 		if (IsRailwayStation(tile) && IsFrontEngine(v) &&
  2406 		if (IsRailwayStation(tile) && IsFrontEngine(v) &&
  2404 				!IsCompatibleTrainStationTile(tile + TileOffsByDiagDir(DirToDiagDir(v->direction)), tile)) {
  2407 				!IsCompatibleTrainStationTile(tile + TileOffsByDiagDir(DirToDiagDir(v->direction)), tile)) {
  2405 			StationID station_id = GetStationIndex(tile);
  2408 			DiagDirection dir = DirToDiagDir(v->direction);
  2406 
  2409 
  2407 			if ((!(v->current_order.flags & OFB_NON_STOP) && !_patches.new_nonstop) ||
  2410 			x &= 0xF;
  2408 					(v->current_order.type == OT_GOTO_STATION && v->current_order.dest == station_id)) {
  2411 			y &= 0xF;
  2409 				if (!(_patches.new_nonstop && v->current_order.flags & OFB_NON_STOP) &&
  2412 
  2410 						v->current_order.type != OT_LEAVESTATION &&
  2413 			if (DiagDirToAxis(dir) != AXIS_X) Swap(x, y);
  2411 						v->last_station_visited != station_id) {
  2414 			if (y == TILE_SIZE / 2) {
  2412 					DiagDirection dir = DirToDiagDir(v->direction);
  2415 				if (dir != DIAGDIR_SE && dir != DIAGDIR_SW) x = TILE_SIZE - 1 - x;
  2413 
  2416 				if (x == 12) return VETSB_ENTERED_STATION | (VehicleEnterTileStatus)(station_id << VETS_STATION_ID_OFFSET); /* enter station */
  2414 					x &= 0xF;
  2417 				if (x < 12) {
  2415 					y &= 0xF;
  2418 					uint16 spd;
  2416 
  2419 
  2417 					if (DiagDirToAxis(dir) != AXIS_X) Swap(x, y);
  2420 					v->vehstatus |= VS_TRAIN_SLOWING;
  2418 					if (y == TILE_SIZE / 2) {
  2421 					spd = _enter_station_speedtable[x];
  2419 						if (dir != DIAGDIR_SE && dir != DIAGDIR_SW) x = TILE_SIZE - 1 - x;
  2422 					if (spd < v->cur_speed) v->cur_speed = spd;
  2420 						if (x == 12) return VETSB_ENTERED_STATION | (VehicleEnterTileStatus)(station_id << VETS_STATION_ID_OFFSET); /* enter station */
       
  2421 						if (x < 12) {
       
  2422 							uint16 spd;
       
  2423 
       
  2424 							v->vehstatus |= VS_TRAIN_SLOWING;
       
  2425 							spd = _enter_station_speedtable[x];
       
  2426 							if (spd < v->cur_speed) v->cur_speed = spd;
       
  2427 						}
       
  2428 					}
       
  2429 				}
  2423 				}
  2430 			}
  2424 			}
  2431 		}
  2425 		}
  2432 	} else if (v->type == VEH_ROAD) {
  2426 	} else if (v->type == VEH_ROAD) {
  2433 		if (v->u.road.state < RVSB_IN_ROAD_STOP && !IsReversingRoadTrackdir((Trackdir)v->u.road.state) && v->u.road.frame == 0) {
  2427 		if (v->u.road.state < RVSB_IN_ROAD_STOP && !IsReversingRoadTrackdir((Trackdir)v->u.road.state) && v->u.road.frame == 0) {