Giter Site home page Giter Site logo

fabianterhorst / coreclr-module Goto Github PK

View Code? Open in Web Editor NEW
73.0 14.0 70.0 129.38 MB

Old alt:V CoreClr (.NET Core Common Language Runtime) community made module. New: https://github.com/altmp/coreclr-module

License: MIT License

Dockerfile 0.03% C# 99.95% Shell 0.01% PowerShell 0.02%
hacktoberfest altv nuget coreclr csharp dotnet

coreclr-module's Introduction

alt:V C# module

The new repository for the alt:V C# module is located at https://github.com/altmp/coreclr-module

Package Version
AltV.Net nuget nuget nuget
AltV.Net.Async nuget nuget nuget
AltV.Net.Async.CodeGen nuget nuget nuget
AltV.Net.CApi nuget nuget nuget
AltV.Net.Client nuget nuget nuget
AltV.Net.ColShapes nuget nuget nuget
AltV.Net.EntitySync nuget nuget nuget
AltV.Net.EntitySync.ServerEvent nuget nuget nuget
AltV.Net.Interactions nuget nuget nuget
AltV.Net.Resources.Chat.Api nuget nuget nuget
AltV.Net.Shared nuget nuget nuget

Repository containing the C# module for alt:V multiplayer.

Structure

Directory Description
/api C# Scripting Api
/docs C# Documentation published to alt:V Docs
/runtime C# c++ runtime using the alt:V Module Api

Contributions

All contributions are greatly appreciated. If there are any questions or you would like to discuss a feature, contact the module maintainer.

Documentation

Documentation can be found at alt:V Docs

coreclr-module's People

Contributors

apokalypser avatar arochka avatar b2soft avatar buddiestv avatar c0nnex avatar chaosfreak93 avatar cptprice1139 avatar deluvas1911 avatar dependabot[bot] avatar doxoh avatar durtyfree avatar duydang2311 avatar emcifuntik avatar fabianterhorst avatar ithr0n avatar juztim avatar kiwiskiwi avatar kuroosh avatar lennartf22 avatar leonmrbonnie avatar litolax avatar lsvmoretti avatar mcp4nth3r avatar pauljschell avatar renovate-bot avatar silverdark avatar thedutchdev avatar unnvaldr avatar zackaryh8 avatar zziger avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

coreclr-module's Issues

Add AltV.Net.Resources.Chat

This will be the first optional c# resource that should build via github actions. It should build a zip that contains resource.cfg, server and clientside files.

Entity's positions doesn't refresh

Example:
player.SetPosition(466f, -635f, 28f);
or
player.Position = new Position(466f, -635f, 28f);

player.Position doesn't refresh, the old remains.
Same thing on GetPosition()

[Documentation] LLDB Debugging

Create documentation for LLDB Debugging.

sudo apt install lldb
dotnet tool install -g dotnet-sos
dotnet sos install
lldb
setclrpath /usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.3
quit
dotnet sos install
lldb
process attach -p <PID>
continue // enter it each time when it reached a breakpoint
clrstack // to get native stacktrace

Add IConvertible Interface to Position/Rotation

Client:
alt.emitServer("test","somestring",new alt.Vector3(1,2,3);

Server:

[ClientEvent("test")]
public void myCoolFun(IPlayer player, params object[] args)
{ // args[1] is object[3] { "x":1, "y":2,"z";3 } looks like "dynamic"
var pos = (Position)Convert.ChangeType(typeof(Position),args[1]);
}

will fail because Position does not implement IConvertible.
Yes one could cast it, by IConvertible is the cleaner solution.
Even Better: get rid off Rotation/Position type and use Vector3 ;)

Add optional networking entity module

Add optional networking entity module that synchronizes the entities and the shared data with the clients. This will make it possible to create objects, peds and markers from serverside.
The server will send the entities via a tcp socket or probably websockets and protobuf serialization to the clients. Can't use udp socket because cef doesn't support it. The entities will support serverside and synchronized meta data. The entity types will be generic on serverside and the client will have to decide how to render them when entering / exiting streaming range.

AltEntitySync.Init sync rate issue (missing documentation?)

When using AltEntitySync.Init i can't set the sync rate as described in multiple documentations/examples.
What i am trying to do:

AltEntitySync.Init(1, 100, (threadId) => false,
               (threadCount, repository) => new ServerEventNetworkLayer(threadCount, repository),
               (entity, threadCount) => (entity.Id % threadCount),
               (entityId, entityType, threadCount) => (entityId % threadCount),
               (threadId) => new LimitedGrid3(50_000, 50_000, 100, 10_000, 10_000, 300),
               new IdProvider());

Documentation/examples i used:
http://csharp.altv.mp/articles/entity-sync.html
https://github.com/DasNiels/altv-object-streamer/
https://github.com/LameuleFR/altv-csharp-streamer

AltEntitiySync_Init

Add Rotation Degree as Attribute for Entitys

I would appreciate adding a degree side rotation attribute for entitys as well, since a lot of rotation based methods use 180ยฐ rotation (e.g. player rotation or camera rotation) and the current attribute gives back radiant which has to be converted first

Method to get all players asynchronously

Currently there is option to get all players synchronously Alt.GetAllPlayers() but there is no method to get them asynchronously like AltAsync.GetAllPlayers().

CreateTextLabel function

It would be nice to have a Alt.CreateTextLabel function.
Here are some parameters:
Alt.CreateTextLabel(string text, Position pos, float range, float size, int font, Color color, bool entitySeethrough = false, uint dimension = uint.MaxValue)

I will make another post for the Color struct. #

Vehicle.Remove and Alt.RemoveVehicle Crash

The usage of both Vehicle.Remove and Alt.RemoveVehicle seem to crash my server. I'm kind of lost and I've tried it in multiple different scenarios and still crashes. I'm not too sure if I'm doing something wrong, but figured I'd report just in case it were an issue.

The code I'm using is really simple, at first I check if the player is in any vehicle and if they are in the drivers seat. If they match these conditions, that's fine then we remove the vehicle using either;

player.Vehicle.Remove();
or
Alt.RemoveVehicle(player.Vehicle)

Even under a try - catch, weirdly it does not provide any details as to what the cause of the error is.

Access violation exception

If you try to call player.GetNameAsync() in the disconnect event it throws an access violation exception because AltNative.Player.Player_GetName(player.NativePointer, ref ptr) uses IntPtr.Zero from ReadOnlyPlayer

4418e8e117f2810be269ca68425b9b73

AltAsync Float/Double event transmission problem

When you send a float/double from clientside using alt.emitServer("eventName", 0.2) everything is as expected, you get float/double on serverside event handler. But when you send it using alt.emitserver("eventName", 2) you get 0 on your float/double value.

Steps to reproduce:

  1. Register an event that accepts float/double on serverside
  2. Send an event from clientside with int value

Here is a showcase of the problem on a screenshot, with or without parseFloat problem still occurs
GTA5_7MP95WXn04

Branch: rc
Build: #1300

Alt.OffClient and AltAsync.OffClient don't work

  1. Short description: registering OnClient in AltAsync or Alt registers fine, but when trying to unregister methods still get called when emitting event from clientside.
  2. What happens: OffClient does not unregister event
  3. What should happen: OffClient should unregister event and unregistered method souldn't be called when events are being emitted from clientside
  4. Steps and code to reproduce:
    1. Construct class
    2. Emit events, only one line is being printed Async event called! 0 or sync for sync event
    3. Call finish method, emit events, methods still get called, Async event called! 0 being printed
  5. Version: 3.0-dev16, nugets are updated to their latest versions

When trying to construct class again, two instances of class receive events, and this results in code not working properly

using System;
using System.Threading.Tasks;
using AltV.Net;
using AltV.Net.Async;

    public class TestEvents
    {
        public static int InstanceNumber = 0;
        private int _instanceNumber;

        private TestEvents()
        {
            this._instanceNumber = TestEvents.InstanceNumber;
            TestEvents.InstanceNumber++;
            AltAsync.OnClient<AltCorePlayer, int>("testEventJob:asyncEvent", this.AsyncEvent);
            Alt.OnClient<AltCorePlayer, int>("testEventJob:event", this.Event);
        }

        private async void AsyncEvent(AltCorePlayer player, int n)
        {
            Console.WriteLine($"Async event called! {this._instanceNumber}");   
        }

        private void Event(AltCorePlayer player, int n)
        {
            Console.WriteLine($"Sync event called! {this._instanceNumber}");
        }
        public void Finish()
        {
            AltAsync.OffClient<AltCorePlayer, int>("testEventJob:asyncEvent", this.AsyncEvent);
            Alt.OffClient<AltCorePlayer, int>("testEventJob:event", this.Event);
        }
    }
}

