Merge branch 'master' into jgrpp-nrt

# Conflicts:
#	src/console_cmds.cpp
#	src/script/api/script_order.cpp
#	src/station_cmd.cpp
#	src/statusbar_gui.cpp
#	src/town_gui.cpp
This commit is contained in:
Jonathan G Rennison
2019-08-24 11:00:41 +01:00
33 changed files with 525 additions and 140 deletions

View File

@@ -95,6 +95,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"
@@ -1166,12 +1167,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);