'Lead is null' error

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

Moderators: winston, another_commander, Getafix

Post Reply
UK_Eliter
---- E L I T E ----
---- E L I T E ----
Posts: 1248
Joined: Sat Sep 12, 2009 11:58 pm
Location: Essex (mainly industrial and occasionally anarchic)

'Lead is null' error

Post by UK_Eliter »

Several times I've got the following error under '1.81.0.5850-140709-1708635 (x86-64 test release) under Windows 6.2.9200 64-bit' - and I think I got it with the 1.8 release version too.

Code: Select all

JavaScript exception (oolite-populator 1.81): TypeError: lead is null
It happens in (or on entering) interstellar space, and it might be due to - or exposed by - my InterstellarTweaks OXP, which I am revising. I can glean more info - and test without that OXP installed - if that would be useful.

There is no crash or obvious in-game problem.
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: 'Lead is null' error

Post by cim »

Could you check the output in the debug console of

Code: Select all

Ship.keysForRole("pirate");
Ship.keysForRole("pirate-light-freighter");
Ship.keysForRole("pirate-medium-freighter");
Ship.keysForRole("pirate-heavy-freighter");
please. The populator should only give that error if it tries to add a pirate pack and fails (which it shouldn't do normally in interstellar space, though you might have modified it to do so)
UK_Eliter
---- E L I T E ----
---- E L I T E ----
Posts: 1248
Joined: Sat Sep 12, 2009 11:58 pm
Location: Essex (mainly industrial and occasionally anarchic)

Re: 'Lead is null' error

Post by UK_Eliter »

cim

I forget how to use the debug console and indeed things might have changed since I last used it. Please give me / point me towards some instructions. Thanks.
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: 'Lead is null' error

Post by cim »

[wiki]Debug_OXP[/wiki] is the documentation - it depends which OS you're on.

If you can't get it to work, then

Code: Select all

log(this.name,Ship.keysForRole("pirate").toSource());
log(this.name,Ship.keysForRole("pirate-light-freighter").toSource());
log(this.name,Ship.keysForRole("pirate-medium-freighter").toSource());
log(this.name,Ship.keysForRole("pirate-heavy-freighter").toSource());
put in your startUp will do.

Without ship OXPs you'll get something like

Code: Select all

["gecko", "python", "cobra3-pirate", "ferdelance", "mamba", "adder", "moray", "cobramk1", "cobramk1-alt", "sidewinder", "krait"]

["cobra3-alternate", "python", "moray", "cobramk1-alt"]

["cobra3-alternate", "boa-pirate", "python-blackdog"]

["boa-pirate", "boa-mk2-pirate", "anaconda-pirate", "python-blackdog"]
UK_Eliter
---- E L I T E ----
---- E L I T E ----
Posts: 1248
Joined: Sat Sep 12, 2009 11:58 pm
Location: Essex (mainly industrial and occasionally anarchic)

Re: 'Lead is null' error

Post by UK_Eliter »

Thanks cim.

Attempting to download the version of the OXP on the webpage you cite, that version being 'Debug OXP for Oolite 1.77.1', produced 'The page you requested could not be found. Perhaps it was attacked by a thargoid?'.

Putting the log commands that you mention into my InterstellarTweaks OXP's startup function - and doing nothing else - yields:

Code: Select all

0:29:09.616 [IST_masterScript]: ["eagle2", "cobramk1", "ferdelance3Pirate", "mw-asp", "sidewinder", "anaconda", "adck_eagle_two_a", "cobra3M2-pirate", "adck_eagle_two_b", "adck_eagle_two_c", "adck_eagle_two_d", "adck_eagle_two_e", "adck_eagle_two_f", "adck_eagle_two_g", "cobra3M2-alternate", "ferdelance3+T_HardPiratePoliceDecomissioned", "ringhals", "adck_eagle_three_a", "adck_eagle_three_b", "adck_eagle_three_c", "adck_eagle_three_d", "adck_eagle_three_e", "adck_eagle_three_f", "adck_eagle_three_g", "kraitM2", "staer9_cobra2x", "drake", "staer9_iguana", "ferdelance2a", "cobramk1M2", "ferdelance2f", "pythonM2-blackdog", "kirin-xm", "cobra3-trader", "ferdelance2t", "drakemk2", "python-blackdog", "mamba-escort", "ferdelance3+HardPirate", "staer9_sidewinder-x", "reduxvampirate", "purgwolftrader", "werewolftrader", "viper3-renegade", "adck_eagle_one", "staer9_python-cruiser", "aphid-re2dux", "reduxmk1vampirate", "ferdelance3PirateKing", "mussurana", "rogue-frigate", "dragon-an", "cobra3-pirate", "aspmk1", "morayM2", "staer9_python-x", "xarik", "blackcobra4", "cobramk1-alt", "reduxmark1goldvampirate", "reduxpurgvampirate", "asp", "adder", "wolfmk2M2", "impcourier", "moray", "superSidewinderPirate", "cobra4", "superSidewinderHarderPirate", "morayMED", "pythonM2", "mambaM2", "geckoM2", "adck_eagle_four", "excalibur-pirate", "Falcon", "adck_eagle_two", "wolfmk2SE", "ferdelanceM2", "basilisk", "asp_explorer", "krait", "hydra1", "hydra2", "cobra3rapier-pirate", "rhs_mark_gecko_shipset", "smivsShieldTail", "dragon-se", "sbwolf-re2dux", "ferdelance", "gecko", "smivsPurpleHaze", "staer9_cat", "cobra3-alternate", "Kestrel", "ferdelance3PirateVariant", "adck_imp_trader", "cobra3courier", "sidewinderM2", "ferdelance3HardPirateVariant", "rattle", "remorse_of_conscience_pirate", "aspM2", "Falcon-E", "Falcon-S", "ferdelance3HardPirate", "mamba", "paladin-pirate", "cobra3rapier", "sidewinder-escort", "boa", "staer9_mw-asp", "wolfmk2-alt", "python-trader", "adck_eagle_four_a", "adck_eagle_four_b", "adck_eagle_four_c", "adck_eagle_four_d", "adck_eagle_four_e", "adck_eagle_four_f", "adck_eagle_four_g", "python", "dragon-m", "cividom", "adck_wyvern_explorer-pirate", "worm_missionary03", "cobra3courier-pirate", "adck_eagle_three", "kirin-cv", "adck_imp_courier-pirate", "adck_eagle_one_a", "adck_eagle_one_b", "adck_eagle_one_c", "adck_eagle_one_d", "adck_eagle_one_e", "python-cruiser", "adck_eagle_one_f", "adck_eagle_one_g", "adck_imp_trader-pirate", "ferdelance3+T_HardPirate", "boa-mk2", "anarchies-renegade_viper", "copperhead-pirate", "impcourier-navy", "staer9_mussurana", "phoenix-pirate", "civipurg", "cobramk1M2-alt", "wolfmk1", "wolfmk2"]

00:29:09.616 [IST_masterScript]: ["rhs_big_boss_vamppurg_spacelane_shipset", "rhs_big_boss_iguana_spacelane_shipset", "rhs_big_boss_cobra4_spacelane_shipset", "rhs_big_boss_supercobra_spacelane_shipset", "rhs_big_boss_pitviper_spacelane_shipset", "rhs_big_boss_impcourier_spacelane_shipset", "rhs_big_boss_wolfmk2SE_spacelane_shipset"]

00:29:09.616 [IST_masterScript]: ["boa-pirate", "rhs_mark_pythonet_shipset", "rhs_mark_python_shipset"]

00:29:09.616 [IST_masterScript]: ["boa-pirate", "anaconda-pirate", "rhs_mark_pythonet_shipset", "rhs_mark_imptrader_shipset", "rhs_mark_pcc_shipset", "rhs_big_boss_imptrader_spacelane_shipset", "rhs_mark_python_shipset", "boa-mk2-pirate"]
When I remove all OXPs other than InterstellarTweaks, I get:

Code: Select all

00:32:31.246 [IST_masterScript]: ["rhs_mark_gecko_shipset", "hydra1", "hydra2", "ferdelance", "adder", "krait", "cobramk1", "basilisk", "kirin-xm", "moray", "smivsPurpleHaze", "sbwolf-re2dux", "cobramk1-alt", "cobra3-pirate", "rattle", "gecko", "sidewinder", "kirin-cv", "mamba", "python", "smivsShieldTail", "aphid-re2dux"]

00:32:31.247 [IST_masterScript]: ["rhs_big_boss_wolfmk2SE_spacelane_shipset", "rhs_big_boss_impcourier_spacelane_shipset", "moray", "rhs_big_boss_vamppurg_spacelane_shipset", "cobramk1-alt", "cobra3-alternate", "rhs_big_boss_supercobra_spacelane_shipset", "rhs_big_boss_iguana_spacelane_shipset", "rhs_big_boss_pitviper_spacelane_shipset", "rhs_big_boss_cobra4_spacelane_shipset", "python"]

00:32:31.247 [IST_masterScript]: ["rhs_mark_pythonet_shipset", "python-blackdog", "boa-pirate", "rhs_mark_python_shipset", "cobra3-alternate"]

00:32:31.247 [IST_masterScript]: ["rhs_mark_pcc_shipset", "rhs_mark_pythonet_shipset", "python-blackdog", "boa-pirate", "anaconda-pirate", "rhs_mark_python_shipset", "rhs_big_boss_imptrader_spacelane_shipset", "boa-mk2-pirate", "rhs_mark_imptrader_shipset"]
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: 'Lead is null' error

Post by cim »

UK_Eliter wrote:
Debug OXP for Oolite 1.77.1'
If you're using the nightly builds, you can skip that step, as they come with the Debug OXP anyway.

Those lists look okay. What are you doing within the IS populator?
UK_Eliter
---- E L I T E ----
---- E L I T E ----
Posts: 1248
Joined: Sat Sep 12, 2009 11:58 pm
Location: Essex (mainly industrial and occasionally anarchic)

Re: 'Lead is null' error

Post by UK_Eliter »

cim wrote:
What are you doing within the IS populator?

Code: Select all

/*
=============================

OVERVIEW OF HOW THE SCRIPT WORKS
Ordered by event, in time order.

=============================

(1) this.shipWillLaunchFromStation [Oolite event handler]

	On, only, the *first* run of this routine, my code does various things including making array of any OXP worldscripts that contain populator scripts and an array of any that contain repopulator scripts.

(2) this.playerWillEnterWitchspace [Oolite event handler]

	If in INTERSTELLAR space, then decide the following, to be acted upon on later:
		Will we tweak the jump?
			If yes, will we do the new or the modified scenario?
				If we will do the modified scenario, determine which type (onlyBugs, onlyNavy, extraNavy) of it we will do.

(3) this.interstellarTweaks_customInterstellarPopulator [Setup via planetinfo.plist. Runs immediately before this.shipWillExitWitchspace.]

	If doing tweak of the 'modified' type - or indeed doing no tweak at all - then run all worldscipts and inbuilt populators that would normally run. Or rather do so under certain conditions . .
	If doing tweak of the 'new type', run none of the above populators.
	NB: My code does no population, strictly defined, i.e. does not use 'system.setPopulator'. That is because it seems feasible  (at least while few expansion packs use that method) only to remove various ships - and, after that, add ships - later on.

(4) this.shipWillExitWitchspace [Oolite event handler]

	If in NORMAL space, then - sometimes - do various things . .
	If in INTERSTELLAR space, start a timer ('this.interstellarPostWillExit_Timer') to run routine 'this.$interstellarWillExitTimed'.
		(I have this on a timer because one thing that the routine does is to move the player and moving the player immediately crashes Oolite - or at least Oolite < 1.79.)

(5) this.$interstellarWillExitTimed [my timed routine]

	If in INTERSTELLAR space, actually start to implement the various tweaks.
	In case of all tweaks save extraNavy, this involves clearing (or parially clearing) space, moving the player (temporarily in all cases except newScenario) and populating it

(6) this.shipExitedWitchspace [Oolite event handler]

	If doing any modification except extraNavy, set a timer (this.timerForReturnEtc) which will run a routine (this.returnEtcTimed) described below.
	(Have this on timer in order to (1) have something closer to the final word on population, (2 ) keep player away from changes until they are finished.)

(7) this.returnEtcTimed [my timed routine]

	Does any final clearing, and - except for when doing the newScenario, returns the player.

There is also

(8) this.interstellarTweaks_customInterstellarRePopulator  [Setup via planetinfo.plist. Runs every 20 seconds in interstellar space.]

	This sometimes adds various ships directly, and sometimes runs both Oolite's inbuilt interstellar repopulator and OXP interstellar repopulators.
*/

I hope that is reasonably clear, and also sufficiently detailed. (Also: rather amazingly, perhaps, the above does work - aside from the error in question.)
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: 'Lead is null' error

Post by cim »

If you add logging to each function to note when it's called, presumably the error occurs between steps 3 and 4? Are you definitely calling the IS populators of the other worldscripts, and not their normal ones?
UK_Eliter
---- E L I T E ----
---- E L I T E ----
Posts: 1248
Joined: Sat Sep 12, 2009 11:58 pm
Location: Essex (mainly industrial and occasionally anarchic)

Re: 'Lead is null' error

Post by UK_Eliter »

cim wrote:
If you add logging to each function to note when it's called, presumably the error occurs between steps 3 and 4? Are you definitely calling the IS populators of the other worldscripts, and not their normal ones?
Thanks cim.

The problem occurs - when it does occur, which is about half the time - after my script's this.startUp and before this.shipWillLaunchFromStation. And it occurs irrespective of whether I load a saved ship file or not.

I've checked that I am calling the IS populators of other worldscripts and not their normal ones, and I do seem to be doing the former. But I am still investigating my code . .
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: 'Lead is null' error

Post by cim »

UK_Eliter wrote:
The problem occurs - when it does occur, which is about half the time - after my script's this.startUp and before this.shipWillLaunchFromStation. And it occurs irrespective of whether I load a saved ship file or not.
Okay, that's interesting. It makes much more sense as a place for the error, but Interstellar Tweaks doesn't change the normal system populator at all, does it? Might be worth doing the usual OXP-halving test since it might not be your OXP at all that's doing this.
UK_Eliter
---- E L I T E ----
---- E L I T E ----
Posts: 1248
Joined: Sat Sep 12, 2009 11:58 pm
Location: Essex (mainly industrial and occasionally anarchic)

Re: 'Lead is null' error

Post by UK_Eliter »

The culprit appears to the the Asteroid Storm OXP. (I have version 4.03, which is the latest.) I've posted a link in the relevant thread.

EDIT: I may have misidentified the culprit here. The error is back in my log, even without Asteroid Storm installed!
Last edited by UK_Eliter on Sun Jul 13, 2014 7:12 pm, edited 1 time in total.
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Re: 'Lead is null' error

Post by Eric Walch »

But asteroid storm in not adding any ships. Only in the mission system are asteroids added.
Post Reply