From 8bb9b28cf84c685effd96bcf32a91093fa5207c4 Mon Sep 17 00:00:00 2001 From: stuyk Date: Sat, 15 Jun 2024 23:06:46 -0600 Subject: [PATCH] fix: adjust marker type to support string names, and numbers --- src/main/server/controllers/markers.ts | 6 +- src/main/shared/types/marker.ts | 99 +++++++++++++------------- 2 files changed, 56 insertions(+), 49 deletions(-) diff --git a/src/main/server/controllers/markers.ts b/src/main/server/controllers/markers.ts index 06353944a..4528da125 100644 --- a/src/main/server/controllers/markers.ts +++ b/src/main/server/controllers/markers.ts @@ -1,6 +1,6 @@ import * as alt from 'alt-server'; import * as Utility from '@Shared/utility/index.js'; -import { Marker } from '@Shared/types/marker.js'; +import { Marker, MarkerType } from '@Shared/types/marker.js'; import { Events } from '@Shared/events/index.js'; const GroupType = 'marker'; @@ -16,6 +16,10 @@ const markerGroup = new alt.VirtualEntityGroup(MAX_MARKERS); * @return */ export function useMarkerGlobal(marker: Marker, maxDistance: number = 50) { + if (typeof marker.type !== 'number') { + marker.type = MarkerType[marker.type]; + } + if (maxDistance > 50) { maxDistance = 50; } diff --git a/src/main/shared/types/marker.ts b/src/main/shared/types/marker.ts index 96a6d874d..2fddc77ff 100644 --- a/src/main/shared/types/marker.ts +++ b/src/main/shared/types/marker.ts @@ -1,57 +1,60 @@ import * as alt from 'alt-shared'; -export enum MarkerType { - UPSIDE_DOWN_CONE = 0, - CYLINDER = 1, - CHEVRON_UP = 2, - THIN_CHEVRON_UP = 3, - CHECKERED_FLAG = 4, - CHECKERED_FLAG_CIRCLE = 5, - VERTICLE_CIRCLE = 6, - PLANE_MODEL = 7, - LOST_MC = 8, - LOST_MC_SOLID = 9, - NUMBER_0 = 10, - NUMBER_1 = 11, - NUMBER_2 = 12, - NUMBER_3 = 13, - NUMBER_4 = 14, - NUMBER_5 = 15, - NUMBER_6 = 16, - NUMBER_7 = 17, - NUMBER_8 = 18, - NUMBER_9 = 19, - CHEVRON_UP_SINGLE = 20, - CHEVRON_UP_DOUBLE = 21, - CHEVRON_UP_TRIPLE = 22, - FLAT_CIRCLE = 23, - REPLAY = 24, - FLAT_CIRCLE_SKINNY = 25, - FLAT_CIRCLE_SKINNY_DIRECTIONAL = 26, - FLAT_CIRCLE_SKINNY_SPLIT = 27, - SPHERE = 28, - DOLLAR_SIGN = 29, - HORIZONTAL_BARS = 30, - WOLF_HEAD = 31, - QUESTION = 32, - PLANE = 33, - HELICOPTER = 34, - BOAT = 35, - CAR = 36, - MOTORCYCLE = 37, - BIKE = 38, - TRUCK = 39, - PARACHUTE = 40, - JETPACK = 41, - SAW_BLADE = 42, - FLAT_VERTICAL_GRADIENT = 43, -} +export const MarkerType = { + UPSIDE_DOWN_CONE: 0, + CYLINDER: 1, + CHEVRON_UP: 2, + THIN_CHEVRON_UP: 3, + CHECKERED_FLAG: 4, + CHECKERED_FLAG_CIRCLE: 5, + VERTICLE_CIRCLE: 6, + PLANE_MODEL: 7, + LOST_MC: 8, + LOST_MC_SOLID: 9, + NUMBER_0: 10, + NUMBER_1: 11, + NUMBER_2: 12, + NUMBER_3: 13, + NUMBER_4: 14, + NUMBER_5: 15, + NUMBER_6: 16, + NUMBER_7: 17, + NUMBER_8: 18, + NUMBER_9: 19, + CHEVRON_UP_SINGLE: 20, + CHEVRON_UP_DOUBLE: 21, + CHEVRON_UP_TRIPLE: 22, + FLAT_CIRCLE: 23, + REPLAY: 24, + FLAT_CIRCLE_SKINNY: 25, + FLAT_CIRCLE_SKINNY_DIRECTIONAL: 26, + FLAT_CIRCLE_SKINNY_SPLIT: 27, + SPHERE: 28, + DOLLAR_SIGN: 29, + HORIZONTAL_BARS: 30, + WOLF_HEAD: 31, + QUESTION: 32, + PLANE: 33, + HELICOPTER: 34, + BOAT: 35, + CAR: 36, + MOTORCYCLE: 37, + BIKE: 38, + TRUCK: 39, + PARACHUTE: 40, + JETPACK: 41, + SAW_BLADE: 42, + FLAT_VERTICAL_GRADIENT: 43, +}; -export type Marker = { +export type MarkerBase = { uid?: string; - type: MarkerType; pos: alt.IVector3; scale: alt.IVector3; color: alt.RGBA; dimension?: number; }; + +export type Marker = { + type: number | keyof typeof MarkerType; +} & MarkerBase;