The online racing simulator
Quote from Dygear :Using $PRISM->hosts->getHostById($HostID)->State, will get you the ISS state flags for that host.

Actually it's $PRISM->hosts->getStateById($HostID)->State , but you got me looking in the right direction.
Quote from Victor :Actually it's $PRISM->hosts->getStateById($HostID)->State , but you got me looking in the right direction.

Oh, sorry! Should really fact check myself before I hit submit. :P
Quote from Dygear :Cargame, if you can try that out, let me know what's working and what's not on a populated server.

Hmm it still is only working for one car...

Or should I say... One MCI package.

It looks like it is only working for the first player inside a MCI package because when somebody leaves it switches to another player.

Oh, and while your on it...

This shouldn't crash PRISM, only the LVS system should not work in these cases;

Quote :< IS_STA Packet from S1.
PHP WARNING:
file_get_contents(/prism043a/data/pth/BL1X.pth): failed to open stream: No such file or directory in /prism043a/modules/prism_pth.php on line 25

Quote from cargame.nl :It looks like it is only working for the first player inside a MCI package because when somebody leaves it switches to another player.

Oh, yeah. That's because I'm using return and not continue.

Quote from cargame.nl :This shouldn't crash PRISM, only the LVS system should not work in these cases;

Yeah, that's because, I don't have the X/Y pth files, and I don't have a mechanism yet to load a pth file based off the current layout. It's something that I've never had, and I would need the pth files, and the layout files that your using. These would have to be standardized for use on other servers, or the LVS plugin will only really work on Cargame servers, while that might be good for you, it does not help anyone else.
It's no problem for me because I can fix that myself if I want. I talk for others here

Who? No idea, but it's not bad to have a good fundamental base. Why do I not submit changes then? I think my coding and thinking is way too messy/sloppy/old for official stuff.

And like I said, there don't necessarily need to be support but this shouldn't lead to a complete crash. All I wanted to say. Just my opinion
I pushed a new branch 'messaging'.

