forked from mirror/OpenTTD
Add #6887: Option to show zone inside local authority boundary of towns
Can be found at town information > local authority window Layout for button is same as Graph Keys Turn on/off for every town individually
This commit is contained in:
@@ -83,6 +83,7 @@
|
||||
#include "window_gui.h"
|
||||
#include "linkgraph/linkgraph_gui.h"
|
||||
#include "viewport_kdtree.h"
|
||||
#include "town_kdtree.h"
|
||||
#include "viewport_sprite_sorter.h"
|
||||
#include "bridge_map.h"
|
||||
#include "company_base.h"
|
||||
@@ -1038,12 +1039,49 @@ static void DrawTileHighlightType(const TileInfo *ti, TileHighlightType tht)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Highlights tiles insede local authority of selected towns.
|
||||
* @param *ti TileInfo Tile that is being drawn
|
||||
*/
|
||||
static void HighlightTownLocalAuthorityTiles(const TileInfo *ti)
|
||||
{
|
||||
/* Going through cases in order of computational time. */
|
||||
|
||||
if (_town_local_authority_kdtree.Count() == 0) return;
|
||||
|
||||
/* Tile belongs to town regardless of distance from town. */
|
||||
if (GetTileType(ti->tile) == MP_HOUSE) {
|
||||
if (!Town::GetByTile(ti->tile)->show_zone) return;
|
||||
|
||||
DrawTileSelectionRect(ti, PALETTE_CRASH);
|
||||
return;
|
||||
}
|
||||
|
||||
/* If the closest town in the highlighted list is far, we can stop searching. */
|
||||
TownID tid = _town_local_authority_kdtree.FindNearest(TileX(ti->tile), TileY(ti->tile));
|
||||
Town *closest_highlighted_town = Town::Get(tid);
|
||||
|
||||
if (DistanceManhattan(ti->tile, closest_highlighted_town->xy) >= _settings_game.economy.dist_local_authority) return;
|
||||
|
||||
/* Tile is inside of the local autrhority distance of a highlighted town,
|
||||
but it is possible that a non-highlighted town is even closer. */
|
||||
Town *closest_town = ClosestTownFromTile(ti->tile, _settings_game.economy.dist_local_authority);
|
||||
|
||||
if (closest_town->show_zone) {
|
||||
DrawTileSelectionRect(ti, PALETTE_CRASH);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified tile is selected and if so draws selection using correct selectionstyle.
|
||||
* @param *ti TileInfo Tile that is being drawn
|
||||
*/
|
||||
static void DrawTileSelection(const TileInfo *ti)
|
||||
{
|
||||
/* Highlight tiles insede local authority of selected towns. */
|
||||
HighlightTownLocalAuthorityTiles(ti);
|
||||
|
||||
/* Draw a red error square? */
|
||||
bool is_redsq = _thd.redsq == ti->tile;
|
||||
if (is_redsq) DrawTileSelectionRect(ti, PALETTE_TILE_RED_PULSATING);
|
||||
|
Reference in New Issue
Block a user