diff --git a/Explorer/Assets/DCL/Browser/DecentralandUrls/DecentralandUrl.cs b/Explorer/Assets/DCL/Browser/DecentralandUrls/DecentralandUrl.cs index 63d0d08742..462fdff571 100644 --- a/Explorer/Assets/DCL/Browser/DecentralandUrls/DecentralandUrl.cs +++ b/Explorer/Assets/DCL/Browser/DecentralandUrls/DecentralandUrl.cs @@ -3,6 +3,7 @@ namespace DCL.Multiplayer.Connections.DecentralandUrls public enum DecentralandUrl { Host, + Genesis, ArchipelagoStatus, GatekeeperStatus, diff --git a/Explorer/Assets/DCL/Browser/DecentralandUrls/DecentralandUrlsSource.cs b/Explorer/Assets/DCL/Browser/DecentralandUrls/DecentralandUrlsSource.cs index cf81bc828c..a288611528 100644 --- a/Explorer/Assets/DCL/Browser/DecentralandUrls/DecentralandUrlsSource.cs +++ b/Explorer/Assets/DCL/Browser/DecentralandUrls/DecentralandUrlsSource.cs @@ -50,11 +50,12 @@ private static string RawUrl(DecentralandUrl decentralandUrl) => DecentralandUrl.Notification => $"https://notifications.decentraland.{ENV}/notifications", DecentralandUrl.NotificationRead => $"https://notifications.decentraland.{ENV}/notifications/read", DecentralandUrl.FeatureFlags => $"https://feature-flags.decentraland.{ENV}", - DecentralandUrl.Market => $"https://market.decentraland.org", - DecentralandUrl.AssetBundlesCDN => $"https://ab-cdn.decentraland.org", + DecentralandUrl.Market => "https://market.decentraland.org", + DecentralandUrl.AssetBundlesCDN => "https://ab-cdn.decentraland.org", DecentralandUrl.ArchipelagoStatus => $"https://archipelago-stats.decentraland.{ENV}/status", DecentralandUrl.GatekeeperStatus => $"https://comms-gatekeeper.decentraland.{ENV}/status", - _ => throw new ArgumentOutOfRangeException(nameof(decentralandUrl), decentralandUrl, null) + DecentralandUrl.Genesis => $"https://realm-provider-ea.decentraland.{ENV}/main", + _ => throw new ArgumentOutOfRangeException(nameof(decentralandUrl), decentralandUrl, null!) }; } } diff --git a/Explorer/Assets/Scripts/ECS/SceneLifeCycle/Realm/IRealmNavigator.cs b/Explorer/Assets/Scripts/ECS/SceneLifeCycle/Realm/IRealmNavigator.cs index 4ed80224a5..73b48662ab 100644 --- a/Explorer/Assets/Scripts/ECS/SceneLifeCycle/Realm/IRealmNavigator.cs +++ b/Explorer/Assets/Scripts/ECS/SceneLifeCycle/Realm/IRealmNavigator.cs @@ -9,7 +9,6 @@ namespace ECS.SceneLifeCycle.Realm { public interface IRealmNavigator { - public const string GENESIS_URL = "https://realm-provider.decentraland.org/main"; public const string WORLDS_DOMAIN = "https://worlds-content-server.decentraland.org/world"; public const string LOCALHOST = "http://127.0.0.1:8000"; diff --git a/Explorer/Assets/Scripts/Global/Dynamic/BootstrapContainer.cs b/Explorer/Assets/Scripts/Global/Dynamic/BootstrapContainer.cs index b042a98261..0c3e744be9 100644 --- a/Explorer/Assets/Scripts/Global/Dynamic/BootstrapContainer.cs +++ b/Explorer/Assets/Scripts/Global/Dynamic/BootstrapContainer.cs @@ -69,7 +69,7 @@ CancellationToken ct WebBrowser = browser, DebugSettings = debugSettings, CommandLineArgs = new CommandLineArgs(), - LocalSceneDevelopment = appParametersParser.LocalSceneDevelopment || launchSettings.GetStartingRealm() == IRealmNavigator.LOCALHOST, + LocalSceneDevelopment = appParametersParser.LocalSceneDevelopment || launchSettings.StartingRealmUrl(decentralandUrlsSource) == IRealmNavigator.LOCALHOST, }; await bootstrapContainer.InitializeContainerAsync(settingsContainer, ct, async container => @@ -91,7 +91,7 @@ await bootstrapContainer.InitializeContainerAsync appParameters = new (); + private readonly Dictionary appParameters = new (); public bool EnableAnalytics { private get; init; } - public Bootstrap(IDebugSettings debugSettings, ICommandLineArgs commandLineArgs) + public Bootstrap(IDebugSettings debugSettings, ICommandLineArgs commandLineArgs, IDecentralandUrlsSource decentralandUrlsSource) { this.debugSettings = debugSettings; + this.decentralandUrlsSource = decentralandUrlsSource; this.commandLineArgs = commandLineArgs; } @@ -53,7 +55,7 @@ public void PreInitializeSetup(RealmLaunchSettings launchSettings, UIDocument cu splashScreen.ShowSplash(); cursorRoot.EnsureNotNull(); - startingRealm = URLDomain.FromString(launchSettings.GetStartingRealm()); + startingRealm = URLDomain.FromString(launchSettings.StartingRealmUrl(decentralandUrlsSource)); startingParcel = launchSettings.TargetScene; // Hides the debug UI during the initial flow @@ -110,7 +112,7 @@ CancellationToken ct EnableLandscape = debugSettings.EnableLandscape && !bootstrapContainer.LocalSceneDevelopment, EnableLOD = debugSettings.EnableLOD && !bootstrapContainer.LocalSceneDevelopment, EnableAnalytics = EnableAnalytics, HybridSceneParams = launchSettings.CreateHybridSceneParams(startingParcel), - LocalSceneDevelopmentRealm = bootstrapContainer.LocalSceneDevelopment ? launchSettings.GetStartingRealm() : string.Empty, + LocalSceneDevelopmentRealm = bootstrapContainer.LocalSceneDevelopment ? launchSettings.StartingRealmUrl(decentralandUrlsSource) : string.Empty, AppParameters = appParameters, }, backgroundMusic, @@ -175,7 +177,10 @@ UIDocument debugUiRoot public async UniTask LoadStartingRealmAsync(DynamicWorldContainer dynamicWorldContainer, CancellationToken ct) { - await dynamicWorldContainer.RealmController.SetRealmAsync(startingRealm, ct); + if (startingRealm.HasValue == false) + throw new InvalidOperationException("Starting realm is not set"); + + await dynamicWorldContainer.RealmController.SetRealmAsync(startingRealm.Value, ct); } public async UniTask UserInitializationAsync(DynamicWorldContainer dynamicWorldContainer, diff --git a/Explorer/Assets/Scripts/Global/Dynamic/ChatCommands/ChangeRealmChatCommand.cs b/Explorer/Assets/Scripts/Global/Dynamic/ChatCommands/ChangeRealmChatCommand.cs index da6dda63bc..c2a404a1a4 100644 --- a/Explorer/Assets/Scripts/Global/Dynamic/ChatCommands/ChangeRealmChatCommand.cs +++ b/Explorer/Assets/Scripts/Global/Dynamic/ChatCommands/ChangeRealmChatCommand.cs @@ -1,6 +1,7 @@ using CommunicationData.URLHelpers; using Cysharp.Threading.Tasks; using DCL.Chat.Commands; +using DCL.Multiplayer.Connections.DecentralandUrls; using ECS.SceneLifeCycle.Realm; using System.Collections.Generic; using System.Text.RegularExpressions; @@ -24,15 +25,7 @@ public class ChangeRealmChatCommand : IChatCommand private const string WORLD_SUFFIX = ".dcl.eth"; // Parameters to URL mapping - private static readonly Dictionary PARAM_URLS = new () - { - { "genesis", IRealmNavigator.GENESIS_URL }, - { "goerli", IRealmNavigator.GOERLI_URL }, - { "goerli-old", IRealmNavigator.GOERLI_OLD_URL }, - { "stream", IRealmNavigator.STREAM_WORLD_URL }, - { "sdk", IRealmNavigator.SDK_TEST_SCENES_URL }, - { "test", IRealmNavigator.TEST_SCENES_URL }, - }; + private readonly Dictionary paramUrls; public static readonly Regex REGEX = new ($@"^/({COMMAND_WORLD}|{COMMAND_GOTO})\s+((?!-?\d+\s*,\s*-?\d+$).+?)(?:\s+(-?\d+)\s*,\s*(-?\d+))?$", RegexOptions.Compiled); private readonly URLDomain worldDomain = URLDomain.FromString(IRealmNavigator.WORLDS_DOMAIN); @@ -43,16 +36,26 @@ public class ChangeRealmChatCommand : IChatCommand private string? worldName; private string? realmUrl; - public ChangeRealmChatCommand(IRealmNavigator realmNavigator) + public ChangeRealmChatCommand(IRealmNavigator realmNavigator, IDecentralandUrlsSource decentralandUrlsSource) { this.realmNavigator = realmNavigator; + + paramUrls = new Dictionary + { + { "genesis", decentralandUrlsSource.Url(DecentralandUrl.Genesis) }, + { "goerli", IRealmNavigator.GOERLI_URL }, + { "goerli-old", IRealmNavigator.GOERLI_OLD_URL }, + { "stream", IRealmNavigator.STREAM_WORLD_URL }, + { "sdk", IRealmNavigator.SDK_TEST_SCENES_URL }, + { "test", IRealmNavigator.TEST_SCENES_URL }, + }; } public async UniTask ExecuteAsync(Match match, CancellationToken ct) { worldName = match.Groups[2].Value; - if (!PARAM_URLS.TryGetValue(worldName, out realmUrl)) + if (!paramUrls.TryGetValue(worldName, out realmUrl)) { if (!worldName.EndsWith(WORLD_SUFFIX)) worldName += WORLD_SUFFIX; @@ -63,6 +66,7 @@ public async UniTask ExecuteAsync(Match match, CancellationToken ct) var realm = URLDomain.FromString(realmUrl!); Vector2Int parcel = default; + if (match.Groups[3].Success && match.Groups[4].Success) parcel = new Vector2Int(int.Parse(match.Groups[3].Value), int.Parse(match.Groups[4].Value)); diff --git a/Explorer/Assets/Scripts/Global/Dynamic/DynamicWorldContainer.cs b/Explorer/Assets/Scripts/Global/Dynamic/DynamicWorldContainer.cs index b0baacd346..71adebe38a 100644 --- a/Explorer/Assets/Scripts/Global/Dynamic/DynamicWorldContainer.cs +++ b/Explorer/Assets/Scripts/Global/Dynamic/DynamicWorldContainer.cs @@ -312,6 +312,7 @@ async UniTask InitializeContainersAsync(IPluginSettingsContainer settingsContain parcelServiceContainer.TeleportController, container.RoomHub, remoteEntities, + bootstrapContainer.DecentralandUrlsSource, staticContainer.GlobalWorldProxy, container.LODContainer.RoadPlugin, genesisTerrain, @@ -369,7 +370,7 @@ async UniTask InitializeContainersAsync(IPluginSettingsContainer settingsContain var chatCommandsFactory = new Dictionary> { { GoToChatCommand.REGEX, () => new GoToChatCommand(realmNavigator) }, - { ChangeRealmChatCommand.REGEX, () => new ChangeRealmChatCommand(realmNavigator) }, + { ChangeRealmChatCommand.REGEX, () => new ChangeRealmChatCommand(realmNavigator, bootstrapContainer.DecentralandUrlsSource) }, { DebugPanelChatCommand.REGEX, () => new DebugPanelChatCommand(debugBuilder) }, { ShowEntityInfoChatCommand.REGEX, () => new ShowEntityInfoChatCommand(worldInfoHub) }, { ClearChatCommand.REGEX, () => new ClearChatCommand(chatHistory) }, diff --git a/Explorer/Assets/Scripts/Global/Dynamic/RealmLaunchSettings.cs b/Explorer/Assets/Scripts/Global/Dynamic/RealmLaunchSettings.cs index 1dffc9f48f..f188e1ad84 100644 --- a/Explorer/Assets/Scripts/Global/Dynamic/RealmLaunchSettings.cs +++ b/Explorer/Assets/Scripts/Global/Dynamic/RealmLaunchSettings.cs @@ -1,4 +1,5 @@ -using ECS.SceneLifeCycle.Realm; +using DCL.Multiplayer.Connections.DecentralandUrls; +using ECS.SceneLifeCycle.Realm; using System; using System.Collections.Generic; using System.Linq; @@ -46,11 +47,11 @@ public HybridSceneParams CreateHybridSceneParams(Vector2Int startParcel) return new HybridSceneParams(); } - public string GetStartingRealm() + public string StartingRealmUrl(IDecentralandUrlsSource decentralandUrlsSource) { return initialRealm switch { - InitialRealm.GenesisCity => IRealmNavigator.GENESIS_URL, + InitialRealm.GenesisCity => decentralandUrlsSource.Url(DecentralandUrl.Genesis), InitialRealm.SDK => IRealmNavigator.SDK_TEST_SCENES_URL, InitialRealm.Goerli => IRealmNavigator.GOERLI_URL, InitialRealm.StreamingWorld => IRealmNavigator.STREAM_WORLD_URL, @@ -58,7 +59,7 @@ public string GetStartingRealm() InitialRealm.World => IRealmNavigator.WORLDS_DOMAIN + "/" + targetWorld, InitialRealm.Localhost => IRealmNavigator.LOCALHOST, InitialRealm.Custom => customRealm, - _ => IRealmNavigator.GENESIS_URL, + _ => decentralandUrlsSource.Url(DecentralandUrl.Genesis), }; } diff --git a/Explorer/Assets/Scripts/Global/Dynamic/RealmNavigator.cs b/Explorer/Assets/Scripts/Global/Dynamic/RealmNavigator.cs index 5b7793216a..540bf18802 100644 --- a/Explorer/Assets/Scripts/Global/Dynamic/RealmNavigator.cs +++ b/Explorer/Assets/Scripts/Global/Dynamic/RealmNavigator.cs @@ -6,6 +6,7 @@ using DCL.Landscape; using DCL.MapRenderer; using DCL.MapRenderer.MapLayers; +using DCL.Multiplayer.Connections.DecentralandUrls; using DCL.Multiplayer.Connections.RoomHubs; using DCL.Multiplayer.Profiles.Entities; using DCL.ParcelsService; @@ -33,14 +34,13 @@ namespace Global.Dynamic { public class RealmNavigator : IRealmNavigator { - private readonly URLDomain genesisDomain = URLDomain.FromString(IRealmNavigator.GENESIS_URL); - private readonly ILoadingScreen loadingScreen; private readonly IMapRenderer mapRenderer; private readonly IGlobalRealmController realmController; private readonly ITeleportController teleportController; private readonly IRoomHub roomHub; private readonly IRemoteEntities remoteEntities; + private readonly IDecentralandUrlsSource decentralandUrlsSource; private readonly ObjectProxy globalWorldProxy; private readonly RoadPlugin roadsPlugin; private readonly TerrainGenerator genesisTerrain; @@ -62,6 +62,7 @@ public RealmNavigator( ITeleportController teleportController, IRoomHub roomHub, IRemoteEntities remoteEntities, + IDecentralandUrlsSource decentralandUrlsSource, ObjectProxy globalWorldProxy, RoadPlugin roadsPlugin, TerrainGenerator genesisTerrain, @@ -84,6 +85,7 @@ public RealmNavigator( this.cameraSamplingData = cameraSamplingData; this.roomHub = roomHub; this.remoteEntities = remoteEntities; + this.decentralandUrlsSource = decentralandUrlsSource; this.globalWorldProxy = globalWorldProxy; } @@ -168,9 +170,12 @@ public async UniTask TryInitializeTeleportToParcelAsync(Vector2Int parcel, Cance { bool isGenesis = !realmController.RealmData.ScenesAreFixed; - if (!isLocal && !isGenesis) { await TryChangeRealmAsync(genesisDomain, ct, parcel); } - else + if (!isLocal && !isGenesis) { + var url = URLDomain.FromString(decentralandUrlsSource.Url(DecentralandUrl.Genesis)); + await TryChangeRealmAsync(url, ct, parcel); + } + else await loadingScreen.ShowWhileExecuteTaskAsync(async parentLoadReport => { ct.ThrowIfCancellationRequested(); @@ -184,7 +189,6 @@ await loadingScreen.ShowWhileExecuteTaskAsync(async parentLoadReport => parentLoadReport.SetProgress(RealFlowLoadingStatus.PROGRESS[Completed]); }, ct); - } } catch (TimeoutException) { } }