Skip to content

Commit

Permalink
Merge branch 'develop' into rust_beta/staging
Browse files Browse the repository at this point in the history
  • Loading branch information
raulssorban committed Oct 21, 2023
2 parents 3db9060 + f5b3452 commit 8d5418d
Show file tree
Hide file tree
Showing 11 changed files with 71 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Carbon.Core/.msbuild/Protocol.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
carbon that forces the users to update all the compontents at the
same time, like updating core and hooks in one shot.
-->
<CarbonProtocol>2023.11.02.0</CarbonProtocol>
<CarbonProtocol>2023.10.23.0</CarbonProtocol>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion Carbon.Core/Carbon.Components/Carbon.SDK
3 changes: 1 addition & 2 deletions Carbon.Core/Carbon/Carbon.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
<PackageReference Include="Lib.Harmony" Version="2.2.2" />
<ProjectReference Include="$(SolutionDir)\Carbon.Components\Carbon.Common\Carbon.Common.csproj" Private="false" />
<ProjectReference Include="$(SolutionDir)\Carbon.Components\Carbon.Common.Client\Carbon.Common.Client.csproj" />
<ProjectReference Include="$(SolutionDir)\Carbon.Components\Carbon.Compiler\Carbon.Compiler.csproj" />
</ItemGroup>

<ItemGroup>
Expand All @@ -34,4 +33,4 @@
<Target Name="CustomRelease" AfterTargets="Build" DependsOnTargets="PrepareRelease">
<Copy SourceFiles="$(OutputPath)$(Product).dll" DestinationFolder="$(c_managed)" />
</Target>
</Project>
</Project>
37 changes: 32 additions & 5 deletions Carbon.Core/Carbon/src/Hooks/HookCallerInternal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public override object[] AllocateBuffer(int count)

return buffer;
}
public override object[] RescaleBuffer(object[] oldBuffer, int newScale)
public override object[] RescaleBuffer(object[] oldBuffer, int newScale, CachedHook hook)
{
if (oldBuffer.Length == newScale)
{
Expand All @@ -69,18 +69,37 @@ public override object[] RescaleBuffer(object[] oldBuffer, int newScale)

for (int i = 0; i < newScale; i++)
{
var value = newBuffer[i];

if (i > oldBuffer.Length - 1)
{
newBuffer[i] = null;
newBuffer[i] = value = null;
}
else
{
newBuffer[i] = oldBuffer[i];
newBuffer[i] = value = oldBuffer[i];
}

if (i <= hook.DefaultParameterValues.Length - 1 && value == null)
{
newBuffer[i] = hook.DefaultParameterValues[i];
}
}

return newBuffer;
}
public override void ProcessDefaults(object[] buffer, CachedHook hook)
{
var length = buffer.Length;

for (int i = 0; i < length; i++)
{
if (i <= hook.DefaultParameterValues.Length - 1 && buffer[i] == null)
{
buffer[i] = hook.DefaultParameterValues[i];
}
}
}
public override void ClearBuffer(object[] buffer)
{
for (int i = 0; i < buffer.Length; i++)
Expand Down Expand Up @@ -121,7 +140,11 @@ public override object CallHook<T>(T hookable, uint hookId, BindingFlags flags,

if (actualLength != args.Length)
{
args = RescaleBuffer(args, actualLength);
args = RescaleBuffer(args, actualLength, cachedHook);
}
else
{
ProcessDefaults(args, cachedHook);
}
}
}
Expand Down Expand Up @@ -228,7 +251,11 @@ object DoCall(CachedHook hook)

if (actualLength != args.Length)
{
args = RescaleBuffer(args, actualLength);
args = RescaleBuffer(args, actualLength, hook);
}
else
{
ProcessDefaults(args, hook);
}
}

Expand Down
11 changes: 3 additions & 8 deletions Carbon.Core/Carbon/src/Hooks/HookEx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,13 @@ public HookEx(TypeInfo type)
TargetMethods = new();
TargetType = metadata.Target;

if (Attribute.IsDefined(type, typeof(HookAttribute.Identifier), false))
Identifier = type.GetCustomAttribute<HookAttribute.Identifier>()?.Value ?? $"{Guid.NewGuid():N}";

if (Attribute.IsDefined(type, typeof(HookAttribute.Options), false))
Options = type.GetCustomAttribute<HookAttribute.Options>()?.Value ?? HookFlags.None;
Identifier = type.GetCustomAttribute<HookAttribute.Identifier>()?.Value ?? $"{Guid.NewGuid():N}";
Options = type.GetCustomAttribute<HookAttribute.Options>()?.Value ?? HookFlags.None;
Checksum = type.GetCustomAttribute<HookAttribute.Checksum>()?.Value ?? default;

if (Attribute.IsDefined(type, typeof(HookAttribute.Dependencies), false))
Dependencies = type.GetCustomAttribute<HookAttribute.Dependencies>()?.Value ?? default;

if (Attribute.IsDefined(type, typeof(HookAttribute.Checksum), false))
Checksum = type.GetCustomAttribute<HookAttribute.Checksum>()?.Value ?? default;

if (Options.HasFlag(HookFlags.MetadataOnly))
{
SetStatus(HookState.Inactive);
Expand Down
1 change: 0 additions & 1 deletion Carbon.Core/Carbon/src/Loaders/ScriptLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
using Carbon.Core;
using Carbon.Extensions;
using Carbon.Jobs;
using Facepunch;
using Oxide.Core;
using Oxide.Core.Plugins;
using Oxide.Plugins;
Expand Down
11 changes: 11 additions & 0 deletions Tools/Build/linux/publish_git.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,16 @@ if [ ! -d "$TEMP" ]; then
mkdir -p "$TEMP"
fi

git fetch --tags

echo "** Git Metadata:"

for tag in $(git tag -l); do
git tag -d "$tag"
done

git fetch --tags

cd "$TEMP"
git branch --show-current > .gitbranch
echo "** Branch done."
Expand All @@ -33,6 +41,9 @@ echo "** Comment done."
git log -1 --format="%ci" HEAD > .gitdate
echo "** Date done."

git describe --tags > .gittag
echo "** Tag done."

git remote get-url origin > .giturl
echo "** URL done."

Expand Down
2 changes: 1 addition & 1 deletion Tools/Build/win/build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if "%1" EQU "" (
set BUILD_TARGET=%1
)

call "%~dp0publish_git.bat"
call "%~dp0publish_git.bat" %3

echo ** Set the build target config to %BUILD_TARGET%

Expand Down
21 changes: 19 additions & 2 deletions Tools/Build/win/publish_git.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
::
:: Copyright (c) 2022-2023 Carbon Community
:: Copyright (c) 2022-2023 Carbon Community
:: All rights reserved
::
@echo off
Expand All @@ -13,6 +13,13 @@ if not exist %TEMP% (

echo ** Git Metadata:

FOR /F "tokens=*" %%i IN ('git tag -l') DO (
git tag -d %%i
)

git fetch --tags


cd %TEMP%
git branch --show-current > .gitbranch
echo ** Branch done.
Expand All @@ -32,10 +39,20 @@ echo ** Comment done.
git log -1 --format=%%%ci HEAD > .gitdate
echo ** Date done.

if "%1" EQU "" (
git describe --tags > .gittag
echo ** Tag done.
) else (
echo %1 > .gittag
echo ** Tag done.
)



git remote get-url origin > .giturl
echo ** URL done.

git log -1 --name-status --format= > .gitchanges
echo ** Changes done.

cd %HOME%
cd %HOME%

0 comments on commit 8d5418d

Please sign in to comment.