Phase N.1 step 8 (final code cleanup): now that ACDREAM_USE_WB_SCENERY
has been default-on (commit b84ecbd), remove the legacy in-line
algorithms so we don't accumulate dead-code drift.
Deleted:
- SceneryGenerator.UseWbScenery (feature flag)
- SceneryGenerator.IsOnRoad / DisplaceObject / RoadHalfWidth (legacy
ports — Generate used to call them)
- The legacy in-line implementation in Generate()
- SceneryGeneratorTests.DisplaceObject_* (test the deleted method)
- SceneryWbConformanceTests.cs entirely (purpose served — proved
equivalence pre-migration; would compare WB to WB after delete)
Renamed:
- GenerateViaWb -> GenerateInternal (it's the only path now)
Kept:
- Public IsRoadVertex predicate (small surface, useful)
- WbSceneryAdapter (consumed by GenerateInternal)
- All WbSceneryAdapterTests (still cover the adapter)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
51 lines
1.8 KiB
C#
51 lines
1.8 KiB
C#
using AcDream.Core.World;
|
|
using DatReaderWriter.Types;
|
|
|
|
namespace AcDream.Core.Tests.World;
|
|
|
|
/// <summary>
|
|
/// Tests for SceneryGenerator. As of Phase N.1 (commit b84ecbd / Task 8 final
|
|
/// commit), the displacement / road / slope / rotation / scale algorithms run
|
|
/// through WorldBuilder's helpers (SceneryHelpers + TerrainUtils). The only
|
|
/// our-side code remaining is the small <see cref="SceneryGenerator.IsRoadVertex"/>
|
|
/// predicate, which is what these tests cover.
|
|
/// </summary>
|
|
public class SceneryGeneratorTests
|
|
{
|
|
// Terrain word layout (ushort):
|
|
// bits 0-1 = Road (non-zero → on a road)
|
|
// bits 2-6 = TerrainType
|
|
// bits 11-15 = SceneType
|
|
|
|
[Theory]
|
|
[InlineData(0x0000, false)] // no road bits
|
|
[InlineData(0x0001, true)] // road bit 0 set
|
|
[InlineData(0x0002, true)] // road bit 1 set
|
|
[InlineData(0x0003, true)] // both road bits set
|
|
[InlineData(0x007C, false)] // terrain type bits only, no road
|
|
[InlineData(0xF800, false)] // scenery bits only, no road
|
|
[InlineData(0xF803, true)] // road + scenery bits
|
|
public void IsRoadVertex_CorrectlyIdentifiesRoadBits(ushort raw, bool expectedIsRoad)
|
|
{
|
|
Assert.Equal(expectedIsRoad, SceneryGenerator.IsRoadVertex(raw));
|
|
}
|
|
|
|
[Fact]
|
|
public void IsRoadVertex_ZeroTerrain_IsNotRoad()
|
|
{
|
|
Assert.False(SceneryGenerator.IsRoadVertex(0));
|
|
}
|
|
|
|
[Fact]
|
|
public void IsRoadVertex_MatchesTerrainInfoRoadProperty()
|
|
{
|
|
for (ushort raw = 0; raw < 4; raw++)
|
|
{
|
|
TerrainInfo ti = raw;
|
|
bool expectedFromStruct = ti.Road != 0;
|
|
bool actual = SceneryGenerator.IsRoadVertex(raw);
|
|
Assert.True(actual == expectedFromStruct,
|
|
$"raw=0x{raw:X4}: IsRoadVertex={actual} but TerrainInfo.Road={ti.Road}");
|
|
}
|
|
}
|
|
}
|