feat(world): an edit mode world constructs none of the zone's objects

With -editmode 1 the world loads the zone file, terrain scene map, navmesh and
level revisions, but makes no level objects, carver blockers, spawners, spawner
networks, triggers, vanity objects or live event objects. The zone control
object stays with the zone's own template, as the client makes the same one
itself (LevelManager::LoadZoneControlObject, 0x01082660); its server script
does nothing and a race track's does not take the player into a race. Such a
world lets in only accounts at editor_gm_level.

Plumbing only: no command starts an edit mode instance yet (docs/EditMode.md).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Aaron Kimbrell
2026-11-10 17:34:13 -06:00
parent 4cf0909d52
commit f6914940c1
14 changed files with 219 additions and 14 deletions

View File

@@ -0,0 +1,69 @@
// Edit mode (docs/EditMode.md): who may enter, and a level file's objects not being made.
#include "GameDependencies.h"
#include "EditMode.h"
#include "EntityManager.h"
#include "Level.h"
#include "LevelFile.h"
#include "Zone.h"
#include "GeneralUtils.h"
#include "dConfig.h"
#include "eObjectBits.h"
#include "dZoneManager.h"
#include <gtest/gtest.h>
class EditModeTests : public GameDependenciesTest {
protected:
void SetUp() override { SetUpDependencies(); }
void TearDown() override { TearDownDependencies(); }
};
TEST_F(EditModeTests, OnlyEditorAccountsMayEnter) {
EXPECT_TRUE(EditMode::MayEnter(eGameMasterLevel::OPERATOR, eGameMasterLevel::OPERATOR));
EXPECT_FALSE(EditMode::MayEnter(eGameMasterLevel::DEVELOPER, eGameMasterLevel::OPERATOR));
EXPECT_FALSE(EditMode::MayEnter(eGameMasterLevel::CIVILIAN, eGameMasterLevel::OPERATOR));
EXPECT_FALSE(EditMode::MayEnter(eGameMasterLevel::CIVILIAN, eGameMasterLevel::CIVILIAN));
EXPECT_TRUE(EditMode::MayEnter(eGameMasterLevel::DEVELOPER, eGameMasterLevel::JUNIOR_DEVELOPER));
// editor_gm_level, 9 unless set
EXPECT_EQ(EditMode::RequiredLevel(), eGameMasterLevel::OPERATOR);
Game::config->SetDatabaseValues({ { "editor_gm_level", "8" } }, {});
EXPECT_EQ(EditMode::RequiredLevel(), eGameMasterLevel::DEVELOPER);
Game::config->SetDatabaseValues({ { "editor_gm_level", "0" } }, {});
EXPECT_EQ(EditMode::RequiredLevel(), eGameMasterLevel::FORUM_MODERATOR);
Game::config->SetDatabaseValues({}, {});
}
// In edit mode a level file's objects and spawners are not made; the player start marker still gives the spawn point
TEST_F(EditModeTests, LevelObjectsAreNotMade) {
Game::zoneManager->SetEditMode(true);
ASSERT_TRUE(Game::zoneManager->GetEditMode());
std::vector<SceneObject> objects;
SceneObject object;
object.id = 1001;
object.lot = 2365;
objects.push_back(object);
SceneObject spawner;
spawner.id = 1002;
spawner.lot = 176;
objects.push_back(spawner);
SceneObject start;
start.id = 1003;
start.lot = LOT_MARKER_PLAYER_START;
start.position = NiPoint3(10.0f, 20.0f, 30.0f);
objects.push_back(start);
Level::LoadSceneObjects(objects, 4);
// (a level object's ID gets the client bit when it is made)
for (const LWOOBJID id : { 1001, 1002, 1003 }) {
EXPECT_EQ(Game::entityManager->GetEntity(id), nullptr);
LWOOBJID made = id;
GeneralUtils::SetBit(made, eObjectBits::CLIENT);
EXPECT_EQ(Game::entityManager->GetEntity(made), nullptr);
}
EXPECT_TRUE(Game::zoneManager->GetSpawners().empty());
EXPECT_EQ(Game::zoneManager->GetZone()->GetSpawnPos(), NiPoint3(10.0f, 20.0f, 30.0f));
}