roadveh_cmd.c
changeset 3153 e83501906eae
parent 3144 33e42feae531
child 3157 3f35e2d9c8e3
equal deleted inserted replaced
3152:00aa2d4cf39e 3153:e83501906eae
   307 }
   307 }
   308 
   308 
   309 static const Depot* FindClosestRoadDepot(const Vehicle* v)
   309 static const Depot* FindClosestRoadDepot(const Vehicle* v)
   310 {
   310 {
   311 	TileIndex tile = v->tile;
   311 	TileIndex tile = v->tile;
   312 	int i;
       
   313 
   312 
   314 	if (v->u.road.state == 255) tile = GetVehicleOutOfTunnelTile(v);
   313 	if (v->u.road.state == 255) tile = GetVehicleOutOfTunnelTile(v);
   315 
   314 
   316 	if (_patches.new_pathfinding_all) {
   315 	if (_patches.new_pathfinding_all) {
   317 		NPFFoundTargetData ftd;
   316 		NPFFoundTargetData ftd;
   325 			return NULL; /* Target not found */
   324 			return NULL; /* Target not found */
   326 		}
   325 		}
   327 		/* We do not search in two directions here, why should we? We can't reverse right now can we? */
   326 		/* We do not search in two directions here, why should we? We can't reverse right now can we? */
   328 	} else {
   327 	} else {
   329 		RoadFindDepotData rfdd;
   328 		RoadFindDepotData rfdd;
       
   329 		DiagDirection i;
       
   330 
   330 		rfdd.owner = v->owner;
   331 		rfdd.owner = v->owner;
   331 		rfdd.best_length = (uint)-1;
   332 		rfdd.best_length = (uint)-1;
   332 
   333 
   333 		/* search in all directions */
   334 		/* search in all directions */
   334 		for (i = 0; i != 4; i++) {
   335 		for (i = 0; i != 4; i++) {
  1185 	HandleRoadVehLoading(v);
  1186 	HandleRoadVehLoading(v);
  1186 
  1187 
  1187 	if (v->current_order.type == OT_LOADING) return;
  1188 	if (v->current_order.type == OT_LOADING) return;
  1188 
  1189 
  1189 	if (v->u.road.state == 254) {
  1190 	if (v->u.road.state == 254) {
  1190 		int dir;
  1191 		DiagDirection dir;
  1191 		const RoadDriveEntry* rdp;
  1192 		const RoadDriveEntry* rdp;
  1192 		byte rd2;
  1193 		byte rd2;
  1193 
  1194 
  1194 		v->cur_speed = 0;
  1195 		v->cur_speed = 0;
  1195 
  1196 
  1196 		dir = GB(_m[v->tile].m5, 0, 2);
  1197 		dir = GB(_m[v->tile].m5, 0, 2);
  1197 		v->direction = dir * 2 + 1;
  1198 		v->direction = DiagDirToDir(dir);
  1198 
  1199 
  1199 		rd2 = _roadveh_data_2[dir];
  1200 		rd2 = _roadveh_data_2[dir];
  1200 		rdp = _road_drive_data[(_opt.road_side << 4) + rd2];
  1201 		rdp = _road_drive_data[(_opt.road_side << 4) + rd2];
  1201 
  1202 
  1202 		x = TileX(v->tile) * 16 + (rdp[6].x & 0xF);
  1203 		x = TileX(v->tile) * 16 + (rdp[6].x & 0xF);