The online racing simulator
Searching in All forums
(920 results)
detail
S3 licensed
Ok, here is a dirty version of plugins system. Thanks to Dygear for the idea. The previous version didn't work actually, because correcting one mistake, I've made another. This time I've tested the app and all the functions, didn't see anything going wrong and didn't change anything then

Delete the previous version, because this one doesn't need anything from there.

So, see the plugins folder for details. One of the plugins co-works with another one. Unfortunately, calling functions from other plugins coudn't be shorter. But now it is possible to have several plugins handling the same packet and interoperating with each other. Dygear's get_client_name($PLID) function and the "database" beyond it can be made with a plugin.

I've avoided making a function like "register_plugin" to minimize and simplify the code. Plugins system uses the same naming convention.

Some settings should be moved from the main scripts into config. This version is less optimized, because it unpacks any packet when receives it. Actually, it's better to decode only if there is a handler for the packet. Need to work on this, but it's late night already, have to work tomorrow.
detail
S3 licensed
Quote from Dygear :Each plugin should be it's own file, and there really should be a plugin directory.
Something like this code would make writing plugins for InSim so much easier.

Ok, I'll think about it.

Actually, right now you can already write a bit easier than in your example. The constants are already defined, you don't need to write bare numbers.

<?php 
    $Laps 
get_client_lap($PLID);

// I'd define an array to avoid copying many if's. Just more compact code.
$WorkString = array(PITLANE_EXIT => 'left pit lane',
        
PITLANE_ENTER =>'entered pit lane',
        
PITLANE_NO_PURPOSE => 'entered for no purpose',
        
PITLANE_DT => 'entered for drive-through',
        
PITLANE_SG => 'entered for stop-go');
        
ISP_MST("{$PName} {$WorkString[$Work]} on lap ${Laps}.");
    }
}
?>

detail
S3 licensed
Quote from Ian.H :Silly question


Quote from detail :(Actually, I already don't need that since I've made the parser I needed).



It could be useful if someone shares this stuff. BTW, I have published a PHP parser for InSim (it's not yet able to make dynamic structures, like CMX where an int defines the number of blocks, but it won't be hard to implement).
detail
S3 licensed
I know that. Those in the wiki repeat the descriptions from the official site. But I want a different thing. Look into InSim.txt for the example. That file effectively is a C header file, you can include it into code and have all the structures defined. You don't have to rewrite them in your code as I'm doing right now with CMX files.

See the difference.

CMX specification. Just a text.

LIGHTSCHEME BLOCK :

16 char 0 lightscheme name : name
16 char 16 sky texture name : texture
16 char 32 environment texture : texture
1 col 48 sky colour : rgb0 - average sky colour
1 col 52 sun colour : rgb0 - artist defined
1 float 56 sun intensity : sun colour multiplier
1 float 60 sky boost : sky colour multiplier
1 float 64 sun heading : radians, CCW from forward(Y)
1 float 68 sun pitch : radians, up from ground

InSim: an includable header.
struct IS_ISI // InSim Init - packet to initialise the InSim system
{
byte Size; // 44
byte Type; // ISP_ISI
byte ReqI; // If non-zero LFS will send an IS_VER packet
byte Zero; // 0

word UDPPort; // Port for UDP replies from LFS (0 to 65535)
word Flags; // Bit flags for options (see below)

byte Sp0; // 0
byte Prefix; // Special host message prefix character
word Interval; // Time in ms between NLP or MCI (0 = none)

char Admin[16]; // Admin password (if set in LFS)
char IName[16]; // A short name for your program
};

I'd like, for example, the CMX specs to be presented like the latter. (Actually, I already don't need that since I've made the parser I needed).

If somebody has made those structures for other projects, please, share them.
Request to Scawen: specifications of cmx, lyt & other files
detail
S3 licensed
I don't ask just for specifications, I know they are here. My request is to release a C header file, like InSim.txt, so that other programmers could include them or parse.

