Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiplayer quickstart #107

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Multiplayer quickstart #107

wants to merge 7 commits into from

Conversation

amathieson
Copy link
Collaborator

No description provided.

@amathieson amathieson requested a review from space928 September 27, 2024 11:26
 + Use nuget version of OH in multiplayer
Copy link
Owner

@space928 space928 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very messy for an example, please tidy it up and follow the prescribed code style.

_OmsiHookExamples/Multiplayer_Client/GameClient.cs Outdated Show resolved Hide resolved
_OmsiHookExamples/Multiplayer_Client/GameClient.cs Outdated Show resolved Hide resolved
_OmsiHookExamples/Multiplayer_Client/GameClient.cs Outdated Show resolved Hide resolved
_OmsiHookExamples/Multiplayer_Client/GameClient.cs Outdated Show resolved Hide resolved
//vehicle.AbsPosition_Inv = update.abs_position_inv;
i++;
}
else
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tidy this up a bit.

readonly static int MINOR_VERSION = 0;
public static void ParseMessage(byte[] message, Telepathy.Client client, GameClient gameClient)
{
message.AsSpan<byte>(0, message.Length);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use this lovely span you just made?

{
internal class GameClient
{
public Tuple<int, long, long> LastPing;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tuple<int, long, long> LastPing --> (int xxx, long yyy, long zzz) lastPing

default:
{
Console.WriteLine($"Data received {message}");
break;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please be consistent with where you put your break statements.

while (true)
{
Telepathy.Message msg;
while (client.GetNextMessage(out msg))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just realised that the version of Telepathy on NuGet is really out of date (from 2019)...
Latest build is here: https://github.com/MirrorNetworking/Telepathy/actions/runs/10029006044

Anyway, is this a blocking method? If so, why do you thread sleep at the end of this method?

{
case OMSIMPMessages.Messages.REQUEST_VERSION:
{
byte[] buff = new byte[12];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, this is an avoidable allocation...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants