The online racing simulator
InSim lag issue
(8 posts, started )
InSim lag issue
My and my brother are connected to my server (locked).

no lag issues to be seen.

Once I load the insim php script (using php insim.php within putty), it all connects all well and good, but it causes lag above the cars (lag x.xxS).

Quote :
while(TRUE) {
$packet = fread($receiver, 1024);
//lots of shit here! :P
}

thats what I'm using, any hints?
If you've set the stream to be non-blocking, that will hammer the CPU, and cause lag.

You may wish to consider using socket_*, which gives you the opportunity to use socket_select - which prevents CPU hammering.
I've not compiled PHP with those.

Is stream blocking needed? any work arounds?
imo if you want to code proper networking scripts, socket_select (or better stream_select) is the only way to go.
A work around would be to use things like usleep () to pause a little in every while-loop, but this is ugly coding imo. Hence the xxx_select function is much better, as it will wait until there's actually a packet to read. Or you can set it to wait for X (micro)seconds, if there are other things you must do in the loop than read a packet.
okay, now that I have made that much better (thanks for the tips ).

There's one thing that I need to do, that I just cannot understand.

Thats the location of the car, (as in, x/y on the map).

Possible?
You can use MCI(all cars) packets or OutSim(only your car) to get the positions
Yeah I figured that I can use the MCI,
when I use them, the XYZ goes CRAZY when movement is found, and it takes AGES for it to settle back down.

How often should I request them?
Anybody got a PHP script how to unpack them properly?
Sorted the above issues

InSim lag issue
(8 posts, started )
FGED GREDG RDFGDR GSFDG