The online racing simulator
[ideas] Pits exit line and points/vectors editor
An idea for a pitlane exit (and enter) AI steward. I post it here, because it contains more technical details than general discussion. Besides, there are many other tools and marshals, so I think it's better for their authors to make this feature, than for me to start another narrow-purpose InSim tool.

Everybody has seen the oval tracks on public hosts: the pit entrance and exit lanes are separated with barriers along the turns, because few drivers follow the marks. Usually a driver joins and at the pits' exit goes straight into the racing line.

The similar, though not that dangerous things may take place on the other tracks.

The idea is to punish those drivers. For usual races, drive-through penalty would be enough. Also there is a quite typical case: a noob joins a host during a race at oval and exits straightforward to the racing line. In this case, it would be safer to make him spectate instantly.

Forcing to spectate can also be applied to those who use the known bug wiyh Kyoto ring pits, which allows resetting from pits on the racing line.

How I'd make the app work

In each case there are two actions together: entering or exiting pits and crossing the line. Line crossing takes place on the same lap with entry/exit. So, for each player we keep an array of data:

1) XY(-1) coordinates
2) XY(-2) coordinates
3) "crossed the line" flag = 1
4) "exited pits" flag = 2
5) "entered pits" flag = 4
6) "joined race right this moment" flag (i.e. the player joined the race or shift+s-ed and hasn't yet left the pitlane) = 8
7) "abnormally accelerated" (to catch car reset) = 16

When a driver enters pit lane, the program sets the player's corresponding flag to "1", and the same for exiting pits. When the driver crosses the separating line, that flag is set to "1". If someone has joined the race (IS_NPL packet received), he also "gets" the flag 6). When crossing a splint or finish line (IS_LAP, IS_SPX packets), all flags are set to 0.

If someone exits pits and crosses the line, we'll have a set of flags: 1 + 2 = 3 (see the list above). If someone enters pitlane crossing a line, it will be 1 + 4 = 5. If someone joins the race and exits from pits, he will have 2 + 8, and if he crosses the line, he will have 2 + 8 + 1 = 11. Kyoto ring pitlane trick: 1 + 2 + 16 (the separating line should continue along the pit lane).

And so on. Simple binary operations. If someone gets a special combination, he is punished. As you see, entering pits may be distinguished from exiting, and punished in a different way, if one cares.

So, the algorythm is the following:

1. get packet of data
2. process it: calculate coordinates, check some conditions and set flags
3. check flags and set punishments to those having specific combinations

Defining the line and pits if needed

I suppose, it should be a set of vectors:

[1: [x1][y1][x2][y2]]
[2: [x1][y1][x2][y2]]
[3: [x1][y1][x2][y2]]
...

that would draw the line. It should be, of course, unique for each track configuration.

Crossing the line basically means that car's movement line crosses this line. We have 2 straights, each set by 2 points and check if they cross and where is the crossing (one point of each straight would be 0, another 1, and we check if the crossing is in this range for each straight).

Acceleration checking is also simple:

speed vector: (vx(t), vy(t)) = (x(t) - x(t-1), y(t) - y(t-1))

acceleration vector: (ax(t), ay(t)) = (vx(t) - vx(t-1), vy(t) - vy(t-1)) = (x(t) - 2x(t-1) + x(t-2), y(t) - 2y(t-1) + y(t-2)).

I haven't found any packet to report pits exiting and entering when driving. So, if pits are needed to be defined, they can be made as set of triangles. Each triangle should have apexes coords and normal vectors per each side (directed inside of the triangle).

(coords of car) - (coords of an apex) will give a vector of car's relative position. Scalar product is positive (not negative) if the car is to the inside of this triangle side. The same for all 3 sides. If all the scalar products for each normal vectors are positive, the point is inside of the triangle.

Another idea: SMX track co-ordinates operating utility

An application that would draw a track and let the user place points and vectors in WYSIWYG mode and give the necessary information:

For a single point:
XY co-ordinates, Z coord of the ground in the place

For 2 points:
1) vector between the 2 points
2) straight line equation coefficients3
3) normal vector to the left and to the right (drawing the normal vector on the map)

For 3 points (triangle):
1) size, square, perimeter, angles
2) normal vectors

For 3 points (angle mode):
1) degrees, radians
2) cosine, sine, tangent and so on
3) bisector vector

Well, maybe even without the latter, but with a possibility to export the values (or just open/save).

P.S. Going to sleep right now. If illustrations are needed, ask me, I'll make them.
mmmh, i think its a good idea..
#3 - filur
Wow, complicated.

I've got pit exit penalty going on all tracks in my insim stuffs by simply grabbing a clients current x/y and testing if they're currently inside a predefined 2d polygon. My WYSIWYG polygon editor is LFS itself.

Penalizing on pit entry doesn't work too good on circuit tracks so i skipped that, but maybe it'll work on the oval.

Your idea for detecting car resets is neat, but i would never attempt automating something which is so likely to be triggered by lag, and i'm sure a CRS packet added to insim would fit in a compatible patch.

struct CarReset
{
char Id [4] // CRS + zero
char UName
char PName
word VerifyId
};

Or perhaps use the spare in CPR and redefine CPR as Conn Player Rename/Reset.

Quote from detail :When crossing a splint or finish line (IS_LAP, IS_SPX packets), all flags are set to 0.

Some finish lines can be crossed inside the pitlane/before actually correctly leaving the pits.
Quote from filur :I've got pit exit penalty going on all tracks in my insim stuffs by simply grabbing a clients current x/y and testing if they're currently inside a predefined 2d polygon. My WYSIWYG polygon editor is LFS itself.

Good news!

How do you define a polygon? Do you split it into triangles?

Quote from filur :Some finish lines can be crossed inside the pitlane/before actually correctly leaving the pits.

I know. But the next tick the app will notice that the car is inside pits and will rise that flag again. Dropping flags at splits would prevent punishment for occasional crossing, for example, if someone spinned in the beginning of the lap and crossed the line, he can safely enter pits the same lap.
Quote from filur :

I've got pit exit penalty going on all tracks in my insim stuffs by simply grabbing a clients current x/y and testing if they're currently inside a predefined 2d polygon.

WOW really? is any of this released?

Just a question, as i understand nearly none of this technical stuff... Does this mean its possible to run something which could issue a penaulty, like a drive thru to a driver who crosses the pit lane exit line? And to report this in some sort of output?

That would personally make my life so much easier in organised events etc..?
Quote from mkinnov8 :WOW really? is any of this released?

Just a question, as i understand nearly none of this technical stuff... Does this mean its possible to run something which could issue a penaulty, like a drive thru to a driver who crosses the pit lane exit line? And to report this in some sort of output?

That would personally make my life so much easier in organised events etc..?

Not yet. He's been working on it for the past few months. He wants to make sure that there is no trouble shooting going on and there for the first release should be rock solid.
Cool.

Ive just read the Insim.txt document, and i could hear the wind whistling through my head. I havent got a clue! I mean.... lol

No worries. I wont hyjak the thread.
#8 - filur
Quote from detail :How do you define a polygon? Do you split it into triangles?

A collection of X/Y points.

Quote from mkinnov8 :Does this mean its possible to run something which could issue a penaulty, like a drive thru to a driver who crosses the pit lane exit line? And to report this in some sort of output?

Yes.

But as Dygear describes, it's not complete. You can visit FLP Racing and cross the pit exit line a few times though.
You're sure you don't want to make it publicly available for more feedback? This sounds very interesting!
Quote from traxxion :You're sure you don't want to make it publicly available for more feedback? This sounds very interesting!

It's working great and has been for very long, but the package is so much bigger then the pit exit thing. Alot of stuff to organize.
traxxion, it will be public when its done. it works really well right now on the FLP-Server, doesnt it?
Quote from filur :It's working great and has been for very long, but the package is so much bigger then the pit exit thing. Alot of stuff to organize.

Theres nothing we can do to get you to semi-release just the pit exit part !!

No, totally understood, just hope its sooner than later, Ill try finding the server later today.
As they say filur; release early and release often

Then again, I am guilty of the same thing

FGED GREDG RDFGDR GSFDG