@@ -252,105 +252,113 @@ export function populateGraph(g: Graph, chartData: ChartPoint[], bySponsor: bool
252252 if (itsYou) {
253253 g.setNodeAttribute(gPatp, 'color', colors.YOUR_GAL);
254254 }
255− g.addNode(sPatp, {
256− label: sPatp,
257− size: starSize,
258− color: itsYou ? colors.YOU : colors.GOLDT2,
259− x: starX,
260− y: starY,
261− zIndex: 8,
262− });
263− if (lastStarArm == arm) {
264− g.addEdge(sPatp, lastStarPatp, {
265− color: colors.LGREY,
266− size: 0.1,
267− zIndex: 7,
268− });
269− } else {
270− g.addEdge(sPatp, gPatp, {
271− color: colors.LGREY,
272− size: 0.2,
273− zIndex: 9,
255+ try {
256+ g.addNode(sPatp, {
257+ label: sPatp,
258+ size: starSize,
259+ color: itsYou ? colors.YOU : colors.GOLDT2,
260+ x: starX,
261+ y: starY,
262+ zIndex: 8,
274263 });
275− }
276− lastStarArm = arm;
277− lastStarPatp = sPatp;
278− if (star.sponsor) {
279− sponsorEdges.push([sPatp, star.sponsor, {
280− color: colors.GREEN,
281− size: 0.2,
282− zIndex: 11,
283− }]);
284− }
285−
286− const planets = star[subsKey] || [];
287− const numPlanets = planets.length;
288− // const maxPlanetDistance = starSize * 1.6 * 4000 * 64;
289− const maxPlanetDistance = minDistanceBetweenStars * 0.45;
290− const minPlanetDistance = maxPlanetDistance / 4;
291− const {
292− coords: planetCoords,
293− numArms: numPlanetArms,
294− minDistanceBetween: minDistanceBetweenPlanets,
295− } = arrangePointsInSpirals(numPlanets,
296− {
297− maxDistance: maxPlanetDistance,
298− minDistance: minPlanetDistance,
299− startX: starX,
300− startY: starY,
301− maxArms: 30,
302− makeSingleArmCircle: true,
303− });
304− let lastPlanetArm = null;
305− let lastPlanetPatp = null;
306− planets.forEach((planet, pi) => {
307− const pPatp = planet.patp;
308− const [planetX, planetY] = planetCoords[pi].coords;
309− const arm = planetCoords[pi].arm;
310− const planetSize = Math.sqrt(Math.min(minPlanetDistance, minDistanceBetweenPlanets)) / 1300;
311− const planetEdgeSize = planetSize / 3;
312− const itsYou = pPatp === '~' + window.ship;
313− if (itsYou) {
314− g.setNodeAttribute(sPatp, 'color', colors.YOUR_STAR);
315− g.setNodeAttribute(gPatp, 'color', colors.YOUR_GAL);
264+ if (lastStarArm == arm) {
265+ g.addEdge(sPatp, lastStarPatp, {
266+ color: colors.LGREY,
267+ size: 0.1,
268+ zIndex: 7,
269+ });
270+ } else {
271+ g.addEdge(sPatp, gPatp, {
272+ color: colors.LGREY,
273+ size: 0.2,
274+ zIndex: 9,
275+ });
276+ }
277+ lastStarArm = arm;
278+ lastStarPatp = sPatp;
279+ if (star.sponsor) {
280+ sponsorEdges.push([sPatp, star.sponsor, {
281+ color: colors.GREEN,
282+ size: 0.2,
283+ zIndex: 11,
284+ }]);
316285 }
317− try {
318− g.addNode(pPatp, {
319− label: pPatp,
320− size: planetSize,
321− color: itsYou ? colors.YOU : (planet.dominion == 'l2' ? colors.GREEN : colors.BLUE),
322− x: planetX,
323− y: planetY,
324− zIndex: 6,
286+
287+ const planets = star[subsKey] || [];
288+ const numPlanets = planets.length;
289+ // const maxPlanetDistance = starSize * 1.6 * 4000 * 64;
290+ const maxPlanetDistance = minDistanceBetweenStars * 0.45;
291+ const minPlanetDistance = maxPlanetDistance / 4;
292+ const {
293+ coords: planetCoords,
294+ numArms: numPlanetArms,
295+ minDistanceBetween: minDistanceBetweenPlanets,
296+ } = arrangePointsInSpirals(numPlanets,
297+ {
298+ maxDistance: maxPlanetDistance,
299+ minDistance: minPlanetDistance,
300+ startX: starX,
301+ startY: starY,
302+ maxArms: 30,
303+ makeSingleArmCircle: true,
325304 });
326− if (lastPlanetArm == arm) {
327− g.addEdge(pPatp, lastPlanetPatp, {
328− color: colors.DGREY,
329− size: planetEdgeSize,
330− zIndex: 5,
305+ let lastPlanetArm = null;
306+ let lastPlanetPatp = null;
307+ planets.forEach((planet, pi) => {
308+ const pPatp = planet.patp;
309+ const [planetX, planetY] = planetCoords[pi].coords;
310+ const arm = planetCoords[pi].arm;
311+ const planetSize = Math.sqrt(Math.min(minPlanetDistance, minDistanceBetweenPlanets)) / 1300;
312+ const planetEdgeSize = planetSize / 3;
313+ const itsYou = pPatp === '~' + window.ship;
314+ if (itsYou) {
315+ g.setNodeAttribute(sPatp, 'color', colors.YOUR_STAR);
316+ g.setNodeAttribute(gPatp, 'color', colors.YOUR_GAL);
317+ }
318+ try {
319+ g.addNode(pPatp, {
320+ label: pPatp,
321+ size: planetSize,
322+ color: itsYou ? colors.YOU : (planet.dominion == 'l2' ? colors.GREEN : colors.BLUE),
323+ x: planetX,
324+ y: planetY,
325+ zIndex: 6,
331326 });
332− } else {
333− if (numPlanetArms == 1) {
334− g.addEdge(pPatp, sPatp, {
327+ if (lastPlanetArm == arm) {
328+ g.addEdge(pPatp, lastPlanetPatp, {
335329 color: colors.DGREY,
336330 size: planetEdgeSize,
337331 zIndex: 5,
338332 });
333+ } else {
334+ if (numPlanetArms == 1) {
335+ g.addEdge(pPatp, sPatp, {
336+ color: colors.DGREY,
337+ size: planetEdgeSize,
338+ zIndex: 5,
339+ });
340+ }
339341 }
342+ if (planet.sponsor) {
343+ sponsorEdges.push([pPatp, planet.sponsor, {
344+ color: colors.GREEN,
345+ size: planetEdgeSize,
346+ zIndex: 11,
347+ }]);
348+ }
349+ lastPlanetArm = arm;
350+ lastPlanetPatp = pPatp;
351+ } catch (e) {
352+ let msg = `Couldn't add ${pPatp} to the graph`;
353+ console.error(msg, e);
354+ alertMe(msg + '\n' + e.message);
340355 }
341− if (planet.sponsor) {
342− sponsorEdges.push([pPatp, planet.sponsor, {
343− color: colors.GREEN,
344− size: planetEdgeSize,
345− zIndex: 11,
346− }]);
347− }
348− } catch (e) {
349− console.error(`Couldn't add ${pPatp} to the graph`, e);
350− }
351− lastPlanetArm = arm;
352− lastPlanetPatp = pPatp;
353− });
356+ });
357+ } catch (e) {
358+ let msg = `Couldn't add ${sPatp} to the graph`;
359+ console.error(msg, e);
360+ alertMe(msg + '\n' + e.message);
361+ }
354362 });
355363 });
356364 sponsorEdges.forEach(([point, sponsor, attrs]) => {
@@ -361,3 +369,7 @@ export function populateGraph(g: Graph, chartData: ChartPoint[], bySponsor: bool
361369 }
362370 return g;
363371}
372+
373+function alertMe(msg: string) {
374+ alert('Encountered an error, please tell ~midlev-mindyr: ' + msg);
375+}