Fix stuff

This commit is contained in:
Sardelka9515
2023-02-16 18:56:56 +08:00
parent e5f426690f
commit 6e2b4aff2f
12 changed files with 44 additions and 17 deletions

View File

@ -115,14 +115,14 @@ namespace RageCoop.Client.Installer
UpdateStatus("Checking conflicts");
var menyooConfig = Path.Combine(root, @"menyooStuff\menyooConfig.ini");
var settingsPath = Path.Combine(root, SettingsPath);
Settings settings = null;
ClientSettings settings = null;
try
{
settings = Util.ReadSettings(settingsPath);
}
catch
{
settings = new Settings();
settings = new();
}
if (File.Exists(menyooConfig))

View File

@ -119,5 +119,10 @@ namespace RageCoop.Client.Scripting
[LibraryImport("RageCoop.Client.dll")]
private static partial int GetLastResultLenInChars();
[LibraryImport("RageCoop.Client.dll")]
[return: MarshalAs(UnmanagedType.I1)]
public static partial bool RegisterCustomEventHandler(CustomEventHash hash, IntPtr ptrHandler);
}
}

View File

@ -1,9 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<OutDir>..\..\bin\API</OutDir>
<DocumentationFile>..\..\bin\API\RageCoop.Client.Scripting.xml</DocumentationFile>
<NoWarn>CS1591</NoWarn>
</PropertyGroup>
<ItemGroup>

View File

@ -236,7 +236,6 @@ namespace RageCoop.Client
MainChat.OnKeyDown(e.KeyCode);
return;
}
#if CEF
if (CefRunning)
{

View File

@ -15,6 +15,7 @@
<NoWarn>CS1591</NoWarn>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
<GenerateDocumentationFile>False</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>
<TrimmerRootDescriptor Include="Trimming.xml" />

View File

@ -3,6 +3,7 @@ using RageCoop.Core;
using RageCoop.Core.Scripting;
using System;
using System.Collections.Generic;
using System.Reflection.Metadata;
using System.Runtime.InteropServices;
using static RageCoop.Core.Scripting.CustomEvents;
@ -85,6 +86,26 @@ namespace RageCoop.Client.Scripting
[UnmanagedCallersOnly(EntryPoint = nameof(GetLastResultLenInChars))]
public static int GetLastResultLenInChars() => _lastResult?.Length ?? 0;
[UnmanagedCallersOnly(EntryPoint = nameof(RegisterCustomEventHandler))]
public static bool RegisterCustomEventHandler(CustomEventHash hash, IntPtr ptrHandler)
{
try
{
lock (CustomEventHandlers)
{
if (!CustomEventHandlers.TryGetValue(hash, out var handlers))
CustomEventHandlers.Add(hash, handlers = new());
handlers.Add(new(ptrHandler));
}
return true;
}
catch (Exception ex)
{
Log.Error(nameof(RegisterCustomEventHandler), ex);
return false;
}
}
/// <summary>
/// Convert Entity ID to handle
/// </summary>

View File

@ -183,7 +183,7 @@ namespace RageCoop.Client.Scripting
/// Get the local player's ID
/// </summary>
/// <returns>PlayerID</returns>
public static int LocalPlayerID => LocalPlayerID;
public static int LocalPlayerID => Main.LocalPlayerID;
/// <summary>
/// Check if player is connected to a server

View File

@ -197,7 +197,6 @@ namespace RageCoop.Client.Scripting
return;
}
var t = returnType;
var id = (int)e.Args[1];

View File

@ -16,9 +16,6 @@
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'API'">
<OutDir>..\bin\API</OutDir>
<Deterministic>true</Deterministic>
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
<ProduceOnlyReferenceAssembly>true</ProduceOnlyReferenceAssembly>
</PropertyGroup>
<ItemGroup>

View File

@ -27,10 +27,10 @@ namespace RageCoop.Core
/// Shortcut to <see cref="BufferReader.ThreadLocal"/>
/// </summary>
/// <returns></returns>
public static unsafe BufferReader GetReader(byte* data=null,int cbData=0)
public static unsafe BufferReader GetReader(byte* data = null, int cbData = 0)
{
var reader = BufferReader.ThreadLocal.Value;
reader.Initialise(data,cbData);
reader.Initialise(data, cbData);
return reader;
}
@ -39,8 +39,9 @@ namespace RageCoop.Core
/// Shortcut to <see cref="BufferWriter.ThreadLocal"/>
/// </summary>
/// <returns></returns>
public static BufferWriter GetWriter(bool reset=true) {
var writer=BufferWriter.ThreadLocal.Value;
public static BufferWriter GetWriter(bool reset = true)
{
var writer = BufferWriter.ThreadLocal.Value;
if (reset)
{
writer.Reset();

View File

@ -15,7 +15,7 @@ using System.Resources;
[assembly: AssemblyCulture("")]
// Version information
[assembly: AssemblyVersion("1.6.0.32")]
[assembly: AssemblyFileVersion("1.6.0.32")]
[assembly: AssemblyVersion("1.6.0.33")]
[assembly: AssemblyFileVersion("1.6.0.33")]
[assembly: NeutralResourcesLanguageAttribute( "en-US" )]

View File

@ -1,9 +1,9 @@
cd "%~dp0"
git submodule update --init
if exist "bin" rmdir /s /q "bin"
dotnet build -c Release
dotnet build -c API Core\RageCoop.Core.csproj
dotnet build -c API Server\RageCoop.Server.csproj
cd %~dp0
copy .\Client\Scripts\obj\Release\ref\RageCoop.Client.dll .\bin\API\RageCoop.Client.dll /y
dotnet build -c API Client\RageCoop.Client.Scripting.csproj
del .\bin\API\RageCoop.Server.exe
if exist .\bin\Release\Client\SubProcess rmdir .\bin\Release\Client\SubProcess /s /q