Skip to content

Commit

Permalink
Merge branch 'dev' into rc
Browse files Browse the repository at this point in the history
  • Loading branch information
Doxoh committed Jan 9, 2025
2 parents 45481b7 + 51cdf54 commit deea4ab
Show file tree
Hide file tree
Showing 24 changed files with 418 additions and 88 deletions.
64 changes: 64 additions & 0 deletions CONTRIBUTE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# How to Contribute

## Implementing [cpp-sdk](https://github.com/altmp/cpp-sdk) Changes

To implement a new `cpp-sdk` change or add a missing implementation, follow these steps:

1. **Create a New Branch**
- Start by creating a new branch based on the [dev](https://github.com/altmp/coreclr-module/tree/dev) branch.
- In the submodule `runtime`, create another branch also based on the [dev](https://github.com/altmp/coreclr-module-runtime/tree/dev) branch.

2. **Update the cpp-sdk Version**
- If required, update the `cpp-sdk` version in the `runtime` branch.

3. **Add the cpp-sdk Method**
- Add the new `cpp-sdk` method to the appropriate classes.
For example, to implement [IPlayer.GetSocialClubId()](https://github.com/altmp/cpp-sdk/blob/30b5e35ab7081f7e8ff7ac2bc0568aa7cf38e6be/objects/IPlayer.h#L90C20-L90C31), update the following runtime classes:
- [player.h](https://github.com/altmp/coreclr-module-runtime/blob/dev/c-api/entities/player.h)
- [player.cpp](https://github.com/altmp/coreclr-module-runtime/blob/dev/c-api/entities/player.cpp)

4. **Run the CApi Generator**
- Run the [CApi Generator](https://github.com/altmp/coreclr-module/blob/dev/api/AltV.Net.CApi.Generator/Program.cs) with the `runtime/c-api` folder as the working directory.

5. **Push Changes**
- Push all changes to the `runtime` branch.

6. **Implement the Method in the C# Module**
- Use the `runtime` branch to implement the method within the C# module.
For the example above, add the `SocialClubId` as a getter to the `IPlayer` interface.

7. **Add the Getter Implementation**
- Implement the getter in the `Player` class to invoke the unsafe runtime call `Core.Library.*`.

8. **Extend the AsyncPlayer Class**
- Add the method to the `AsyncPlayer` class, ensuring it calls the parent method from the `Player` class.

9. **Push Changes**
- Push all changes to the `module` branch.

10. **Testing**
- Open powershell window, change directory to root module folder. Run `gen_local_win_env.ps1` and wait everything downloaded.
- To test the changes, use the `windows-build.bat` file in the `runtime/server` folder to generate a `coreclr-module.dll`.
- Place the generated DLL in the server's `modules` folder.
- Build the module project and copy the new module DLLs to the C# resource folder and the project directory of the resource.
```
<ItemGroup>
<Reference Include="AltV.Net">
<HintPath>lib\AltV.Net.dll</HintPath>
</Reference>
<Reference Include="AltV.Net.Async">
<HintPath>lib\AltV.Net.Async.dll</HintPath>
</Reference>
<Reference Include="AltV.Net.Interactions">
<HintPath>lib\AltV.Net.Interactions.dll</HintPath>
</Reference>
<None Update="lib\*.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
```
- Test your changes thoroughly.
- **Clientside cannot be tested yet**
11. **Submit Pull Requests**
- Create separate pull requests for both the `module` branch and the `runtime` branch.
14 changes: 14 additions & 0 deletions api/AltV.Net.Async/Elements/Entities/AsyncConnectionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,19 @@ public ulong HardwareIdExHash
}
}
}

public string HardwareId3
{
get
{
lock (ConnectionInfo)
{
if (!AsyncContext.CheckIfExistsOrCachedNullable(ConnectionInfo)) return default;
return ConnectionInfo.HardwareId3;
}
}
}

public string AuthToken
{
get
Expand All @@ -74,6 +87,7 @@ public string AuthToken
}
}
}

public bool IsDebug
{
get
Expand Down
12 changes: 12 additions & 0 deletions api/AltV.Net.Async/Elements/Entities/AsyncPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,18 @@ public ulong HardwareIdExHash
}
}

public string HardwareId3
{
get
{
lock (Player)
{
if (!AsyncContext.CheckIfExistsOrCachedNullable(Player)) return default;
return Player.HardwareId3;
}
}
}

