Files
DarkflameServer/tests/dGameTests/SceneGhostingTests.cpp
Aaron Kimbrell 36997723af feat: scene ghosting, as the client streams a zone's scenes
The client keeps the scene under the player loaded, the scenes the zone
file's transitions connect to it, and the global scene
(the client's scene streaming and terrain scene lookup
the client's terrain scene lookup and connected scenes; transitions naming a
missing scene dropped as the client does).

- ZoneScenes (dCommon): the terrain's scene map lookup and the scene graph,
  shared by the world server and the dashboard.
- Objects remember the scene they were placed in (spawners pass theirs on).
- ghosting_scenes=1 (world config, off by default): players get the objects
  of their loaded scenes instead of the ones within the ghosting distances;
  objects from no scene go by the scene under them. Zones without a scene
  map keep distance ghosting.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-28 22:31:17 -05:00

28 lines
1.1 KiB
C++

#include "GameDependencies.h"
#include <gtest/gtest.h>
#include "Entity.h"
#include "ZoneScenes.h"
class SceneGhostingTest : public GameDependenciesTest {
protected:
void SetUp() override { SetUpDependencies(); }
void TearDown() override { TearDownDependencies(); }
};
// Objects keep the scene they were placed in, which scene ghosting goes by; objects from no scene go by their position
TEST_F(SceneGhostingTest, EntitiesKeepTheirScene) {
EntityInfo placed = info;
placed.scene = 12;
const auto fromScene = std::make_unique<Entity>(20, placed);
EXPECT_EQ(fromScene->GetScene(), 12);
const auto spawned = std::make_unique<Entity>(21, info);
EXPECT_EQ(spawned->GetScene(), -1);
// A player standing in scene 3, whose client keeps 0, 3 and 5 loaded
const std::set<uint32_t> loaded{ 0, 3, 5 };
EXPECT_FALSE(ZoneScenes::InLoadedScene(fromScene->GetScene(), 3, loaded)); // placed in scene 12, though it stands in 3
EXPECT_TRUE(ZoneScenes::InLoadedScene(spawned->GetScene(), 5, loaded));
EXPECT_FALSE(ZoneScenes::InLoadedScene(spawned->GetScene(), 12, loaded));
}