Update cb acceptance area zoning and fix it for new cb
This commit is contained in:
@@ -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) ***
|
||||
|
||||
@@ -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<ZoningBorder, bool> 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<int>(0, tx - radius),
|
||||
(uint16)max<int>(0, ty - radius),
|
||||
(uint16)min<int>(tx + radius + 1, MapSizeX()),
|
||||
(uint16)min<int>(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);
|
||||
|
||||
9
src/citymania/minimap.cpp
Normal file
9
src/citymania/minimap.cpp
Normal file
@@ -0,0 +1,9 @@
|
||||
#include "../stdafx.h"
|
||||
|
||||
#include "minimap.hpp"
|
||||
|
||||
#include "../safeguards.h"
|
||||
|
||||
namespace citymania {
|
||||
|
||||
} // namespace citymania
|
||||
40
src/citymania/minimap.hpp
Normal file
40
src/citymania/minimap.hpp
Normal file
@@ -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 */
|
||||
@@ -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
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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)
|
||||
};
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user