public string AuthToken
{
get
Expand Down
84 changes: 66 additions & 18 deletions api/AltV.Net.CApi/Events/ClientEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,86 +8,134 @@ namespace AltV.Net.CApi.ClientEvents
public delegate void TickModuleDelegate();

public delegate void ClientEventModuleDelegate(string name, IntPtr args, ulong size);

public delegate void ServerEventModuleDelegate(string name, IntPtr args, ulong size);

public delegate void WebViewEventModuleDelegate(IntPtr webView, string name, IntPtr args, ulong size);

public delegate void RmlEventModuleDelegate(IntPtr rmlElement, string name, IntPtr args);

public delegate void WebSocketEventModuleDelegate(IntPtr webSocket, string name, IntPtr args, ulong size);

public delegate void AudioEventModuleDelegate(IntPtr audio, string name, IntPtr args, ulong size);
public delegate void ConsoleCommandModuleDelegate(string name, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] string[] args, int argsSize);

public delegate void ConsoleCommandModuleDelegate(string name,
[MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] string[] args, int argsSize);

public delegate void PlayerSpawnModuleDelegate();

public delegate void PlayerDisconnectModuleDelegate();

public delegate void PlayerEnterVehicleModuleDelegate(IntPtr baseObject, BaseObjectType type, byte seat);

public delegate void PlayerLeaveVehicleModuleDelegate(IntPtr baseObject, BaseObjectType type, byte seat);
public delegate void PlayerChangeVehicleSeatModuleDelegate(IntPtr pointer, BaseObjectType type, byte oldSeat, byte newSeat);
public delegate void PlayerChangeAnimationModuleDelegate(IntPtr pointer, BaseObjectType type, uint oldDict, uint newDict, uint oldName, uint newName);
public delegate void PlayerChangeInteriorModuleDelegate(IntPtr pointer, BaseObjectType type, uint oldIntLoc, uint newIntLoc);

public delegate void PlayerChangeVehicleSeatModuleDelegate(IntPtr pointer, BaseObjectType type, byte oldSeat,
byte newSeat);

public delegate void PlayerChangeAnimationModuleDelegate(IntPtr pointer, BaseObjectType type, uint oldDict,
uint newDict, uint oldName, uint newName);

public delegate void PlayerChangeInteriorModuleDelegate(IntPtr pointer, BaseObjectType type, uint oldIntLoc,
uint newIntLoc);

public delegate void PlayerDimensionChangeModuleDelegate(IntPtr pointer, BaseObjectType type, int oldDim,
int newDim);

public delegate void PlayerWeaponShootModuleDelegate(uint weapon, ushort totalAmmo, ushort ammoInClip);

public delegate void PlayerWeaponChangeModuleDelegate(uint oldWeapon, uint newWeapon);

public delegate void GameEntityCreateModuleDelegate(IntPtr pointer, BaseObjectType type);

public delegate void GameEntityDestroyModuleDelegate(IntPtr pointer, BaseObjectType type);

public delegate void AnyResourceErrorModuleDelegate(string name);

public delegate void AnyResourceStartModuleDelegate(string name);

public delegate void AnyResourceStopModuleDelegate(string name);

public delegate void KeyDownModuleDelegate(uint key);

public delegate void KeyUpModuleDelegate(uint key);

public delegate void ScreenshotResultModuleDelegate(IntPtr strPtr);
public delegate void HttpResponseModuleDelegate(int statusCode, string body, IntPtr headerKeys, IntPtr headerValues, int headerSize);

public delegate void HttpResponseModuleDelegate(int statusCode, string body, IntPtr headerKeys, IntPtr headerValues,
int headerSize);

public delegate void ConnectionCompleteModuleDelegate();

public delegate void GlobalMetaChangeModuleDelegate(string key, IntPtr value, IntPtr oldValue);

public delegate void GlobalSyncedMetaChangeModuleDelegate(string key, IntPtr value, IntPtr oldValue);

public delegate void LocalMetaChangeModuleDelegate(string key, IntPtr value, IntPtr oldValue);
public delegate void StreamSyncedMetaChangeModuleDelegate(IntPtr target, BaseObjectType type, string key, IntPtr value, IntPtr oldValue);
public delegate void SyncedMetaChangeModuleDelegate(IntPtr target, BaseObjectType type, string key, IntPtr value, IntPtr oldValue);
public delegate void MetaChangeModuleDelegate(IntPtr target, BaseObjectType type, string key, IntPtr value, IntPtr oldValue);

public delegate void StreamSyncedMetaChangeModuleDelegate(IntPtr target, BaseObjectType type, string key,
IntPtr value, IntPtr oldValue);

