diff --git a/src/common.ts b/src/common.ts index b7c61c6..07894f0 100644 --- a/src/common.ts +++ b/src/common.ts @@ -2,8 +2,6 @@ import type { TeleportEndpoint, TeleporterTypes } from './types/teleportEndpoint type Pos = [number, number, number]; -const randomNumber = Math.random(); - export function createEndpoint( name: string = '', teleporterType: TeleporterTypes = 'Spacestation', @@ -13,8 +11,8 @@ export function createEndpoint( galaxy: number = 0, systemIndex: number = 0, planet: number = 0, - position: Pos = [randomNumber, randomNumber, randomNumber], - facing: Pos = [randomNumber, randomNumber, randomNumber], + position: Pos = [1, 1, 1], + facing: Pos = [1, 1, 1], isFeatured: boolean = false, calcWarpOffset: boolean = false ): TeleportEndpoint { diff --git a/src/components/EditEndpointDialogue.vue b/src/components/EditEndpointDialogue.vue index e7b178e..a042485 100644 --- a/src/components/EditEndpointDialogue.vue +++ b/src/components/EditEndpointDialogue.vue @@ -91,11 +91,20 @@ const ids = { }; const editButtonText = computed(() => (props.endpointData.Name ? 'Save Changes' : 'Add Endpoint')); + +const isOutOfSafeRange = computed(() => { + const systemIndex = newEndpointAddress.value.substring(1, 4); + const systemNumber = parseInt(systemIndex, 16); + const lastSafeIndex = 122; + const aboveSafeRange = systemNumber > lastSafeIndex; + return aboveSafeRange && endpointToAddress(props.endpointData) !== newEndpointAddress.value; +}); diff --git a/src/components/EndpointCard.vue b/src/components/EndpointCard.vue index aae7c9b..86cd0ed 100644 --- a/src/components/EndpointCard.vue +++ b/src/components/EndpointCard.vue @@ -26,8 +26,8 @@ function removeEndpoint() { diff --git a/src/stores/endpointData.ts b/src/stores/endpointData.ts index 2c3d67d..894b686 100644 --- a/src/stores/endpointData.ts +++ b/src/stores/endpointData.ts @@ -6,6 +6,7 @@ interface State { json: TeleportEndpoint[]; filter: string; filterType: TeleporterTypes | ''; + jsonError: boolean; } export const useEndpointDataStore = defineStore('endpointData', { @@ -14,11 +15,18 @@ export const useEndpointDataStore = defineStore('endpointData', { json: [], filter: '', filterType: '', + jsonError: false, }), actions: { parseJson() { - this.json = JSON.parse(this.jsonInputString || '[]'); + try { + this.json = JSON.parse(this.jsonInputString || '[]'); + this.jsonError = false; + } catch (error) { + console.error(error); + this.jsonError = true; + } }, }, });