Live for Speed - LFS Main Site
- LFS World
- LFS News
- LFS Manual
- LFS Merchandise
  http://foros.cerolag.com/f-live-for-speed-latinoamerica-146/

Go Back   Live for Speed > Main > LFS Programmer Forum > PHPInSimMod - PRISM

Reply
 
Thread Tools Search this Thread Display Modes
Old 9th April 2012, 12:26   #91  -   
MariusMM
S2 licensed
 
Join Date: Aug 2007
Location: Norway
Posts: 178
MariusMM's online stats
All right, maybe it's supposed to happen then. I was thinking it was an error in my code.

Anyway, I managed to fix it by doing this before saving the image:
Code:
image.RotateFlip(RotateFlipType.RotateNoneFlipY);
So now the racing line fit's perfectly on top of the bitmaps that can be downloaded on lfs.net
Reply With Quote
Old 18th April 2012, 19:09   #92  -   
Victor
Developer
 
Victor's Avatar
 
Join Date: Jan 2003
Posts: 6,034
Victor's online stats
directx uses a flipped y axis. So it's normal to flip y in other applications.
__________________
LFS Main website
LFS World (LFS statistics and more)
LFS Manual
LFS Merchandise
Reply With Quote
Old 19th April 2012, 03:52   #93  -   
Dygear
S2 licensed
 
Dygear's Avatar
 
Racername: (EAGLE)Dygear
Join Date: Feb 2005
Location: Levittown, NY.
Posts: 3,583
Dygear's online stats
Quote:
Originally Posted by Victor View Post
directx uses a flipped y axis. So it's normal to flip y in other applications.
Good to know.
__________________
Paramedic & Programmer
LFSWorldSDK & PHPInSimMod
No help via MSN or PM
Reply With Quote
Old 23rd April 2012, 15:31   #94  -   
cargame.nl
S2 licensed
 
Join Date: Dec 2009
Posts: 2,600
cargame.nl's online stats
Quote:
Originally Posted by Dygear View Post
Once I fixed the buttons.
Would be nice to get a bugfree release of all the progress being made the last month(s).
__________________
cargame.nl forum
* hosted by qserverhosting.com
Reply With Quote
Old 17th July 2012, 21:38   #95  -   
T3charmy
S2 licensed
 
Racername: [SC]T3charmy
Join Date: Dec 2010
Posts: 257
T3charmy's online stats
Is the &$username done on purpose?

