mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-19 18:25:27 +00:00
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:
@@ -47,7 +47,7 @@ Level::Level(Zone* parentZone, const std::string& filepath, int32_t sceneID) {
|
||||
static_cast<LevelFile::ChunkHeader&>(header) = chunkHeader;
|
||||
m_ChunkHeaders.insert(std::make_pair(id, header));
|
||||
}
|
||||
LoadSceneObjects(levelFile.objects);
|
||||
LoadSceneObjects(levelFile.objects, m_SceneID);
|
||||
}
|
||||
|
||||
void Level::MakeSpawner(const SceneObject& obj, int32_t sceneID) {
|
||||
@@ -120,7 +120,18 @@ void Level::MakeSpawner(const SceneObject& obj, int32_t sceneID) {
|
||||
Game::zoneManager->MakeSpawner(spawnInfo);
|
||||
}
|
||||
|
||||
void Level::LoadSceneObjects(const std::vector<SceneObject>& objects) {
|
||||
void Level::LoadSceneObjects(const std::vector<SceneObject>& objects, const int32_t sceneID) {
|
||||
// Edit mode: the GM's client has the level's objects from its own files, so none is made here. The oldest files
|
||||
// keep the spawn point in an object, which is still read.
|
||||
if (Game::zoneManager->GetEditMode()) {
|
||||
for (const auto& obj : objects) {
|
||||
if (obj.lot != LOT_MARKER_PLAYER_START) continue;
|
||||
Game::zoneManager->GetZoneMut()->SetSpawnPos(obj.position);
|
||||
Game::zoneManager->GetZoneMut()->SetSpawnRot(obj.rotation);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
CDFeatureGatingTable* featureGatingTable = CDClientManager::GetTable<CDFeatureGatingTable>();
|
||||
|
||||
CDFeatureGating gating;
|
||||
@@ -181,7 +192,7 @@ void Level::LoadSceneObjects(const std::vector<SceneObject>& objects) {
|
||||
}
|
||||
|
||||
if (obj.lot == 176) { //Spawner
|
||||
MakeSpawner(obj, m_SceneID);
|
||||
MakeSpawner(obj, sceneID);
|
||||
} else { //Regular object
|
||||
EntityInfo info;
|
||||
info.spawnerID = 0;
|
||||
@@ -191,7 +202,7 @@ void Level::LoadSceneObjects(const std::vector<SceneObject>& objects) {
|
||||
info.rot = obj.rotation;
|
||||
info.settings = obj.settings;
|
||||
info.scale = obj.scale;
|
||||
info.scene = m_SceneID;
|
||||
info.scene = sceneID;
|
||||
Game::entityManager->CreateEntity(info);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,11 +20,12 @@ public:
|
||||
|
||||
static void MakeSpawner(const SceneObject& obj, int32_t sceneID = -1);
|
||||
|
||||
// Makes the objects and spawners of a level file. In edit mode (dZoneManager::GetEditMode) none: only the player
|
||||
// start marker's place is taken
|
||||
static void LoadSceneObjects(const std::vector<SceneObject>& objects, int32_t sceneID = -1);
|
||||
|
||||
std::map<uint32_t, Header> m_ChunkHeaders;
|
||||
private:
|
||||
Zone* m_ParentZone;
|
||||
int32_t m_SceneID = -1;
|
||||
|
||||
//private functions:
|
||||
void LoadSceneObjects(const std::vector<SceneObject>& objects);
|
||||
};
|
||||
|
||||
@@ -138,7 +138,8 @@ void Zone::LoadZoneIntoMemory() {
|
||||
}
|
||||
}
|
||||
|
||||
if (m_FileFormatVersion >= Zone::FileFormatVersion::EarlyAlpha) {
|
||||
// Edit mode: no spawner networks (the paths themselves are kept, they are only data)
|
||||
if (m_FileFormatVersion >= Zone::FileFormatVersion::EarlyAlpha && !Game::zoneManager->GetEditMode()) {
|
||||
for (const Path& path : m_Paths) {
|
||||
if (path.pathType != PathType::Spawner) continue;
|
||||
SpawnerInfo info{};
|
||||
@@ -286,7 +287,8 @@ void Zone::LoadScene(ZoneScene&& zoneScene) {
|
||||
LWOSCENEID lwoSceneID(scene.id, scene.sceneType);
|
||||
|
||||
std::string luTriggersPath = scene.filename.substr(0, scene.filename.size() - 4) + ".lutriggers";
|
||||
if (Game::assetManager->HasFile((m_ZonePath + luTriggersPath).c_str())) LoadLUTriggers(luTriggersPath, scene);
|
||||
// Edit mode: no triggers
|
||||
if (!Game::zoneManager->GetEditMode() && Game::assetManager->HasFile((m_ZonePath + luTriggersPath).c_str())) LoadLUTriggers(luTriggersPath, scene);
|
||||
|
||||
m_Scenes[lwoSceneID] = std::move(scene);
|
||||
}
|
||||
|
||||
@@ -57,8 +57,7 @@ void dZoneManager::Initialize(const LWOZONEID& zoneID) {
|
||||
EntityInfo info;
|
||||
info.lot = zoneControlTemplate;
|
||||
|
||||
/* Yep its hardcoded like this in the client too, this exact value. */
|
||||
info.id = 0x3FFF'FFFFFFFELL;
|
||||
info.id = ZONE_CONTROL_OBJECT_ID;
|
||||
Entity* zoneControl = Game::entityManager->CreateEntity(info, nullptr, nullptr, true);
|
||||
m_ZoneControlObject = zoneControl;
|
||||
|
||||
@@ -73,7 +72,9 @@ void dZoneManager::Initialize(const LWOZONEID& zoneID) {
|
||||
|
||||
LOG("Zone prepared in: %llu ms", (endTime - startTime));
|
||||
|
||||
VanityUtilities::SpawnVanity();
|
||||
// The vanity objects are server objects the client's editor would not know
|
||||
if (!m_EditMode) VanityUtilities::SpawnVanity();
|
||||
else LOG("Zone %i is in edit mode: no level objects, spawners, triggers or vanity objects were loaded", zoneID.GetMapID());
|
||||
}
|
||||
|
||||
dZoneManager::~dZoneManager() {
|
||||
|
||||
@@ -23,6 +23,9 @@ private:
|
||||
void LoadWorldConfig();
|
||||
|
||||
public:
|
||||
// The zone control object's ID, the same fixed value in the client (LevelManager::LoadZoneControlObject, 0x01082660)
|
||||
static constexpr LWOOBJID ZONE_CONTROL_OBJECT_ID = 0x3FFF'FFFFFFFELL;
|
||||
|
||||
void Initialize(const LWOZONEID& zoneID);
|
||||
~dZoneManager();
|
||||
|
||||
@@ -30,6 +33,13 @@ public:
|
||||
Zone* GetZoneMut() const;
|
||||
const Zone* GetZone() const { return GetZoneMut(); };
|
||||
bool HasZone() const { return m_pZone != nullptr; };
|
||||
|
||||
/**
|
||||
* A GM's edit mode (docs/EditMode.md): the zone's level objects, spawners, spawner networks and triggers are not
|
||||
* loaded, so the GM's client is the only one that has them. Set before Initialize.
|
||||
*/
|
||||
bool GetEditMode() const { return m_EditMode; }
|
||||
void SetEditMode(bool value) { m_EditMode = value; }
|
||||
void LoadZone(const LWOZONEID& zoneID); //Discard the current zone (if any) and loads a new zone.
|
||||
|
||||
/* Adds a spawner to the zone with the specified ID. */
|
||||
@@ -103,6 +113,7 @@ private:
|
||||
bool m_PlayerLoseCoinsOnDeath = false;
|
||||
bool m_DisableSaveLocation = false;
|
||||
bool m_MountsAllowed = true;
|
||||
bool m_EditMode = false;
|
||||
bool m_PetsAllowed = true;
|
||||
std::map<LWOOBJID, Spawner*> m_Spawners;
|
||||
std::optional<WorldConfig> m_WorldConfig = std::nullopt;
|
||||
|
||||
Reference in New Issue
Block a user