I have a PHP parser of InSim.txt that imports all the consants and structures into PHP. I could use it for file formats if there were a file of the same format.
detail
S3 licensed
Updated.

1. Added a simple scheduler of the packets to be sent (better to say delayed delivery). Some debugging work needed on this, because sometimes I get one packet twice. I'm out of ideas what's the reason (adding and removing var_dump's and print's in some unknown way made it work properly or not)
2. Added a callback mechanism for text commands.
3. Commented most of the code.

The demo script says "hello" to each visitor (after random number of seconds). If you type "!say" command, it will reply to you.

[edit] Reuploaded the file (serious bugs, corrupted structures).
Last edited by detail, .
detail
S3 licensed
What will change in InSim with introduction of multibyte codepages?
detail
S3 licensed
So, here is a simple working demo of the app that maintains a connection and calls back user functions when receiving packets.

You have to name your callback function like CBF_ISP_NCN (callback function for new connection packet) and set standard arguments.

Here the first time I faced the limitations of PHP. It's tempting, but I can't do like in JavaScript:

<?php 
define
("ISP_ISI"1);
...
userfunc[ISP_ISI] = function($param1$param2) {
// code 
};
?>

Anyway, I already have a dirty workaround for this.

Of course, to make a more functional and stable app, I need 1) error handling in the functions to prevent wrong calls from a user 2) connection/LFS failure handling 3) keeping state info in memory so that all of it were available to user functions instantly.

Anyway, I wanted to output a working thing AFAP, and here it is.

Though, I doubt if this thing, with such a complex callback mechanism, can handle 32 cars with 10 MCI packets per second... (40 packets to be exact)
php InSim application demo/POC
detail
S3 licensed
Here is a bare and dirty concept demo that connects, maintains connection and logs the events, and surprise! CALLS USER FUNCTIONS FOR PACKETS! (something similar to LuaLFS)

This is an early working demo, so don't expect too much from it.

how to run it
Modify config.inc.php (and php_insim_base.php for admin password) and run
> php.exe -q php_insim_base.php

You need a dedicated host to run (config and .bat attached).

Why I do this? So far, I want to make a PHP app for myself. To make it, I need a base application. I hope this can be a base for others and there will be other contributors. Though I like the concept of LuaLFS and it looks very tempting, still I don't want to spread myself into many languages. (Having to work in VBA at my work and at the same time to code something in PHP for hobby, is such a pain...)

P.S. lurLFSd is a nice thing, yet I can't (rely on|wait for) this project.
Last edited by detail, .
detail
S3 licensed
Ok, now I understand: it happens when my InSim app disconnects and LFS tries to send keepalive packets. LFS tries to connect to the same port, and there are no slots. That's what causes this message.
InSim: why so many message packets? [resolved]
detail
S3 licensed
I study the InSim.txt and can't understand why there are so many different packets for text messages and commands.

What's the difference between IS_MSO, IS_MSX and IS_MTC?
What is IS_MSX for?
What does "messages in" and "messages out" mean? (I thought I got the logic, but now I'm confused)
PHP InSim app draft
detail
S3 licensed
Last edited by detail, .
detail
S3 licensed
Probably you didn't get it: I don't run the script again. I get these messages after the first and the only run of the host and the script.

0) No LFS is running for much time.
1) I start a new instance of LFS host
2) then I run a script just once. As soon as it recieves the ISP_VER packet, it ends.

And still there are those junk messages.
[php] Strange behaviour of LFS host
detail
S3 licensed
I run LFS nogfx host and then connect to it with a php script

> php\php.exe -q script.php


<?php 
include("insim_constants.inc.php");

set_time_limit (0);

$address '192.168.0.2';
$speakPort 29999;
$listenPort 30000;
$maxClients 1;

$sockIn socket_create(AF_INETSOCK_DGRAMSOL_UDP) or die("Couldn't create listen socket");
socket_bind($sockIn$address$listenPort) or die('Could not bind to address'); 