It contains the fix for the State bug reported on GH and it contains a new class for sending messages to LFS. I put that in prism_functions.php (even though it's a class, it feels like a helper function)

Because it's pretty simple I'll post here it as well :


<?php 
class Msg2Lfs
{
    public 
$PLID 0;
    public 
$UCID 0;
    public 
$Text '';
    public 
$Sound SND_SILENT;
    
    public function 
__construct($text '')
    {
        
$this->Text $text;
        return 
$this;
    }
    
    public function &
__call($name$arguments)
    {
        if (
property_exists(get_class($this), $name))
            
$this->$name array_shift($arguments);
        return 
$this;
    }
    
    public function 
send($hostId NULL)
    {
        if (
$this->Text == '') { return; }
        
        global 
$PRISM;

        
// Decide what IS packet to use to send this message
        
if (($PRISM->hosts->getStateById($hostId)->State ISS_MULTI) === 0)
        {
            
// Single player
            
IS_MSL()->Msg($this->Text)->Sound($this->Sound)->send();
        }
        else
        {
            
// Multi player
            
if ($this->UCID 0)
                
IS_MTC()->UCID($this->UCID)->Text($this->Text)->Sound($this->Sound)->send();
            else if (
$this->PLID 0)
                
IS_MTC()->PLID($this->PLID)->Text($this->Text)->Sound($this->Sound)->send();
            else
                
IS_MSX()->Text($this->Text)->send();
        }

        return 
$this;
    }
}; function 
Msg2Lfs() { return new Msg2Lfs; }
?>

You can continue to use the same chained notation for sending messages to LFS, but you don't have to decide anymore what packet type to use. Msg2Lfs decides it for you.

so instead of :

<?php 
IS_MTC
()->PLID($CompCar->PLID)->Text('You are ^1off^9 the track!')->Send();
?>

you can just write :

<?php 
Msg2Lfs
()->PLID($CompCar->PLID)->Text('You are ^1off^9 the track!')->Send();
?>

easy peasy!
If you do not provide a PLID or UCID, then an MSX packet will be used. Or if prism is connected to a single player client, MSL will be used, despite of the PLID being set.

I recommend using that function for all your messages to LFS.

I've made the LVS.php file an example where I've replaced all IS_MTC and IS_MSX with Msg2Lfs.
I'll merge that when I get home, thank you.

Vic, do you have any interest in doing a LFSString class? I'm looking for a class that I can bolt onto the message packets, and have it take over to the Text and Msg propertys. I want something that will allow me to do something like this...


<?php 
public function onMsgOut(IS_MSO $MSO)
{
    
$MSO->Msg->toUTF8(); // Converts to UTF-8
    
$MSO->Msg->toUTF8(); // Converts to UTF-16
    
$MSO->Msg->toHTML(); // To HTML string.
    
$MSO->Msg->toLFS(); // To LFS String
    
$MSO->Msg->Strip(); // Remove all colors.
    
$MSO->Msg->Wrap(80); // Word Wrap at the 80th Char.
}
?>

Pretty sure we can come up with better method names then that, but that's pretty much what I'm looking for. I've seen some pretty funky things happen with code pages so I'm sure that you would do a better job that I could on the subject.
i'll have a think about it
So I merged Vic's changes, and I fixed the bug in LVS where it only reports too the first player. These have changes have been committed and uploaded to github. I checked these changes on cargames server, and they worked without incident, but that was only on WE1R. The only thing I have to add now is a support for pth files based on layouts. So I'll do a check in the program to see if the track is an X or Y track, and then I'll check to see if their is a pth file that corresponds to the layout. I will require that all server hosts to keep their pth files in a single directory within prism to standardize it for all server hosts and promote compatibility for all.

Vic and I also discussed a class for LFS strings, that should help everyone out, but it might be a while until we see it. I'd like to have it for version 0.5.0, so we all have some time to ponder how we want this to look.
Pushed another update, that includes support for custom pth files on the open configs. You have to have the custom pth files in $PRISM/data/pth/ AND the layout name must match that of the PTH file. Tested on Cargames server again, it loads the normal tracks as you where running SO5R, but I've yet to be able to test it with a custom layout ... I've also added protected to the plugin should it try to load a pth file that is not there, it will not crash, but use the HLV packets to keep track of the lap validity.

Now I just have to fix the buttons that I broke in the last version and we are ready for version 0.4.4.
OK checked functionality of this version on B11R (Blackwood layout without chicane section)

It does not load the correct pth file...

My PHP 5.3.10 version has problems with this section of LVS.php (AXI packet handling);

if ($trackType != 'X' OR $trackType != 'Y')
return; # Not a open layout where we need to check for custom pth files.

It somehow produces an always false.. Even if trackType is set to X or Y.

But even if I comment this out and B11.pth is running... Cars are repeatedly reported off track on some sections of the track while they are not.
Quote from cargame.nl :

<?php 
        
if ($trackType != 'X' OR $trackType != 'Y')
?>

It somehow produces an always false.. Even if trackType is set to X or Y.

I don't have an explanation for that right now. The string would be BL1X or BL1Y right, I'm not crazy?

Quote from cargame.nl :But even if I comment this out and B11.pth is running... Cars are repeatedly reported off track on some sections of the track while they are not.

First, the layout file that is loaded, is called B11.lyt, and the B11.pth is in the $PRISM/data/pth/ directory right?
Quote from Dygear :I don't have an explanation for that right now. The string would be BL1X or BL1Y right, I'm not crazy?

You are not... $trackType also contains Y when I echo it to the console. Can't explain it either. I commented those two lines out and B11.pth got loaded.

As a matter of fact I had this problem before... I used strpos as solution to check if there was a particular character in a string.

Quote from Dygear :
First, the layout file that is loaded, is called B11.lyt, and the B11.pth is in the $PRISM/data/pth/ directory right?

Yeah.. Echoed $path which is correct and console also mentioned it loaded that pth file. The pth file works also for the most part of the track. I think it has something to do with internal structure of that pth. That its different in node counting.
Quote from cargame.nl :You are not... $trackType also contains Y when I echo it to the console. Can't explain it either. I commented those two lines out and B11.pth got loaded.

As a matter of fact I had this problem before... I used strpos as solution to check if there was a particular character in a string.

Well that's good to know. What with it being 7:11 am and I've been up all night, I tend to lose my marbles a little bit.

Quote from cargame.nl :Yeah.. Echoed $path which is correct and console also mentioned it loaded that pth file. The pth file works also for the most part of the track. I think it has something to do with internal structure of that pth. That its different in node counting.

Well, that really depends on how the pth is structured. ARIO might take the whole path into consideration (that is significantly slower computationally), but for us the Node that's reported in the CompCar packet MUST match that of the PTH file, or we'll report that they are not in THAT node, because they are not.

Doing logic at 4am, never a good idea. Doing logic at 10:44am, a better idea.


<?php 
        
if ($trackType == 'X' OR $trackType == 'Y')
?>

That's what I wanted.

Checkout the github repo for some goodies.


<?php 
php

    define
('ROOTPATH'dirname(realpath(__FILE__)));

    require(
'./modules/prism_pth.php');

    
$pth = new PTH('./data/pth/BL1.pth');
    
$pth->drawPath('./BL1.png');

?>

Yep, this is now totally possible, you can now SEE the path that the PTH parser has. All you have to do is call the drawPath method, and tell it where to save the image file. (It's ALWAYS going to be an PNG.)
Quote from Dygear :Well, that really depends on how the pth is structured. ARIO might take the whole path into consideration (that is significantly slower computationally), but for us the Node that's reported in the CompCar packet MUST match that of the PTH file, or we'll report that they are not in THAT node, because they are not.

lfs doesn't actually send node information on open configs. The node id will always be 0.
Quote from Dygear :

<?php 
php

    define
('ROOTPATH'dirname(realpath(__FILE__)));

    require(
'./modules/prism_pth.php');

    
$pth = new PTH('./data/pth/BL1.pth');
    
$pth->drawPath('./BL1.png');

?>

Yep, this is now totally possible, you can now SEE the path that the PTH parser has. All you have to do is call the drawPath method, and tell it where to save the image file. (It's ALWAYS going to be an PNG.)

just a small note regarding the path drawing :

If creating a 2560*2560 image as in :

<?php 
126
$im imagecreatetruecolor(25602560);
?>

then it's better to add 1280 to every point, instead of 1024 as in :

<?php 
139
$dlx2 = ($p->Nodes[$i]->DirX $LeftCos - (-$p->Nodes[$i]->DirY) * $LeftSin) * $p->Nodes[$i]->DriveLeft + ($p->Nodes[$i]->CenterX 1024);
?>

simply because 1280 will be at the center of the 2560*2560 image that is being created.
Also I'm not sure if 1024 is big enough - it could be that some portions of a path will be outside the image boundaries. Best use 1280 for these map related things as, so far, all tracks fit nicely in a 2560*2560 area where every pixel equals one metre.

(btw want me to rewrite that method so it uses the quicker code?)
Quote from Victor :lfs doesn't actually send node information on open configs. The node id will always be 0.

Well, then that explains it!

Quote from Victor :(btw want me to rewrite that method so it uses the quicker code?)

Lol, yeah! I'm all for quicker code!
yeah best not use utf8 in code itself. Text strings can be utf, but not the code itself.

about custom pth files - what format are those in? Is there a documentation? Did someone make a custom pth drawing tool?
In any case the way to do this would be to simply find the custom node (polygon) using the racer's coordinates. If no poly found, the car is off the track. This will be more cpu intesive but it can still be pretty fast when optimised.
I would imagine that a custom path file as such would contain a list of polygons that describe the drivable areas.
If so, prism will have to have a CustomPTH class for those purposes. It should implement and expose the same methods as the PTH class.
Quote from Victor :
about custom pth files - what format are those in? Is there a documentation? Did someone make a custom pth drawing tool?

Yeah...

Custom pth files made by EQ Worry as stated before. Found here; http://www.airio.eu/files/LFS_PTH_V16.zip

He also used something to draw that pth info to an image but sadly I cannot ask him about more information because he is from the LFS planet lately for some reason. I had personal contact with him too but even that is not possible at the moment.

Airio (.Net InSim) is working perfectly with these custom pth files, that is also my reference.. But like I said, need to try these changes and the drawPNG thing Dygear is talking about.

In my head this doesn't add up though...;

Quote from Dygear :Doing logic at 4am, never a good idea. Doing logic at 10:44am, a better idea.


<?php 
        
if ($trackType == 'X' OR $trackType == 'Y')
?>

That's what I wanted.
.


<?php 
        
if ($trackType == 'X' OR $trackType == 'Y')
            return; 
# Not a open layout where we need to check for custom pth files.
?>

Because trackType X or Y actually ís open layout so it needs to process it when X/Y trackType is true.. But.. Hmm small problem anyway
I can just make it a string 'delta'. I just thought that was intresting from a programming standpoint that the PHP engine supports that. I always program in UTF-8 encoded format for all of my PHP files due to the web design work that I used to do, it carried over to PRISM and indeed some of the variables and functions that I named using UTF-8 strings. It's odd that NetBeans does not support it, Notepad2 does and that's what I'm using for a basic text editor.


Quote from nl2dav :In my head this doesn't add up though...;


<?php 
        
if ($trackType == 'X' OR $trackType == 'Y')
            return; 
# Not a open layout where we need to check for custom pth files.
?>

Because trackType X or Y actually ís open layout so it needs to process it when X/Y trackType is true.. But.. Hmm small problem anyway

My comment is backwards. Should read


<?php 
# Is a open layout where we need to check for custom pth files.
?>

That did make sense when it was !=, but now that it's == that's the correct comment. Silly mistakes!
Well with setting tweaking I think it will support it too. But if more people are going to use PRISM as InSim it maybe is good to have full compatibility across editors.

Sometimes I use good old Notepad.exe for quick edits or vi which is a Linux text editor which also does not like the use of it. Well.. Not like is a big word, but lets say it's less easy to read...

See attachment..

It's only this file so not a big deal.. But even Github highlights it as 'strange'.
Attached images
Image1.jpg
Quote from Dygear :
My comment is backwards. Should read


<?php 
# Is a open layout where we need to check for custom pth  files.
?>

That did make sense when it was !=, but now that it's == that's the correct comment. Silly mistakes!

Yes but but...

The return... Means... It's aborting the whole check procedure.

So it does not do any further custom pth processing in the end right now
Quote from nl2dav :Yes but but...

The return... Means... It's aborting the whole check procedure.

So it does not do any further custom pth processing in the end right now

Yeah, I'm just going to take a look at the whole block again. I've not slept, and it's reflecting in my programming.

FGED GREDG RDFGDR GSFDG