The online racing simulator
InSim and LFSUsername + detection of green light + IP address of LFS server
Hi Guys,
I started write some small application which finally should calculate times and laps for “shorter” endurance races.
Now I finished first necessary stuff for our cup. It should test the speed limit during first lap and if it is exceed the player is penalized.
Next step will be “warm-up” checker + restart.

And why I am writing here? Of course I have some questions. I am using LFSlib (.NET)

I don’t know:
1)How to obtain LFS user name. If it is possible. (solved, thanks guys)

2)When I am connecting to dedicated server. I need to obtain its IP address. Exist there any possibilities how to translate “LFS server name to IP name”

I think this isn’t possible in InSim, but I have to ask J
1)Exist there any possibility how to detect the green lights (on start-semaphore). I am detecting the car-speed. But this is a bit dirty hack J
2)Exist there any possibility how to handle the start-semaphore?

When anyone wants to test it, download it from: www.interregion.cz/jarda/EGT.ZIP


But keep in mind. It is in development phase (not all from UI is implemented in code, only necessary parts and a lot of UI are missing now) and globally for me it is test, what all I am able to do with InSim. Source code added and is free for use.

On purpose the setting is stored into XML instead any DB. DB is planned for web-appl.

Edit: at 1) I tested it offline and there the connect packet doesn't exist (comes) of-course, my stupidity, as usually
The LFS username is in the NCN packet along with player name and other stuff. As for the rest of it. Im not so sure.
-
(nikka) DELETED by nikka : nevermind...
Quote :1)Exist there any possibility how to detect the green lights (on start-semaphore). I am detecting the car-speed. But this is a bit dirty hack

may be use if it possible when race start time?
Quote from A.Fedorov :may be use if it possible when race start time?

I am not sure, when the race start (packet comes) the cars are on start grid and waits until green flag.
using TINY_RES
if (ISP_RES.ETime > 0) { GreenLigth = true; }
how about tracking the MCI's, and detecting any movements? once they all move ,its pretty safe to say its green?
Quote from Krammeh :how about tracking the MCI's, and detecting any movements? once they all move ,its pretty safe to say its green?

Yes this is exactly the "dirty hack" which I am using now. But I think the advice "A.Fedorov" will be cool. I am looking forward to evening = I will test it. Thanks a lot.
i only suppose this method. No testing
Quote from A.Fedorov :using TINY_RES
if (ISP_RES.ETime > 0) { GreenLigth = true; }

does this work? I doubt.
When I have tested this, LFS only answered to a TINY_RES when I have requested the IS_RES after a race but not during a race. It seem there is no chance to receive a IS_RES during a race.

I suggest you tell us, what do you need the detection of the green light for? Maybe someone has an idea for a different solution.
Ок. i found IT! Your search stop.
use TINY_GTH and SMALL_RTP for get time. Greenlight always flash at 12 second.

if (ISP_MCI && one_pass == NULL) { TINY_GTH; }
if (ISP_SMALL && ISP_SMALL.subt == SMALL_RTP) {
time = ISP_SMALL.uval;
if (time >= 1200 && time < 1210) { echo "GO!!!"; }
one_pass = true;
}
Just curious where the information of the light always flashing at 12 seconds comes from, because to me its quite different... I don't know a different way to do it, but it would be nice to make sure the sources are 100% correct.
I test this with lua script many times.
Traffic-light different start (first red ligth) but greenlight always start at 12 second

example.

(re)start
wait (2 second)
first red start on 3 sec
second red start on 4 sec
wait (7 second)
green start 12 sec

OR

(re)start
wait (5 second)
first red start on 6 sec
second red start on 7 sec
wait (4 second)
green start 12 sec
Quote from Soeren Scharf :
I suggest you tell us, what do you need the detection of the green light for? Maybe someone has an idea for a different solution.

The program checks pit stops. If it was made in right time = when pit the stop window is opened. Otherwise it isn't counted in requested pit-stop counts.