Add optional collision shape module

Add support for

  • Cylinder
  • Sphere
  • (2d/3d) Rectangle

The callbacks are getting triggered from a different thread.
A collision shape will be a world object that supports server side data and custom object factories.

Using HostBuilder and a HostedService, server stop gets stuck

Note
This is a carry-over from altmp/altv-issues#707.

Client/server version
Build #1301, branch release

Current behavior
When using the HostBuilder and a HostedService the server stop gets stuck. Consider the following code:

namespace Test
{
    public class Program : Resource
    {
        private IHost _host;

        public Program() 
            => _host = CreateHostBuilder()
                .Build();

        public static IHostBuilder CreateHostBuilder() 
            => Host.CreateDefaultBuilder()
                .ConfigureHostConfiguration((builder) => {
                    builder
                        .SetBasePath(Directory.GetCurrentDirectory())
                        .AddJsonFile("appsettings.json", optional: true)
                        .AddUserSecrets<Core>();
                })
                .ConfigureLogging((context, builder) => {
                    builder
                        .AddConfiguration(context.Configuration)
                        .AddSentry();
                })
                .ConfigureServices(ConfigureServices)
                .UseConsoleLifetime();

        public async static void ConfigureServices(HostBuilderContext context, IServiceCollection collection)
        {
            [...]

            // Add Core
            collection.AddHostedService<Core>();
        }

        public async override void OnStart()
        {
            await _host.StartAsync();
        }

        public async override void OnStop()
        {
            await _host.StopAsync();
        }
    }

    public class Core : IHostedService
    {
        public async Task StartAsync(CancellationToken cancellationToken)
        {
             Console.WriteLine("Start");
        }

        public async Task StopAsync(CancellationToken cancellationToken)
        {
            Console.WriteLine("Stop");
        }
    }
}

Produces the following output:

[21:55:03] alt:V Server, build #1301, branch release
[21:55:03] Starting alt:V Server on 0.0.0.0:7788
[21:55:03] coreclr-module: version found: 3.1.9
[21:55:03] coreclr-module: greatest version: 3.1.9
[21:55:04] Loading resource test
Start
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
      Content root path: /opt/altv
[21:55:04] Loaded resource test
[21:55:04] Starting HTTP server on 0.0.0.0:7788
[21:55:04] Console thread started (ThreadId: 8)
[21:55:04] Main thread started (ThreadId: 6)
[21:55:04] VoicePacketProcess thread started (ThreadId: 9)
[21:55:04] VoiceStreamer thread started (ThreadId: 10)
[21:55:04] Colshape thread started (ThreadId: 11)
[21:55:04] EntityStreamer thread started (ThreadId: 36)
[21:55:04] Network thread started (ThreadId: 38)
[21:55:04] Server started
^Cinfo: Microsoft.Hosting.Lifetime[0]
      Application is shutting down...

Context (environment)
Currently only tested within a Docker Container, but this should not really matter.

Position overload

Add Position overload for double which converts x, y, z to float in background.

[REGRESSION] Host can throw InvalidOperationException at any point in time

There is currently a regression bug in the AltV.Net.Host implementation, that can lead to the following exception:

InvalidOperationException:
AssemblyLoadContext is unloading or was already unloaded.

As it turns out, the Host class only holds a weak reference to the load context in its static dictionary and no other objects are holding any references on it.

var resourceAssemblyLoadContext =
new ResourceAssemblyLoadContext(resourceDllPath, resourcePath, resourceName, isCollectible);
_loadContexts[resourceDllPath] = new WeakReference(resourceAssemblyLoadContext);

Therefore, the load context is eligible for garbage collection at any time!

This is exactly what happens in our case, when we load larger libraries with lots of dependencies in our ServerResource.OnStart() method.
It happens at different points in time, with different assemblies, but GC is always triggert at some point in the start process and an exception is thrown on the next try to load an assembly into the already finalized load context.

This is a regression. It should work on the master branch, because it does not use a WeakReference there.

I will provide a PR, that fixes this issue and should not leak any memory either.

