Can older deprecation alerts be switched back on for the log

For test results, bug reports, announcements of new builds etc.

Moderators: winston, another_commander, Getafix

Post Reply
User avatar
Lestradae
---- E L I T E ----
---- E L I T E ----
Posts: 3095
Joined: Tue Apr 17, 2007 10:30 pm
Location: Vienna, Austria

Can older deprecation alerts be switched back on for the log

Post by Lestradae »

I guess this is a question for the devs ...

Can older deprecation alerts be switched back on for the error log? I mean, anything that has been deprecated in 1.75.1 since 1.70 upwards?

It would be very useful if that was possible - thanks in advance for any useful answer.
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Re: Can older deprecation alerts be switched back on for the

Post by JensAyton »

All previously deprecated JavaScript functionality has been completely removed. Many of the compatibility shims were implemented in JavaScript, and you could find them by digging through the revision history of oolite-global-prefix.js. The old implementations might not work in 1.75.1, though.
User avatar
Kaks
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 3009
Joined: Mon Jan 21, 2008 11:41 pm
Location: The Big Smoke

Re: Can older deprecation alerts be switched back on for the

Post by Kaks »

Ugh, the cull has been impressive, the best thing to do is to feed us a list of the various errors you have on the log - maybe in small doses, to avoid overwhelming us - and we should be able to give you the MNSR equivalents without too much trouble.
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Re: Can older deprecation alerts be switched back on for the

Post by Commander McLane »

Kaks wrote:
Ugh, the cull has been impressive, the best thing to do is to feed us a list of the various errors you have on the log - maybe in small doses, to avoid overwhelming us - and we should be able to give you the MNSR equivalents without too much trouble.
Or look them up in the documentation. In most cases it's fairly evident what the new name of a method or property is.
User avatar
Lestradae
---- E L I T E ----
---- E L I T E ----
Posts: 3095
Joined: Tue Apr 17, 2007 10:30 pm
Location: Vienna, Austria

Re: Can older deprecation alerts be switched back on for the

Post by Lestradae »

Kaks wrote:
Ugh, the cull has been impressive, the best thing to do is to feed us a list of the various errors you have on the log - maybe in small doses, to avoid overwhelming us - and we should be able to give you the MNSR equivalents without too much trouble.
Thanks all for the answers ... yes, that would be very nice, will see to it that I feed in small doses :D

My problem lies less with changing to the newer and actualised equivalents, I was more wondering if I could get the older deprecations written to the log at all - the way I understand it, things that were deprecated after 1.73 gave a warning in the 1.74 log but will no longer show up as deprecation warning in a 1.75 log - or am I mistaken there?

And I would like to be alerted about any and all deprecations as far back as 1.70, if at all possible.

As to how to change deprecations then ...
Commander McLane wrote:
look them up in the documentation. In most cases it's fairly evident what the new name of a method or property is.
... this.
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Re: Can older deprecation alerts be switched back on for the

Post by JensAyton »

Lestradae wrote:
My problem lies less with changing to the newer and actualised equivalents, I was more wondering if I could get the older deprecations written to the log at all - the way I understand it, things that were deprecated after 1.73 gave a warning in the 1.74 log but will no longer show up as deprecation warning in a 1.75 log - or am I mistaken there?
It depends. If you try to call a non-existent method, like player.ship.wibble(), you’ll get an error. If you try to define an obsolete event handler, you won’t, because you can create properties with just about any name you want.
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Re: Can older deprecation alerts be switched back on for the

Post by Commander McLane »

For event handler you could sort of test them by inserting a log line into each of them.

Say you have something like

Code: Select all

this.shipDestroyedTarget = function(target)
{
    // do stuff
}
and are not certain if it's still working (in this case it isn't).

Then just insert a log message

Code: Select all

this.shipDestroyedTarget = function(target)
{
    log("test", "shipDestroyedTarget is working");
    // do stuff
}
and make a ship with this script destroy a target. If you get

Code: Select all

shipDestroyedTarget is working
in your log, the handler has fired correctly. If you don't, it hasn't.

(The example shipDestroyedTarget was actually replaced. Looking it up in the Wiki you see that there is now a handler named shipTargetDestroyed, which is the same thing with a new name.)

Or you go through all release notes since whenever you stopped developing your OXPs. All release notes list which old event handlers got replaced with which new handlers. Then you can open your script and perform a find&replace for one after the other. Perhaps this would be the most efficient method.
User avatar
Lestradae
---- E L I T E ----
---- E L I T E ----
Posts: 3095
Joined: Tue Apr 17, 2007 10:30 pm
Location: Vienna, Austria

Re: Can older deprecation alerts be switched back on for the

Post by Lestradae »

Both (McLane) suggestions are good and after I read what Ahruman had to say probably this ...
Commander McLane wrote:
Or you go through all release notes since whenever you stopped developing your OXPs. All release notes list which old event handlers got replaced with which new handlers. Then you can open your script and perform a find&replace for one after the other. Perhaps this would be the most efficient method.
... is going to be my strategy.

I hoped the old deprecation alerts could perhaps somehow be switched back on, that would have been easier & faster on me - but meh, I'll do as suggested.

Cheers & thanks for the help

L
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Re: Can older deprecation alerts be switched back on for the

Post by JensAyton »

This script will notify you of deprecated event handlers. You’ll need to fill in the list yourself, though.

Code: Select all

"use strict";

this.name = "deprecation-warnings";


(function() {
    const deprecated =
    {
        deprecatedEvent: "newEvent",
        deprecatedEvent2: "newEvent2"
    };
    
    for (var deprecatedName in deprecated)
    {
        if (deprecated.hasOwnProperty(deprecatedName))
        {
            var newName = deprecated[deprecatedName];
            createDeprecationHandler(deprecatedName, newName);
        }
    }
    
    function createDeprecationHandler(deprecatedName, newName)
    {
        Object.defineProperty(Script.prototype, deprecatedName,
        {
            get: function () { return this[newName]; },
            set: function (value)
            {
                log("js.deprecated", "Event handler " + deprecatedName + " is deprecated. Use " + newName + " instead.");
                this[newName] = value;
            }
        });
    }
})();
User avatar
Gimi
---- E L I T E ----
---- E L I T E ----
Posts: 2073
Joined: Tue Aug 29, 2006 5:02 pm
Location: Norway

Re: Can older deprecation alerts be switched back on for the

Post by Gimi »

How about installing old versions of Oolite on memory sticks or something similar. Not the ideal solution, but should be feasible if there are specific errors messages you are looking for.
"A brilliant game of blasting and trading... Truly a mega-game... The game of a lifetime."
(Gold Medal Award, Zzap!64 May 1985).
Post Reply