The online racing simulator
Searching in All forums
(82 results)
xspeedasx
S3 licensed
Ok so its just what I thought - its based on bandwidth and not specific/corrupt insim packets..
I'll try to record my inSim behavior - what packets are being sent at which rates (bytes/s). Maybe it will give a better understanding where is the bottleneck.
Thanks for explanation!
Last edited by xspeedasx, .
DDoS Protection too strict?
xspeedasx
S3 licensed
Hi, I'm getting quite considerable amount of these notifications while messing with my InSim app (on LFS hosting).
Quote from server activity :
Nov 10 09:28:53 [RC] : [DDoS Protection] Host network attack detected.
Nov 10 09:28:53 [RC] : [DDoS Protection] Lock-down mode is now enabled!


Is there a way to know what exactly triggers them?
Is there a debug log of some sorts for LFS-hosted servers?
xspeedasx
S3 licensed
Well, just now, the .NET 6 LTS has been released.. and its going to be supported for the next 3 years (hence the LTS).
While the .NET 5 is not LTS and will not be getting any patches soon.
So I'll probably be upgrading net5 branch to net6, but a pull request will have to be made to the net5 branch in the main repository and then renamed to net6. Does that sound good?

P.S. the net 4.5 InSim.NET was upgraded to support 0.6W (insim 9). It just wasn't posted to NuGet so you (InSim.NET users) have to clone/download the source and build it yourself Big grin it shouldn't be very hard, post here if you're having any difficulties with that.
xspeedasx
S3 licensed
Quote from gu3st :Except those unverified mods still open LFS up to legal issues by potentially distributing copywritten work.

I took this in consideration:
Quote from xspeedasx :There would be minimal requirements (legality, profanity, etc) to submit mod as "unverified"

xspeedasx
S3 licensed
Hi, I would like use another game's user-created content management as a reference to LFS mod system.

There's this game called Beat Saber (maybe you've heard about it, idk Big grin):

You slash some boxes in VR to the rhythm of a song.

There's a huge modding community for it, since original content is considerably boring.
Although all mods (custom songs/maps) break the copyright and are borderline illegal, just hear me out about it Big grin

There's this "underground" leaderboard (scoresaber.com) that only includes results from modded songs.
But the interesting part is that not all modded songs count to your "total score".
There's a ranking team that approves maps if they conform to the criteria and follow guidelines.

So the takeaway from this would be a 2-tier mod list - verified and unverified mods.

Servers could choose if they want to enable none, only verified or all mods.
There would be minimal requirements (legality, profanity, etc) to submit mod as "unverified" - later the creator could be guided how to improve it to reach a "verified" status.
So a small team could focus more on whether mods are worthy of being officially verified, and the unverified mods can still be accessed by masses and receive votes.

When the system settles, there could be some changes made to it according to how it goes.

That's my 2 cents. Thank you for reading Smile
xspeedasx
S3 licensed
Can the mods be renamed?
in that case, getting the freshest name always would be more preferred than managing staleness of a cache or having a separate call.
xspeedasx
S3 licensed
Quote from Scawen :I was wondering if it would be helpful to send the actual car name along in InSim packets.

The server already can relate car name to Skin ID.

My suggestion is to either
1) make bigger version of existing packets, with full car names included as well as Skin ID.
or
2) provide simple packets to ask the host to convert between Skin ID and car name.

What the game server actually could do, for case (2) above:

- For any given car name could look up the Skin ID and return the Skin ID if that car name exists as an uploaded mod.
- For a given Skin ID, it could return the car name. But for this one it only knows the car names for Skin ID of players in the race.

Would any of that be helpful? It seems better to avoid web queries if possible.

web queries are much slower than using direct TCP/UDP to the server (and also requires the OAuth flow/token management flow) so getting that data from lfs server would be ideal.

(Web API can still be used when integrating insim control/monitoring into websites)

* 1st option would be much easier for insim developers to quickstart their apps with human-readable car names (for leaderboards, car allowing ui options, other tasks that would require car names).

But on the other hand - it would increase bandwidth with (mostly) unnecessary data - if mod car names don't change it would be more efficient to store those values in a cache.

* which covers the 2nd option - it would be more efficient to request car names from server when they are actually needed (with a new IS_TINY probably) and can be cache them locally. But that requires having a more structured insim app, which most of the tinkerers don't bother to make

