The online racing simulator
Searching in All forums
(983 results)
Dygear
S3 licensed
Known Bug Seems the error is with This Line in the state handler.

Pretty sure this is the fix for that.

Patch for PRISM/modules/prism_statehandler.php [L415:L421]

<?php 
        
public function onTakeOverCar(IS_TOC $TOC)
        {
                
# Adds it to the new client.
                
$this->parent->clients[$TOC->NewUCID]->players[$TOC->PLID] = $this->parent->players[$TOC->PLID];
                
# Removes it from the old client.
                
unset($this->players[$TOC->PLID]);
        }
?>

In theory, that should be it, if anyone wants to give that patch a go and let me know. I'm on a Mac right now, and don't have direct access to the game to test it.
Dygear
S3 licensed
If you mean your running the track in the reversed direction, then yes. If you mean, that you are driving the wrong way on a normal direction of the track then no. But at the same time, no application would work in that case because the SPX and LAP packets are not sent from InSim to the Application.
Dygear
S3 licensed
There is a plugin in PRISM that's called Timing & Scoring, it's based off how FOM (Formula One Management) does the overlays for the F1.
Dygear
S3 licensed
Official Sniper, that's hilarious.
Dygear
S3 licensed
Thank you for your help amp88. There are some changes that I'd like to see, such as not having a shifts table, I can move the context of a shift into the PHP class. I'd also move the RoleCertifications as a check to the class as well, as I keep this information in their session data, that I access via a member class. Although, I might take your schema as I think it's better then the way I handled it. ShiftCrews is interesting, and I think I can build on that into the PHP class as well, within the context of adding a member to a crew.

Thank you so much for you help, I'll let you know how I end'ed up programming this up later on once it's all done.
Dygear
S3 licensed
I don't have an answer for that. Might be the reason I've lost my mind. I think I might need a vacation.
Dygear
S3 licensed
I'm using PHP 5.5.7, and SQLite 3.8.2 as the database (I updated and compiled it into PHP, that version of SQLite is non-standard for PHP 5.5.7).

The goals of the database structure is as follows
  1. Only one member can be assigned to one spot on the crew.
    Effectively, that means that a person can't fill the ALS spot and the MVO spot concurrently.
  2. A member, once taken a spot on crew owns that crew spot, be it for that week or permanently.
    There are two types that I have to deal with.
    • Permanent crew members, these are the people that have made a commitment to show up each week and fill that spot on that crew.
    • Non-Permanent crew members, that are able to fill that spot only for that week. Once the shift is over, that spot on crew becomes available once again for anyone else to pick up.
  3. A member on a crew spot can request coverage.
    Effectively, this means that they are unable to fill that spot, but they are still responsible for it until someone else states that they can take it.
Members can only sign up for spots within their level of care.
A BLS member can't sign up for an ALS spot. A non-driver can't sign up for the MVO spot. Anyone can sign up for the 5TH spot. And ALS members higher levels of care, so they can sign up for BLS spots as they wish.

So what I need is a permanent bit, and a coverage bit, right? The permanent bit would say this person is taking this spot on this crew from now on. And a coverage bit would say I need someone to fill this spot on this crew because I can't be there.

The whole SQL syntax for that is a nightmare for me. I can't wrap my head around having someone sign up for a permeate spot on say January 1st, 2014 for the Wednesday 1900 - 2300 as ALS and then need coverage for the next month for the 5th of February for that spot that they took back in January. Ideally once someone takes that spot, it would only produce one SQL data-entry. How does one handle the case of needing coverage later on for a permanent crew member.

The whole point of the database is that you also have an audit trail, so should someone pick up that spot, they then own that spot for that week that the original person needed coverage. But what if they can't do it and then they need coverage! That whole process needs to work in that situation as well. Then it comes back to the original guy who is already permeate on that spot is able to cover the guy that was covering him. I still want the audit trail, even if it's circled back to the original person who had it.

The real power in this comes from the audit reports. I want to know the number of times that a person was unable to fill there spot on crew. So when it gets to something like 3 times in a row then maybe that person should come off of that position until things settle down for them. Or people who look for coverage within 24 hours of the crew starting, how many times does that happen, is it more common with this person then that person?

Being able to build these reports is the strongest reason to use this. Instead of pen and paper.

---

If nothing else, I never properly defined what I wanted it to do. And I'm sorry, you asked from some database structure and I never gave it to you.

CREATE TABLE login(id TEXT PRIMARY KEY NOT NULL, given_name TEXT NOT NULL, family_name TEXT NOT NULL, lastseen INTEGER NOT NULL);

This table contains the information about the id of the client, and the name.

CREATE TABLE certification ( id, certification, certification_expiration, FOREIGN KEY(id) REFERENCES login(id) ON DELETE CASCADE )

This gives you information about their certification level, and when it expires. Technically speaking, it would be possible for someone who is ALS (AEMT-P, AEMT-CC) to become BLS and vice versa.

CREATE TABLE status ( id, rank, driver, class INTEGER, FOREIGN KEY(id) REFERENCES login(id) ON DELETE CASCADE )

