mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-02 10:53:44 +00:00
fix(zone): spawner paths have an activate-on-load byte only from version 9
The client reads a spawner path's activateOnLoad byte only when the path is newer than version 8 (LevelPath::FromBuffer, 1.10.64: pathVersion > 8) and otherwise keeps its default of 1 (Path::InitializeSpawnerInfo). The reader read the byte for every version, which would misread an older spawner path from there on, and its default was 0. The byte is now read from version 9, and an older path's spawner is active on load as in the client. No zone file on disk has a spawner path older than version 9, so what the world spawns is unchanged. Check in game: nothing to check (spawners on live worlds are unchanged). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -204,6 +204,33 @@ TEST(ZoneFileTests, ReadsLegacyPaths) {
|
||||
EXPECT_EQ(platform.pathWaypoints[0].movingPlatform.wait, 1.5f);
|
||||
}
|
||||
|
||||
// Spawner paths before version 9 have no activate-on-load byte; the client then activates them on load
|
||||
TEST(ZoneFileTests, SpawnerNetActiveFromVersion9) {
|
||||
ZoneBytes w;
|
||||
w.Put<uint32_t>(41).Put<uint32_t>(3).Put<uint32_t>(1150);
|
||||
w.Point(0, 0, 0).Put(1.0f).Put(0.0f).Put(0.0f).Put(0.0f);
|
||||
w.Put<uint32_t>(1);
|
||||
w.Text("scene.lvl").Put<uint32_t>(0).Put<uint32_t>(0).Text("Global").Put<uint8_t>(0).Put<uint8_t>(0).Put<uint8_t>(0);
|
||||
w.Put<uint8_t>(0).Text("zone.raw").Text("Name").Text("Description");
|
||||
w.Put<uint32_t>(0).Put<uint32_t>(0).Put<uint32_t>(1).Put<uint32_t>(2);
|
||||
for (const uint32_t version : { 8u, 9u }) {
|
||||
w.Put<uint32_t>(version).Wide("Spawner").Put<uint32_t>(4).Put<uint32_t>(0).Put<uint32_t>(0);
|
||||
w.Put<int32_t>(6010).Put<uint32_t>(10).Put<int32_t>(1).Put<uint32_t>(1).Put<int64_t>(123);
|
||||
if (version >= 9) w.Put<uint8_t>(0);
|
||||
w.Put<uint32_t>(1).Point(1, 1, 1).Put(1.0f).Put(0.0f).Put(0.0f).Put(0.0f).Put<uint32_t>(0);
|
||||
}
|
||||
|
||||
std::istringstream stream(w.data);
|
||||
ZoneFile zone;
|
||||
zone.Read(stream);
|
||||
EXPECT_FALSE(stream.fail());
|
||||
EXPECT_EQ(stream.peek(), std::char_traits<char>::eof());
|
||||
ASSERT_EQ(zone.paths.size(), 2u);
|
||||
EXPECT_EQ(zone.paths[0].spawner.spawnerNetActive, 1);
|
||||
EXPECT_EQ(zone.paths[0].pathWaypoints.at(0).position, NiPoint3(1, 1, 1));
|
||||
EXPECT_EQ(zone.paths[1].spawner.spawnerNetActive, 0);
|
||||
}
|
||||
|
||||
TEST(ZoneFileTests, ShortFilesThrowOrFail) {
|
||||
const auto zone = SampleZone();
|
||||
for (const size_t length : { size_t{ 3 }, size_t{ 40 }, zone.size() / 2, zone.size() - 1 }) {
|
||||
|
||||
Reference in New Issue
Block a user