The online racing simulator
PHPInSimMod - PRISM 0.1.5 Discussion
Because this is still an Alpha release, none of the functions are documented with any markup for doxygen, but I'm working on that now, so we can get to 0.2.0. (Code first, write documentation later, I hope most of my inline code was documented for the non-obvious stuff.)
Cool.

Would it be possible to include a simple 'Hello, world!' example for nonces like me who don't know how it works? I know you're planning on writing full documentation, but just a snippet to get started would be useful.
Quote from DarkTimes :Cool.

Would it be possible to include a simple 'Hello, world!' example for nonces like me who don't know how it works? I know you're planning on writing full documentation, but just a snippet to get started would be useful.

I have not really started on the plugin system in full yet. Messages to chat will be possible in the next version.
Well Dygear:

Seemed to work pretty well. Connected to LFS and everything. Did get a few errors where a packet was expected to be one size. It happened when I added a lot of AI cars. Is a great start though

(I will be disecting the code to see what I can learn from it.

(Just from looking it over in notepad (yes, I know.. Notepad).. some of the line-endings aren't consistent. The PHP files in Modules is using unix(?) line endings, whereas the main PHPInsimMod.php is using CRLF. Just a small thing that's easy to fix.

Best code block ever:

<?php 
/**
            * Dygear to Ripnet: Yeah I have no idea how this one works.
            */
            
elseif (preg_match("/^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9])$/"$ipOrHostname))
            { 
# Yep its a valid hostname
                
$this->cvars['hostname'] = $ipOrHostname;
            }
?>

Quote from dawesdust_12 :Did get a few errors where a packet was expected to be one size. It happened when I added a lot of AI cars.

I will try to reproduce this error, must admit. I never looked into AI cars when I was testing.


Quote from dawesdust_12 :Best code block ever:

Yeah, I'm really no good with regular expression, and ripnet is much better at it then I am.


Anyway, please keep the bug reports coming!
Quote from Dygear :I will try to reproduce this error, must admit. I never looked into AI cars when I was testing.

I'll go and get an example. Also, Convert everything to a consistent line ending (as said by my edit above).

Looks very good though Dygear, very stoked on the possibilities of this!

Ah... On testing. It happens when you start a SP race.. it's because the messages that LFS sends saying what setup the AI is using (when set to not player setup).. are longer than what LFS usually permits...

It's sending a: Unknown Type Byte of 116, with reported size of 110 bytes and actual size of 512 bytes.. then a "unknown type byte 108.. reported 32 bytes.. actual 512 bytes. " Then finally "unknown type byte of 76, reported 94 bytes.. actual 400 bytes..."

Also: Restarting race has PRISM end... I am running it on client side currently too.
Quote from dawesdust_12 :I'll go and get an example. Also, Convert everything to a consistent line ending (as said by my edit above).

Yeah, I think morpha programs on a unix box, or a mac or something. I'll convert all of them to CRLF.

Quote from dawesdust_12 :Ah... On testing. It happens when you start a SP race.. it's because the messages that LFS sends saying what setup the AI is using (when set to not player setup).. are longer than what LFS usually permits...

It's sending a: Unknown Type Byte of 116, with reported size of 110 bytes and actual size of 512 bytes.. then a "unknown type byte 108.. reported 32 bytes.. actual 512 bytes. " Then finally "unknown type byte of 76, reported 94 bytes.. actual 400 bytes..."

I'm really very glad I put that part of the code in! I don't usually due error handling properly, but I did it in this case just because I knew it was going to be running some so many different machines. Turns out it might of been this best thing I've done thus far! Although I don't think any packet get's up to 512 bytes, so I'm pretty sure that's just a full buffer that it's taking as a whole packet. I wonder ...

Quote from dawesdust_12 :Also: Restarting race has PRISM restart... I am running it on client side currently too.

Could you clarify this? Restarting the race does what to PRISM?

(I did all of my testing on my client, while connected to servers, and while I had my own listen server running.)
For whatever reason.. (I'm doing SInglePlayer race.. not a local server).. a Shift+R just stops PRISM. I haffto start the php file again.
Quote from dawesdust_12 :For whatever reason.. (I'm doing SInglePlayer race.. not a local server).. a Shift+R just stops PRISM. I haffto start the php file again.

Ok, that's kinda strange. I'll be sure to submit a bug report on all of these.
Tried to reproduce your SHIFT + R bug, and I don't have that problem on my side.

Full console log attached.

Please the next time you test make a batch file on your computer that looks like the following:

bebug.bat
@echo off
php -e PHPInSimMod.php %1 %2 > deb.log
pause

Then run that. After you produce that crash again, post the deb.log file here.

[edit] Don't freak out when the console does not produce a result, as your putting all input into the deb.log it has the output that would go into the console screen. [/edit]

[edit] If you see any output on the screen, those are PHP level warnings and they should also be posted, but within the post body. They will not be apart of the deb.log file. [edit]
Ok! Now I can reproduce your error! It's when you restart with AI cars that this bug happens.

PHP Warning: require_once(C:\Program Files\Live For Speed\addons\PRISM/modules/prism_IS_NONE.php): failed to open stream: No such file or directory in C:\Program Files\Live For Speed\addons\PRISM\PHPInSimMod.php on line 246
PHP Fatal error: require_once(): Failed opening required 'C:\Program Files\Live For Speed\addons\PRISM/modules/prism_IS_NONE.php' (include_path='.;C:\php5\pear') in C:\Program Files\Live For Speed\addons\PRISM\PHPInSimMod.php on line 246

So I'll fix both that and this:

PHP Notice: Undefined index: Tyres in C:\Program Files\Live For Speed\addons\PRISM\modules\prism_packets.php on line 32

EDIT: This post might not be so pertinent now as you've figured out what's gone awry as shown above. I'll leave it here for the record though.
Dygear:

Attached is my debug log.

The situation was:
Single Player mode (not MP or a Local hosted server)
19 AI cars in FO8's
SO1 (They totally can't make the chicane.. makes really comical slides and crashes!)
- Started PRISM from the Race End screen (as also going from the main menu, to the Single player screen has PRISM end).
- Went "Go"
- Waited a few seconds, then pressed Shift+R.
- My CMD window goes "Press any Key to continue" (which means it's reached the pause in the .BAT).
Attached files
deb.log.txt - 2.5 KB - 263 views
Quote from dawesdust_12 :EDIT: This post might not be so pertinent now as you've figured out what's gone awry as shown above. I'll leave it here for the record though.

Thanks, I'll look over your log file anyway!

Quote from dawesdust_12 :Ah... On testing. It happens when you start a SP race.. it's because the messages that LFS sends saying what setup the AI is using (when set to not player setup).. are longer than what LFS usually permits...

It's sending a: Unknown Type Byte of 116, with reported size of 110 bytes and actual size of 512 bytes.. then a "unknown type byte 108.. reported 32 bytes.. actual 512 bytes. " Then finally "unknown type byte of 76, reported 94 bytes.. actual 400 bytes..."

I think the failing of the program also happens due to the buffer being overflowed in PHP, shown by the bytes being 512 the buffer size that is set. But I'll have to make sure of this before I can move on. It might also have something to do with the fact that It's trying call the class IS_NONE ...
Quote from dawesdust_12 :It's sending a: Unknown Type Byte of 116, with reported size of 110 bytes and actual size of 512 bytes.. then a "unknown type byte 108.. reported 32 bytes.. actual 512 bytes. " Then finally "unknown type byte of 76, reported 94 bytes.. actual 400 bytes..."

Ok, fixed this. Now I'm going to tackle github, and sourcefroge because the next release is now ready. (0.1.6)

FGED GREDG RDFGDR GSFDG