Merge branch 'zoning' into jgrpp
Conflicts: src/station_gui.cpp src/zoning_cmd.cpp
This commit is contained in:
@@ -5542,6 +5542,7 @@ STR_ZONING_NO_ZONING :Nothing
|
|||||||
STR_ZONING_AUTHORITY :Authority
|
STR_ZONING_AUTHORITY :Authority
|
||||||
STR_ZONING_CAN_BUILD :Where I can't build
|
STR_ZONING_CAN_BUILD :Where I can't build
|
||||||
STR_ZONING_STA_CATCH :Station catchment
|
STR_ZONING_STA_CATCH :Station catchment
|
||||||
|
STR_ZONING_STA_CATCH_OPEN :Station catchment (window open)
|
||||||
STR_ZONING_BUL_UNSER :Unserved buildings
|
STR_ZONING_BUL_UNSER :Unserved buildings
|
||||||
STR_ZONING_IND_UNSER :Unserved industries
|
STR_ZONING_IND_UNSER :Unserved industries
|
||||||
STR_ZONING_TRACERESTRICT :Restricted signals
|
STR_ZONING_TRACERESTRICT :Restricted signals
|
||||||
|
@@ -34,6 +34,7 @@
|
|||||||
#include "linkgraph/linkgraph.h"
|
#include "linkgraph/linkgraph.h"
|
||||||
#include "zoom_func.h"
|
#include "zoom_func.h"
|
||||||
#include "departures_gui.h"
|
#include "departures_gui.h"
|
||||||
|
#include "zoning.h"
|
||||||
|
|
||||||
#include "widgets/station_widget.h"
|
#include "widgets/station_widget.h"
|
||||||
|
|
||||||
@@ -1310,10 +1311,12 @@ struct StationViewWindow : public Window {
|
|||||||
this->sort_orders[0] = SO_ASCENDING;
|
this->sort_orders[0] = SO_ASCENDING;
|
||||||
this->SelectSortOrder((SortOrder)_settings_client.gui.station_gui_sort_order);
|
this->SelectSortOrder((SortOrder)_settings_client.gui.station_gui_sort_order);
|
||||||
this->owner = Station::Get(window_number)->owner;
|
this->owner = Station::Get(window_number)->owner;
|
||||||
|
ZoningStationWindowOpenClose(Station::Get(window_number));
|
||||||
}
|
}
|
||||||
|
|
||||||
~StationViewWindow()
|
~StationViewWindow()
|
||||||
{
|
{
|
||||||
|
ZoningStationWindowOpenClose(Station::Get(window_number));
|
||||||
DeleteWindowById(WC_TRAINS_LIST, VehicleListIdentifier(VL_STATION_LIST, VEH_TRAIN, this->owner, this->window_number).Pack(), false);
|
DeleteWindowById(WC_TRAINS_LIST, VehicleListIdentifier(VL_STATION_LIST, VEH_TRAIN, this->owner, this->window_number).Pack(), false);
|
||||||
DeleteWindowById(WC_ROADVEH_LIST, VehicleListIdentifier(VL_STATION_LIST, VEH_ROAD, this->owner, this->window_number).Pack(), false);
|
DeleteWindowById(WC_ROADVEH_LIST, VehicleListIdentifier(VL_STATION_LIST, VEH_ROAD, this->owner, this->window_number).Pack(), false);
|
||||||
DeleteWindowById(WC_SHIPS_LIST, VehicleListIdentifier(VL_STATION_LIST, VEH_SHIP, this->owner, this->window_number).Pack(), false);
|
DeleteWindowById(WC_SHIPS_LIST, VehicleListIdentifier(VL_STATION_LIST, VEH_SHIP, this->owner, this->window_number).Pack(), false);
|
||||||
|
@@ -23,6 +23,7 @@ enum ZoningEvaluationMode {
|
|||||||
ZEM_AUTHORITY, ///< Check the local authority's opinion.
|
ZEM_AUTHORITY, ///< Check the local authority's opinion.
|
||||||
ZEM_CAN_BUILD, ///< Check wither or not the player can build.
|
ZEM_CAN_BUILD, ///< Check wither or not the player can build.
|
||||||
ZEM_STA_CATCH, ///< Check catchment area for stations
|
ZEM_STA_CATCH, ///< Check catchment area for stations
|
||||||
|
ZEM_STA_CATCH_WIN, ///< Check catchment area for stations with their station windows open
|
||||||
ZEM_BUL_UNSER, ///< Check for unserved buildings
|
ZEM_BUL_UNSER, ///< Check for unserved buildings
|
||||||
ZEM_IND_UNSER, ///< Check for unserved industries
|
ZEM_IND_UNSER, ///< Check for unserved industries
|
||||||
ZEM_TRACERESTRICT, ///< Check for restricted signals
|
ZEM_TRACERESTRICT, ///< Check for restricted signals
|
||||||
@@ -49,4 +50,9 @@ void ShowZoningToolbar();
|
|||||||
void ZoningMarkDirtyStationCoverageArea(const Station *st);
|
void ZoningMarkDirtyStationCoverageArea(const Station *st);
|
||||||
inline void ZoningMarkDirtyStationCoverageArea(const Waypoint *st) { } // no-op
|
inline void ZoningMarkDirtyStationCoverageArea(const Waypoint *st) { } // no-op
|
||||||
|
|
||||||
|
inline void ZoningStationWindowOpenClose(const Station *st)
|
||||||
|
{
|
||||||
|
if (_zoning.inner == ZEM_STA_CATCH_WIN || _zoning.outer == ZEM_STA_CATCH_WIN) ZoningMarkDirtyStationCoverageArea(st);
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* ZONING_H */
|
#endif /* ZONING_H */
|
||||||
|
@@ -24,6 +24,7 @@
|
|||||||
#include "station_map.h"
|
#include "station_map.h"
|
||||||
#include "town.h"
|
#include "town.h"
|
||||||
#include "tracerestrict.h"
|
#include "tracerestrict.h"
|
||||||
|
#include "window_func.h"
|
||||||
#include "zoning.h"
|
#include "zoning.h"
|
||||||
|
|
||||||
Zoning _zoning;
|
Zoning _zoning;
|
||||||
@@ -83,9 +84,11 @@ bool IsAreaWithinAcceptanceZoneOfStation(TileArea area, Owner owner, StationFaci
|
|||||||
* the owner of the stations
|
* the owner of the stations
|
||||||
* @param StationFacility facility_mask
|
* @param StationFacility facility_mask
|
||||||
* one or more facilities in the mask must be present for a station to be used
|
* one or more facilities in the mask must be present for a station to be used
|
||||||
|
* @param open_window_only
|
||||||
|
* only use stations which have their station window open
|
||||||
* @return true if a station is found
|
* @return true if a station is found
|
||||||
*/
|
*/
|
||||||
bool IsTileWithinAcceptanceZoneOfStation(TileIndex tile, Owner owner, StationFacility facility_mask)
|
bool IsTileWithinAcceptanceZoneOfStation(TileIndex tile, Owner owner, StationFacility facility_mask, bool open_window_only)
|
||||||
{
|
{
|
||||||
int catchment = _settings_game.station.station_spread + (_settings_game.station.modified_catchment ? MAX_CATCHMENT : CA_UNMODIFIED);
|
int catchment = _settings_game.station.station_spread + (_settings_game.station.modified_catchment ? MAX_CATCHMENT : CA_UNMODIFIED);
|
||||||
|
|
||||||
@@ -98,7 +101,9 @@ bool IsTileWithinAcceptanceZoneOfStation(TileIndex tile, Owner owner, StationFac
|
|||||||
Rect rect = st->GetCatchmentRect();
|
Rect rect = st->GetCatchmentRect();
|
||||||
if ((uint)rect.left <= TileX(tile) && TileX(tile) <= (uint)rect.right
|
if ((uint)rect.left <= TileX(tile) && TileX(tile) <= (uint)rect.right
|
||||||
&& (uint)rect.top <= TileY(tile) && TileY(tile) <= (uint)rect.bottom) {
|
&& (uint)rect.top <= TileY(tile) && TileY(tile) <= (uint)rect.bottom) {
|
||||||
return true;
|
if (!open_window_only || FindWindowById(WC_STATION_VIEW, st->index) != NULL) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,10 +188,12 @@ SpriteID TileZoneCheckOpinionEvaluation(TileIndex tile, Owner owner)
|
|||||||
*
|
*
|
||||||
* @param TileIndex tile
|
* @param TileIndex tile
|
||||||
* @param Owner owner
|
* @param Owner owner
|
||||||
|
* @param open_window_only
|
||||||
|
* only use stations which have their station window open
|
||||||
* @return black if within, light blue if only in acceptance zone
|
* @return black if within, light blue if only in acceptance zone
|
||||||
* and nothing if no nearby station.
|
* and nothing if no nearby station.
|
||||||
*/
|
*/
|
||||||
SpriteID TileZoneCheckStationCatchmentEvaluation(TileIndex tile, Owner owner)
|
SpriteID TileZoneCheckStationCatchmentEvaluation(TileIndex tile, Owner owner, bool open_window_only)
|
||||||
{
|
{
|
||||||
// Never on a station.
|
// Never on a station.
|
||||||
if (IsTileType(tile, MP_STATION)) {
|
if (IsTileType(tile, MP_STATION)) {
|
||||||
@@ -199,12 +206,14 @@ SpriteID TileZoneCheckStationCatchmentEvaluation(TileIndex tile, Owner owner)
|
|||||||
for (Station * const *st_iter = stations.GetStations()->Begin(); st_iter != stations.GetStations()->End(); ++st_iter) {
|
for (Station * const *st_iter = stations.GetStations()->Begin(); st_iter != stations.GetStations()->End(); ++st_iter) {
|
||||||
const Station *st = *st_iter;
|
const Station *st = *st_iter;
|
||||||
if (st->owner == owner) {
|
if (st->owner == owner) {
|
||||||
return SPR_ZONING_INNER_HIGHLIGHT_BLACK;
|
if (!open_window_only || FindWindowById(WC_STATION_VIEW, st->index) != NULL) {
|
||||||
|
return SPR_ZONING_INNER_HIGHLIGHT_BLACK;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// For accepted goods
|
// For accepted goods
|
||||||
if (IsTileWithinAcceptanceZoneOfStation(tile, owner, ~FACIL_NONE)) {
|
if (IsTileWithinAcceptanceZoneOfStation(tile, owner, ~FACIL_NONE, open_window_only)) {
|
||||||
return SPR_ZONING_INNER_HIGHLIGHT_LIGHT_BLUE;
|
return SPR_ZONING_INNER_HIGHLIGHT_LIGHT_BLUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -248,7 +257,7 @@ SpriteID TileZoneCheckUnservedBuildingsEvaluation(TileIndex tile, Owner owner)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// For accepted goods
|
// For accepted goods
|
||||||
if (IsTileWithinAcceptanceZoneOfStation(tile, owner, ~FACIL_NONE)) {
|
if (IsTileWithinAcceptanceZoneOfStation(tile, owner, ~FACIL_NONE, false)) {
|
||||||
return SPR_ZONING_INNER_HIGHLIGHT_ORANGE;
|
return SPR_ZONING_INNER_HIGHLIGHT_ORANGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -318,13 +327,14 @@ SpriteID TileZoneCheckTraceRestrictEvaluation(TileIndex tile, Owner owner)
|
|||||||
SpriteID TileZoningSpriteEvaluation(TileIndex tile, Owner owner, ZoningEvaluationMode ev_mode)
|
SpriteID TileZoningSpriteEvaluation(TileIndex tile, Owner owner, ZoningEvaluationMode ev_mode)
|
||||||
{
|
{
|
||||||
switch (ev_mode) {
|
switch (ev_mode) {
|
||||||
case ZEM_CAN_BUILD: return TileZoneCheckBuildEvaluation(tile, owner);
|
case ZEM_CAN_BUILD: return TileZoneCheckBuildEvaluation(tile, owner);
|
||||||
case ZEM_AUTHORITY: return TileZoneCheckOpinionEvaluation(tile, owner);
|
case ZEM_AUTHORITY: return TileZoneCheckOpinionEvaluation(tile, owner);
|
||||||
case ZEM_STA_CATCH: return TileZoneCheckStationCatchmentEvaluation(tile, owner);
|
case ZEM_STA_CATCH: return TileZoneCheckStationCatchmentEvaluation(tile, owner, false);
|
||||||
case ZEM_BUL_UNSER: return TileZoneCheckUnservedBuildingsEvaluation(tile, owner);
|
case ZEM_STA_CATCH_WIN: return TileZoneCheckStationCatchmentEvaluation(tile, owner, true);
|
||||||
case ZEM_IND_UNSER: return TileZoneCheckUnservedIndustriesEvaluation(tile, owner);
|
case ZEM_BUL_UNSER: return TileZoneCheckUnservedBuildingsEvaluation(tile, owner);
|
||||||
case ZEM_TRACERESTRICT: return TileZoneCheckTraceRestrictEvaluation(tile, owner);
|
case ZEM_IND_UNSER: return TileZoneCheckUnservedIndustriesEvaluation(tile, owner);
|
||||||
default: return ZONING_INVALID_SPRITE_ID;
|
case ZEM_TRACERESTRICT: return TileZoneCheckTraceRestrictEvaluation(tile, owner);
|
||||||
|
default: return ZONING_INVALID_SPRITE_ID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -353,6 +363,7 @@ static uint GetZoningModeDependantStationCoverageRadius(const Station *st, Zonin
|
|||||||
{
|
{
|
||||||
switch (ev_mode) {
|
switch (ev_mode) {
|
||||||
case ZEM_STA_CATCH: return st->GetCatchmentRadius();
|
case ZEM_STA_CATCH: return st->GetCatchmentRadius();
|
||||||
|
case ZEM_STA_CATCH_WIN: return st->GetCatchmentRadius();
|
||||||
case ZEM_BUL_UNSER: return st->GetCatchmentRadius();
|
case ZEM_BUL_UNSER: return st->GetCatchmentRadius();
|
||||||
case ZEM_IND_UNSER: return st->GetCatchmentRadius() + 10; // this is to wholly update industries partially within the region
|
case ZEM_IND_UNSER: return st->GetCatchmentRadius() + 10; // this is to wholly update industries partially within the region
|
||||||
default: return 0;
|
default: return 0;
|
||||||
|
@@ -38,6 +38,7 @@ static const StringID _zone_type_strings[] = {
|
|||||||
STR_ZONING_AUTHORITY,
|
STR_ZONING_AUTHORITY,
|
||||||
STR_ZONING_CAN_BUILD,
|
STR_ZONING_CAN_BUILD,
|
||||||
STR_ZONING_STA_CATCH,
|
STR_ZONING_STA_CATCH,
|
||||||
|
STR_ZONING_STA_CATCH_OPEN,
|
||||||
STR_ZONING_BUL_UNSER,
|
STR_ZONING_BUL_UNSER,
|
||||||
STR_ZONING_IND_UNSER,
|
STR_ZONING_IND_UNSER,
|
||||||
STR_ZONING_TRACERESTRICT,
|
STR_ZONING_TRACERESTRICT,
|
||||||
@@ -49,6 +50,7 @@ static const ZoningEvaluationMode _zone_type_modes[] = {
|
|||||||
ZEM_AUTHORITY,
|
ZEM_AUTHORITY,
|
||||||
ZEM_CAN_BUILD,
|
ZEM_CAN_BUILD,
|
||||||
ZEM_STA_CATCH,
|
ZEM_STA_CATCH,
|
||||||
|
ZEM_STA_CATCH_WIN,
|
||||||
ZEM_BUL_UNSER,
|
ZEM_BUL_UNSER,
|
||||||
ZEM_IND_UNSER,
|
ZEM_IND_UNSER,
|
||||||
ZEM_TRACERESTRICT,
|
ZEM_TRACERESTRICT,
|
||||||
|
Reference in New Issue
Block a user