Skip to content

Commit 7c1a067

Browse files
committed
refactor: update _blips array
The blips array now reflects the structure of the blips that is in the resource.
1 parent 411aea7 commit 7c1a067

File tree

1 file changed

+45
-2
lines changed

1 file changed

+45
-2
lines changed

js/src/init.js

+45-2
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,55 @@ function initPage() {
3737
});
3838
}
3939

40+
function getBlipMarkerId(blip){
41+
if(_blips[blip.type] == null){
42+
return -1;
43+
}
44+
45+
var blipArrayForType = _blips[blip.type];
46+
47+
for(var b in blipArrayForType){
48+
var blp = blipArrayForType[b];
49+
50+
if (blp.x == blip.x && blp.y == blip.y && blp.z == blip.z){
51+
return blp.markerId;
52+
}
53+
}
54+
55+
// Couldn't find it..
56+
return -1;
57+
}
58+
59+
function getBlipIndex(blip){
60+
if (_blips[blip.type] == null){
61+
return -1;
62+
}
63+
64+
var blipArrayForType = _blips[blip.type];
65+
66+
for(var b in blipArrayForType){
67+
var blp = blipArrayForType[b];
68+
69+
if (blp.x == blip.x && blp.y == blip.y && blp.z == blip.z){
70+
return b;
71+
}
72+
}
73+
74+
// Couldn't find it..
75+
return -1;
76+
}
77+
4078
function createBlip(blip){
4179
var obj = new MarkerObject(blip.name, new Coordinates(blip.x, blip.y, blip.z), MarkerTypes[blip.type], blip.description, "", "");
4280

43-
_blips[_blipCount++] = blip;
81+
if (_blips[blip.type] == null){
82+
_blips[blip.type] = [];
83+
}
84+
85+
blip.markerId = createMarker(false, false, obj, "") - 1;
4486

45-
createMarker(false, false, obj, "");
87+
_blips[blip.type].push(blip);
88+
_blipCount++;
4689
}
4790

4891
function blipSuccess(data, textStatus){

0 commit comments

Comments
 (0)