Join us at the Oolite Anniversary Party -- London, 7th July 2024, 1pm
More details in this thread.

CompassTargetChanged doesn't work on entering new system

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

Moderators: another_commander, winston, Getafix

Post Reply
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2290
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia

CompassTargetChanged doesn't work on entering new system

Post by Wildeblood »

In 1.76 (has this been fixed in trunk already?) when entering a new system, the compass target is set to the planet, and compassTargetChanged fires if the compass is not in COMPASS_MODE_PLANET. But, if the compass is already in planet mode when you leave the previous system, compassTargetChanged does not fire. Hello? It's a different planet!
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: CompassTargetChanged doesn't work on entering new system

Post by Kaks »

Fixed in rev5359. In addition to that, the compass target will change to undefined just after willEnterWitchspace, if jumping away from a normal system.

Interstellar space and nova systems stop the compass from working, so nothing is going to happen there compass-wise...


For possible interest to oxp HUD makers, switching the compass off in flight (either by switching to a compass-free hud, or by making the compass depend on some breakable piece of equipment) now triggers yet another compassTargetChanged event, this time with target null; switching the compass on will trigger compassTargetChanged again (from null to the previous target).

It used to be possible to switch targets with the '\' button even if the advanced compass wasn't displayed, the switch itself taking place only after the compass was switched on again, but it's no longer the case. It's now possible to switch compass targets only if there's a compass displayed on screen (a transparent one, even).

Hope this helps. :)
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2290
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia

Re: CompassTargetChanged doesn't work on entering new system

Post by Wildeblood »

Kaks wrote:
It used to be possible to switch targets with the '\' button even if the advanced compass wasn't displayed, the switch itself taking place only after the compass was switched on again, but it's no longer the case. It's now possible to switch compass targets only if there's a compass displayed on screen (a transparent one, even). Hope this helps.
Thanks. That is much better.
Kaks wrote:
For possible interest to oxp HUD makers, switching the compass off in flight (either by switching to a compass-free hud, or by making the compass depend on some breakable piece of equipment) now triggers yet another compassTargetChanged event, this time with target null; switching the compass on will trigger compassTargetChanged again (from null to the previous target).
No thanks.

How do I make the SVN repository thingy spit out the previous version of HeadUpDisplay.m - I forgot to make a back-up before I updated to r5359? :oops:
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: CompassTargetChanged doesn't work on entering new system

Post by Kaks »

if you use tortoiseSVN it's a piece of cake, just look at the revision you're interested in, double-click the file in question from the list in the bottom half of the screen, and you'll see the 'before' and 'after' versions side by side - ctrl-a + ctrl-c will do the rest!
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2290
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia

Re: CompassTargetChanged doesn't work on entering new system

Post by Wildeblood »

Kaks wrote:
if you use tortoiseSVN it's a piece of cake...
And if I don't?
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: CompassTargetChanged doesn't work on entering new system

Post by cim »

Either: copy and paste from the web interface: http://svn.berlios.de/wsvn/oolite-linux

Or: svn up -r 5358 will revert your local repo to 5358, you can take a backup of the file, and then do svn up to return to the latest version.
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: CompassTargetChanged doesn't work on entering new system

Post by Kaks »

Cim was faster! :)


Still, if you're using windows I'd recommend tortoiseSVN ( or rabbitVCS if you're on linux), it does make using svn a lot easier... 'course, if you prefer using the command line there are always man pages... ;)


Incidentally:
Step 1: mention which actual client you use.
Step 2: get the right advice for your client! :)
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2290
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia

Re: CompassTargetChanged doesn't work on entering new system

Post by Wildeblood »

Kaks wrote:
For possible interest to oxp HUD makers, switching the compass off in flight (either by switching to a compass-free hud, or by making the compass depend on some breakable piece of equipment) now triggers yet another compassTargetChanged event, this time with target null; switching the compass on will trigger compassTargetChanged again (from null to the previous target).
Your new COMPASS_MODE_INACTIVE value will only appear in player.ship.compassMode while the compass isn't drawn, but it will never be sent as the second parameter in compassTargetChanged, is that right?

And, if I just comment out the last line of this, so it doesn't send the bogus compassTargetChanged, that shouldn't break anything else?

Code: Select all

        if (EXPECT_NOT(!_compassUpdated && _compassActive && [self checkPlayerInSystemFlight])) // compass gone / broken / disabled ?
        {
                // trigger the targetChanged event with whom == null
                _compassActive = NO;
                [PLAYER doScriptEvent:OOJSID("compassTargetChanged") withArguments:[NSArray arrayWithObjects:[NSNull null], OOStringFromCompassMode([PLAYER compassMode]), nil]];
        }
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: CompassTargetChanged doesn't work on entering new system

Post by Kaks »

Wildeblood wrote:
Your new COMPASS_MODE_INACTIVE value will only appear in player.ship.compassMode while the compass isn't drawn, but it will never be sent as the second parameter in compassTargetChanged, is that right?
That's right. It's used purely as an internal flag.

Wildeblood wrote:
And, if I just comment out the last line of this, so it doesn't send the bogus compassTargetChanged, that shouldn't break anything else?
Probably not, though your private build might well break oxps relying on the new compassTargetChanged behaviour.

If you want to filter out compassTargetChanged() events relating to the compass being switched off, a simpler - and suggested - alternative is to have

Code: Select all

this.compassTargetChanged(target,mode)
{
   // I don't care about the compass being turned off!
   if (target===null) return;

   // 'bogus-free' stuff follows!
             ....
}
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
Post Reply