Should someone no longer be a driver, then they can no longer take the MVO spot on crew. If they are permeate on a crew or signed up for a crew, as an MVO then they must be removed.
Last edited by Dygear, .
Dygear
S3 licensed
Quote from amp88 :Your post and the development site you've linked to are pretty difficult to understand. Are you just venting or are you looking for input?

A bit of both.
SOS - I've ran out of talent.
Dygear
S3 licensed
I pretty much ran out of talent. I've tried and tried to impalement a crew board for my Ambulance Corps, and for the life of me I just can't wrap my head around getting what we do with Marker and a White Board to translate to HTML and PHP. Here's my attempt at both Rubber Ducky Programming and getting some help should the solution not present it's self.

http://crew.wlvac.net/ Is the URL that I'm using to test away from the general members eyes. Once I'm done, it will become a page on http://www.wlvac.net/. I've programmed this too 90% of the way done, like twice now over the course of the past 2 years and I hated the implementation so much each time that I thew out all of the code.

I never got my head around how to map the actions such as "Covering a Crew", to "Going Permanent on a Crew" or "Finding Coverage For This Week" to an SQL statement, and I pretty much always hated how it looked on screen.

So maybe Rubber Ducky'ing this is not going to help. It might just be that I hate my code.
Dygear
S3 licensed
I'm really not sure. I've not had any experience with character conversions in LFS. My understanding is that it should be ASCII, and then converted with the escape sequence. For best results, I would type the message in LFS, and then capture the MSO packet and dump the "Msg" too the console. That way you can make sure the text is correct in game, and all you need to do is copy that part into your plugin.
Dygear
S3 licensed
Are you doing a proper ^ carret change to the correct charset within the button text? Take a look at LFS Strings and Escape Codes for what you should be doing.
Dygear
S3 licensed
Might want to include an MD5 hash of the file in your post just in case you need to do a repost later on.
Dygear
S3 licensed
Post the plugin, the whole thing, that you are attempting to use this in, or a striped down use case so we can see what you wrote.


<?php 
php
class test extends Plugins
{
    const 
URL 'http://lfsforum.net/forumdisplay.php?f=312';
    const 
NAME 'Test Code';
    const 
DESCRIPTION 'Just a plugin that I use to test code in.';
    const 
AUTHOR "Mark 'Dygear' Tomlin";
    const 
VERSION PHPInSimMod::VERSION;

    public function 
__construct()
    {
        
$this->registerSayCommand('test''cmdTest''The Code To Test.');
    }

    public function 
cmdTest($cmd$ucid)
    {
        foreach (
$this->getHostState()->players as $plid => $player)
            
console($player->PName);
    
        foreach (
$this->getHostState()->clients as $ucid => $client)
            
console($client->UName);

        return 
PLUGIN_HANDLED;
    }
}
?>

