src/ship_cmd.cpp
branchgamebalance
changeset 9912 1ac8aac92385
parent 9911 0b8b245a2391
child 9913 e79cd19772dd
equal deleted inserted replaced
9911:0b8b245a2391 9912:1ac8aac92385
    41 	TRACK_BIT_Y | TRACK_BIT_LOWER | TRACK_BIT_RIGHT, // 0x2A, // DIAGDIR_NW
    41 	TRACK_BIT_Y | TRACK_BIT_LOWER | TRACK_BIT_RIGHT, // 0x2A, // DIAGDIR_NW
    42 };
    42 };
    43 
    43 
    44 static TrackBits GetTileShipTrackStatus(TileIndex tile)
    44 static TrackBits GetTileShipTrackStatus(TileIndex tile)
    45 {
    45 {
    46 	uint32 r = GetTileTrackStatus(tile, TRANSPORT_WATER);
    46 	uint32 r = GetTileTrackStatus(tile, TRANSPORT_WATER, 0);
    47 	return TrackdirBitsToTrackBits((TrackdirBits)(TRACKDIR_BIT_MASK & (r | r >> 8)));
    47 	return TrackdirBitsToTrackBits((TrackdirBits)(TRACKDIR_BIT_MASK & (r | r >> 8)));
    48 }
    48 }
    49 
    49 
    50 void DrawShipEngine(int x, int y, EngineID engine, SpriteID pal)
    50 void DrawShipEngine(int x, int y, EngineID engine, SpriteID pal)
    51 {
    51 {
   112 	TileIndex tile2 = v->tile;
   112 	TileIndex tile2 = v->tile;
   113 
   113 
   114 	if (_patches.new_pathfinding_all) {
   114 	if (_patches.new_pathfinding_all) {
   115 		NPFFoundTargetData ftd;
   115 		NPFFoundTargetData ftd;
   116 		Trackdir trackdir = GetVehicleTrackdir(v);
   116 		Trackdir trackdir = GetVehicleTrackdir(v);
   117 		ftd = NPFRouteToDepotTrialError(v->tile, trackdir, TRANSPORT_WATER, v->owner, INVALID_RAILTYPE);
   117 		ftd = NPFRouteToDepotTrialError(v->tile, trackdir, TRANSPORT_WATER, 0, v->owner, INVALID_RAILTYPE);
   118 		if (ftd.best_bird_dist == 0) {
   118 		if (ftd.best_bird_dist == 0) {
   119 			best_depot = GetDepotByTile(ftd.node.tile); /* Found target */
   119 			best_depot = GetDepotByTile(ftd.node.tile); /* Found target */
   120 		} else {
   120 		} else {
   121 			best_depot = NULL; /* Did not find target */
   121 			best_depot = NULL; /* Did not find target */
   122 		}
   122 		}
   477 		i = RemoveFirstTrack(&bits);
   477 		i = RemoveFirstTrack(&bits);
   478 
   478 
   479 		pfs.best_bird_dist = (uint)-1;
   479 		pfs.best_bird_dist = (uint)-1;
   480 		pfs.best_length = (uint)-1;
   480 		pfs.best_length = (uint)-1;
   481 
   481 
   482 		FollowTrack(tile, 0x3800 | TRANSPORT_WATER, (DiagDirection)_ship_search_directions[i][dir], (TPFEnumProc*)ShipTrackFollower, NULL, &pfs);
   482 		FollowTrack(tile, 0x3800 | TRANSPORT_WATER, 0, (DiagDirection)_ship_search_directions[i][dir], (TPFEnumProc*)ShipTrackFollower, NULL, &pfs);
   483 
   483 
   484 		if (best_track != INVALID_TRACK) {
   484 		if (best_track != INVALID_TRACK) {
   485 			if (pfs.best_bird_dist != 0) {
   485 			if (pfs.best_bird_dist != 0) {
   486 				/* neither reached the destination, pick the one with the smallest bird dist */
   486 				/* neither reached the destination, pick the one with the smallest bird dist */
   487 				if (pfs.best_bird_dist > best_bird_dist) goto bad;
   487 				if (pfs.best_bird_dist > best_bird_dist) goto bad;
   512 
   512 
   513 static inline NPFFoundTargetData PerfNPFRouteToStationOrTile(TileIndex tile, Trackdir trackdir, NPFFindStationOrTileData* target, TransportType type, Owner owner, RailTypeMask railtypes)
   513 static inline NPFFoundTargetData PerfNPFRouteToStationOrTile(TileIndex tile, Trackdir trackdir, NPFFindStationOrTileData* target, TransportType type, Owner owner, RailTypeMask railtypes)
   514 {
   514 {
   515 
   515 
   516 	void* perf = NpfBeginInterval();
   516 	void* perf = NpfBeginInterval();
   517 	NPFFoundTargetData ret = NPFRouteToStationOrTile(tile, trackdir, target, type, owner, railtypes);
   517 	NPFFoundTargetData ret = NPFRouteToStationOrTile(tile, trackdir, target, type, 0, owner, railtypes);
   518 	int t = NpfEndInterval(perf);
   518 	int t = NpfEndInterval(perf);
   519 	DEBUG(yapf, 4, "[NPFW] %d us - %d rounds - %d open - %d closed -- ", t, 0, _aystar_stats_open_size, _aystar_stats_closed_size);
   519 	DEBUG(yapf, 4, "[NPFW] %d us - %d rounds - %d open - %d closed -- ", t, 0, _aystar_stats_open_size, _aystar_stats_closed_size);
   520 	return ret;
   520 	return ret;
   521 }
   521 }
   522 
   522 
   595 	return _new_vehicle_direction_table[offs];
   595 	return _new_vehicle_direction_table[offs];
   596 }
   596 }
   597 
   597 
   598 static TrackBits GetAvailShipTracks(TileIndex tile, int dir)
   598 static TrackBits GetAvailShipTracks(TileIndex tile, int dir)
   599 {
   599 {
   600 	uint32 r = GetTileTrackStatus(tile, TRANSPORT_WATER);
   600 	uint32 r = GetTileTrackStatus(tile, TRANSPORT_WATER, 0);
   601 	return (TrackBits)((r | r >> 8) & _ship_sometracks[dir]);
   601 	return (TrackBits)((r | r >> 8) & _ship_sometracks[dir]);
   602 }
   602 }
   603 
   603 
   604 static const byte _ship_subcoord[4][6][3] = {
   604 static const byte _ship_subcoord[4][6][3] = {
   605 	{
   605 	{