Completely bamboozled....

For AI and campaign script related discussions and questions
Post Reply
User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Completely bamboozled....

Post by aubergine »

So, I've defined this function:

Code: Select all

Map.taskTilesToSectors = function taskTilesToSectors(taskData,processData,runData,processName,taskName,alert) {
	// check tiles are present (run aborts if not)
	if (!runData.hasOwnProperty("tiles")) alert("Unable to find runData.tiles", PROCESS_ALERT_ERROR); // line 96
	// create sectors array
	runData.sectors = [];
	// convert tiles in to sector objects
	runData.tiles.forEach(function(tile,i) {
		runData.sectors[i] = Map.tileToSectorLoc(tile);//Map.tileToSector(tile);
	});
}
The runData param will get populated with an object when the function is called.

BUT... Currently nothing is calling this function, yet for some reason I'm getting this error in the logs:

Code: Select all

info    |01:48:06: [loadPlayerScript:428] Uncaught exception at line 96, file multiplay/skirmish/eggplant.js: TypeError: Result of expression 'runData' [undefined] is not an object.
What on earth is going on? If the function isn't getting called (and I've checked extensively that it isn't getting called), why am I getting that *runtime* error? Is this some jslint weirdness?

If I comment out line 96, the error shifts to line 98, etc. The function isn't getting executed by anything, so of course runData will be undefined at JS code parsing time, but... ARGH! *brain melts*
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Re: Completely bamboozled....

Post by aubergine »

Update: It looks like jslint is getting confused when I assign a named function to a property on an object.

If I change this:

Code: Select all

Map.taskTilesToSectors = function taskTilesToSectors(taskData,processData,runData,processName,taskName,alert) {
To this:

Code: Select all

Map.taskTilesToSectors = function(taskData,processData,runData,processName,taskName,alert) {
The error goes away.... *very* annoying :(
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
Post Reply