mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-20 02:35:28 +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:
@@ -98,6 +98,11 @@ CppScripts::Script* const ScriptComponent::GetScript() {
|
||||
void ScriptComponent::SetScript(const std::string& scriptName) {
|
||||
// Scripts are managed by the CppScripts class and are effecitvely singletons
|
||||
// and they may also be used by other script components so DON'T delete them.
|
||||
// Edit mode (docs/EditMode.md): the zone control object stays, its zone script does not run
|
||||
if (Game::zoneManager && Game::zoneManager->GetEditMode() && m_Parent->GetObjectID() == dZoneManager::ZONE_CONTROL_OBJECT_ID) {
|
||||
m_Script = CppScripts::GetInvalidScript();
|
||||
return;
|
||||
}
|
||||
m_Script = CppScripts::GetScript(m_Parent, scriptName);
|
||||
}
|
||||
|
||||
|
||||
@@ -118,7 +118,8 @@ namespace GameMessages {
|
||||
std::vector<Entity*> racingControllers = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::RACING_CONTROL);
|
||||
for (Entity* racingController : racingControllers) {
|
||||
auto* racingComponent = racingController->GetComponent<RacingControlComponent>();
|
||||
if (racingComponent != nullptr) {
|
||||
// Edit mode: a race track's zone control doesn't take the GM into a race (or send them out for having no car)
|
||||
if (racingComponent != nullptr && !Game::zoneManager->GetEditMode()) {
|
||||
racingComponent->OnPlayerLoaded(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ set(DGAME_DUTILITIES_SOURCES "BrickDatabase.cpp"
|
||||
"CheatDetection.cpp"
|
||||
"DashboardActions.cpp"
|
||||
"EconomyLedger.cpp"
|
||||
"EditMode.cpp"
|
||||
"DashboardNotify.cpp"
|
||||
"GUID.cpp"
|
||||
"LiveEvents.cpp"
|
||||
|
||||
13
dGame/dUtilities/EditMode.cpp
Normal file
13
dGame/dUtilities/EditMode.cpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#include "EditMode.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "CharacterComponent.h"
|
||||
#include "Game.h"
|
||||
#include "GeneralUtils.h"
|
||||
#include "dConfig.h"
|
||||
|
||||
eGameMasterLevel EditMode::RequiredLevel() {
|
||||
const auto level = GeneralUtils::TryParse<uint32_t>(Game::config->GetValue("editor_gm_level")).value_or(CharacterComponent::DEFAULT_EDITOR_GM_LEVEL);
|
||||
return static_cast<eGameMasterLevel>(std::clamp<uint32_t>(level, 1, 9));
|
||||
}
|
||||
18
dGame/dUtilities/EditMode.h
Normal file
18
dGame/dUtilities/EditMode.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include "eGameMasterLevel.h"
|
||||
|
||||
/**
|
||||
* Edit mode (docs/EditMode.md): a private instance of a zone whose world server constructs none of the zone's level
|
||||
* objects, spawners or triggers, for editing the zone in the game client. Only the plumbing is here; nothing starts
|
||||
* such an instance yet.
|
||||
*/
|
||||
namespace EditMode {
|
||||
// Whether an account may be in an edit mode instance
|
||||
inline bool MayEnter(const eGameMasterLevel accountLevel, const eGameMasterLevel requiredLevel) {
|
||||
return accountLevel != eGameMasterLevel::CIVILIAN && accountLevel >= requiredLevel;
|
||||
}
|
||||
|
||||
// The account GM level an edit mode instance lets in: editor_gm_level (9 unless set)
|
||||
eGameMasterLevel RequiredLevel();
|
||||
}
|
||||
Reference in New Issue
Block a user