This is my code, installed in the PRISM/plugins/test.php, and I've activated the plugin in the config file as well.
PRISM & PHP 5.6.0 Examples
Dygear
S3 licensed
Implemented
  • Importing namespaced functions
    Proposes to allow importing namespaced functions through a new `use function` sequence.
    The proposal is to combine existing keywords to a new sequence that allows importing functions into a namespace. This should make namespaced functions less of a pain to use and discourage placing them in the global namespace. Since functions and classes are in separate namespaces, it is not feasible to use the use keyword for both, as it would likely result in conflicts and overhead. Instead of introducing a new keyword, it would be possible to combine use and function to a sequence. This new use function combo would work as follows:

    <?php 
    namespace foo\bar {
        function 
    baz() {
            return 
    'foo.bar.baz';
        }
        function 
    qux() {
            return 
    baz();
        }
    }

    namespace {
        use function 
    foo\bar\bazfoo\bar\qux;
        
    var_dump(baz());
        
    var_dump(qux());
    }
    ?>

    All of this applies not only to functions, but also to namespaced constants. For consistency, a use const sequence should also be introduced, that does the same thing for constants:

    <?php 
    namespace foo\bar {
        const 
    baz 42;
    }

    namespace {
        use const 
    foo\bar\baz;
        
    var_dump(baz);
    }
    ?>

    Just like classes, it should be possible to alias imported functions and constants:

    <?php 
    namespace {
        use function 
    foo\bar as foo_bar;
        use const 
    foo\BAZ as FOO_BAZ;
        
    var_dump(foo_bar());
        
    var_dump(FOO_BAZ);
    }
    ?>

    Functions can be treated as an extension of the language, or to be used to create a custom meta-language. An example of this is building a HTML tree, but this could be anything, really.
    A HTML building DSL:

    <?php 
    use function html\divhtml\phtml\em;

    $html div(p('Some'em('Text')));
    ?>

    Avoiding noise and clutter is really important to make this usable and readable.


  • Constant Scalar Expressions
    This RFC proposes adding support for Constant Scalar Expressions with support for constants being operands.
    This RFC brings static scalar expressions to the parser. This allows places that only take static values (const declarations, property declarations, function arguments, etc) to also be able to take static expressions.

    This can allow for writing far easier to understand code, by allowing for far more expressive code.

    The main difference to Anthony's RFC is (apart from a few operators more) that constants can be involved in these scalar operations:

    <?php 
    const 1;

    const 
    a?2:100// here the value of the constant "b" is dependent on the constant "a"
    ?>

    This also means that this is valid code:

    <?php 
    class Foo {
        const 
    FOO 1;
        const 
    BAR << 1;
        const 
    GREETING "HELLO";
        const 
    BAZ self::GREETING." WORLD!"
    }
    ?>

    As is this:

    <?php 
    const BAR 1;

    function 
    foo($a 1$b << 3$c BAR?10:100) {}
    ?>



  • Remove calls from incompatible context
    Calls from incompatible context deprecated in 5.6 (will be removed in next version).
  • Dedicated syntax for variadic functions
    This RFC introduces a dedicated syntax for variadic functions.
    Currently variadic functions are implemented by fetching the function arguments using func_get_args(). The following code sample shows an implementation of a variadic function used to prepare and execute a MySQL query (I'll be making use of this example throughout the RFC):

    <?php 
    class MySQL implements DB {
        protected 
    $pdo;
        public function 
    query($query) {
            
    $stmt $this->pdo->prepare($query);
            
    $stmt->execute(array_slice(func_get_args(), 1));
            return 
    $stmt;
        }
        
    // ...
    }

    $userData $db->query('SELECT * FROM users WHERE id = ?'$userID)->fetch();
    ?>

    There are two issues with the above approach:
    Firstly, by just looking at the function signature public function query($query) you cannot know that this is actually a variadic function. You'd think that the function can only run a normal query and doesn't support bound parameters.
    Secondly, because func_get_args() returns *all* arguments passed to the function you first need to remove the $query parameter using array_slice(func_get_args(), 1).

    This RFC proposed to solve these issues by adding a special syntax for variadic functions:

    <?php 
    class MySQL implements DB {
        public function 
    query($query, ...$params) {
            
    $stmt $this->pdo->prepare($query);
            
    $stmt->execute($params);
            return 
    $stmt;
        }
        
    // ...
    }

    $userData $db->query('SELECT * FROM users WHERE id = ?'$userID)->fetch();
    ?>

    The ...$params syntax indicates that this is a variadic function and that all arguments after $query should be put into the $params array. Using the new syntax both of the issues mentioned above are solved.


  • phpdbg
    Distribute phpdbg with PHP, a PHP debugger
In voting phase
  • Argument unpacking
    This RFC proposes a syntax for argument unpacking.
    This RFC complements the variadics RFC. It introduces a syntax for unpacking arrays and Traversables into argument lists (also known as “splat operator”, “scatter operator” or “spread operator”).

    As a usage example, consider a variadic method public function query($query, ...$params). You are provided a $query and an array of $params and want to call the method using these. Currently this is possible using call_user_func_array():

    <?php 
    all_user_func_array
    ([$db'query'], array_merge(array($query), $params))
    ?>

    This RFC proposes a syntax for unpacking arguments directly in the call syntax:

    <?php 
    db
    ->query($query, ...$params)
    ?>


Under Discussion
  • Expectations
    This RFC proposes adding a modern Expectation/Assertion API.
    The assertion statement has the prototype:

    <?php 
    oid assert 
    (mixed $expression [, mixed $message])
    ?>

    At execution time, expression will be evaluated, if the result is false, an AssertionException will be thrown. In some cases, expression will be an expensive evaluation that you do not wish to execute in a production environment, assertions can therefore be disabled and enabled via the PHP_INI_ALL configuration setting zend.assertions. Disabling assertions will almost entirely eliminate the performance penalty making them equivalent to an empty statement.

    In any case, assertions should never be used to perform tasks required for the code to function, nor should they change the internal state of any object except where that state is used only by other assertions, these are not rules that are enforced by Zend, but are nonetheless the best rules to follow. If an object of a class which extends AssertionException is used for message, it will be thrown if the assertion fails, any other expression will be used as the message for the AssertionException. If no message is provided, the statement will be used as the message in AssertionException. If expression is a constant string, compatibility with the old API is employed, the string is compiled and used as the expression.

    PHP programmers tend to document how their code is supposed to work in comments, this is a fine approach for generating automated documentation, but leaves us a little bewildered, and tired of digging through documentation at runtime when things go wrong:

    <?php 
    if ($i == 0) {
        
    // ...
    } else if ($i == 1) {
        
    // ...
    } else { // We know ($i % 3 == 2)
        // ...
    }
    ?>

    Becomes:

    <?php 
    if ($i == 0) {
        
    // ...
    } else if ($i == 1) {
        
    // ...
    } else {
        
    assert ($i == 2);
    }
    ?>

    In a development environment, this forces the executor to make you aware of your mistake.

    Another good example for using assertions might be a switch block with no default case:

    <?php 
    switch ($suit) {
        case 
    CLUBS:
            
    /* ... */
        
    break;

        case 
    DIAMONDS:
            
    /* ... */
        
    break;

        case 
    HEARTS:
            
    /* ... */
        
    break;

        case 
    SPADES:
            
    /* ... */
        
    break;
    }
    ?>

    The above switch assumes that suit can only be one of four values, to test this assumption add the default case:

    <?php 
    switch ($suit) {
        case 
    CLUBS:
            
    /* ... */
        
    break;

        case 
    DIAMONDS:
            
    /* ... */
        
    break;

        case 
    HEARTS:
            
    /* ... */
        
    break;

        case 
    SPADES:
            
    /* ... */
        
    break;

        default:
            
    assert (false"Unrecognized suit passed through switch: {$suit}");
    }
    ?>

    The previous example highlights another general area where you should use assertions: place an assertion at any location you assume will not be reached. The statement to use is:

    <?php 
    ssert
    (false)
    ?>

    Suppose you have a method that looks like:

    <?php 
    public function method() {
        for (
    /*...*/) {

            if (
    /* ... */)
                return 
    true;
        }

    }
    ?>

    The above code assumes that one of the iterations results in a return value being passed back to the caller of ::method(), to test this assumption:

    <?php 
    public function method() {
        for (
    /*...*/) {

            if (
    /* ... */)
                return 
    true;
        }
        
    assert(false);
    }
    ?>

    Assertions allow the possibility to perform precondition and postcondition checks:

    <?php 
    public function setResponseCode($code) {
        
    $this->code $code;
    }
    ?>

    Becomes:

    <?php 
    public function setResponseCode($code) {
        
    assert($code 550 && $code 100"Invalid response code provided: {$code}");

        
    $this->code $code;
    }
    ?>

    The example above performs a precondition check on the code parameter.


  • Automatic Property Initialization
    This RFC proposes automatic assignments of constructor arguments to properties.
    This proposal is an alternative to https://wiki.php.net/rfc/constructor-promotion. It uses a different syntactical approach to shorthand constructors borrowed from the Dart Language, in addition to suggesting variations of that approach.

    Instead of writing:

    <?php 
    class Point 
    {
        private 
    $x$y;

        public function 
    __construct($x$y)
        {
            
    $this->$x;
            
    $this->$y;
        }
    }
    ?>

    You can just write:

    <?php 
    class Point
    {
        private 
    $x$y;

        public function 
    __construct($this->x$this->y);
    }
    ?>

    The two snippets are functionally equivalent and achieve the same.
    Quoting from the Dart Manual:
    Quote :
    If an argument has this. before it in a constructor argument list, the field with that name will automatically be initialized with that argument’s value. This example shows another little feature too: if a constructor body is completely empty, you can just use a semicolon ( instead of {}.

    The proposal suggests to adopt this functionality to PHP, which is really two features:
    allow for $this→foo as constructor arguments
    allow for methodless constructors


  • Named Parameters
    This RFC proposes introducing named parameters.
    Named arguments are a way to pass arguments to a function, which makes use of the parameter names rather than the position of the parameters:

    <?php 
        
    // Using positional arguments:
        
    array_fill(010042);
        
    // Using named arguments:
        
    array_fill(start_index => 0num => 100value => 42);
    ?>

    The order in which the named arguments are passed does not matter. The above example passes them in the same order as they are declared in the function signature, but any other order is possible too:

    <?php 
    rray_fill
    (value => 42num => 100start_index => 0)
    ?>

    It is possible to combine named arguments with normal, positional arguments and it is also possible to specify only some of the optional arguments of a function, irregardless of their order:

    <?php 
        htmlspecialchars
    ($stringdouble_encode => false);
        
    // Same as
        
    htmlspecialchars($stringENT_COMPAT ENT_HTML401'UTF-8'false);
    ?>



  • Support for anonymous catches
    This RFC proposes adding catch-statements without variables, and fully anonymous catches.
    With the recent addition of the finally keyword for try-catch statements, PHP is now in line with many other languages such as C#, Python and Ruby (and probably many others). Those languages differ from PHP in that they don't require a variable to bind the exception in, and don't even require specifying a certain Exception class.
    Thus, this RFC proposes to add syntax support for:

    <?php 
    try
    {
        
    $this->connectToServer();
    }
    catch (
    ConnectionLostException)
    {
        
    $this->retry(3);
    }
    ?>

    In this case, we don't need the exception object itself as the exception type is descriptive enough of what happened, and we do not need to log anything because the operation is tried again in 3 seconds. By not specifying a variable, we avoid the impression that we do actually need it. It also helps static analysis tools (e.g. as implemented in IDEs) more accurately discover unused variables.

    We can take this one step further, to also get rid of the class:

    <?php 
    try
    {
        
    $this->connectToServer();
    }
    catch
    {
        
    $this->retry(3);
    }
    ?>



  • unset(): return bool if the variable has existed
    Add to unset a return value if the deletion was successful
    The purpose of this RFC is to make unset return something meaningful. People also shouldn't have to wonder why they can't use unset if it isn't as a standalone expression. This removes also an inconsistency: the function's return value is void, states the docs. It is until now the only function (language construct, function-like) (apart from echo, which already has an alternative: print) which has no return value.
    Change unset()'s behaviour to:
    • return true if deletion was successful
    • return false if deletion failed (e.g. there was nothing to delete or the deleting function has failed)
    The feature could be useful in if's like:

    <?php 
    public function deleteKey ($key) {
        if (unset(
    $this->array[$key])) {
            
    // do some cleanup
        
    }
    }
    ?>

    This is the way we do it today:

    <?php 
    public function deleteKey ($key) {
        if (isset(
    $this->array[$key])) {
            unset(
    $this->array[$key]);
            
    // do some cleanup
        
    }
    }
    ?>

    But even now we can't be sure if the variable was unset, because the __unset() magic method may not have deleted it. With the patch __unset() can return a value (which is internally casted to bool) and inform the caller of unset() if the deletion was successful.


  • Remove reliance of Zend API
    A proposal to remove the use of the Zend API in PHP libraries.
    Currently, PHP's interpreter, the Zend Engine, provides access to its internals via the Zend API. This RFC provides a rationale for this access, by removing the Zend API. This RFC does not describe how to remove access, and what to replace it with. That is described separately, in php_native_interface. The goals of this RFC are predicated on achieving the goals of php_native_interface.


  • PHP Native Interface
    Provide complete alternative to writing libraries interfaces using the Zend API libraries.
    This describes the design of phpni, the PHP Native Interface. This design is in early stages.
    • Remove any couping between the Zend Engine, extensions and SAPIs.
    • Support all major use cases of the Zend API
      • embedding within SAPIs
      • proving access to C libraries
      • providing the ability to rewrite performance sensitive code in C
    • Significantly simplify creation of extensions
    • Allow other PHP implementations to use the same interface.
    • This is intended to be a static process. That is, we are replacing the static compilation of extensions with another static process. We do not intend to simplify or support run-time binding, like JNI, JNA or libffi. Instead it is imagined the result will be a single libphplibs.a, which statically links into libphp5.so.
    Take the use case of wrapping a C library to expose its functionality in user space. The major idea is to “automatically” import C functions into a special namespace. The PHP library functions would then be comprised of PHP user space code which calls those C functions directly. That way it is possible to craft an API that is separate from the C implementation.

    Lets take a simple example. Assume we have a C library XXX, with 3 functions, x, y and z. We'd like to expose this in user space as a class called MyXXX, with methods a and b. We create a file with the signatures of x, y and z:

    extensions/xxx/sigs.h

    int x (int, int);
    void y (char*, int);
    void z (char*, int);

    We then write our user space code:
    extensions/xxx/MyXXX.php

    <?php 
    class MyXXX
    {
        function 
    __construct ($username)
        {
            
    $this->username $username;
        }

        function 
    ($w1$w2)
        {
            
    $foo = \internals\XXX\($w1$w2);
            \
    internals\XXX\($this->username$foo);
        }

        function 
    ($m1$m2)
        {
            
    $foo = \internals\XXX\($m1$m2);
            \
    internals\XXX\($this->username$foo);
            return 
    $foo;
        }
    }
    ?>

    In order to interface between the PHP code and the C functions, a tool will be required to generate code. This tool will obviously be implementation specific. SWIG could be used to create this. Since the libraries would no longer use the Zend API, the tight coupling would be broken. It would now be possible to change major parts of the Zend engine without affecting the operation of any other part of PHP. It would no longer be necessary to know the Zend API to write extensions. Instead, only the API of the C library is necessary, and the interface can be created in PHP user code.


  • Function call chaining
    Function call chaining implementation.

  • Enum language structure
    A proposal to add the enum language structure
    Frequently developers need to produce code like this:

    <?php 
    const    LOG_LEVEL_DEBUG 1,
            
    LOG_LEVEL_INFO 2,
            
    LOG_LEVEL_WARNING 3,
            
    LOG_LEVEL_ERROR 4;

    // Or

    class Tokens {
        const    
    T_IF 258,
                
    T_ELSE 259,
                
    T_WHILE 260,
                
    T_DO 261;
    }
    ?>

    The proposal is that this could be written in a much more concise manner:

    <?php 
    enum 
    {
        
    LOG_LEVEL_DEBUG,
        
    LOG_LEVEL_INFO,
        
    LOG_LEVEL_WARNING,
        
    LOG_LEVEL_ERROR
    };

    // Or

    class Tokens {
        
    enum {
            
    T_IF 258,
            
    T_ELSE,
            
    T_WHILE,
            
    T_DO
        
    };
    }
    ?>

    The keyword enum is reserved. An enum may be defined wherever a class or interface could be defined, and the same namespacing, naming and referencing restrictions apply.

    <?php 
    namespace Cards;

    enum Suit {
        
    SPADES => '1',
        
    HEARTS => 2,
        
    DIAMONDS// Will have value 3
        
    CLUBS,    // Will have value 4
    }

    var_dumpSuit::SPADES );         // enum(Cards\Suit)(1)
    var_dumpSuit::SPADES == );    // bool(true)
    var_dumpSuit::SPADES === );   // bool(true) - because the value is cast to an integer upon declaration
    var_dumpSuit::SPADES == '1' );  // bool(true)
    var_dumpSuit::SPADES === '1' ); // bool(false)
    ?>

    Unlike array declarations, however, a duplicate value causes a fatal error. An enum member may be referenced as EnumName::VALUE just like a class constant. A scalar may be (explicitly or implicitly) cast to an enum member:

    <?php 
    // Using declaration of Suit above
    var_dump( (Suit));       // enum(Cards\Suit)(1)
    var_dump( (Suit)true );    // enum(Cards\Suit)(1)
    var_dump( (Suit)('one') ); // null
    ?>



  • Making T_FUNCTION optional for method declarations
    A proposal for removing the requirement to use T_FUNCTION in method declarations.
    It is proposed that this is valid code:

    <?php 
    class Foo {
        const 
    42;
        private 
    $var;

        public 
    bar() {
            echo 
    "Hello World";
        }
    }

    $foo = new Foo();
    $foo->bar();
    ?>

    While technically possible this RFC suggests that the following shall NOT be valid for keeping the code readable:

    <?php 
    class Foo {
        const 
    42;
        private 
    $var;

        
    bar() {
            echo 
    "Hello World";
        }
    }

    $foo = new Foo();
    $foo->bar();
    ?>



  • CLI options for strict and quiet modes
    This RFC proposes a -W option to turn on maximum error reporting, and a -Q option for no error reporting.

  • Skipping optional parameters
    Skipping optional parameters in function calls
    As PHP does not have named parameter support, a very common for function is to have many optional arguments, like this:

    <?php 
    unction create_query
    ($where$order_by$join_type=''$execute false$report_errors true) {...
    ?>

    If we always use defaults, it's fine. But what if we need ot change $report_errors but don't care about the others? We'd have to find function definition and copy-paste all other defaults into the call, which is annoying, error-prone and may not do what you wanted if some of the defaults change.
    The proposal is to allow skipping optional arguments in a call, thus making them assume default values as they do when they are not provided, like this:

    <?php 
    reate_query
    ("deleted=0""name", default, default, /*report_errors*/ true)
    ?>

    This means that $join_type and $execute are going to use defaults. Of course, if we ever get implementation of named parameters, it may also solve this problem, but until we do, this can be a partial solution.


  • Systemd socket activation
    Systemd socket activation support for PHP-FPM

  • Add a deprecated modifier for functions
    Add a deprecated modifier for functions
    This RFC proposes the addition of a “deprecated” modifier for methods and functions giving the ZEND_ACC_DEPRECATED flag to functions, thus throwing an E_DEPRECATED error when they are called.

    <?php 
    deprecated 
    function myFunction() {
        
    // ...
    }

    myFunction();
    ?>

    Results in
    Deprecated: Function myFunction() is deprecated in ... on line 5



  • Moving to an AST-based parsing/compilation process
    Proposes to improve the current parsing/compilation process by introducing an AST as an intermediary structure
In Draft
  • Scalar Type Casting Magic Methods
    This RFC proposes a set of new scalar type casting magic methods for classes.
    This RFC and patch introduces 4 new magic methods:
    • __toInt() - Called when casting an object explicitly to an integer (or passing it to an internal function which expects an integer)
    • __toFloat() - Called when casting an object explicitly to a float (or passing it to an internal function which expects a float)
    • __toArray() - Called when casting an object explicitly to an array (or passing it to an internal function which expects an array)
    • __toScalar() - Called when using an object in an implicit scalar scope without type information (for example: $obj + 1).
    • __toBool() - Called when casting an object explicitly to a boolean (or passing it to an internal function which expects a boolean)


  • Isset/Set Operator
    This RFC proposes new operators for handling unset/falsey variables.
    ?= Will be a new operator that allows the user to set an unset or falsey variable. This handy operator will help avoid dreaded unset variable notices.

    <?php 
    $foo 
    ?= 'default';

    // which is functionally equivalent to:
    $foo = (isset($foo) && $foo) ? $foo 'default';

    // or
    if (!isset($foo) || !$foo$foo 'default';
    ?>

    ??: will be equivalent to the ternary short hand ?: except that it also checks for isset().

    <?php 
    // $bar is unset

    $foo $bar ?: 'other'// Throws undefined notice

    $foo $bar ??: 'other'// Does NOT throw undefined notice

    // ??: is functionally equivalent to:
    $foo = (isset($bar) && $foo) ? $bar $other;
    ?>

    This will be very helpful for echoing default variables in HTML like so:

    <?php 
    div 
    class="= $user ??: 'guest' "> ... </div
    ?>




  • Comparison inconsistency
    This RFC is to discuss comparison related inconsistency.

  • PDO version 1 improvements
    This RFC proposes a set of improvements to be made to PDO.

  • Tainted variables
    This RFC proposes an implementation of variable tainting in PHP.

  • Jsonable interface
    Feature request to allow support json_(encode|decode) to handle Object instance conversions.
    Consider this piece of code:

    <?php 
    class Person
    {
        public 
    $name;
        protected 
    $age;
        private 
    $salary;

        public function 
    __construct($name$age$salary)
        {
            
    $this->name $name;
            
    $this->age $age;
            
    $this->salary $salary;
        }

        
    // ...
    }

    $person = new \Person('Jesus Christ'3210000);

    echo 
    json_encode($person);
    ?>

    PHP is able to convert public variables, so the return of this script will be:

    <?php 
    "name""Jesus Christ"
    ?>

    However, we may want json_(encode|decode) to also export/import protected and private information.

    A non-intrusive solution should be smooth just like SPL Serializable interface.

    <?php 
    interface Jsonable
    {
        public function 
    __toJson();
    ?>

    It is well known that at this stage, any developer is able to write a piece of code (a method) like the following one to include a similar support:

    <?php 
    class Person implements Jsonable
    {
        public function 
    __toJson()
        {
            
    $str '{"__CLASS__": "' get_class($this) . '"';

            
    $reflClass = new \ReflectionClass($this);

            foreach (
    $reflClass->getProperties() as $reflProperty) {
                
    $reflProperty->setAccessible(true);
                
    $value $reflProperty->getValue($this);

                
    $str .= ', ' json_encode($reflProperty->getName()) . ': ';

                if (
    is_object($value) && $value instanceof Jsonable) {
                    
    $str .= $value->__toJson();
                } else if ( ! 
    is_resource($value)) {
                    
    $str .= json_encode($value);
                }
            }

            
    $str .= '}';

            return 
    $str;
        }
    }
    ?>

    By implementing natively Jsonable, it would be simply necessary to:

    <?php 
    class Person
    {
        
    // ...

        
    public function __toJson()
        {
            return array(
    'name''age''salary');
        }
    }
    ?>

    It would be even possible to add custom export support, example:

    <?php 
    class Person
    {
        
    // ...

        
    public function __toJson()
        {
            return array(
    'salary');
        }
    }
    ?>



  • Object and Array Literals
    This RFC proposes first-class, inline object and array literals similar to JSON.

    <?php 
    // new syntax for simple arrays:
    $a = [1,2,'three'];
    // equivalent to current:
    $a = array(1,2,'three');

    // associative arrays:
    // (examples are equivalent; see discussion)
    $a = ['one' => 1'two' => 2'three' => 'three'];
    $a = ['one'1'two'2'three''three'];
    // equivalent to current:
    $a = array('one' => 1'two' => 2'three' => 'three');

    // anonymous object:
    // (examples are equivalent; see discussion)
    $a = {'one'1'two'2'three'3};
    $a = {'one' => 1'two' => 2'three' => 3};
    // equivalent to:
    $a = new \StdClass;
    $a->one 1$a->two 2$a->three 'three';
    // or:
    $a = (object)array('one' => 1'two' => 2'three' => 'three');

    // PHP conventions (dynamic keys/values)
    $val 'apple';
    $record = {"favourite_fruit"$val};
    // true expression:
    $record->favourite_fruit == "apple";

    $key "colour";
    $record = {$key"red"};
    echo 
    $record->colour// outputs "red"

    $colour "green";
    $vehicle "truck";
    $record = {'notes'"Drives a {$colour} $vehicle."};
    echo 
    $record->notes// outputs "Drives a green truck."

    // inline functions:
    $creditCard '5105105105105100';
    $doc = {"credit_card_reminder"substr($creditCard, -4)};
    echo 
    $doc->credit_card_reminder// outputs "5100"

    // 'invalid' keys:
    $obj = {'key with spaces''still works'};
    echo 
    $obj->{'key with spaces'}; // outputs 'still works'
    $doc = {'$set': {"has_logged_in"'yes'}};
    echo 
    $doc->{'$set'}->has_logged_in// outputs "yes"

    ?>


  • Weak References
    This RFC proposes the introduction of Weak References in PHP via a new SPL class.

  • Line Markers in PHP
    This RFC proposes the introduction of line markers in PHP.

  • Loop+Else control structure
    This RFC proposes an optional “else” clause that can be used after while, for, and foreach loops.
    Proposed syntax will look as follows:

    <?php 
    // "foreach" example (display a list of names)
    foreach ($array as $x) {
        echo 
    "Name: {$x->name}\n";
    } else {
        echo 
    "No records found!\n";
    }

    // "for" example (unset a range of keys from array, then return it, or return null on error)
    for ($i some_very_expensive_and_ugly_looking_calculation($array); $i >= 0$i--) {
        unset(
    $array[$i]);
    } else {
        return 
    null// horrific error!
    }
    return 
    $array;

    // "while" example (return true if any $search matches have been removed from $array)
    while ($temp array_search($search$array)) {
        unset(
    $array[$temp]);
    } else {
        unset(
    $array[$search]); // just because we can
        
    return false;
    }
    return 
    true;
    ?>


Last edited by Dygear, .
Dygear
S3 licensed
Quote from DarkKostas :It's InSim bug. I've been having the same problem using InSim.NET. It's exactly as you said MCI gets recieved before the actual NPL. What i did to fix it, is to make check on MCI if player is out of pits, before i do everything else.

Thanks mate, it saves me from tracking that bug down. Glad it was not my fault, lol.
Dygear
S3 licensed

<?php 
    
foreach ($this->getHostState()->players as $plid => $player)
        
console($player->PName);
    
?>

This will always return the current players for the current server that PRISM is processing the packet from. As you can connect to multiple servers with the same instance of PRISM.


<?php 
    
foreach ($this->getHostState($hostID)->players as $plid => $player)
        
console($player->PName);
    
?>

With this code, you can get information about the host state for $hostID.


<?php 
    
foreach ($this->getHostState()->clients as $ucid => $client)
        
console($client->UName);
    
?>

Also works to get all clients using the same syntax.
Dygear
S3 licensed
Quote from MadCatX :I think that PRISM takes advantage of PHP 5.5 (or at least it's on the TODO list) so you should probably get that.

It does not use PHP 5.5 yet, but you should still get it, it makes the code run faster, and it uses less memory. The next version of PRISM (0.5.0) will use PHP 5.5.

Quote from Ssaint :The path to your log folder does not exist : Array
Fatal error encountered. Exiting...
Safe shutdown: 12-24-13@01:45:24

All you need to do is make a logs folder underneath the PRISM folder and that error will go away.
Dygear
S3 licensed
Oh yes, I forgot about the in between states. I gues that means 4 bits then! 1000 for far left, 0100 for mid left, 0000 for center, 0010 for mid right, and 0001 for far right.
Dygear
S3 licensed
I've not dissected the network packs, so I have no idea of how head movements are sent to the client, but as I see it right now, they have 3 states, Left, Right and Center. That's 2 bits at least. If you bump that up to a whole byte (8 bits) you can get 256 different values. If you use that for just X, that's plenty of room for a fairly good amount fluidity. Or you could use 4 bits (upper nibble) for X, and the 4 lower bits (lower nibble) for Y, giving you 8 states that you can kinda tween between. The nibble with tween idea might make more sense given the expected number of packets a second for updates (3 - 6 Packets Per Second).
Dygear
S3 licensed
Quote from just2fast :Future improvement suggestion:
It´s seems that the headtracking isn´t recorded when watching the replay. It would be nice to see the real headmovements there.
Especially when racing online (havent´t tested yet), so it would be possible to see where a driver is looking at.
In this way it would also be possible to communicate with each other in a non verbal way -> e.g. head gestures "yes" or "Nooooooooooooo"

That would be amazing!
Dygear
S3 licensed
Vettle gets #1, it's automatic. Everyone else get's to pick from 2 - 99.
Dygear
S3 licensed
Thank you kind Sir.
Dygear
S3 licensed
Can someone post a reply of a packed server, with as many people as possible (I'd like to see a full server, with every car racing that is possible.) So I can run benchmarks against the same data set.
Dygear
S3 licensed
The problem is speed of the algorithm. One car (C), on one track (T), on one node (N) using one point is one calculation, and that's what we offer with the MCI packets, with the official tracks, as we get node information (C * N). When we don't get node information, we have One car, on one track, times by the number of points on the track (C^N). Because now we have to test for each node within the pth file. Now when your talking about multiple cars, and multiple points the problem is compounded again. You have to check every car against every point. This quickly becomes an expensive operation for just one server, yet alone a few that PRISM could be installed on, effectively becoming multiple cars, on multiple tracks, using all of the nodes. It's a question of speed, what the fastest way to get this done without having the node information for each client.

To this end, I'm designing PRISM to be fast first. It's going thorough a whole redesign for PHP 5.5, and that upgrade with the same code base alone is a 20% - 40% speed improvement without any code changes (Cool, free performance.) Using SPL, on top of that it should be 25% faster then native arrays when writing data, and use 40% of the memory size, but there is hardly any difference in iteration speed. So my last hope is implementation of R* Trees. It would be odd if an SQLite query would be faster then native memory because of the underlying C structure, but who knows! It's worth a shot for speed.
Lap Verification System (LVS)
Dygear
S3 licensed
Cargame has been poking and prodding me for literally years now over the LVS plugin. The plugin verifies that each player's vehicle is on the track at all times. It currently only supports official tracks, using Node information within the packet. The next step is to enhance it to use custom pth files. To make sure this is as fast as possible, as we are talking potentially about doing this over 250 times a second, I've been looking up some solutions. The slowest solution in theory should be the standard PHP array. Then comes SPL (Standard PHP Library) Fixed Arrays and R* Tree using SQLite databases. These two are what I'm going to be testing to see what is faster ... let the battle commence!
FGED GREDG RDFGDR GSFDG