diff --git a/sources/Aliases/AliasSource.uc b/sources/Aliases/AliasSource.uc index 1d6b542..b97bc46 100644 --- a/sources/Aliases/AliasSource.uc +++ b/sources/Aliases/AliasSource.uc @@ -68,6 +68,13 @@ protected function OnCreated() HashValidAliasesFromPerObjectConfig(); } +protected function OnDestroyed() +{ + loadedAliasObjects.length = 0; + _.memory.Free(aliasHash); + aliasHash = none; +} + // Ensures that our `Aliases` class is properly linked with this // source's class. Logs failure otherwise. private final function bool AssertAliasesClassIsOwnedByThisSource() diff --git a/sources/Commands/BroadcastListener_Commands.uc b/sources/Commands/BroadcastListener_Commands.uc deleted file mode 100644 index 458d514..0000000 --- a/sources/Commands/BroadcastListener_Commands.uc +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Overloaded broadcast events listener to catch commands input from - * the in-game chat. - * Copyright 2020 - 2021 Anton Tarasenko - *------------------------------------------------------------------------------ - * This file is part of Acedia. - * - * Acedia is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, version 3 of the License, or - * (at your option) any later version. - * - * Acedia is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Acedia. If not, see . - */ -class BroadcastListener_Commands extends BroadcastListenerBase - abstract; - -// TODO: reimplement with even to provide `APlayer` in the first place -static function bool HandleText( - Actor sender, - out string message, - optional name messageType) -{ - local Text messageAsText; - local APlayer callerPlayer; - local Parser parser; - local Commands_Feature commandFeature; - local PlayerService service; - // We only want to catch chat messages - // and only if `Commands` feature is active - if (messageType != 'Say') return true; - commandFeature = - Commands_Feature(class'Commands_Feature'.static.GetInstance()); - if (commandFeature == none) return true; - if (!commandFeature.UsingChatInput()) return true; - // We are only interested in messages that start with "!" - parser = __().text.ParseString(message); - if (!parser.Match(P("!")).Ok()) - { - parser.FreeSelf(); - // Convert color tags into colors - messageAsText = __().text.FromFormattedString(message); - message = messageAsText.ToColoredString(,, __().color.White); - messageAsText.FreeSelf(); - return true; - } - // Extract `APlayer` from the `sender` - service = PlayerService(class'PlayerService'.static.Require()); - if (service != none) { - callerPlayer = service.GetPlayer(PlayerController(sender)); - } - // Pass input to command feature - commandFeature.HandleInput(parser, callerPlayer); - parser.FreeSelf(); - return false; -} - -defaultproperties -{ -} \ No newline at end of file diff --git a/sources/Commands/BuiltInCommands/ACommandTest.uc b/sources/Commands/BuiltInCommands/ACommandTest.uc new file mode 100644 index 0000000..731d232 --- /dev/null +++ b/sources/Commands/BuiltInCommands/ACommandTest.uc @@ -0,0 +1,72 @@ +/** + * Command for changing nickname of the player. + * Copyright 2021 Anton Tarasenko + *------------------------------------------------------------------------------ + * This file is part of Acedia. + * + * Acedia is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3 of the License, or + * (at your option) any later version. + * + * Acedia is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Acedia. If not, see . + */ +class ACommandTest extends Command; + +protected function BuildData(CommandDataBuilder builder) +{ + builder.Name(P("test")).Summary(P("Tests various stuff. Simply call it.")) + .OptionalParams() + .ParamText(P("option")); +} + +protected function Executed(CommandCall result) +{ + local Parser parser; + local AssociativeArray root; + /*local int i; + local WeaponLocker lol; + local array aaa; + local Text message; + local Timer testTimer; + message = _.text.FromString("Is lobby?" @ _.kf.IsInLobby() @ + "Is pre game?" @ _.kf.IsInPreGame() @ + "Is trader?" @ _.kf.IsTraderActive() @ + "Is wave?" @ _.kf.IsWaveActive() @ + "Is finished?" @ _.kf.IsGameFinished() @ + "Is wipe?" @ _.kf.IsWipe()); + _.console.ForAll().WriteLine(message); + testTimer = Timer(_.memory.Allocate(class'Timer')); + testTimer.SetInterval(result.GetParameters().GetInt(P("add"))); + testTimer.Start(); + testTimer.OnElapsed(self).connect = OnTick; + testTimer.SetAutoReset(true); + for (i = 0; i < 100; i += 1) { + class'WeaponLocker'.default.bCollideWorld = false; + class'WeaponLocker'.default.bBlockActors = false; + lol = WeaponLocker(_.memory.Allocate(class'WeaponLocker')); + aaa[i] = lol; + Log("HUH" @ lol.Destroy()); + class'WeaponLocker'.default.bCollideWorld = true; + class'WeaponLocker'.default.bBlockActors = true; + } + for (i = 0; i < 100; i += 1) { + if (aaa[i] != none) + { + Log("UMBRA" @ aaa[i]); + } + }*/ + parser = _.text.ParseString("{\"innerObject\":{\"my_bool\":true,\"array\":[\"Engine.Actor\",false,null,{\"something \\\"here\\\"\":\"yes\",\"maybe\":0.003},56.6],\"one more\":{\"nope\":324532,\"whatever\":false,\"o rly?\":\"ya rly\"},\"my_int\":-9823452},\"some_var\":-7.32,\"another_var\":\"aye!\"}"); + root = _.json.ParseObjectWith(parser); + result.GetCallerPlayer().Console().WriteLine(_.json.PrettyPrint(root)); +} + +defaultproperties +{ +} \ No newline at end of file diff --git a/sources/Commands/Command.uc b/sources/Commands/Command.uc index 9d3fd1b..80a805b 100644 --- a/sources/Commands/Command.uc +++ b/sources/Commands/Command.uc @@ -165,6 +165,47 @@ protected function Constructor() dataBuilder = none; } +protected function Finalizer() +{ + local int i; + local array subCommands; + local array