so that's that Big grin any other thoughts?

EDIT: In any case, it would be possible to implement caching/requesting into the library itself (thinking about InSim.NET) and return extended NPL, RES, etc. packets which would include actual car name (CFullName for example).
Last edited by xspeedasx, .
xspeedasx
S3 licensed
Quote from crazyboy232 :Are we(old school 4.5 framework guys) going to receive an update for the updated car names and everything else as well? Smile

Hi, sure, I'll give it a crack after work - should be pretty straightforward
xspeedasx
S3 licensed
Quote from Bass-Driver :Are there packets that doesn't require the divide/multiply stuff?

in InSim 9 all packet sizes are modified Smile
xspeedasx
S3 licensed
From the PHP code it seems that the parameters should be POSTed in x-www-form-urlencoded format.

I'm using Postman to do that, but the server responds with 401:

{
"error": {
"message": "Client authentication failed: invalid_client"
}
}

And yes, my app is registered with no redirect url and SPA option turned off
LFS REST API General support
xspeedasx
S3 licensed
Starting a new thread about REST API so that I can work out some issues and possibly help others on their way going forward.

Here is some known info so far:

First, register your application at https://www.lfs.net/account/api .
You can then request a Bearer token with your client ID and client secret at id.lfs.net. Quick example:

// Request a Bearer token by using the client_credentials grant type.
// This requires client_id and client_secret.
// One can simply fetch that by POSTing those values. See below for example.

$accessTokenUrl = 'https://id.lfs.net/oauth2/access_token';
$accessTokenPost = [
'grant_type' => 'client_credentials',
'client_id' => 'dfffniwufhnfr823nhr',
'client_secret' => '4n8rrrn3ycnf48ycf8ny4r',
];

$context = stream_context_create([
'http' => [
'method' => 'POST',
'header' => 'Content-Type: application/x-www-form-urlencoded',
'content' => http_build_query($accessTokenPost),
'ignore_errors' => true,
]
]);
$result = file_get_contents($accessTokenUrl, false, $context);
if ($result)
{
$json = json_decode($result);
print_r($json);
}
else
{
var_dump($http_response_header);
var_dump($result);
}

With the obtained Bearer token, you can use our new API at https://api.lfs.net . Quick example:

$bearerToken = 'abcdefetc';
$apiUrl = 'https://api.lfs.net/vehiclemod';
$opts = array('http' =>
array(
'method' => 'GET',
'header' => 'Authorization: Bearer '.$bearerToken,
)
);

$result = file_get_contents(
$apiUrl,
false,
stream_context_create($opts)
);

if ($result)
{
header('Content-Type: application/json');
echo $result;
}
else
{
var_dump($http_response_header);
var_dump($result);
}

That gives you a list of all vehicle mods. The schema of a VehicleModSummary object:

{
"data": {
"id": string // Vehicle Mod identifier. AKA Skin ID, in HEX format
"name": string // Vehicle Mod name
"descriptionShort": string // Short description
"description": string // Description
"userId": int // Uploader user ID
"userName": string // Uploader user Name
"wip": boolean // Work In Progress
"publishedAt": int // Unixtimestamp of publish date
"numDownloads": int // Number of downloads
"curUsage": int // Number of racers using this mod online right now
"rating": int // Rating, from 0 - 5
"numRatings": int // Number of people who rated
"version": int // Vehicle Mod Version
"lastDownloadedAt": int // Unixtimestamp of last download date
"class": int // Vehicle class
"ev": boolean // Electric Vehicle if true
}
}
}

"class":
0: Object
1: Touring car
2: Saloon car
3: Buggy
4: Formula
5: GT
6: Kart
7: Bike
8: Van
9: Truck
10: Formula 1
11: Formula SAE