$sockOut socket_create(AF_INETSOCK_DGRAMSOL_UDP) or die("Couldn't create send socket");
socket_connect($sockOut$address$speakPort) or die('Could not connect to address'); 

$pack pack("CCCxSSxCSa16a16"44ISP_ISI1$listenPortISF_NLP361000"detail""detail");
socket_write($sockOut$packstrlen($pack));
print(
bin2hex(socket_read($sockIn20PHP_BINARY_READ)));

exit;
?>

Actually, the script makes a connection, receives ISP_VER and prints its contents to stdout, then closes. LFS should close the connection on timeout.

Strange thing is that in LFS window I see


InSim - UDP : detail (port 30000)
InSim - UDP : no slots available
InSim - UDP : no slots available
InSim timeout : detail

What causes those 2 "no slots" messages? I don't run the script twice.
detail
S3 licensed
Quote from senn :Do you think ppl who use a mouse are gonna put "MOUSE" into their name? wtf is wrong with ppl.

Nice idea! I'll do that!
Problem with 3 language layouts in patch Y
detail
S3 licensed
I use 3 layouts: Russian, English and Italian. I need all them in LFS as well. Before all three worked fine, but in Y Italian doesn't work correctly for me. Instead of symbols like è à ò ù ì, I get those without diacritic signs: e a o u i. Windows XP64. Before patch Y it always worked.
detail
S3 licensed
наконец-то ещё один кирилический перевод
detail
S3 licensed
The joke about a pink wheel is useless, because for a mouse driver nothing has changed in LFS. I continue driving with mouse and don't see a problem to change gear. Yes, I'd like to buy a rudder & pedals (not a round wheel), but don't want to bother myself with mounting and unmount it to the table.
Last edited by detail, .
detail
S3 licensed
The lessons are changed a lot, thus the files with the old texts are not used anymore. And looks like Hungarian translator hasn't done the new translation before patch Y was released.
detail
S3 licensed
First, a suggestion. In the lessons, FZ50 GTR runs on the oval. Once in S2 we've made a race in usual FZ50 on KY1R. This is the only car that has to brake on the oval. Maybe make a lesson with it? The most complicated part in this is T1: you may brake there, but also you may enter it in a slight drift which will absorb the excessive speed. Maybe add some AI and make several laps race?
Last edited by detail, .
[Aston] Markings on the ground float inside of the car
detail
S3 licensed
Once I bought a big chinese firework, 4 units. Don't remember the title, it said something about "devil" or "inferno". Well... it was rather a bomb. You put it on a butt end, fire the fuse. It fires the first time, jumping high into the air and then explodes with a lot of noise. I wanted to test one and chose the one in which the fuse was torn off. I fired it and quite rashly threw it from me. UNEXPECTEDLY it blew up in a fraction of second! It flew towards me in centimeters from my head, then it hit a garage door beyond me and UNEXPECTEDLY exploded. I was shocked. (Actually I knew how it works, but it happened too unpredictably). Only when I returned home, I got how dangerous was it.

I was 14 or 15 years old. That new year I fired all the remaining bombs and never more bought such stuff.
detail
S3 licensed
The most funny way this shaking effect was expressed in LFS was before, maybe patch V or W, when the viewpoint could travel anywhere. If you drove backwards into a wall, you could see your head. In BF1 at the oval your eyes moved laterally as far as to the wheel! Was funny watching your car from the outside.

Back in 2003 I noticed that moving POV makes you feel you turn or brake more that in reality, and I switched it off.
detail
S3 licensed
Agree. Moreover, it doesn't take long to learn and adjust. Just couple of hours of driving, and you switch gears properly.
Quote from JTbo :If clutch burns, your 1st gear is too tall or you are not driving properly

True. I also noted that 1st gear was too tall in all the best setups.
FGED GREDG RDFGDR GSFDG