From 137c28e789a40dc3842ea5f658317b8219fe933f Mon Sep 17 00:00:00 2001 From: Nathan Flurry Date: Mon, 7 Oct 2024 03:14:35 -0700 Subject: [PATCH] fix: expose backend endpoint and game version to local game server via env --- Assets/Rivet/Editor/RivetGlobal.cs | 3 - Assets/Rivet/Editor/TaskManager.cs | 13 +--- Assets/Rivet/Editor/UI/Dock/Dock.cs | 26 ++++---- Assets/Rivet/Editor/UI/Dock/Tabs/Develop.uxml | 1 + .../Editor/UI/Dock/Tabs/DevelopController.cs | 60 +++++++++++++---- Assets/Rivet/Editor/Util/Builder.cs | 64 +++++++++++++------ Assets/Scripts/MultiplayerManager.cs | 12 +++- 7 files changed, 117 insertions(+), 62 deletions(-) diff --git a/Assets/Rivet/Editor/RivetGlobal.cs b/Assets/Rivet/Editor/RivetGlobal.cs index 5d49391..f338877 100644 --- a/Assets/Rivet/Editor/RivetGlobal.cs +++ b/Assets/Rivet/Editor/RivetGlobal.cs @@ -205,9 +205,6 @@ public string CurrentBuildSlug } } - // MARK: Local Game Server - public string? LocalGameServerExecutablePath; - // MARK: Bootstrap public async Task Bootstrap() { diff --git a/Assets/Rivet/Editor/TaskManager.cs b/Assets/Rivet/Editor/TaskManager.cs index 61ceef3..6340704 100644 --- a/Assets/Rivet/Editor/TaskManager.cs +++ b/Assets/Rivet/Editor/TaskManager.cs @@ -192,15 +192,11 @@ private void OnTaskLog(string message, RivetTask.LogType type) RivetTask.LogType.STDERR => LogType.STDERR, _ => LogType.META }; - + // Strip [stdout] and [stderr] prefixes message = StripLogPrefix(message); - // Filter out Unity stack traces - if (!IsUnityStackTrace(message)) - { - AddLogLine(message, logType); - } + AddLogLine(message, logType); } private string StripLogPrefix(string message) @@ -216,11 +212,6 @@ private string StripLogPrefix(string message) return message; } - private bool IsUnityStackTrace(string message) - { - return (message.Contains(" (at ") && message.EndsWith(")")) || message.StartsWith("UnityEngine."); - } - public void AddLogLine(string message, LogType type) { LogEntries.Add(new LogEntry(message, type)); diff --git a/Assets/Rivet/Editor/UI/Dock/Dock.cs b/Assets/Rivet/Editor/UI/Dock/Dock.cs index 448640d..dc45c87 100644 --- a/Assets/Rivet/Editor/UI/Dock/Dock.cs +++ b/Assets/Rivet/Editor/UI/Dock/Dock.cs @@ -130,24 +130,20 @@ public void OnEnable() initMessage: "Open \"Develop\" and press \"Start\" to start game server.", getStartConfig: () => { - if (plugin.LocalGameServerExecutablePath != null) + return Task.FromResult(new TaskConfig { - return Task.FromResult(new TaskConfig + Name = "game_server.start", + Input = new JObject { - Name = "game_server.start", - Input = new JObject - { - ["cwd"] = Builder.ProjectRoot(), - ["cmd"] = plugin.LocalGameServerExecutablePath, - ["args"] = new JArray { "-batchmode", "-nographics", "-server" }, + ["cwd"] = Builder.ProjectRoot(), + ["cmd"] = Builder.GetDevDedicatedServerExecutablePath(), + ["args"] = new JArray { "-batchmode", "-nographics", "-server" }, + ["envs"] = new JObject { + ["BACKEND_ENDPOINT"] = SharedSettings.BackendEndpoint, + ["GAME_VERSION"] = SharedSettings.GameVersion, } - }); - } - else - { - RivetLogger.Warning("LocalGameServerManager.Start: no local game server executable path"); - return null; - } + } + }); }, getStopConfig: () => { diff --git a/Assets/Rivet/Editor/UI/Dock/Tabs/Develop.uxml b/Assets/Rivet/Editor/UI/Dock/Tabs/Develop.uxml index b332cc5..014528b 100644 --- a/Assets/Rivet/Editor/UI/Dock/Tabs/Develop.uxml +++ b/Assets/Rivet/Editor/UI/Dock/Tabs/Develop.uxml @@ -18,6 +18,7 @@ + diff --git a/Assets/Rivet/Editor/UI/Dock/Tabs/DevelopController.cs b/Assets/Rivet/Editor/UI/Dock/Tabs/DevelopController.cs index f5a1fd7..1aa5c11 100644 --- a/Assets/Rivet/Editor/UI/Dock/Tabs/DevelopController.cs +++ b/Assets/Rivet/Editor/UI/Dock/Tabs/DevelopController.cs @@ -31,6 +31,7 @@ public class DevelopController private DropdownField _remoteEnvironmentDropdown; private DropdownField _playTypeDropdown; + private DropdownField _playStepsDropdown; private SliderInt _playerCount; private Button _lgsStart; private Button _lgsStop; @@ -59,6 +60,7 @@ void InitUI() _remoteEnvironmentDropdown = _root.Q("EnvironmentBody").Q("EnvironmentDropdown"); _playTypeDropdown = _root.Q("PlayBody").Q("TypeDropdown"); + _playStepsDropdown = _root.Q("PlayBody").Q("StepsDropdown"); _playerCount = _root.Q("PlayBody").Q("PlayerCountSlider"); _lgsStart = _root.Q("PlayBody").Q("ButtonRow").Q("StartButton").Q