You can also get more detailed by performing a GET /vehiclemod/{id} which will return:
{
"data": {
"id": string // Vehicle Mod identifier. AKA Skin ID, in HEX format
"name": string // Vehicle Mod name
"descriptionShort": string // Short description
"description": string // Description
"userId": int // Uploader user ID
"userName": string // Uploader user Name
"wip": boolean // Work In Progress
"publishedAt": int // Unixtimestamp of publish date
"numDownloads": int // Number of downloads
"curUsage": int // Number of racers using this mod online right now
"rating": int // Rating, from 0 - 5
"numRatings": int // Number of people who rated
"version": int // Vehicle Mod Version
"lastDownloadedAt": int // Unixtimestamp of last download date
"class": int // Vehicle class
"ev": boolean // Electric Vehicle if true
"vehicle": {
"iceCc": int // ICE cc
"iceNumCylinders": int // ICE number of cylinders
"iceLayout": int // ICE engine layout
"evRedLine": float // EV redline
"drive": int // Drive
"shiftType": int // Shift type
"power": float // Power in kW
"maxPowerRpm": int // Max power at RPM
"torque": float // Torque in Nm
"maxTorqueRpm": int // Max torque at RPM
"mass": float // Total mass of vehicle in kg
"bhp": float // BHP
"powerWightRatio": float // Power to weight ratio
"bhpTon": float // BHP per ton
"fuelTankSize": float // Fuel tank size. If "ev" = true, its unit is kWh, otherwise litres
}
}
}

"class":
0: Object
1: Touring car
2: Saloon car
3: Buggy
4: Formula
5: GT
6: Kart
7: Bike
8: Van
9: Truck
10: Formula 1
11: Formula SAE

"iceLayout":
0: inline
1: flat
2: V

"drive":
0: None
1: Rear wheel drive
2: Front wheel drive
3: All wheel drive

"shiftType":
0: None
1: H-pattern gearbox
2: Motorbike
3: Sequential
4: Sequential with ignition cut
5: Paddle
6: Electric motor
7: Centrifugal clutch

xspeedasx
S3 licensed
well the
packet[0] = 8 * 4;

should be 2 (divided by 4 so that sizes up to 1020 can fit into 0-255 possible values).
packet[0] = 8 / 4;

and the size after reading can be calculated like this:

