Skip to content

Commit 4d34caa

Browse files
authored
Merge pull request #60 from morganchristiansson/fix-ore-placements
Fix ore placements
2 parents 517ffa5 + 2fea678 commit 4d34caa

1 file changed

Lines changed: 17 additions & 21 deletions

File tree

CMap.cpp

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,15 +1294,6 @@ static const TerrainDesc* getTerrainDesc(const bobMAP& map, Uint8 rawTextureId)
12941294
return nullptr;
12951295
}
12961296

1297-
static bool nodeIsMountain(const bobMAP& map, const MapNode& node, bool checkBoth = true)
1298-
{
1299-
const auto* rsu = getTerrainDesc(map, node.rsuTexture);
1300-
const auto* usd = getTerrainDesc(map, node.usdTexture);
1301-
if(checkBoth)
1302-
return rsu && usd && rsu->kind == TerrainKind::Mountain && usd->kind == TerrainKind::Mountain;
1303-
return (rsu && rsu->kind == TerrainKind::Mountain) || (usd && usd->kind == TerrainKind::Mountain);
1304-
}
1305-
13061297
static bool nodeHasTerrainFlag(const bobMAP& map, const MapNode& node, ETerrain flag, bool checkBoth = true)
13071298
{
13081299
const auto* rsu = getTerrainDesc(map, node.rsuTexture);
@@ -2211,23 +2202,23 @@ void CMap::modifyResource(Position pos)
22112202

22122203
// SPECIAL CASE: test if we should set water only
22132204
// test if vertex is surrounded by meadow and meadow-like textures
2214-
auto isBuildableLand = [&](const MapNode& node) {
2215-
const auto* rsu = getTerrainDesc(*map, node.rsuTexture);
2216-
const auto* usd = getTerrainDesc(*map, node.usdTexture);
2217-
return rsu && usd && rsu->kind == TerrainKind::Land && rsu->Is(ETerrain::Buildable)
2218-
&& usd->kind == TerrainKind::Land && usd->Is(ETerrain::Buildable);
2219-
};
2220-
if(isBuildableLand(*mapVertices[0]) && isBuildableLand(*mapVertices[1]) && isBuildableLand(*mapVertices[2])
2221-
&& isBuildableLand(*mapVertices[3]))
2205+
// Original logic: both triangles for v0/v1, only rsu for v2, only usd for v3
2206+
if(getTerrainDesc(*map, mapVertices[0]->rsuTexture)->Is(ETerrain::Buildable)
2207+
&& getTerrainDesc(*map, mapVertices[0]->usdTexture)->Is(ETerrain::Buildable)
2208+
&& getTerrainDesc(*map, mapVertices[1]->rsuTexture)->Is(ETerrain::Buildable)
2209+
&& getTerrainDesc(*map, mapVertices[1]->usdTexture)->Is(ETerrain::Buildable)
2210+
&& getTerrainDesc(*map, mapVertices[2]->rsuTexture)->Is(ETerrain::Buildable)
2211+
&& getTerrainDesc(*map, mapVertices[3]->usdTexture)->Is(ETerrain::Buildable))
22222212
{
22232213
curVertex.resource = 0x21;
22242214
}
22252215
// SPECIAL CASE: test if we should set fishes only
22262216
// test if vertex is surrounded by water (first section) and at least one non-water texture in the second section
2217+
// Original logic: both triangles for v0/v1, only rsu for v2, only usd for v3
22272218
else if(nodeHasTerrainFlag(*map, *mapVertices[0], ETerrain::Shippable, true)
22282219
&& nodeHasTerrainFlag(*map, *mapVertices[1], ETerrain::Shippable, true)
2229-
&& nodeHasTerrainFlag(*map, *mapVertices[2], ETerrain::Shippable, true)
2230-
&& nodeHasTerrainFlag(*map, *mapVertices[3], ETerrain::Shippable, true)
2220+
&& getTerrainDesc(*map, mapVertices[2]->rsuTexture)->Is(ETerrain::Shippable)
2221+
&& getTerrainDesc(*map, mapVertices[3]->usdTexture)->Is(ETerrain::Shippable)
22312222
&& (!nodeHasTerrainFlag(*map, *mapVertices[2], ETerrain::Shippable, false)
22322223
|| !nodeHasTerrainFlag(*map, *mapVertices[3], ETerrain::Shippable, false)
22332224
|| !nodeHasTerrainFlag(*map, *mapVertices[4], ETerrain::Shippable, false)
@@ -2244,8 +2235,13 @@ void CMap::modifyResource(Position pos)
22442235
curVertex.resource = 0x87;
22452236
}
22462237
// test if vertex is surrounded by mining textures
2247-
else if(nodeIsMountain(*map, *mapVertices[0], true) && nodeIsMountain(*map, *mapVertices[1], true)
2248-
&& nodeIsMountain(*map, *mapVertices[2], true) && nodeIsMountain(*map, *mapVertices[3], true))
2238+
// Original logic: both triangles for v0/v1, only rsu for v2, only usd for v3
2239+
else if(getTerrainDesc(*map, mapVertices[0]->rsuTexture)->Is(ETerrain::Mineable)
2240+
&& getTerrainDesc(*map, mapVertices[0]->usdTexture)->Is(ETerrain::Mineable)
2241+
&& getTerrainDesc(*map, mapVertices[1]->rsuTexture)->Is(ETerrain::Mineable)
2242+
&& getTerrainDesc(*map, mapVertices[1]->usdTexture)->Is(ETerrain::Mineable)
2243+
&& getTerrainDesc(*map, mapVertices[2]->rsuTexture)->Is(ETerrain::Mineable)
2244+
&& getTerrainDesc(*map, mapVertices[3]->usdTexture)->Is(ETerrain::Mineable))
22492245
{
22502246
// check which resource to set
22512247
if(mode == EDITOR_MODE_RESOURCE_RAISE)

0 commit comments

Comments
 (0)