diff --git a/cm_changelog.txt b/cm_changelog.txt index ad947d8826..b2b5839a9e 100644 --- a/cm_changelog.txt +++ b/cm_changelog.txt @@ -75,7 +75,8 @@ This is usable for any OpenTTD servers == CHANGELOG == *** next -- Add new map mode showing industries, height and farms at the same time. +- Add new minimap mode showing industries, height and farms at the same time. +- Rename "CB town border" zone to "CB cargo acceptance", switch it to new colored highlight and fix for new CB mode. - Show engine id in build window in newgrf developer mode. *** 1.10.1 (15 Apr 2020) *** diff --git a/src/citymania/highlight.cpp b/src/citymania/highlight.cpp index 7fb9a4c0b4..d934eb620c 100644 --- a/src/citymania/highlight.cpp +++ b/src/citymania/highlight.cpp @@ -8,6 +8,7 @@ #include "../industry.h" #include "../landscape.h" #include "../town.h" +#include "../town_kdtree.h" #include "../tilearea_type.h" #include "../tilehighlight_type.h" #include "../viewport_func.h" @@ -195,6 +196,33 @@ static void SetStationSelectionHighlight(const TileInfo *ti, TileHighlight &th) } } +std::pair CalcCBAcceptanceBorders(TileIndex tile) { + int tx = TileX(tile), ty = TileY(tile); + uint16 radius = _settings_client.gui.cb_distance_check; + bool in_zone = false; + ZoningBorder border = ZoningBorder::NONE; + _town_kdtree.FindContained( + (uint16)max(0, tx - radius), + (uint16)max(0, ty - radius), + (uint16)min(tx + radius + 1, MapSizeX()), + (uint16)min(ty + radius + 1, MapSizeY()), + [tx, ty, radius, &in_zone, &border] (TownID tid) { + Town *town = Town::GetIfValid(tid); + if (!town) + return; + + int dx = TileX(town->xy) - tx; + int dy = TileY(town->xy) - ty; + in_zone = in_zone || (max(abs(dx), abs(dy)) <= radius); + if (dx == radius) border |= ZoningBorder::TOP_RIGHT; + if (dx == -radius) border |= ZoningBorder::BOTTOM_LEFT; + if (dy == radius) border |= ZoningBorder::TOP_LEFT; + if (dy == -radius) border |= ZoningBorder::BOTTOM_RIGHT; + } + ); + return std::make_pair(border, in_zone); +} + TileHighlight GetTileHighlight(const TileInfo *ti) { TileHighlight th; if (ti->tile == INVALID_TILE) return th; @@ -265,6 +293,12 @@ TileHighlight GetTileHighlight(const TileInfo *ti) { } auto z = getter(check_tile); if (z) th.ground_pal = th.structure_pal = GetTintBySelectionColour(pal[z]); + } else if (_zoning.outer == CHECKCBACCEPTANCE) { + auto b = CalcCBAcceptanceBorders(ti->tile); + if (b.first) + th.add_border(b.first, SPR_PALETTE_ZONING_WHITE); + if (b.second) + th.ground_pal = th.structure_pal = PALETTE_TINT_WHITE; } else if (_zoning.outer == CHECKACTIVESTATIONS) { auto getter = [](TileIndex t) { if (!IsTileType (t, MP_STATION)) return 0; @@ -394,6 +428,7 @@ void UpdateAdvertisementZoning(TileIndex center, uint radius, uint8 zone) { } } + void InitializeZoningMap() { for (Town *t : Town::Iterate()) { UpdateTownZoning(t, 0); diff --git a/src/citymania/minimap.cpp b/src/citymania/minimap.cpp new file mode 100644 index 0000000000..6259b8b417 --- /dev/null +++ b/src/citymania/minimap.cpp @@ -0,0 +1,9 @@ +#include "../stdafx.h" + +#include "minimap.hpp" + +#include "../safeguards.h" + +namespace citymania { + +} // namespace citymania diff --git a/src/citymania/minimap.hpp b/src/citymania/minimap.hpp new file mode 100644 index 0000000000..7dfdff05b0 --- /dev/null +++ b/src/citymania/minimap.hpp @@ -0,0 +1,40 @@ +#ifndef CITYMANIA_MINIMAP_HPP +#define CITYMANIA_MINIMAP_HPP + +#include "../core/endian_func.hpp" + +namespace citymania { + +#define MKCOLOUR(x) TO_LE32X(x) +#define MKCOLOURGROUP(x, y) \ + MKCOLOUR(((uint32)(x) << 24) | ((uint32)(x) << 16) | ((uint32)(x) << 8) | (uint32)(x)), \ + MKCOLOUR(((uint32)(x) << 24) | ((uint32)(y) << 16) | ((uint32)(y) << 8) | (uint32)(x)), \ + MKCOLOUR(((uint32)(x) << 24) | ((uint32)(y) << 16) | ((uint32)(x) << 8) | (uint32)(x)), \ + MKCOLOUR(((uint32)(x) << 24) | ((uint32)(y) << 16) | ((uint32)(y) << 8) | (uint32)(x)), \ + MKCOLOUR(((uint32)(y) << 24) | ((uint32)(x) << 16) | ((uint32)(x) << 8) | (uint32)(x)), \ + MKCOLOUR(((uint32)(y) << 24) | ((uint32)(y) << 16) | ((uint32)(y) << 8) | (uint32)(x)), \ + MKCOLOUR(((uint32)(y) << 24) | ((uint32)(y) << 16) | ((uint32)(x) << 8) | (uint32)(x)), \ + MKCOLOUR(((uint32)(y) << 24) | ((uint32)(y) << 16) | ((uint32)(y) << 8) | (uint32)(x)) + + +static const uint32 _yellow_map_heights[] = { + MKCOLOURGROUP(0x22, 0x23), + MKCOLOURGROUP(0x23, 0x24), + MKCOLOURGROUP(0x24, 0x25), + MKCOLOURGROUP(0x25, 0x26), + MKCOLOURGROUP(0x27, 0x27), + MKCOLOUR(0x27272727), +}; + +static const uint32 _orange_map_heights[] = { + MKCOLOURGROUP(0xC0, 0xC1), + MKCOLOURGROUP(0xC1, 0xC2), + MKCOLOURGROUP(0xC2, 0xC3), + MKCOLOURGROUP(0xC3, 0xC4), + MKCOLOURGROUP(0xC4, 0xC5), + MKCOLOUR(0xC5C5C5C5), +}; + +} // namespace citymania + +#endif /* CITYMANIA_MINIMAP_HPP */ diff --git a/src/lang/english.txt b/src/lang/english.txt index a4d08af4c7..b0cbf0e568 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -5259,7 +5259,7 @@ STR_ZONING_BUL_CATCH :{BLACK}City cat STR_ZONING_BUL_UNSER :{BLACK}Unserved buildings STR_ZONING_IND_UNSER :{BLACK}Unserved industries STR_ZONING_TOWN_ZONES :{BLACK}Town zones -STR_ZONING_CB_TOWN_BORDERS :{BLACK}CB town borders +STR_ZONING_CB_ACCEPTANCE :{BLACK}CB cargo acceptance STR_ZONING_CB_BORDERS :{BLACK}CB borders STR_ZONING_NEW_CB_BORDERS :{BLACK}New CB borders STR_ZONING_ADVERTISEMENT_ZONES :{BLACK}Advertisement diff --git a/src/rev.cpp b/src/rev.cpp index 4c361125db..b6a45578fc 100644 --- a/src/rev.cpp +++ b/src/rev.cpp @@ -83,4 +83,4 @@ const byte _openttd_revision_tagged = 1; const uint32 _openttd_newgrf_version = 1 << 28 | 10 << 24 | 0 << 20 | 1 << 19 | 28004; -const char _citymania_version[] = "20200514-master-mafcf064445 18.05.20"; +const char _citymania_version[] = "20200518-master-m81787f93a5 18.05.20"; diff --git a/src/zoning.h b/src/zoning.h index a4180266cc..6c5acdf4b4 100644 --- a/src/zoning.h +++ b/src/zoning.h @@ -16,7 +16,7 @@ enum EvaluationMode { CHECKTOWNZONES, ///< Town zones (Tz*) CHECKCBBORDERS, ///< Citybuilder cargo acceptment zone CHECKNEWCBBORDERS, ///< Citybuilder cargo acceptment zone - CHECKCBTOWNBORDERS, ///< Citybuilder server town borders + CHECKCBACCEPTANCE, ///< Citybuilder cargo acceptance zone CHECKTOWNADZONES, ///< Town advertisement zone CHECKTOWNGROWTHTILES, ///< Town growth tiles (new house, skipped/removed house) }; diff --git a/src/zoning_cmd.cpp b/src/zoning_cmd.cpp index 4869a7737e..7003eeb284 100644 --- a/src/zoning_cmd.cpp +++ b/src/zoning_cmd.cpp @@ -278,12 +278,9 @@ SpriteID TileZoneCheckNewCBBorders(TileIndex tile) { //Check CB town acceptance area SpriteID TileZoneCheckCBBorders(TileIndex tile) { - Town *town = CMCalcClosestTownFromTile(tile); - - if (town != NULL) { - if (DistanceManhattan(town->xy, tile) <= _settings_client.gui.cb_distance_check) { - return SPR_PALETTE_ZONING_LIGHT_BLUE; //cb catchment - } + for (Town *town : Town::Iterate()) { + if (DistanceMax(town->xy, tile) <= _settings_client.gui.cb_distance_check) + return SPR_PALETTE_ZONING_LIGHT_BLUE; } return INVALID_SPRITE_ID; // no town } @@ -365,7 +362,7 @@ SpriteID TileZoningSpriteEvaluation(TileIndex tile, Owner owner, EvaluationMode case CHECKTOWNZONES: return TileZoneCheckTownZones(tile); case CHECKCBBORDERS: return TileZoneCheckCBBorders(tile); case CHECKNEWCBBORDERS: return TileZoneCheckNewCBBorders(tile); - case CHECKCBTOWNBORDERS: return TileZoneCheckCBTownBorders(tile); + case CHECKCBACCEPTANCE: return TileZoneCheckCBBorders(tile); case CHECKTOWNADZONES: return TileZoneCheckTownAdvertisementZones(tile); case CHECKTOWNGROWTHTILES: return TileZoneCheckTownsGrowthTiles(tile); case CHECKACTIVESTATIONS: return TileZoneCheckActiveStations(tile); @@ -427,6 +424,7 @@ void DrawTileZoning(const TileInfo *ti) { _zoning.outer == CHECKINDUNSER || _zoning.outer == CHECKTOWNADZONES || _zoning.outer == CHECKSTACATCH || + _zoning.outer == CHECKCBACCEPTANCE || _zoning.outer == CHECKACTIVESTATIONS || _zoning.outer == CHECKTOWNGROWTHTILES) { // handled by citymania zoning diff --git a/src/zoning_gui.cpp b/src/zoning_gui.cpp index 2cd5137214..05f89ae896 100644 --- a/src/zoning_gui.cpp +++ b/src/zoning_gui.cpp @@ -19,7 +19,7 @@ const StringID _zone_types[] = { STR_ZONING_TOWN_ZONES, STR_ZONING_CB_BORDERS, STR_ZONING_NEW_CB_BORDERS, - STR_ZONING_CB_TOWN_BORDERS, + STR_ZONING_CB_ACCEPTANCE, STR_ZONING_ADVERTISEMENT_ZONES, STR_ZONING_TOWN_GROWTH_TILES, }; @@ -141,8 +141,8 @@ static Hotkey zoning_hotkeys[] = { Hotkey(WKC_SHIFT | '4', "unserved_buildings", ZTW_OUTER_FIRST + CHECKBULUNSER), Hotkey(WKC_SHIFT | '5', "unserved_industries", ZTW_OUTER_FIRST + CHECKINDUNSER), Hotkey(WKC_SHIFT | '6', "town_zone", ZTW_OUTER_FIRST + CHECKTOWNZONES), - Hotkey(WKC_SHIFT | '7', "CB_acceptance", ZTW_OUTER_FIRST + CHECKCBBORDERS), - Hotkey(WKC_SHIFT | '8', "CB_build_borders", ZTW_OUTER_FIRST + CHECKCBTOWNBORDERS), + Hotkey(WKC_SHIFT | '7', "CB_acceptance", ZTW_OUTER_FIRST + CHECKCBACCEPTANCE), + Hotkey(WKC_SHIFT | '8', "CB_build_borders", ZTW_OUTER_FIRST + CHECKCBACCEPTANCE), Hotkey(WKC_SHIFT | '9', "advertisement", ZTW_OUTER_FIRST + CHECKTOWNADZONES), Hotkey(WKC_SHIFT | '0', "growth_tiles", ZTW_OUTER_FIRST + CHECKTOWNGROWTHTILES), Hotkey((uint16)0, "active_stations", ZTW_OUTER_FIRST + CHECKACTIVESTATIONS),