It can be defined by lap (isn't problem to detect it) and by time. I am detecting the car speed on start. It is ok, but the time is a bit shifted. (I start the timer(s), when this is detected).

But it seem I will have to change it too, because, there is some delay untir the packet comes and I detect it. At all for Pit-stop window it is ok. I am just interested, if there is any possibility how to detect it exactly (better)
Quote from A.Fedorov :I test this with lua script many times.
Traffic-light different start (first red ligth) but greenlight always start at 12 second

example.

(re)start
wait (2 second)
first red start on 3 sec
second red start on 4 sec
wait (7 second)
green start 12 sec

OR

(re)start
wait (5 second)
first red start on 6 sec
second red start on 7 sec
wait (4 second)
green start 12 sec

You do realise thats totally wrong? theres only one track on LFS where the lights stay the same time and thats drag strip. Like IRL.
Quote from BabyOnWheels :The program checks pit stops. If it was made in right time = when pit the stop window is opened. Otherwise it isn't counted in requested pit-stop counts.
...

ok, the main fact is, that you do not need the exact time immediately, you need it at a later time.

So it is possible to wait for the first car crossing the first split time, then you will receive an IS_SPX packet where the elapsed race time is included (started counting at the same moment when green light flashes). I doubt somebody is able to enter the pitlane before crossing at least one split time

Nevertheless it is still a rough estimation, because you get the packets with some network delay. But as long as you get the IS_SPX and the IS_PIT packets with the same delay, the error cancels out.

with kind regards
Soeren
Quote from mcgas001 :You do realise thats totally wrong? theres only one track on LFS where the lights stay the same time and thats drag strip. Like IRL.

You mean that the timing is random for the other tracks? Or that the different lights come on at different intervals?

And wait, how did he get access to any track other than BL to test this?
Quote from mcgas001 :You do realise thats totally wrong? theres only one track on LFS where the lights stay the same time and thats drag strip. Like IRL.

Attentive. The Gap before green light always random because gap before first red too random. The General time always equally. Look at begin race (after restart) and you see this.

edit config.lua (address and password) run and fun

note: for single game time = 8 second
Attached files
GreenLight.ZIP - 112.3 KB - 354 views
Quote from dougie-lampkin :And wait, how did he get access to any track other than BL to test this?

Before we start assumptions, which may or may not be safe and I am not pointing fingers, he never did say he tested on more then BL and thats why I am not believing the "always at 12 seconds" line until I see some serious hard evidence and more so then I timed it 100 times...
Quote from blackbird04217 :Before we start assumptions, which may or may not be safe and I am not pointing fingers, he never did say he tested on more then BL and thats why I am not believing the "always at 12 seconds" line until I see some serious hard evidence and more so then I timed it 100 times...

i have friends (S2) who tested this . Look up and run my script
First thats not too compelling of an argument but like I said I am not choosing sides of that battle nor am I pointing fingers...

Like I did say in my previous statement I don't see and concrete proof, documentation, or anything actual evidence that the green light is always at 12 seconds. Those are dangerous assumptions to make unless the devs put that type of thing in a document, which can still change but that would be verifiable proof that it is always 12 seconds... I still don't think it is, I understand its "possible" but I am fairly sure that I have seen the startup procedure last a lot longer and shorter than 12 seconds...
My proof this is my script
Quote from A.Fedorov :Attentive. The Gap before green light always random because gap before first red too random. The General time always equally. Look at begin race (after restart) and you see this.

edit config.lua (address and password) run and fun

note: for single game time = 8 second

I take what i said back. It seems your right. Which means that in theory LFS lights arnt random. Or atleast that script says differnt
I was wrong. not always 12 second. I look at replay and find mistake where i said earlier.

Time = 12 second + integer(number of racers on grid/2)

1 player - 12 second
2 player - 13 second
3 player - 13 second
4 player - 14 second
5 player - 14 second
New version uploaded.

- Speed limit in first lap finished (ready for testing)
- Warm-up navigation to initial position after 1. lap done (tested in meters, will be changed into cm). necessary to add, check of car movement + restart semaphore (as text).

LfsLib.NET = speed fixed (Int32) / (float) = speed was cut = not float but Int32
CarInfo.cs
/// <summary>
/// The speed of the car in meters/second
/// </summary>
public float Speed
{
get { return (float)compCar.Speed*(float)100/(float)32768; }
}

Edit: New version uploaded, code checkers Refactored, I hope now it is much better and understable
- Speed limit finished
- Warm up checker finished
1

FGED GREDG RDFGDR GSFDG