PHP Code:
    public function getAdminInfo(&$username)
    {
        
$username strToLower($username); 
I was just curious because it seemed to cause issues with

PHP Code:
    protected function canUserAccessCommand($UCID$cmd)
    {
        
# Hosts are automatic admins so due to their nature, they have full access.
        # Commands that have no premission level don't require this check.
        
if ($UCID == OR $cmd['accessLevel'] == -1)
            return 
TRUE;

        global 
$PRISM;
        
$adminInfo $PRISM->admins->getAdminInfo($this->getClientByUCID($UCID)->UName);
        return (
$cmd['accessLevel'] & $adminInfo['accessFlags']) ? TRUE FALSE;
    } 
__________________
My Rig: Cooler Master HAF 912 || Gigabyte GA-970A-D3 || GeForce GTX 560 Ti 1GB || Cooler Master EXtreme 550W
AMD FX-6100 Zambezi 3.3GHz || G.SKILL Ripjaws Series 8GB || Seagate Barracuda 500GB || Dual Boot Win 7/Arch Linux

Reply With Quote
Old 20th July 2012, 05:01   #96  -   
Dygear
S2 licensed
 
Dygear's Avatar
 
Racername: (EAGLE)Dygear
Join Date: Feb 2005
Location: Levittown, NY.
Posts: 3,583
Dygear's online stats
That worked in past version of PHP to keep the memory footprint down, as you only ever had one variable with many references, but in the newer versions of PHP, it optimizes that for you so you don't have to do it any more. Although Vic said that LFS handles usernames as case insensitive.
__________________
Paramedic & Programmer
LFSWorldSDK & PHPInSimMod
No help via MSN or PM
Reply With Quote
Old 9th August 2012, 22:09   #97  -   
T3charmy
S2 licensed
 
Racername: [SC]T3charmy
Join Date: Dec 2010
Posts: 257
T3charmy's online stats
Alright, I'm trying to add ability to have alternating text like seen in LFSLapper(%at%)

I came up with this:

PHP Code:
    public function Text($val)
    {
        if (!
is_array($val))
            
$this->Text $val;
        else{
            
$this->tStage 0;
            
$this->tArray $val;
            
$this->Text $val[0];
            
$this->createTimer($this->key.'_'.$this->UCID.'_TextAlt''nextText'1Timer::REPEAT); #Added Names to my Timers
            
console($this->tStage);
            
console(count($this->tArray));
        }
        return 
$this;
    }
    protected function 
nextText(){
        
$this->tStage += 1;
        
console($this->tStage);
        if(
$this->tStage >= count($this->tArray) ){
            
console($this->tStage);
            
$this->tStage 0;
        }
        
$this->Text $val[$this->tStage];
    } 
But the timer never gets created?

P.S. I added this to the module prism_button.php ... It creates the button fine and everything, but like I said, the timer doesn't get created...

Other timers made in plugins work perfectly fine, only this specific spot do timers not work...
__________________
My Rig: Cooler Master HAF 912 || Gigabyte GA-970A-D3 || GeForce GTX 560 Ti 1GB || Cooler Master EXtreme 550W
AMD FX-6100 Zambezi 3.3GHz || G.SKILL Ripjaws Series 8GB || Seagate Barracuda 500GB || Dual Boot Win 7/Arch Linux

Reply With Quote
Old 10th August 2012, 23:14   #98  -   
misiek08
S2 licensed
 
misiek08's Avatar
 
Racername: misiek08
Join Date: Jul 2008
Location: Poland
Posts: 555
misiek08's online stats
If it's in button class you can't user timer's. Why? because when you call $this->createTimer you call Button::createTimer and it doesn't exists.

Name "Button" is example here.
__________________

CHEAP LFS Server hosting - Look, only 0.15$ / slot! (PayPal payment)
HTML, CSS, JS, AJAX, PHP,C# .NET, Perl, Bash, AMXX Programmer
MySQL, Mod_rewrite user
Reply With Quote
Old 11th August 2012, 17:52   #99  -   
T3charmy
S2 licensed
 
Racername: [SC]T3charmy
Join Date: Dec 2010
Posts: 257
T3charmy's online stats
Quote:
Originally Posted by misiek08 View Post
If it's in button class you can't user timer's. Why? because when you call $this->createTimer you call Button::createTimer and it doesn't exists.

Name "Button" is example here.
I also tried Timers:: but then it spits out an error saying wrong permissions... tried changing to public, still nothing, but error went away... But I think I just thought of a way, I could easily implement this as a plugin ... maybe... I'll have to actually try it to be sure...
__________________
My Rig: Cooler Master HAF 912 || Gigabyte GA-970A-D3 || GeForce GTX 560 Ti 1GB || Cooler Master EXtreme 550W
AMD FX-6100 Zambezi 3.3GHz || G.SKILL Ripjaws Series 8GB || Seagate Barracuda 500GB || Dual Boot Win 7/Arch Linux

Reply With Quote
Old 11th August 2012, 23:16   #100  -   
misiek08
S2 licensed
 
misiek08's Avatar
 
Racername: misiek08
Join Date: Jul 2008
Location: Poland
Posts: 555
misiek08's online stats
I think that it's impossible to use Timer outside the plugins.
__________________

CHEAP LFS Server hosting - Look, only 0.15$ / slot! (PayPal payment)
HTML, CSS, JS, AJAX, PHP,C# .NET, Perl, Bash, AMXX Programmer
MySQL, Mod_rewrite user
Reply With Quote
Old 12th August 2012, 08:23   #101  -   
PoVo
S2 licensed
 
PoVo's Avatar
 
Racername: host
Join Date: Jun 2008
Location: Dublin, Ireland
Posts: 1,817
PoVo's online stats
Quote:
Originally Posted by misiek08 View Post
I think that it's impossible to use Timer outside the plugins.
This.

I was trying to do it too in the button class before. It just doesn't work.
__________________
Free 15GB cloud storage + 5GB free for you and me if you use this referral link
Reply With Quote
Old 10th October 2012, 03:15   #102  -   
cargame.nl
S2 licensed
 
Join Date: Dec 2009
Posts: 2,600
cargame.nl's online stats
After many idle months I started to give attention to PRISM again and there is a quite nasty bug in PlayerHandler.

If a player goes to pits and changes his/her car to a different one or alters settings like mass or air restriction, the values in PlayerHandler do not get updated.

This is because of the emptiness of this right?

Code:
    public function onLeavingPits(IS_NPL $NPL)
    {
        $this->inPits = FALSE;
    }
__________________
cargame.nl forum
* hosted by qserverhosting.com
Reply With Quote
Old 10th October 2012, 12:49   #103  -   
the_angry_angel
S2 licensed
 
the_angry_angel's Avatar
 
Join Date: Jun 2003
Location: UK
Posts: 5,704
the_angry_angel's online stats
Quote:
Originally Posted by cargame.nl View Post
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
File Type: zip onNPL.zip (627 Bytes, 4 views)

Last edited by the_angry_angel; 10th October 2012 at 12:58.
Reply With Quote
Old 10th October 2012, 13:03   #104  -   
cargame.nl
S2 licensed
 
Join Date: Dec 2009
Posts: 2,600
cargame.nl's online stats
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.
__________________
cargame.nl forum
* hosted by qserverhosting.com
Reply With Quote
Old 10th October 2012, 13:17   #105  -   
PoVo
S2 licensed
 
PoVo's Avatar
 
Racername: host
Join Date: Jun 2008
Location: Dublin, Ireland
Posts: 1,817
PoVo's online stats
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:
Code:
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
__________________
Free 15GB cloud storage + 5GB free for you and me if you use this referral link
Reply With Quote
Old 10th October 2012, 13:24   #106  -   
the_angry_angel
S2 licensed
 
the_angry_angel's Avatar
 
Join Date: Jun 2003
Location: UK
Posts: 5,704
the_angry_angel's online stats
Quote:
Originally Posted by cargame.nl View Post
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:
Originally Posted by cargame.nl View Post
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 Thumbnails
Click image for larger version

Name:	visual-diff.png
Views:	26
Size:	141.3 KB
ID:	124089  
Reply With Quote
Old 10th October 2012, 14:53   #107  -   
cargame.nl
S2 licensed
 
Join Date: Dec 2009
Posts: 2,600
cargame.nl's online stats
Quote:
Originally Posted by the_angry_angel View Post
so if that's the case then the constructor has always been broken and needs fixing in of itself!
Well but.. Ehrr.. No..

Code:
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;
Code:
$this->onNPL($NPL);
this cannot do it on its own in the current code.

Quote:
Originally Posted by the_angry_angel View Post
probably aren't using restrictions much
It's not only restrictions, you can also switch secretly to another car!
__________________
cargame.nl forum
* hosted by qserverhosting.com
Reply With Quote
Old 10th October 2012, 14:55   #108  -   
the_angry_angel
S2 licensed
 
the_angry_angel's Avatar
 
Join Date: Jun 2003
Location: UK
Posts: 5,704
the_angry_angel's online stats
Quote:
Originally Posted by cargame.nl View Post
this cannot do it on its own in the current code.
The diff added that function..
Reply With Quote
Old 10th October 2012, 15:17   #109  -   
cargame.nl
S2 licensed
 
Join Date: Dec 2009
Posts: 2,600
cargame.nl's online stats
OK but then you assume that the correct naming is used in the rest of the code right?

Example, should be like this;
Code:
protected $HMass;            # Added mass (kg)
protected $HTRes;            # Intake restriction
It now is;

Code:
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 ..
__________________
cargame.nl forum
* hosted by qserverhosting.com
Reply With Quote
Old 10th October 2012, 17:35   #110  -   
Dygear
S2 licensed
 
Dygear's Avatar
 
Racername: (EAGLE)Dygear
Join Date: Feb 2005
Location: Levittown, NY.
Posts: 3,583
Dygear's online stats
Quote:
Originally Posted by the_angry_angel View Post
@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.
__________________
Paramedic & Programmer
LFSWorldSDK & PHPInSimMod
No help via MSN or PM
Reply With Quote
Old 10th October 2012, 21:21   #111  -   
the_angry_angel
S2 licensed
 
the_angry_angel's Avatar
 
Join Date: Jun 2003
Location: UK
Posts: 5,704
the_angry_angel's online stats
Cool. You want them individually per feature/fix, or are you happy as a bulk and cherry-picking?
Reply With Quote
Old 11th October 2012, 03:43   #112  -   
cargame.nl
S2 licensed
 
Join Date: Dec 2009
Posts: 2,600
cargame.nl's online stats
I continue...

Code:
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.

---
Code:
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?
__________________
cargame.nl forum
* hosted by qserverhosting.com
Reply With Quote
Old 11th October 2012, 07:00   #113  -   
Dygear
S2 licensed
 
Dygear's Avatar
 
Racername: (EAGLE)Dygear
Join Date: Feb 2005
Location: Levittown, NY.
Posts: 3,583
Dygear's online stats
Quote:
Originally Posted by the_angry_angel View Post
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:
Originally Posted by cargame.nl View Post
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.
__________________
Paramedic & Programmer
LFSWorldSDK & PHPInSimMod
No help via MSN or PM
Reply With Quote
Old 11th October 2012, 10:36   #114  -   
cargame.nl
S2 licensed
 
Join Date: Dec 2009
Posts: 2,600
cargame.nl's online stats
Quote:
Originally Posted by Dygear View Post
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!
__________________
cargame.nl forum
* hosted by qserverhosting.com
Reply With Quote
Old 11th October 2012, 13:49   #115  -   
cargame.nl
S2 licensed
 
Join Date: Dec 2009
Posts: 2,600
cargame.nl's online stats
Code:
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 :/
__________________
cargame.nl forum
* hosted by qserverhosting.com
Reply With Quote
Old 11th October 2012, 18:28   #116  -   
cargame.nl
S2 licensed
 
Join Date: Dec 2009
Posts: 2,600
cargame.nl's online stats
OK.. I have no clue and it annoys be...

Code:
    public function __destruct()
    {
                foreach ($this as $key => $value) {
                    unset($this->$key);
                } 
                unset($this);
    }
Best I can come up with

Result;

Code:
                                            [74] => ClientHandler Object
                                                (
                                                )
Better then having invalid data.
__________________
cargame.nl forum
* hosted by qserverhosting.com

Last edited by cargame.nl; 11th October 2012 at 21:14.
Reply With Quote
Old 11th October 2012, 21:18   #117  -   
Dygear
S2 licensed
 
Dygear's Avatar
 
Racername: (EAGLE)Dygear
Join Date: Feb 2005
Location: Levittown, NY.
Posts: 3,583
Dygear's online stats
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.

Code:
global $PRISM;
unset($PRISM->hosts[$PRISM->hosts->getHost()]->clients[$this->UCID]);
__________________
Paramedic & Programmer
LFSWorldSDK & PHPInSimMod
No help via MSN or PM
Reply With Quote
Old 12th October 2012, 03:17   #118  -   
cargame.nl
S2 licensed
 
Join Date: Dec 2009
Posts: 2,600
cargame.nl's online stats
Code:
Fatal error: Call to undefined method HostHandler::getHost()
I think it should be something like this then;

Code:
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;

Code:
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

.
__________________
cargame.nl forum
* hosted by qserverhosting.com

Last edited by cargame.nl; 12th October 2012 at 03:29.
Reply With Quote
Old 13th October 2012, 15:58   #119  -   
the_angry_angel
S2 licensed
 
the_angry_angel's Avatar
 
Join Date: Jun 2003
Location: UK
Posts: 5,704
the_angry_angel's online stats
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.

Last edited by the_angry_angel; 14th October 2012 at 09:04.
Reply With Quote
Old 15th October 2012, 05:46   #120  -   
Dygear
S2 licensed
 
Dygear's Avatar
 
Racername: (EAGLE)Dygear
Join Date: Feb 2005
Location: Levittown, NY.
Posts: 3,583
Dygear's online stats
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.
__________________
Paramedic & Programmer
LFSWorldSDK & PHPInSimMod
No help via MSN or PM
Reply With Quote
Reply

  Live for Speed > Main > LFS Programmer Forum > PHPInSimMod - PRISM

Tags
0.4.3, insim, insimmod, mod, php, phpinsim, prism

  • Submit Thread to Digg
  • Submit Thread to del.icio.us
  • Submit Thread to StumbleUpon
  • Submit Thread to Google

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:12.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Live for Speed © 2002-2014 - Scawen Roberts, Eric Bailey, Victor van Vlaardingen