src/vehicle.cpp
branchcpp_gui
changeset 6253 23983700e3d7
parent 6206 67358999d80d
child 6254 abc6ad7c035c
equal deleted inserted replaced
6252:ca57ad0b45ea 6253:23983700e3d7
  2314 	if (wagon_count != NULL) *wagon_count = 0;
  2314 	if (wagon_count != NULL) *wagon_count = 0;
  2315 
  2315 
  2316 	switch (type) {
  2316 	switch (type) {
  2317 		case VEH_Train:
  2317 		case VEH_Train:
  2318 			FOR_ALL_VEHICLES(v) {
  2318 			FOR_ALL_VEHICLES(v) {
  2319 				if (v->tile == tile && v->type == VEH_Train && v->u.rail.track == 0x80) {
  2319 				if (v->tile == tile && v->type == VEH_Train && v->u.rail.track == TRACK_BIT_DEPOT) {
  2320 					if (IsFrontEngine(v)) {
  2320 					if (IsFrontEngine(v)) {
  2321 						if (engine_list == NULL) continue;
  2321 						if (engine_list == NULL) continue;
  2322 						if (*engine_count == *engine_list_length) ExtendVehicleListSize((const Vehicle***)engine_list, engine_list_length, 25);
  2322 						if (*engine_count == *engine_list_length) ExtendVehicleListSize((const Vehicle***)engine_list, engine_list_length, 25);
  2323 						(*engine_list)[(*engine_count)++] = v;
  2323 						(*engine_list)[(*engine_count)++] = v;
  2324 					} else if (IsFreeWagon(v)) {
  2324 					} else if (IsFreeWagon(v)) {
  2522 			v->load_unload_time_rem = 0;
  2522 			v->load_unload_time_rem = 0;
  2523 			break;
  2523 			break;
  2524 
  2524 
  2525 		case VEH_Road:
  2525 		case VEH_Road:
  2526 			InvalidateWindowClasses(WC_ROADVEH_LIST);
  2526 			InvalidateWindowClasses(WC_ROADVEH_LIST);
  2527 			v->u.road.state = 254;
  2527 			v->u.road.state = RVSB_IN_DEPOT;
  2528 			break;
  2528 			break;
  2529 
  2529 
  2530 		case VEH_Ship:
  2530 		case VEH_Ship:
  2531 			InvalidateWindowClasses(WC_SHIPS_LIST);
  2531 			InvalidateWindowClasses(WC_SHIPS_LIST);
  2532 			v->u.ship.state = TRACK_BIT_SPECIAL;
  2532 			v->u.ship.state = TRACK_BIT_DEPOT;
  2533 			RecalcShipStuff(v);
  2533 			RecalcShipStuff(v);
  2534 			break;
  2534 			break;
  2535 
  2535 
  2536 		case VEH_Aircraft:
  2536 		case VEH_Aircraft:
  2537 			InvalidateWindowClasses(WC_AIRCRAFT_LIST);
  2537 			InvalidateWindowClasses(WC_AIRCRAFT_LIST);
  2735 {
  2735 {
  2736 	if (v->vehstatus & VS_CRASHED) return INVALID_TRACKDIR;
  2736 	if (v->vehstatus & VS_CRASHED) return INVALID_TRACKDIR;
  2737 
  2737 
  2738 	switch (v->type) {
  2738 	switch (v->type) {
  2739 		case VEH_Train:
  2739 		case VEH_Train:
  2740 			if (v->u.rail.track == 0x80) /* We'll assume the train is facing outwards */
  2740 			if (v->u.rail.track == TRACK_BIT_DEPOT) /* We'll assume the train is facing outwards */
  2741 				return DiagdirToDiagTrackdir(GetRailDepotDirection(v->tile)); /* Train in depot */
  2741 				return DiagdirToDiagTrackdir(GetRailDepotDirection(v->tile)); /* Train in depot */
  2742 
  2742 
  2743 			if (v->u.rail.track == 0x40) /* train in tunnel, so just use his direction and assume a diagonal track */
  2743 			if (v->u.rail.track == TRACK_BIT_WORMHOLE) /* train in tunnel, so just use his direction and assume a diagonal track */
  2744 				return DiagdirToDiagTrackdir(DirToDiagDir(v->direction));
  2744 				return DiagdirToDiagTrackdir(DirToDiagDir(v->direction));
  2745 
  2745 
  2746 			return TrackDirectionToTrackdir(FindFirstTrack(v->u.rail.track), v->direction);
  2746 			return TrackDirectionToTrackdir(FindFirstTrack(v->u.rail.track), v->direction);
  2747 
  2747 
  2748 		case VEH_Ship:
  2748 		case VEH_Ship:
  2758 
  2758 
  2759 			if (IsRoadStopTile(v->tile)) /* We'll assume the road vehicle is facing outwards */
  2759 			if (IsRoadStopTile(v->tile)) /* We'll assume the road vehicle is facing outwards */
  2760 				return DiagdirToDiagTrackdir(GetRoadStopDir(v->tile)); /* Road vehicle in a station */
  2760 				return DiagdirToDiagTrackdir(GetRoadStopDir(v->tile)); /* Road vehicle in a station */
  2761 
  2761 
  2762 			/* If vehicle's state is a valid track direction (vehicle is not turning around) return it */
  2762 			/* If vehicle's state is a valid track direction (vehicle is not turning around) return it */
  2763 			if ((v->u.road.state & 7) < 6) return (Trackdir)v->u.road.state;
  2763 			if (!IsReversingRoadTrackdir((Trackdir)v->u.road.state)) return (Trackdir)v->u.road.state;
  2764 
  2764 
  2765 			/* Vehicle is turning around, get the direction from vehicle's direction */
  2765 			/* Vehicle is turning around, get the direction from vehicle's direction */
  2766 			return DiagdirToDiagTrackdir(DirToDiagDir(v->direction));
  2766 			return DiagdirToDiagTrackdir(DirToDiagDir(v->direction));
  2767 
  2767 
  2768 		/* case VEH_Aircraft: case VEH_Special: case VEH_Disaster: */
  2768 		/* case VEH_Aircraft: case VEH_Special: case VEH_Disaster: */
  2769 		default: return INVALID_TRACKDIR;
  2769 		default: return INVALID_TRACKDIR;
  2770 	}
  2770 	}
  2771 }
  2771 }
  2772 /* Return value has bit 0x2 set, when the vehicle enters a station. Then,
  2772 
  2773  * result << 8 contains the id of the station entered. If the return value has
  2773 /**
  2774  * bit 0x8 set, the vehicle could not and did not enter the tile. Are there
  2774  * Returns some meta-data over the to be entered tile.
  2775  * other bits that can be set? */
  2775  * @see VehicleEnterTileStatus to see what the bits in the return value mean.
       
  2776  */
  2776 uint32 VehicleEnterTile(Vehicle *v, TileIndex tile, int x, int y)
  2777 uint32 VehicleEnterTile(Vehicle *v, TileIndex tile, int x, int y)
  2777 {
  2778 {
  2778 	return _tile_type_procs[GetTileType(tile)]->vehicle_enter_tile_proc(v, tile, x, y);
  2779 	return _tile_type_procs[GetTileType(tile)]->vehicle_enter_tile_proc(v, tile, x, y);
  2779 }
  2780 }
  2780 
  2781