Why the sudden change to prototypes?



  • I've noticed a lot of prototypes today now only display:

    function () { return fn.apply(this, arguments); }

    as opposed to the small amount of code they displayed beforehand. Is this is a security change, hiding this code? or a side effect of something else? I ask because it was nice to be able to see some of these functions, especially the checks they were making before executing. I found it very helpful in keeping me from being overly-redundant, and helped me understand how some of the builtins behaved.



  • Dev Team

    Yes, it's a security bug fix, but not hiding the code, there were some sandbox scope leaks because of this. You can check methods sources in the private server code (which will be open sourced soon).



  • Understood. Thank you the reply.



  • @Artem you can augment the methods so that they will still stringify as their original source, possibly with the new wrapper in a comment. I recently did this so that methods wrapped by screeps-profiler could still be read.

    https://github.com/gdborton/screeps-profiler/pull/9


  • Dev Team

    I believe there is no need in that once the engine is open sourced in a couple of weeks.



  • Need? No. Convenience? Yes. Sometimes I'm using the console in-game to do things and being able to spit out a method source is immediately useful. Having to go find it in documentation (and make sure I'm looking at the latest documentation) would be annoying. Annoying enough that it motivated me to fix the problem in screeps-profiler.


  • Culture

    sparr, when the server is open source you can make a pull request 😄