diff --git a/dCommon/ZoneScenes.cpp b/dCommon/ZoneScenes.cpp index 4cac2db59..efc25242d 100644 --- a/dCommon/ZoneScenes.cpp +++ b/dCommon/ZoneScenes.cpp @@ -58,9 +58,11 @@ namespace ZoneScenes { }; for (const auto& transition : transitions) { if (transition.points.size() < 2) continue; - // The low half of a point's LWOSCENEID is the scene, the high half its layer - const auto a = static_cast(transition.points[0].sceneID & 0xFFFFFFFF); - const auto b = static_cast(transition.points[1].sceneID & 0xFFFFFFFF); + // A transition links the scenes of its first and last points (ZoneLoader::ReadZoneFile; 5-point transitions + // of versions 34-38 have 3 more between them). The low half of a point's LWOSCENEID is the scene, the high + // half its layer + const auto a = static_cast(transition.points.front().sceneID & 0xFFFFFFFF); + const auto b = static_cast(transition.points.back().sceneID & 0xFFFFFFFF); if (a == b || !m_Scenes.contains(a) || !m_Scenes.contains(b)) continue; link(a, b); link(b, a); diff --git a/tests/dCommonTests/ZoneScenesTests.cpp b/tests/dCommonTests/ZoneScenesTests.cpp index bb60fd34c..c00e8612a 100644 --- a/tests/dCommonTests/ZoneScenesTests.cpp +++ b/tests/dCommonTests/ZoneScenesTests.cpp @@ -63,6 +63,15 @@ TEST(ZoneScenesTests, LoadsTheConnectedScenes) { EXPECT_TRUE(graph.Neighbours(9).empty()); } +// A 5-point transition (versions 34-38) links its first and last points' scenes +TEST(ZoneScenesTests, FivePointTransitionsLinkTheirEnds) { + SceneTransition transition; + for (const uint64_t scene : { 1, 2, 2, 2, 3 }) transition.points.push_back({ scene, {} }); + const ZoneScenes::SceneGraph graph(Scenes({ 0, 1, 2, 3 }), { transition }); + EXPECT_EQ(graph.Neighbours(1), (std::set{ 3 })); + EXPECT_TRUE(graph.Neighbours(2).empty()); +} + TEST(ZoneScenesTests, AddsTheScenesAroundThePlayerWhileTheReferenceIsOverridden) { const ZoneScenes::SceneGraph graph(Scenes({ 0, 1, 2, 3, 4 }), { Transition(1, 2), Transition(3, 4) }); // Not overridden: only the reference point's scenes, wherever the player is