public ACR(byte[] packet)
{
PacketSize = pakGetByte(packet, 1) * 4;

xspeedasx
S3 licensed
Quote from Bass-Driver :I cannot get the modded carnames to work. Somehow when i convert the characters to Hex, there is always one char that doesn't convert well. I have been looking on the web about converting Strings into bytes and than to Hex and trying several methods, but with no luck.

Hey, take a look at this method, I think it is pretty straightforward when you have the 4 bytes of CName in a packet:
// length is not needed here, since CName is known to be 4
static string pakGetCName(byte[] pak, int first)
{
var buf = new byte[4];
Array.Copy(pak, first, buf, 0, 4);
if (isAlphaNumeric(buf[0]) && isAlphaNumeric(buf[1]) && isAlphaNumeric(buf[2]))
{
return LfsEncoding.Current.GetString(pak, first, len);
}

return buf[2].ToString("X2") + buf[1].ToString("X2") + buf[0].ToString("X2");

bool isAlphaNumeric(byte b)
{
if (b >= '0' && b <= '9') return true;
if (b >= 'A' && b <= 'Z') return true;
if (b >= 'a' && b <= 'z') return true;
return false;
}
}

Quote from Bass-Driver :Also the new packetsizes is a real struggle for me. No idea what todo here. I have been checking insim.Net codes what they have done and trying the same way, based on their code. Also with no luck.

all you have to do is:
[reading packets] when you read in the first byte of the packet - multiply it by 4
[sending packets] same as reading, when writing the packet to insim connection, divide the size by 4

Also, its actually a good idea to have the size passed separately or in your case (I've glanced over the lapper code a little bit) it can be calculated from the buffer length (divided by 4)


EDIT: Updated code snipped to the one that should fit your code
Last edited by xspeedasx, .
xspeedasx
S3 licensed
Quote from Victor :hmm but it's json? No xpath stuff needed.
Anyway, don't let us hijack the insim topic Smile

edit - oh maybe you mean you are now parsing a web page - yeah .. that's not ideal Smile

Sorry, didn't see your post about REST Smile I'll give it a try!
xspeedasx
S3 licensed
well the html approach works but is kind of dirty (parsing html and doing xpath searches is quite slow).
I'm also wondering how paging will work when there will be more approved mods.

The NPL was my total oversight Big grin it was as you said - a Join request with numP=0 - I took parts of my old inSim and was building on top of that so I've missed that ISF_REQ_JOIN was set.
xspeedasx
S3 licensed
Its alright as it is, you just have to fix the conflicts by overwriting files from my branch Smile

btw, updated the net5 branch to support 0.6W version (Insim 9)
xspeedasx
S3 licensed
Would it be possible to get the "nice" name of the mod car (RB4 GT T5 RESCUE~002 in this case) from server through inSim? Or at least a RET API connection to current mod list?

Also I don't remember server sending 2 consecutive NPL packets (one when "join" is clicked, and another on vehicle spawned)


is there a specific reason for that?
xspeedasx
S3 licensed
Quote from Scawen :EDIT: I noticed your (XRZ = 58525A) is the wrong way round. If XRZ was a mod ID (which it can't be, as all are alphanumeric) then it would be number 5A5258 (because of Intel byte order).

Alright this seems pretty straightforward

Quote from chucknorris :Possible solution would be to breakdown the hardcoded cars-section into an array so we can send parameters for any possible car/mod id. We'd have to send multiple packets then, depending on the number of installed mods, but at least it would be a way to do it.

With the new packet sizes there should be more than enough space for sending allowed car list (4x120 bytes)
and HCP could have updated CarHCP struct with a car ID, totalling to 6x120 bytes

EDIT: if we could also sneak in a PLID somewhere in there and set those to each player individually, that would be even better! Big grin
xspeedasx
S3 licensed
Hi, regarding CName:
does this mean that mod's skinID bytes (hex chars) can never be in range of alphanumeric (0x30-39, 0x41-5A, 0x61-7A)?
for example skinId 58525A would translate to "XRZ" and would be neither valid skinId neither an official car?
xspeedasx
S3 licensed
Hi, nice to see you still active on LFS forum Smile
I've raised a PR, but since net5 branch was created based on master (.net 4.5), the PR looks a bit messy, but it should merge(overwrite everything) nicely and work fine - I'm using a package from that exact branch now.

For the future - maybe adding some async/async options for event handlers and inSim commands would be cool.

Although I can attest that the .Net5 version is quite stable - I wrote an app that is capable of handling 5 servers simultaneously, cross-server chat works fine, Discord bot works without any glitches, and servers haven't had any major downtimes.
xspeedasx
S3 licensed
Quote from Bose321 :Cool stuff! Maybe do a pull request? Would only improve the base of the code if it's stable.

Well, the .net5 version doesn't really fit with any of the branches in the original repository (there are versions for .net 4.5, .net core 2 and .net core 3).

So for me to do a PR, the original author should create a new branch that I could create a PR to.
xspeedasx
S3 licensed
Hi, I've forked and converted the lib to .NET 5 (for running on a linux host and single-file self-contained runtime capabilities) and decided to share the code if anyone's interested: https://github.com/xspeedasx/insimdotnet
xspeedasx
S3 licensed
Hi, thinking about this from a Cruise server perspective,

will there be any changes to InSim to support new mod vehicles?
How about vehicle 3(4?)-letter names in IS_NPL, IS_SLC?
Number plates on modded vehicles?

Could we have a bunch of same car with different configurations that could be changed on the fly with insim (with some IS_TINY command for example)?
Could there even be vehicle intake restriction/added weight/weight position changes from insim?
I'm thinking about some cruise server fun stuff like
- NFS U2 style car tuning
- or trucks with different cargo options (no cargo, light cargo, heavy cargo
- or enforcing new driver/bad behavior by limiting performance without having a different vehicle
Forum bug with post index mismatching
xspeedasx
S3 licensed
in the forum link https://www.lfs.net/forum/thread/85771-LFSLazy/page/44 - 44th page - last post is
'-(MicroSpecV) DELETED by MicroSpecV : Retarded questionSun 9 Jul 2017, 10:40'
which comes after post with number #1100

in the 45th page it's repeated and the next post is #1101 (like it should be), but the the page only displays posts till #1124
and page 46 starts with #1126

so in other words - deleted posts count as normal posts and pushes last post out of 'display 25 posts per page' array

possible fixes :
- deleted posts should have a '#' so they count into displayed post queue
- 2 separate selects that select regular posts and another that gets deleted posts that are in the active range
FGED GREDG RDFGDR GSFDG