The online racing simulator
Quote from cargame.nl :This is because of the emptiness of this right?

I can't run PRISM & LFS from work to test this, but I can't see any other immediate reason for it (might be missing something between sandwich bites).

The monkey patch below should sort it (again, not tested as I can't do that here). Copy into your PRISM root and apply using git apply onNPL.patch

Edit: Forgot to say, this patch is against github's master branch.
Attached files
onNPL.zip - 627 B - 940 views
Thanks for the patch, I wasn't after it because that section already is custom but an interesting view on shortening the code you have there. Sadly it currently doesn't work like this because H_TRes and H_Mass are named different in PRISM (HTRes and HMass).

My posting was a bit to aware others of this problem although I ended my posting with a question. Because that piece of code already is custom (added some vars) I wasn't absolutely sure it's something I caused by altering code.. But.. Hmm.. Actually I was sure.. Can I still be followed? LOL... Anyway thanks for acknowledging and your quick hotfix

I didn't make use of PlayerHandler before, constructed my own array but it became too complex to use it for multiple servers so started to use PlayerHandler. I'm surprised nobody else ran into this earlier.
Well, I personally run PRISM as a separate instance for each LFS server so I never noticed it either.

I have my own arrays for tracking the players, however I do notice some errors when IS_TOC is received:
PHP NOTICE:
Undefined variable: PLID in \prism\modules\prism_statehandler.php on line 416
1 :: onTakeOverCar in \prism\modules\prism_statehandler.php:81
2 :: onClientPacket in \prism\modules\prism_statehandler.php:58
3 :: dispatchPacket in \prism\modules\prism_hosts.php:576
4 :: inspectPacket in \prism\modules\prism_hosts.php:487
5 :: handlePacket in \prism\modules\prism_hosts.php:353
6 :: checkTraffic in \prism\PHPInSimMod.php:215
PHP NOTICE:
Undefined index: in \prism\modules\prism_statehandler.php on line 416
1 :: onTakeOverCar in \prism\modules\prism_statehandler.php:81
2 :: onClientPacket in \prism\modules\prism_statehandler.php:58
3 :: dispatchPacket in \prism\modules\prism_hosts.php:576
4 :: inspectPacket in \prism\modules\prism_hosts.php:487
5 :: handlePacket in \prism\modules\prism_hosts.php:353
6 :: checkTraffic in \prism\PHPInSimMod.php:215
PHP NOTICE:
Object of class PlayerHandler could not be converted to int in \prism\modules\prism_statehandler.php on line 416
1 :: onTakeOverCar in \prism\modules\prism_statehandler.php:81
2 :: onClientPacket in \prism\modules\prism_statehandler.php:58
3 :: dispatchPacket in \prism\modules\prism_hosts.php:576
4 :: inspectPacket in \prism\modules\prism_hosts.php:487
5 :: handlePacket in \prism\modules\prism_hosts.php:353
6 :: checkTraffic in \prism\PHPInSimMod.php:215

Quote from cargame.nl :Sadly it currently doesn't work like this because H_TRes and H_Mass are named different in PRISM (HTRes and HMass).

I just moved the constructor code into it's own function (visual diff attached), so if that's the case then the constructor has always been broken and needs fixing in of itself!

Quote from cargame.nl :I'm surprised nobody else ran into this earlier.

Not many people using PRISM and those that are, probably aren't using restrictions much Certainly not something I've played with whilst writing InSim stuff over the years...

@Dygear - what's going on with PRISM? You still accepting pull requests, etc.? Don't wanna waste time if not..
Attached images
visual-diff.png
Quote from the_angry_angel :so if that's the case then the constructor has always been broken and needs fixing in of itself!

Well but.. Ehrr.. No..


protected $HMass; # Added mass (kg)
protected $HTRes; # Intake restriction

...


$this->HMass = $NPL->H_Mass;
$this->HTRes = $NPL->H_TRes;

It's OK, it's there... But the naming is different so if you just copy array contents;

$this->onNPL($NPL);

this cannot do it on its own in the current code.

Quote from the_angry_angel :
probably aren't using restrictions much

It's not only restrictions, you can also switch secretly to another car!
Quote from cargame.nl :this cannot do it on its own in the current code.

The diff added that function..
OK but then you assume that the correct naming is used in the rest of the code right?

Example, should be like this;

protected $HMass; # Added mass (kg)
protected $HTRes; # Intake restriction

It now is;


protected $H_Mass; # Added mass (kg)
protected $H_TRes; # Intake restriction

You currently copy array contents which is not defined?

Maybe I am not so clear in explaining today... Well.. Definitively not because the mailwoman just concluded that too ..
Quote from the_angry_angel :@Dygear - what's going on with PRISM? You still accepting pull requests, etc.? Don't wanna waste time if not..

Always, I've just not had any recently. I also applied DarkTime's fix for the timer in my local, but I was hoping that he would submit it him self to get the credit within the GitHub branch. If anyone wants to submit other patches, I would be happy to release a patch update for this version.
Cool. You want them individually per feature/fix, or are you happy as a bulk and cherry-picking?
I continue...


protected $result = array();
public function onResult(IS_RES $RES)
{
$this->result[] = $RES;
}

This causes the storage of ALL race results including the ones of previous races until track change. Is this really wanted? I think not, so better drop the []?

Race results should be cleared on race restart in my opinion.

---

class ClientHandler extends PropertyMaster
{
..

public $players = array();

What is that players array doing inside ClientHandler? Its empty most of the time. Most of the time, I found it filled with data once, no idea which caused that. I don't think there should be a players array inside ClientHandler anyway, or should it?
Quote from the_angry_angel :Cool. You want them individually per feature/fix, or are you happy as a bulk and cherry-picking?

Ideally, from a git prospective, each edit you make should only take a sentence to explain. If it takes more then one sentence to explain your edit, that really you should split that off into different commits. But from there, I'll cherry pick what ever updates you have. For the most part, I'm pretty sure that I'll add anything that you put in unless I think it goes against the nature of how PRISM or InSim should operate. But as you have a fundamental understanding of InSim, and PRISM is pretty much directly evolved to make sure that the underside of InSim is available, you should be ok.

Quote from cargame.nl :What is that players array doing inside ClientHandler? Its empty most of the time. Most of the time, I found it filled with data once, no idea which caused that. I don't think there should be a players array inside ClientHandler anyway, or should it?

In this case, player's should be inside of client's. Because a client must be made for each player, and each player has to come from a client. An example of this is that each client can have up to four players, one human, and three AIs from the single client connection. There is an intrinsic relationship between these two items, that relationship can also be found within the InSim packets.
Quote from Dygear :An example of this is that each client can have up to four players, one human, and three AIs from the single client connection.

Aahhhhhhww OK, understood!

class ClientHandler extends PropertyMaster
{
public static $handles = array
(
ISP_NCN => '__construct', # 18
ISP_CNL => '__destruct', # 19

....

public function __destruct()
{
unset($this);
}

Can somebody explain what is wrong with this PRISM code?

When a CNL is received (aka client disconnect) the __destruct function is executed (verified with echo "test") ... But.. The unset doesn't work at all. The data of the client stays in the ClientHandler array.

If I change it to unset ($this->UCID); the UCID key and value get removed though... A complete entry doesn't. I do not get it why it doesn't but it looks like the unset is ignored :/
OK.. I have no clue and it annoys be...


public function __destruct()
{
foreach ($this as $key => $value) {
unset($this->$key);
}
unset($this);
}

Best I can come up with

Result;



[74] => ClientHandler Object
(
)

Better then having invalid data.
I tried something without testing it first, the problem is that you can't unset an object from within. What I'll have to do is follow the chain down to the client handler object from within PRISM, that should allow me to do something like this.


global $PRISM;
unset($PRISM->hosts[$PRISM->hosts->getHost()]->clients[$this->UCID]);


Fatal error: Call to undefined method HostHandler::getHost()

I think it should be something like this then;


global $PRISM;
unset($PRISM->hosts->getCurrentHost()->clients[$this->UCID]);

But, that might work in PHP 5.2 (not tested) but PHP 5.3 does this;


Attempt to modify property of non-object

And thats why... I don't like object oriented programming. Stuck for hours finding the correct solution to a simple task.

Almost persuades me to go back to my old fashioned player tracking array but thats cheating huh

.
Could anyone who has patched or fixed an issue in this version of PRISM you either PM me a list of stuff you've had to patch or pop them into this thread, or add them as issues in github and I'll try and test the problems, patch the offending code in my copy (if needed) and submit pull requests to get them into the next version. That way everyone benefits from the fixes.
There's still the out standing bug with the timer function that DarkTime's fixed, I'm still waiting on a reply from him. I wonder if he apparently does not have a GitHub account, but I'd really like to credit him with the fix within the Git resource files, so that it's displayed correctly on the GitHub page.
Quote from Dygear :There's still the out standing bug with the timer function that DarkTime's fixed, I'm still waiting on a reply from him. I wonder if he apparently does not have a GitHub account, but I'd really like to credit him with the fix within the Git resource files, so that it's displayed correctly on the GitHub page.

I don't need a credit for that fix, it was just an observation. I didn't actually fix the bug, I just noticed it when I was trying to figure out how to implement something similar in pyinsim. I think I probably do have a GitHub account, but I don't know how to use it.
Quote from DarkTimes :I don't need a credit for that fix, it was just an observation. I didn't actually fix the bug, I just noticed it when I was trying to figure out how to implement something similar in pyinsim. I think I probably do have a GitHub account, but I don't know how to use it.

Lol, well, if you do have a git hub account, you can make the change by forking the current PRISM master branch, and making the edit in your browser, then sending me a pull request for the change. No need to download git-scm at all.

FGED GREDG RDFGDR GSFDG