Show output of all producing industries on the minimap

This commit is contained in:
dP
2023-04-02 17:03:20 +04:00
parent f283b7cf6f
commit a21cafd2a1
9 changed files with 45 additions and 22 deletions
+1
View File
@@ -910,6 +910,7 @@ int DrawVehiclePurchaseInfo(int left, int right, int y, EngineID engine_number,
if (_settings_client.gui.newgrf_developer_tools) {
SetDParam(0, e->index);
SetDParam(1, e->grf_prop.local_id);
DrawString(left, right, y, CM_STR_PURCHASE_ENGINE_ID);
y += FONT_HEIGHT_NORMAL;
}
+2 -2
View File
@@ -215,14 +215,14 @@ std::multimap<TileIndex, ObjectTileHighlight> Blueprint::GetTiles(TileIndex tile
std::set<StationID> can_build_station_sign;
for (auto &item: this->items) {
if (item.type != Item::Type::RAIL_STATION) continue;
if (GetBlueprintCommand(tile, item)->test())
if (GetBlueprintCommand(tile, item)->test().Succeeded())
can_build_station_sign.insert(item.u.rail.station.id);
}
for (auto &o: this->items) {
auto otile = AddTileIndexDiffCWrap(tile, o.tdiff);
auto palette = CM_PALETTE_TINT_WHITE;
if (o.type != Item::Type::RAIL_SIGNAL && !GetBlueprintCommand(tile, o)->test())
if (o.type != Item::Type::RAIL_SIGNAL && !GetBlueprintCommand(tile, o)->test().Succeeded())
palette = CM_PALETTE_TINT_RED_DEEP;
switch(o.type) {
+2 -2
View File
@@ -70,8 +70,8 @@ public:
return res;
}
bool test() {
return this->call(DC_NONE).Succeeded();
CommandCost test() {
return this->call(DC_NONE);
}
Command &with_tile(TileIndex tile) {
+1
View File
@@ -11,6 +11,7 @@ class Game {
protected:
TownsGrowthTilesIndex towns_growth_tiles_last_month;
TownsGrowthTilesIndex towns_growth_tiles;
uint64 start_countdown = 0;
public:
event::Dispatcher events;
+28 -14
View File
@@ -336,6 +336,7 @@ void ObjectHighlight::AddTile(TileIndex tile, ObjectTileHighlight &&oh) {
void ObjectHighlight::UpdateTiles() {
this->tiles.clear();
this->sprites.clear();
this->cost = CMD_ERROR;
switch (this->type) {
case Type::NONE:
break;
@@ -343,11 +344,12 @@ void ObjectHighlight::UpdateTiles() {
case Type::RAIL_DEPOT: {
auto dir = this->ddir;
auto palette = (cmd::BuildTrainDepot(
this->cost = cmd::BuildTrainDepot(
this->tile,
_cur_railtype,
dir
).test() ? CM_PALETTE_TINT_WHITE : CM_PALETTE_TINT_RED_DEEP);
).test();
auto palette = (cost.Succeeded() ? CM_PALETTE_TINT_WHITE : CM_PALETTE_TINT_RED_DEEP);
this->tiles.insert(std::make_pair(this->tile, ObjectTileHighlight::make_rail_depot(palette, dir)));
auto tile = this->tile + TileOffsByDiagDir(dir);
@@ -364,7 +366,7 @@ void ObjectHighlight::UpdateTiles() {
auto plat_len = ta.h;
if (this->axis == AXIS_X) Swap(numtracks, plat_len);
auto palette = (cmd::BuildRailStation(
this->cost = cmd::BuildRailStation(
this->tile,
_cur_railtype,
this->axis,
@@ -374,7 +376,8 @@ void ObjectHighlight::UpdateTiles() {
_railstation.station_type,
NEW_STATION,
true
).test() ? CM_PALETTE_TINT_WHITE : CM_PALETTE_TINT_RED_DEEP);
).test();
auto palette = (this->cost.Succeeded() ? CM_PALETTE_TINT_WHITE : CM_PALETTE_TINT_RED_DEEP);
auto layout_ptr = AllocaM(byte, (int)numtracks * plat_len);
GetStationLayout(layout_ptr, numtracks, plat_len, nullptr); // TODO statspec
@@ -396,7 +399,7 @@ void ObjectHighlight::UpdateTiles() {
}
case Type::ROAD_STOP: {
auto ta = OrthogonalTileArea(this->tile, this->end_tile);
auto palette = (cmd::BuildRoadStop(
this->cost = cmd::BuildRoadStop(
this->tile,
ta.w,
ta.h,
@@ -406,7 +409,8 @@ void ObjectHighlight::UpdateTiles() {
this->roadtype,
NEW_STATION,
true
).test() ? CM_PALETTE_TINT_WHITE : CM_PALETTE_TINT_RED_DEEP);
).test();
auto palette = (this->cost.Succeeded() ? CM_PALETTE_TINT_WHITE : CM_PALETTE_TINT_RED_DEEP);
for (TileIndex tile : ta) {
this->AddTile(tile, ObjectTileHighlight::make_road_stop(palette, this->roadtype, this->ddir, this->is_truck));
}
@@ -414,23 +418,25 @@ void ObjectHighlight::UpdateTiles() {
}
case Type::ROAD_DEPOT: {
auto palette = (cmd::BuildRoadDepot(
this->cost = cmd::BuildRoadDepot(
this->tile,
this->roadtype,
this->ddir
).test() ? CM_PALETTE_TINT_WHITE : CM_PALETTE_TINT_RED_DEEP);
).test();
auto palette = (this->cost.Succeeded() ? CM_PALETTE_TINT_WHITE : CM_PALETTE_TINT_RED_DEEP);
this->AddTile(this->tile, ObjectTileHighlight::make_road_depot(palette, this->roadtype, this->ddir));
break;
}
case Type::AIRPORT: {
auto palette = (cmd::BuildAirport(
this->cost = cmd::BuildAirport(
this->tile,
this->airport_type,
this->airport_layout,
NEW_STATION,
true
).test() ? CM_PALETTE_TINT_WHITE : CM_PALETTE_TINT_RED_DEEP);
).test();
auto palette = (this->cost.Succeeded() ? CM_PALETTE_TINT_WHITE : CM_PALETTE_TINT_RED_DEEP);
const AirportSpec *as = AirportSpec::Get(this->airport_type);
if (!as->IsAvailable() || this->airport_layout >= as->num_table) break;
@@ -523,8 +529,8 @@ void ObjectHighlight::UpdateTiles() {
break;
}
case Type::INDUSTRY: {
auto cost = cmd::BuildIndustry{this->tile, this->ind_type, this->ind_layout, true, 0}.call(DC_NONE);
if (cost.Succeeded()) {
this->cost = cmd::BuildIndustry{this->tile, this->ind_type, this->ind_layout, true, 0}.call(DC_NONE);
if (this->cost.Succeeded()) {
const IndustrySpec *indspec = GetIndustrySpec(this->ind_type);
if (indspec == nullptr) break;
if (cost.cm.industry_layout >= indspec->layouts.size()) break;
@@ -554,6 +560,10 @@ void ObjectHighlight::UpdateTiles() {
default:
NOT_REACHED();
}
if (this->cost.Succeeded()) {
// TODO overlay size
}
}
void ObjectHighlight::MarkDirty() {
@@ -1288,7 +1298,7 @@ bool Intersects(const Rect &rect, int left, int top, int right, int bottom) {
}
void ObjectHighlight::DrawOverlay(DrawPixelInfo *dpi) {
void ObjectHighlight::DrawSelectionOverlay(DrawPixelInfo *dpi) {
for (auto &s : this->sprites) {
DrawSpriteViewport(s.sprite_id, s.palette_id, s.pt.x, s.pt.y);
}
@@ -1314,6 +1324,10 @@ void ObjectHighlight::DrawOverlay(DrawPixelInfo *dpi) {
// }
}
void ObjectHighlight::DrawOverlay(DrawPixelInfo *dpi) {
if (!this->cost.Succeeded()) return;
}
template <typename F>
uint8 Get(uint32 x, uint32 y, F getter) {
if (x >= MapSizeX() || y >= MapSizeY()) return 0;
@@ -1665,7 +1679,7 @@ bool DrawTileSelection(const TileInfo *ti, const TileHighlightType &tht) {
}
void DrawSelectionOverlay(DrawPixelInfo *dpi) {
_thd.cm.DrawOverlay(dpi);
_thd.cm.DrawSelectionOverlay(dpi);
}
+3
View File
@@ -306,6 +306,8 @@ public:
sp<Blueprint> blueprint = nullptr;
IndustryType ind_type = INVALID_INDUSTRYTYPE;
uint32 ind_layout = 0;
CommandCost cost;
Dimension overlay_dim;
protected:
bool tiles_updated = false;
@@ -333,6 +335,7 @@ public:
TileHighlight GetTileHighlight(const TileInfo *ti);
void Draw(const TileInfo *ti);
void DrawSelectionOverlay(DrawPixelInfo *dpi);
void DrawOverlay(DrawPixelInfo *dpi);
void UpdateTiles();
void MarkDirty();
+4 -2
View File
@@ -237,8 +237,10 @@ MinimapIndustryKdtree _minimap_industry_idx{Kdtree_MinimapIndustryXYFunc};
uint _max_industry_outputs = 0;
bool is_cached_industry(const Industry *ind) {
const IndustrySpec *indspec = GetIndustrySpec(ind->type);
return ((indspec->life_type & (INDUSTRYLIFE_ORGANIC | INDUSTRYLIFE_EXTRACTIVE)) != 0);
for (auto i = 0; i < INDUSTRY_NUM_OUTPUTS; i++)
if (ind->produced_cargo[i] != INVALID_CARGO)
return true;
return false;
}
MinimapIndustryKdtreeEntry get_industry_entry(const Industry *ind) {
+3 -1
View File
@@ -5916,7 +5916,7 @@ CM_STR_CONFIG_SETTING_OPEN_VEHICLE_FOR_SHARED_CLONE :Open vehicle wi
CM_STR_CONFIG_SETTING_OPEN_VEHICLE_FOR_SHARED_CLONE_HELPTEXT :Open vehicle window when cloning vehicles with shared orders (as it does for non-shared ones)
CM_STR_CONFIG_SETTING_OPEN_ORDERS_FOR_NEW_VEHICLES :Open orders window for new vehicles: {STRING2}
CM_STR_CONFIG_SETTING_OPEN_ORDERS_FOR_NEW_VEHICLES_HELPTEXT :Automatically open orders window along with a vehicle window for a new vehicles
CM_STR_PURCHASE_ENGINE_ID :{BLACK}Engine ID: {GOLD}{NUM}
CM_STR_PURCHASE_ENGINE_ID :{BLACK}Engine ID: {GOLD}{NUM} {BLACK}ID(GRF): {GOLD}{NUM}
CM_STR_SMALLMAP_TOOLTIP_SHOW_IMBA_ON_MAP :{BLACK}Show industries on map combined with land contours and vegetation
CM_STR_CONFIG_SETTING_PAUSE_AFTER_LOAD :Pause the game after loading: {STRING2}
CM_STR_CONFIG_SETTING_PAUSE_AFTER_LOAD_HELPTEXT :Control whether the game should be paused after load (if it's not already paused). Useful for desync debugging.
@@ -6059,3 +6059,5 @@ CM_STR_VIEWPORT_TOWN_TINY_EXCELLENT_RATING :{TINY_FONT}{GRE
CM_STR_CARGO_WITH_ID :{STRING} {SILVER}#{NUM}
CM_STR_INDUSTRY_TYPE_WITH_ID :{STRING} {SILVER}#{NUM}
CM_STR_CONFIG_SETTING_TYPE_DROPDOWN_CITYMANIA :CityMania patchpack settings
CM_BUILDING_PREVIEW_COST_ENOUGH :Cost
+1 -1
View File
@@ -5909,7 +5909,7 @@ CM_STR_CONFIG_SETTING_OPEN_VEHICLE_FOR_SHARED_CLONE :Fahrzeugfenster
CM_STR_CONFIG_SETTING_OPEN_VEHICLE_FOR_SHARED_CLONE_HELPTEXT :Fahrzeugfenster beim Klonen von Fahrzeugen mit geteilten Aufträgen öffnen (wie es bei den nicht-geteilten der Fall ist)
CM_STR_CONFIG_SETTING_OPEN_ORDERS_FOR_NEW_VEHICLES :Auftragsfenster für neue Fahrzeuge öffnen: {STRING}
CM_STR_CONFIG_SETTING_OPEN_ORDERS_FOR_NEW_VEHICLES_HELPTEXT :Auftragsfenster automatisch zusammen mit dem Fahrzeugfenster für neue Fahrzeuge öffnen
CM_STR_PURCHASE_ENGINE_ID :{BLACK}Fahrzeug-ID: {GOLD}{NUM}
CM_STR_PURCHASE_ENGINE_ID :{BLACK}Fahrzeug-ID: {GOLD}{NUM} {BLACK}ID(GRF}: {GOLD}{NUM}
CM_STR_SMALLMAP_TOOLTIP_SHOW_IMBA_ON_MAP :{BLACK}Industrien zusammen mit Landkonturen und Vegetation auf der Karte anzeigen
CM_STR_CONFIG_SETTING_PAUSE_AFTER_LOAD :Spiel nach dem Laden pausieren: {STRING}
CM_STR_CONFIG_SETTING_PAUSE_AFTER_LOAD_HELPTEXT :Beeinflusst ob das Spiel nach dem Laden pausiert werden soll (falls es noch nicht pausiert ist). Zum Desync-Debugging nützlich.