This was reported to our repo as a possible .NET Core 3.0 incompatibility of our database provider, but turned out to be unrelated to that (PomeloFoundation/Pomelo.EntityFrameworkCore.MySql#825).

/cc @lsvMoretti

Add Color struct.

Another nice update would be to have a Color Strcut, here I have an example:

`
public struct Color
{
public int Red;
public int Green;
public int Blue;
public int Alpha;

    public Color(int number);
    public Color(int r, int g, int b);
    public Color(int r, int g, int b, int a);

    public int ToInt32();
}

`

Write ColShape example documentation

Filepath needs to be docs/articles/colshapes-example.md
Should contain understandable description about how to create colshapes, what there should be used for and how the events are working.

Write EntitySync documentation

Filepath needs to be docs/articles/networking-entity.md
Should contain understandable description about how to setup networking entity, how to create networking entites, what there should be used for and how client and serverside streaming is working.

Server crashes when unloading resource

When I try to reload any resource after I made changes to it, the server crashes sometimes with the following messages:

Received an unhandled exception from : System.BadImageFormatException: [*.dll] Illegal or unimplemented ELEM_TYPE in signature.
   at \].nary`2.Current
   at AltV.Net.ModuleWrapper.OnStop()
 Received an unhandled exception from : System.BadImageFormatException: Bad IL range.
   at t^D.l.nvokeMember
   at AltV.Net.ModuleWrapper.OnStop()

OnStop contains the following code:

public override void OnStop()
{
	Alt.Log("OnStop");
}

OP Specs:

Distributor ID: Debian
Description:    Debian GNU/Linux 10 (buster)
Release:        10
Codename:       buster

Add dimension to networking entity.

Dimensions are very important argument for example for markers or blips, if you want to create some marker only for one interior. If you could add dimensions to Networking Entity, would be awesome.

Add AltV.Net.Chat module

The module should be used to communicate between chat resource and c# resource.
It should be published to nuget via github actions, because travis build tasks max parallel count is reached.
Requires #64

[EntitySync] Improve init code

The current entity sync init is complex to understand and doesnt support multiple independent instances which makes it almost impossible to use inside libraries.

This api would also allow to provide a network layer per type to fine gain data diffing and serialization for best possible performance.

API proposal:

var entitySync = new EntitySync.Builder()
  .type(number, thread Index (by default type number), space partitioning algorithm, network layer)
 .build();

Add Alt.Server.Console

Im in C# Lib and can't use Console.XXX to set my colors vor other stuff. I would like to do this with Alt.Server.Console.X

Example:
Alt.Server.Console.Forecolor()
Alt.Server.Console.Backcolor()
Alt.Server.Console.Reset() //default values

Networking Entity

When a Client disconnects (via 'reconnect' atm), the Server will throw an error, wether you destroy the networking Entity on ClientSide or not.

System.ObjectDisposedException: The CancellationTokenSource has been disposed. at System.Threading.CancellationTokenSource.ThrowObjectDisposedException() at net.vieapps.Components.WebSockets.WebSocketImplementation.Close() at net.vieapps.Components.WebSockets.WebSocket.CloseWebsocketAsync(ManagedWebSocket websocket, WebSocketCloseStatus closeStatus, String closeStatusDescription) at AltV.Net.NetworkingEntity.Elements.Providers.AuthenticationProvider.<>c__DisplayClass8_0.<<-ctor>b__0>d.MoveNext()

Parameters are partially not usable, when exporting functions.

This returns "true" when called from another resource:

private bool Test(int integer)
{
        return true;
}
Alt.Export("test", new Func<int, bool>(Test));

This returns "false" when called from another resource:

private bool Test(IPlayer player)
{
        return true;
}
Alt.Export("test", new Func<IPlayer, bool>(Test));

Interactions ignoring Dimension.GlobalDimension

Client/server version
Build #1299 (RC)
AltV.Net.Async (1.40.1-rc)
AltV.Net.Interactions (1.1.0-dev-preview)

Current behavior
The interaction is not working in all dimensions if created with Dimension.GlobalDimension

Expected behavior
Global dimension should trigger regardless of player dimension like entity sync

Steps to reproduce
new Interaction(0, 0, new Vector3(0, 0, 72), Dimension.GlobalDimension, 10);
var ia0 = await AltInteractions.FindInteractions(new Position(0, 0, 72), 0);
var ia1 = await AltInteractions.FindInteractions(new Position(0, 0, 72), Dimension.GlobalDimension);
Console.WriteLine($"Interactions dimension 0: {ia0.Length}"); // <-- 0
Console.WriteLine($"Interactions global: {ia1.Length}"); // <-- 1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.