From 9265e97c59391cf3693f360a5fd842e70eb9c4dd Mon Sep 17 00:00:00 2001 From: Anton Tarasenko Date: Mon, 13 Mar 2023 18:42:30 +0700 Subject: [PATCH] Move `CommandAPI` into base API --- .../Commands/BuiltInCommands/ACommandHelp.uc | 0 .../API}/Commands/Command.uc | 0 .../API}/Commands/CommandAPI.uc | 0 .../API}/Commands/CommandDataBuilder.uc | 0 .../API}/Commands/CommandParser.uc | 0 .../API}/Commands/Commands.uc | 0 .../API}/Commands/Commands_Feature.uc | 22 ++++++++++++------- .../API}/Commands/PlayersParser.uc | 0 .../API}/Commands/Tests/MockCommandA.uc | 0 .../API}/Commands/Tests/MockCommandB.uc | 0 .../API}/Commands/Tests/TEST_Command.uc | 0 .../Commands/Tests/TEST_CommandDataBuilder.uc | 0 12 files changed, 14 insertions(+), 8 deletions(-) rename sources/{LevelAPI/Features => BaseAPI/API}/Commands/BuiltInCommands/ACommandHelp.uc (100%) rename sources/{LevelAPI/Features => BaseAPI/API}/Commands/Command.uc (100%) rename sources/{LevelAPI/Features => BaseAPI/API}/Commands/CommandAPI.uc (100%) rename sources/{LevelAPI/Features => BaseAPI/API}/Commands/CommandDataBuilder.uc (100%) rename sources/{LevelAPI/Features => BaseAPI/API}/Commands/CommandParser.uc (100%) rename sources/{LevelAPI/Features => BaseAPI/API}/Commands/Commands.uc (100%) rename sources/{LevelAPI/Features => BaseAPI/API}/Commands/Commands_Feature.uc (96%) rename sources/{LevelAPI/Features => BaseAPI/API}/Commands/PlayersParser.uc (100%) rename sources/{LevelAPI/Features => BaseAPI/API}/Commands/Tests/MockCommandA.uc (100%) rename sources/{LevelAPI/Features => BaseAPI/API}/Commands/Tests/MockCommandB.uc (100%) rename sources/{LevelAPI/Features => BaseAPI/API}/Commands/Tests/TEST_Command.uc (100%) rename sources/{LevelAPI/Features => BaseAPI/API}/Commands/Tests/TEST_CommandDataBuilder.uc (100%) diff --git a/sources/LevelAPI/Features/Commands/BuiltInCommands/ACommandHelp.uc b/sources/BaseAPI/API/Commands/BuiltInCommands/ACommandHelp.uc similarity index 100% rename from sources/LevelAPI/Features/Commands/BuiltInCommands/ACommandHelp.uc rename to sources/BaseAPI/API/Commands/BuiltInCommands/ACommandHelp.uc diff --git a/sources/LevelAPI/Features/Commands/Command.uc b/sources/BaseAPI/API/Commands/Command.uc similarity index 100% rename from sources/LevelAPI/Features/Commands/Command.uc rename to sources/BaseAPI/API/Commands/Command.uc diff --git a/sources/LevelAPI/Features/Commands/CommandAPI.uc b/sources/BaseAPI/API/Commands/CommandAPI.uc similarity index 100% rename from sources/LevelAPI/Features/Commands/CommandAPI.uc rename to sources/BaseAPI/API/Commands/CommandAPI.uc diff --git a/sources/LevelAPI/Features/Commands/CommandDataBuilder.uc b/sources/BaseAPI/API/Commands/CommandDataBuilder.uc similarity index 100% rename from sources/LevelAPI/Features/Commands/CommandDataBuilder.uc rename to sources/BaseAPI/API/Commands/CommandDataBuilder.uc diff --git a/sources/LevelAPI/Features/Commands/CommandParser.uc b/sources/BaseAPI/API/Commands/CommandParser.uc similarity index 100% rename from sources/LevelAPI/Features/Commands/CommandParser.uc rename to sources/BaseAPI/API/Commands/CommandParser.uc diff --git a/sources/LevelAPI/Features/Commands/Commands.uc b/sources/BaseAPI/API/Commands/Commands.uc similarity index 100% rename from sources/LevelAPI/Features/Commands/Commands.uc rename to sources/BaseAPI/API/Commands/Commands.uc diff --git a/sources/LevelAPI/Features/Commands/Commands_Feature.uc b/sources/BaseAPI/API/Commands/Commands_Feature.uc similarity index 96% rename from sources/LevelAPI/Features/Commands/Commands_Feature.uc rename to sources/BaseAPI/API/Commands/Commands_Feature.uc index 30c0ec3..f02ae16 100644 --- a/sources/LevelAPI/Features/Commands/Commands_Feature.uc +++ b/sources/BaseAPI/API/Commands/Commands_Feature.uc @@ -73,7 +73,7 @@ var private /*config*/ bool useMutateInput; // Default is "!". Empty values are also treated as "!". var private /*config*/ Text chatCommandPrefix; -var LoggerAPI.Definition errCommandDuplicate; +var LoggerAPI.Definition errCommandDuplicate, errServerAPIUnavailable; protected function OnEnabled() { registeredCommands = _.collections.EmptyHashTable(); @@ -95,10 +95,11 @@ protected function OnEnabled() { _.chat.OnMessage(self).Disconnect(); } if (useMutateInput || emergencyEnabledMutate) { - _server.unreal.mutator.OnMutate(self).connect = HandleMutate; - } - else { - _server.unreal.mutator.OnMutate(self).Disconnect(); + if (__server() != none) { + __server().unreal.mutator.OnMutate(self).connect = HandleMutate; + } else { + _.logger.Auto(errServerAPIUnavailable); + } } } @@ -106,8 +107,8 @@ protected function OnDisabled() { if (useChatInput) { _.chat.OnMessage(self).Disconnect(); } - if (useMutateInput) { - _server.unreal.mutator.OnMutate(self).Disconnect(); + if (useMutateInput && __server() != none) { + __server().unreal.mutator.OnMutate(self).Disconnect(); } useChatInput = false; useMutateInput = false; @@ -244,7 +245,11 @@ public final static function EmergencyEnable() { if (noWayToInputCommands) { default.emergencyEnabledMutate = true; feature.emergencyEnabledMutate = true; - __server().unreal.mutator.OnMutate(feature).connect = HandleMutate; + if (__server() != none) { + __server().unreal.mutator.OnMutate(feature).connect = HandleMutate; + } else { + __().logger.Auto(default.errServerAPIUnavailable); + } } } @@ -503,4 +508,5 @@ public final function bool HandleInputWith(Parser parser, EPlayer callerPlayer) defaultproperties { configClass = class'Commands' errCommandDuplicate = (l=LOG_Error,m="Command `%1` is already registered with name '%2'. Command `%3` with the same name will be ignored.") + errServerAPIUnavailable = (l=LOG_Error,m="Server API is currently unavailable. Input methods through chat and mutate command will not be available.") } \ No newline at end of file diff --git a/sources/LevelAPI/Features/Commands/PlayersParser.uc b/sources/BaseAPI/API/Commands/PlayersParser.uc similarity index 100% rename from sources/LevelAPI/Features/Commands/PlayersParser.uc rename to sources/BaseAPI/API/Commands/PlayersParser.uc diff --git a/sources/LevelAPI/Features/Commands/Tests/MockCommandA.uc b/sources/BaseAPI/API/Commands/Tests/MockCommandA.uc similarity index 100% rename from sources/LevelAPI/Features/Commands/Tests/MockCommandA.uc rename to sources/BaseAPI/API/Commands/Tests/MockCommandA.uc diff --git a/sources/LevelAPI/Features/Commands/Tests/MockCommandB.uc b/sources/BaseAPI/API/Commands/Tests/MockCommandB.uc similarity index 100% rename from sources/LevelAPI/Features/Commands/Tests/MockCommandB.uc rename to sources/BaseAPI/API/Commands/Tests/MockCommandB.uc diff --git a/sources/LevelAPI/Features/Commands/Tests/TEST_Command.uc b/sources/BaseAPI/API/Commands/Tests/TEST_Command.uc similarity index 100% rename from sources/LevelAPI/Features/Commands/Tests/TEST_Command.uc rename to sources/BaseAPI/API/Commands/Tests/TEST_Command.uc diff --git a/sources/LevelAPI/Features/Commands/Tests/TEST_CommandDataBuilder.uc b/sources/BaseAPI/API/Commands/Tests/TEST_CommandDataBuilder.uc similarity index 100% rename from sources/LevelAPI/Features/Commands/Tests/TEST_CommandDataBuilder.uc rename to sources/BaseAPI/API/Commands/Tests/TEST_CommandDataBuilder.uc