diff --git a/.github/workflows/client-build.yml b/.github/workflows/client-build.yml deleted file mode 100644 index 66c59b350..000000000 --- a/.github/workflows/client-build.yml +++ /dev/null @@ -1,131 +0,0 @@ -### -### Copyright (c) 2023 Carbon Community -### All rights reserved -### -name: Client Build -concurrency: build-carbon-client - -on: - workflow_dispatch: - -jobs: - bootstrap: - name: πŸ₯Ύ Bootstrap - runs-on: ubuntu-latest - - outputs: - date: ${{ steps.step1.outputs.date }} - clock: ${{ steps.step1.outputs.clock }} - tag: ${{ steps.step1.outputs.tag }} - ref: ${{ steps.step1.outputs.ref }} - version: ${{ steps.step1.outputs.version }} - - steps: - #- name: Log environment - # uses: crazy-max/ghaction-dump-context@v1 - - - name: πŸ”— Checkout source code from github - uses: actions/checkout@v3 - - - name: πŸ“… Prepare the environment - id: step1 - run: | - echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT - echo "clock=$(date +'%H:%M:%S')" >> $GITHUB_OUTPUT - echo "tag=$(date +'%Yd%j')" >> $GITHUB_OUTPUT - echo "ref=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT - echo "version=2.8.$(curl -s -L 'https://carbonmod.gg/version?id=client&token=${{secrets.VERSIONS_TOKEN}}')" >> $GITHUB_OUTPUT - - # BUILD WINDOWS -------------------------------------------------------------- - build-windows: - name: πŸ’» Windows - needs: bootstrap - runs-on: windows-latest - continue-on-error: false - - steps: - - name: πŸ”— Checkout source code from github - uses: actions/checkout@v3 - with: - token: ${{ secrets.PAT_ALL_REPO }} - submodules: recursive - - - name: πŸ›€οΈ Setup the dotnet build environment - uses: actions/setup-dotnet@v2 - with: - dotnet-version: 7.0.x - - - name: πŸ”¨ Built Carbon Client on Windows - shell: cmd - run: | - set VERSION=${{ needs.bootstrap.outputs.version }} - cd %GITHUB_WORKSPACE%\Tools\Build\win - call %GITHUB_WORKSPACE%\Tools\Build\win\build_client_debug.bat Debug - call %GITHUB_WORKSPACE%\Tools\Build\win\build_client_debug.bat Release - - - name: ⬆️ Upload the artifacts - uses: actions/upload-artifact@v3 - with: - name: build-develop-windows - path: | - Release/Carbon.Client.Debug.info - Release/Carbon.Client.Debug.zip - Release/Carbon.Client.Release.info - Release/Carbon.Client.Release.zip - - # RELEASE -------------------------------------------------------------------- - release-on-commit: - name: πŸ’Ύ Client Release - needs: [ "bootstrap", "build-windows" ] - runs-on: ubuntu-latest - - steps: - - name: πŸ—‘οΈ Delete existing release tag - uses: dev-drprasad/delete-tag-and-release@92d94d77429cb0436597047a92369526a5824f50 - with: - delete_release: true - tag_name: client_build - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: πŸ’€ Sleep for 5 seconds - run: sleep 5s - shell: bash - - - name: ⬇️ Download artifacts - uses: actions/download-artifact@v3 - with: - path: Release - - - name: Display structure of downloaded files - run: ls -R - working-directory: Release - - - name: 🏷️ Update release tag - uses: softprops/action-gh-release@d4e8205d7e959a9107da6396278b2f1f07af0f9b - with: - draft: false - prerelease: true - tag_name: client_build - name: 'Client Build β€” v${{ needs.bootstrap.outputs.version }}' - body: | - Carbon 4 client (or "C4C") is a sub-project which allows extended communication between Carbon servers and clients running C4C. - It allows developers to load up various features and content server and client-side. - - Read [more] info about how to get started. - - ### How to install - 1. Download the `Carbon.Client.Release.zip` archive from the attachments below. - 2. Unzip the archive to the root of your Rust Client. - 3. Launch RustClient.exe (and not through Steam or Rust.exe, as EAC must be disabled). - - ### How to uninstall - 1. Move or remove the `winhttp.dll` from the root of your Rust client. - 2. Launch Rust through Steam or with EAC as usual. C4C is completely disabled. - - ${{ needs.build-linux.outputs.build_info }} - - [more]: https://docs.carbonmod.gg/docs/carbon-client/getting-started - files: | - Release/build-develop-windows/Carbon.Client.Release.info - Release/build-develop-windows/Carbon.Client.Release.zip diff --git a/Carbon.Core/Carbon.Components/Carbon.Bootstrap b/Carbon.Core/Carbon.Components/Carbon.Bootstrap index 10b815b52..7d2a14369 160000 --- a/Carbon.Core/Carbon.Components/Carbon.Bootstrap +++ b/Carbon.Core/Carbon.Components/Carbon.Bootstrap @@ -1 +1 @@ -Subproject commit 10b815b52125da9eb433df0b5ed7f3cd46693c0d +Subproject commit 7d2a1436948a706bc072b5a669b29bf5a2bf800a diff --git a/Carbon.Core/Carbon.Components/Carbon.Common b/Carbon.Core/Carbon.Components/Carbon.Common index c6ee2f75e..e289b2108 160000 --- a/Carbon.Core/Carbon.Components/Carbon.Common +++ b/Carbon.Core/Carbon.Components/Carbon.Common @@ -1 +1 @@ -Subproject commit c6ee2f75e206d3cb0630383e57faf0ab0baeef86 +Subproject commit e289b2108c7df747bc2658920da582605aed11fc diff --git a/Carbon.Core/Carbon.Components/Carbon.Compat b/Carbon.Core/Carbon.Components/Carbon.Compat index adb23f4a4..2b6a15a0d 160000 --- a/Carbon.Core/Carbon.Components/Carbon.Compat +++ b/Carbon.Core/Carbon.Components/Carbon.Compat @@ -1 +1 @@ -Subproject commit adb23f4a4deda6e80dc7219410e2062bfaa1a579 +Subproject commit 2b6a15a0d034f0d8f30325ef7ed544fe9a48f141 diff --git a/Carbon.Core/Carbon.Components/Carbon.SDK b/Carbon.Core/Carbon.Components/Carbon.SDK index 8900abe0f..686b82334 160000 --- a/Carbon.Core/Carbon.Components/Carbon.SDK +++ b/Carbon.Core/Carbon.Components/Carbon.SDK @@ -1 +1 @@ -Subproject commit 8900abe0f1c8689d55985b5e354e798c47f552ad +Subproject commit 686b823344bdc11a556617711ff3e42e38ee14b5 diff --git a/Carbon.Core/Carbon.Components/Carbon.Test b/Carbon.Core/Carbon.Components/Carbon.Test index 9053d9711..071e99372 160000 --- a/Carbon.Core/Carbon.Components/Carbon.Test +++ b/Carbon.Core/Carbon.Components/Carbon.Test @@ -1 +1 @@ -Subproject commit 9053d97110f91fabab3f8bf4f78cef0c76fce743 +Subproject commit 071e99372ad028e2b2c85d9ba47a1f87a9c23d23 diff --git a/Carbon.Core/Carbon.Hooks/Carbon.Hooks.Base b/Carbon.Core/Carbon.Hooks/Carbon.Hooks.Base index 022be3bf2..b6d2d2fe4 160000 --- a/Carbon.Core/Carbon.Hooks/Carbon.Hooks.Base +++ b/Carbon.Core/Carbon.Hooks/Carbon.Hooks.Base @@ -1 +1 @@ -Subproject commit 022be3bf24f4f6c5c3a4d1c6bfd98a52fe562aaf +Subproject commit b6d2d2fe4c2d8e4e62df91b0888363143e55cbce diff --git a/Carbon.Core/Carbon/src/Hooks/HookCallerInternal.cs b/Carbon.Core/Carbon/src/Hooks/HookCallerInternal.cs index 6c764b226..b126e34e7 100644 --- a/Carbon.Core/Carbon/src/Hooks/HookCallerInternal.cs +++ b/Carbon.Core/Carbon/src/Hooks/HookCallerInternal.cs @@ -1,9 +1,7 @@ ο»Ώusing System; using System.Collections.Generic; using System.Reflection; -using Carbon.Base; using Carbon.Components; -using Carbon.Extensions; using Carbon.Pooling; using Facepunch; using Oxide.Core.Plugins; @@ -23,11 +21,8 @@ public class HookCallerInternal : HookCallerCommon { public override object[] AllocateBuffer(int count) { - if (!_argumentBuffer.TryGetValue(count, out var pool)) - { - _argumentBuffer.Add(count, pool = new HookArgPool(count, 15)); - } - + if (_argumentBuffer.TryGetValue(count, out var pool)) return pool.Take(); + _argumentBuffer[count] = pool = new HookArgPool(count, 15); return pool.Take(); } public override object[] RescaleBuffer(object[] oldBuffer, int newScale, CachedHook hook) @@ -86,10 +81,12 @@ public override void ProcessDefaults(object[] buffer, CachedHook hook) } public override void ReturnBuffer(object[] buffer) { - if (_argumentBuffer.TryGetValue(buffer.Length, out var pool)) + if (!_argumentBuffer.TryGetValue(buffer.Length, out var pool)) { - pool.Return(buffer); + _argumentBuffer[buffer.Length] = pool = new HookArgPool(buffer.Length, 15); } + + pool.Return(buffer); } public override object CallHook(T hookable, uint hookId, BindingFlags flags, object[] args) @@ -184,7 +181,7 @@ public override object CallHook(T hookable, uint hookId, BindingFlags flags, } else { - if (hookInstance.IsValid()) + if (hookInstance != null && hookInstance.IsValid()) { foreach (var cachedHook in hookInstance.Hooks) { diff --git a/Carbon.Core/Carbon/src/Hooks/HookEx.cs b/Carbon.Core/Carbon/src/Hooks/HookEx.cs index ebf3dc4a3..7929ffc92 100644 --- a/Carbon.Core/Carbon/src/Hooks/HookEx.cs +++ b/Carbon.Core/Carbon/src/Hooks/HookEx.cs @@ -195,13 +195,13 @@ public bool ApplyPatch() try { if (_runtime.Prefix != null) - prefix = new HarmonyMethod(_runtime.Prefix); + prefix = new HarmonyMethod(_runtime.Prefix, Priority.VeryHigh); if (_runtime.Postfix != null) - postfix = new HarmonyMethod(_runtime.Postfix); + postfix = new HarmonyMethod(_runtime.Postfix, Priority.VeryHigh); if (_runtime.Transpiler != null) - transpiler = new HarmonyMethod(_runtime.Transpiler); + transpiler = new HarmonyMethod(_runtime.Transpiler, Priority.VeryHigh); if (prefix is null && postfix is null && transpiler is null) throw new Exception($"(prefix, postfix, transpiler not found"); diff --git a/Carbon.Core/Carbon/src/Managers/PatchManager.cs b/Carbon.Core/Carbon/src/Managers/PatchManager.cs index 88ffca0b9..5b172bf6f 100644 --- a/Carbon.Core/Carbon/src/Managers/PatchManager.cs +++ b/Carbon.Core/Carbon/src/Managers/PatchManager.cs @@ -522,25 +522,25 @@ private IEnumerable Hooks { get => _patches.Concat(_dynamicHooks).Concat(_staticHooks).Concat(_metadataHooks); } private IEnumerable GetHookByName(string name) - => LoadedHooks.Where(x => x.HookName.Equals(name, StringComparison.InvariantCulture)) ?? null; + => LoadedHooks.Where(x => x.HookName.Equals(name)) ?? null; private IEnumerable GetHookByFullName(string name) - => LoadedHooks.Where(x => x.HookFullName.Equals(name, StringComparison.InvariantCulture)) ?? null; + => LoadedHooks.Where(x => x.HookFullName.Equals(name)) ?? null; private HookEx GetHookById(string identifier) - => LoadedHooks.FirstOrDefault(x => x.Identifier.Equals(identifier, StringComparison.InvariantCulture)) ?? null; + => LoadedHooks.FirstOrDefault(x => x.Identifier.Equals(identifier)) ?? null; private IEnumerable GetHookByNameAll(string name) - => Hooks.Where(x => x.HookName.Equals(name, StringComparison.InvariantCulture)) ?? null; + => Hooks.Where(x => x.HookName.Equals(name)) ?? null; private IEnumerable GetHookByFullNameAll(string name) - => Hooks.Where(x => x.HookFullName.Equals(name, StringComparison.InvariantCulture)) ?? null; + => Hooks.Where(x => x.HookFullName.Equals(name)) ?? null; private HookEx GetHookByIdAll(string identifier) - => Hooks.FirstOrDefault(x => x.Identifier.Equals(identifier, StringComparison.InvariantCulture)) ?? null; + => Hooks.FirstOrDefault(x => x.Identifier.Equals(identifier)) ?? null; internal bool IsHookLoaded(HookEx hook) - => LoadedHooks.Any(x => x.HookFullName.Equals(hook.HookFullName, StringComparison.InvariantCulture) && x.TargetType == hook.TargetType && x.TargetMethod == hook.TargetMethod && (x.TargetMethodArgs?.SequenceEqual(hook.TargetMethodArgs) ?? true)); + => LoadedHooks.Any(x => x.HookFullName.Equals(hook.HookFullName) && x.TargetType == hook.TargetType && x.TargetMethod == hook.TargetMethod && (x.TargetMethodArgs?.SequenceEqual(hook.TargetMethodArgs) ?? true)); public bool IsHook(string hookName) { @@ -578,21 +578,20 @@ public IEnumerable LoadedDynamicHooks public IEnumerable InstalledDynamicHooks { get => _dynamicHooks.Where(x => x.IsInstalled); } - private bool HookIsSubscribedBy(string identifier, string subscriber) - => _subscribers?.Where(x => x.Identifier.Equals(identifier, StringComparison.InvariantCulture)).Any(x => x.Subscriber == subscriber) ?? false; + => _subscribers?.Where(x => x.Identifier.Equals(identifier)).Any(x => x.Subscriber == subscriber) ?? false; private bool HookHasSubscribers(string identifier) - => _subscribers?.Any(x => x.Identifier.Equals(identifier, StringComparison.InvariantCulture)) ?? false; + => _subscribers?.Any(x => x.Identifier.Equals(identifier)) ?? false; public int GetHookSubscriberCount(string identifier) - => _subscribers.Count(x => x.Identifier.Equals(identifier, StringComparison.InvariantCulture)); + => _subscribers.Count(x => x.Identifier.Equals(identifier)); private void AddSubscriber(string identifier, string subscriber) => _subscribers.Add(item: new Subscription { Identifier = identifier, Subscriber = subscriber }); private void RemoveSubscriber(string identifier, string subscriber) - => _subscribers.RemoveAll(x => x.Identifier.Equals(identifier, StringComparison.InvariantCulture) && x.Subscriber.Equals(subscriber, StringComparison.InvariantCulture)); + => _subscribers.RemoveAll(x => x.Identifier.Equals(identifier) && x.Subscriber.Equals(subscriber)); public void Subscribe(string hookName, string requester) @@ -661,6 +660,11 @@ private void Subscribe(HookEx hook, string requester) } } + public IEnumerable GetHookSubscribers(string identifier) + { + return _subscribers.Where(x => x.Identifier.Equals(identifier)).Select(x => x.Subscriber); + } + public void Unsubscribe(string hookName, string requester) { try @@ -721,6 +725,16 @@ private void Unsubscribe(HookEx hook, string requester) } } + public void UnsubscribeAll(string hookName) + { + var subscribers = GetHookSubscribers(hookName); + + foreach (var subscriber in subscribers) + { + Unsubscribe(hookName, subscriber); + } + } + public static string GetMethodMSILHash(MethodInfo method) => SHA1(method?.GetMethodBody()?.GetILAsByteArray()); diff --git a/README.md b/README.md index 703b071a9..8b8ed5906 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,6 @@ -
@@ -65,7 +64,6 @@ The following branches are shared across all Component and Hook projects and syn - [Carbon.Preloader](https://github.com/CarbonCommunity/Carbon.Preloader/tree/develop): Runtime preloader of dependencies and responsible assembly patching (publicising, injecting, etc.). - [Carbon.Bootstrap](https://github.com/CarbonCommunity/Carbon.Bootstrap/tree/develop): Initial Carbon execution and boot in the primary app-domain. - [Carbon.Common](https://github.com/CarbonCommunity/Carbon.Common/tree/develop): The very basis of Carbon, tools and extensions for overall use and functionality. Primarily a center piece for all dependant sub-components. -- [Carbon.Common.Client](https://github.com/CarbonCommunity/Carbon.Common.Client/tree/develop): Represents a bundle of common features, patches and implementations for Carbon for client communication. - [Carbon.SDK](https://github.com/CarbonCommunity/Carbon.SDK/tree/develop): Infrastructural and contractual features with no implementation. An easy way to identify and organise the structure of our systems. - [Carbon.Modules](https://github.com/CarbonCommunity/Carbon.Modules/tree/develop): Carbon optional modules expanding functionality, enhanced QoL and tools. - [Carbon.Compat](https://github.com/CarbonCommunity/Carbon.Compat/tree/develop): Previously known as Carbon Compatibility Loader written by Patrette (community member). diff --git a/Tools/DepotDownloader b/Tools/DepotDownloader index b96125f9c..c6a5bcf87 160000 --- a/Tools/DepotDownloader +++ b/Tools/DepotDownloader @@ -1 +1 @@ -Subproject commit b96125f9cbbb0f63d47e14784929f255f6c21ce1 +Subproject commit c6a5bcf87e5261cce8bf4d67367dc79b356168b6