public delegate void SyncedMetaChangeModuleDelegate(IntPtr target, BaseObjectType type, string key, IntPtr value,
IntPtr oldValue);

public delegate void MetaChangeModuleDelegate(IntPtr target, BaseObjectType type, string key, IntPtr value,
IntPtr oldValue);

public delegate void TaskChangeModuleDelegate(int oldTask, int newTask);

public delegate void WindowFocusChangeModuleDelegate(byte state);

public delegate void WindowResolutionChangeModuleDelegate(Vector2 oldResolution, Vector2 newResolution);

public delegate void WorldObjectPositionChangeModuleDelegate(IntPtr target, BaseObjectType type, Position oldPosition);
public delegate void WorldObjectPositionChangeModuleDelegate(IntPtr target, BaseObjectType type,
Position oldPosition);

public delegate void WorldObjectStreamInModuleDelegate(IntPtr target, BaseObjectType type);

public delegate void WorldObjectStreamOutModuleDelegate(IntPtr target, BaseObjectType type);


public delegate void NetOwnerChangeModuleDelegate(IntPtr target, BaseObjectType type, IntPtr newOwner, IntPtr oldOwner);
public delegate void NetOwnerChangeModuleDelegate(IntPtr target, BaseObjectType type, IntPtr newOwner,
IntPtr oldOwner);

public delegate void DiscordOAuth2TokenResultModuleDelegate(byte success, string token);

public delegate void WeaponDamageModuleDelegate(IntPtr eventPointer, IntPtr entityPointer,
BaseObjectType entityType, uint weapon, ushort damage, Position shotOffset, BodyPart bodyPart, IntPtr sourceEntityPointer,
BaseObjectType entityType, uint weapon, ushort damage, Position shotOffset, BodyPart bodyPart,
IntPtr sourceEntityPointer,
BaseObjectType sourceEntityType);

public delegate void CreateBaseObjectModuleDelegate(IntPtr baseObject, BaseObjectType type, uint id);

public delegate void RemoveBaseObjectModuleDelegate(IntPtr baseObject, BaseObjectType type);

public delegate void ColShapeModuleDelegate(IntPtr colShapePointer, IntPtr targetEntityPointer, BaseObjectType entityType,
public delegate void ColShapeModuleDelegate(IntPtr colShapePointer, IntPtr targetEntityPointer,
BaseObjectType entityType,
byte state);
public delegate void CheckpointModuleDelegate(IntPtr colShapePointer, IntPtr targetEntityPointer, BaseObjectType entityType,

public delegate void CheckpointModuleDelegate(IntPtr colShapePointer, IntPtr targetEntityPointer,
BaseObjectType entityType,
byte state);

public delegate void EntityHitEntityModuleDelegate(IntPtr targetPointer, BaseObjectType targetType, IntPtr damagerPointer,
public delegate void EntityHitEntityModuleDelegate(IntPtr targetPointer, BaseObjectType targetType,
IntPtr damagerPointer,
BaseObjectType damagerType, uint weaponHash);

public delegate void PlayerStartEnterVehicleModuleDelegate(IntPtr targetPointer, BaseObjectType type, IntPtr player, BaseObjectType playerType, byte seat);
public delegate void PlayerStartLeaveVehicleModuleDelegate(IntPtr targetPointer, BaseObjectType type, IntPtr player, BaseObjectType playerType, byte seat);
public delegate void PlayerStartEnterVehicleModuleDelegate(IntPtr targetPointer, BaseObjectType type, IntPtr player,
BaseObjectType playerType, byte seat);

public delegate void PlayerStartLeaveVehicleModuleDelegate(IntPtr targetPointer, BaseObjectType type, IntPtr player,
BaseObjectType playerType, byte seat);

public delegate void PlayerBulletHitModuleDelegate(uint weapon, IntPtr victimPointer, BaseObjectType victimType,
Position pos);

public delegate void VoiceConnectionModuleDelegate(VoiceConnectionState state);

public delegate void ScriptRPCModuleDelegate(IntPtr eventPointer, string name, IntPtr args, ulong size, ushort answerId);
public delegate void ScriptRPCModuleDelegate(IntPtr eventPointer, string name, IntPtr args, ulong size,
ushort answerId);

public delegate void ScriptRPCAnswerModuleDelegate(ushort answerId, IntPtr answer,
string answerError);
}
}
Loading

0 comments on commit deea4ab

Please sign in to comment.