mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-08-29 09:29:10 +00:00
Compare commits
1 Commits
fix-endgam
...
change-ope
Author | SHA1 | Date | |
---|---|---|---|
|
a5c3f38b58 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -49,9 +49,6 @@ struct EndGameHighScoreBaseWindow : Window {
|
||||
|
||||
this->DrawWidgets();
|
||||
|
||||
/* Fill with the appropriate background colour instead of leaving default window colour */
|
||||
GfxFillRect(Rect{0, 0, this->width, this->height}, PixelColour{105}, FILLRECT_OPAQUE);
|
||||
|
||||
/* Standard background slices are 50 pixels high, but it's designed
|
||||
* for 480 pixels total. 96% of 500 is 480. */
|
||||
Dimension dim = GetSpriteSize(this->background_img);
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** @file yapf_common.hpp Commonly used classes and utilities for YAPF. */
|
||||
/** @file yapf_common.hpp Commonly used classes for YAPF. */
|
||||
|
||||
#ifndef YAPF_COMMON_HPP
|
||||
#define YAPF_COMMON_HPP
|
||||
@@ -119,30 +119,6 @@ class CYapfT
|
||||
{
|
||||
};
|
||||
|
||||
/**
|
||||
* Calculates the octile distance cost between a starting tile / trackdir and a destination tile.
|
||||
* @param start_tile Starting tile.
|
||||
* @param start_td Starting trackdir.
|
||||
* @param destination_tile Destination tile.
|
||||
* @return Octile distance cost between starting tile / trackdir and destination tile.
|
||||
*/
|
||||
inline int OctileDistanceCost(TileIndex start_tile, Trackdir start_td, TileIndex destination_tile)
|
||||
{
|
||||
static constexpr int dg_dir_to_x_offs[] = {-1, 0, 1, 0};
|
||||
static constexpr int dg_dir_to_y_offs[] = {0, 1, 0, -1};
|
||||
|
||||
const DiagDirection exitdir = TrackdirToExitdir(start_td);
|
||||
|
||||
const int x1 = 2 * TileX(start_tile) + dg_dir_to_x_offs[static_cast<int>(exitdir)];
|
||||
const int y1 = 2 * TileY(start_tile) + dg_dir_to_y_offs[static_cast<int>(exitdir)];
|
||||
const int x2 = 2 * TileX(destination_tile);
|
||||
const int y2 = 2 * TileY(destination_tile);
|
||||
const int dx = abs(x1 - x2);
|
||||
const int dy = abs(y1 - y2);
|
||||
const int dmin = std::min(dx, dy);
|
||||
const int dxy = abs(dx - dy);
|
||||
|
||||
return dmin * YAPF_TILE_CORNER_LENGTH + (dxy - 1) * (YAPF_TILE_LENGTH / 2);
|
||||
}
|
||||
|
||||
#endif /* YAPF_COMMON_HPP */
|
||||
|
@@ -194,12 +194,25 @@ public:
|
||||
*/
|
||||
inline bool PfCalcEstimate(Node &n)
|
||||
{
|
||||
static const int dg_dir_to_x_offs[] = {-1, 0, 1, 0};
|
||||
static const int dg_dir_to_y_offs[] = {0, 1, 0, -1};
|
||||
if (this->PfDetectDestination(n)) {
|
||||
n.estimate = n.cost;
|
||||
return true;
|
||||
}
|
||||
|
||||
n.estimate = n.cost + OctileDistanceCost(n.GetLastTile(), n.GetLastTrackdir(), this->dest_tile);
|
||||
TileIndex tile = n.GetLastTile();
|
||||
DiagDirection exitdir = TrackdirToExitdir(n.GetLastTrackdir());
|
||||
int x1 = 2 * TileX(tile) + dg_dir_to_x_offs[(int)exitdir];
|
||||
int y1 = 2 * TileY(tile) + dg_dir_to_y_offs[(int)exitdir];
|
||||
int x2 = 2 * TileX(this->dest_tile);
|
||||
int y2 = 2 * TileY(this->dest_tile);
|
||||
int dx = abs(x1 - x2);
|
||||
int dy = abs(y1 - y2);
|
||||
int dmin = std::min(dx, dy);
|
||||
int dxy = abs(dx - dy);
|
||||
int d = dmin * YAPF_TILE_CORNER_LENGTH + (dxy - 1) * (YAPF_TILE_LENGTH / 2);
|
||||
n.estimate = n.cost + d;
|
||||
assert(n.estimate >= n.parent->estimate);
|
||||
return true;
|
||||
}
|
||||
|
@@ -293,12 +293,25 @@ public:
|
||||
*/
|
||||
inline bool PfCalcEstimate(Node &n)
|
||||
{
|
||||
static const int dg_dir_to_x_offs[] = {-1, 0, 1, 0};
|
||||
static const int dg_dir_to_y_offs[] = {0, 1, 0, -1};
|
||||
if (this->PfDetectDestination(n)) {
|
||||
n.estimate = n.cost;
|
||||
return true;
|
||||
}
|
||||
|
||||
n.estimate = n.cost + OctileDistanceCost(n.segment_last_tile, n.segment_last_td, this->dest_tile);
|
||||
TileIndex tile = n.segment_last_tile;
|
||||
DiagDirection exitdir = TrackdirToExitdir(n.segment_last_td);
|
||||
int x1 = 2 * TileX(tile) + dg_dir_to_x_offs[(int)exitdir];
|
||||
int y1 = 2 * TileY(tile) + dg_dir_to_y_offs[(int)exitdir];
|
||||
int x2 = 2 * TileX(this->dest_tile);
|
||||
int y2 = 2 * TileY(this->dest_tile);
|
||||
int dx = abs(x1 - x2);
|
||||
int dy = abs(y1 - y2);
|
||||
int dmin = std::min(dx, dy);
|
||||
int dxy = abs(dx - dy);
|
||||
int d = dmin * YAPF_TILE_CORNER_LENGTH + (dxy - 1) * (YAPF_TILE_LENGTH / 2);
|
||||
n.estimate = n.cost + d;
|
||||
assert(n.estimate >= n.parent->estimate);
|
||||
return true;
|
||||
}
|
||||
|
@@ -96,12 +96,25 @@ public:
|
||||
{
|
||||
const TileIndex destination_tile = this->has_intermediate_dest ? this->intermediate_dest_tile : this->dest_tile;
|
||||
|
||||
static const int dg_dir_to_x_offs[] = { -1, 0, 1, 0 };
|
||||
static const int dg_dir_to_y_offs[] = { 0, 1, 0, -1 };
|
||||
if (this->PfDetectDestination(n)) {
|
||||
n.estimate = n.cost;
|
||||
return true;
|
||||
}
|
||||
|
||||
n.estimate = n.cost + OctileDistanceCost(n.segment_last_tile, n.segment_last_td, destination_tile);
|
||||
TileIndex tile = n.segment_last_tile;
|
||||
DiagDirection exitdir = TrackdirToExitdir(n.segment_last_td);
|
||||
int x1 = 2 * TileX(tile) + dg_dir_to_x_offs[(int)exitdir];
|
||||
int y1 = 2 * TileY(tile) + dg_dir_to_y_offs[(int)exitdir];
|
||||
int x2 = 2 * TileX(destination_tile);
|
||||
int y2 = 2 * TileY(destination_tile);
|
||||
int dx = abs(x1 - x2);
|
||||
int dy = abs(y1 - y2);
|
||||
int dmin = std::min(dx, dy);
|
||||
int dxy = abs(dx - dy);
|
||||
int d = dmin * YAPF_TILE_CORNER_LENGTH + (dxy - 1) * (YAPF_TILE_LENGTH / 2);
|
||||
n.estimate = n.cost + d;
|
||||
assert(n.estimate >= n.parent->estimate);
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user