@@ -149,6 +149,10 @@ function doPlayerUpdate(players){
149
149
playerCount ++ ;
150
150
if ( plr == null ) return ;
151
151
152
+ if ( ! ( plr . id in localCache ) ) {
153
+ localCache [ plr . id ] = { marker : null } ;
154
+ }
155
+
152
156
if ( $ ( "#playerSelect option[value='" + plr . id + "']" ) . length <= 0 ) {
153
157
$ ( "#playerSelect" ) . append ( $ ( "<option>" , {
154
158
value : plr . id ,
@@ -160,64 +164,41 @@ function doPlayerUpdate(players){
160
164
map . panTo ( convertToMapGMAP ( plr . x , plr . y ) ) ;
161
165
}
162
166
163
- if ( plr . id in localCache ) {
164
-
165
- //console.log(JSON.stringify(plr));
166
- //console.log(JSON.stringify(localCache[plr.name]));
167
-
168
- if ( plr . x == localCache [ plr . id ] . player . x
169
- && plr . y == localCache [ plr . id ] . player . y
170
- && plr . z == localCache [ plr . id ] . player . z ) {
171
- //Don't update position.. Player hasn't moved
172
- console . log ( "Player " + plr . name + " hasn't moved" ) ;
173
- } else {
174
- console . log ( "updated local cache for " + plr . name ) ;
175
- //console.log(JSON.stringify(plr));
176
- if ( localCache [ plr . id ] . marker != null && plr . vehicle && plr . vehicle != localCache [ plr . id ] . player . vehicle ) {
177
- // They've changed vehicle
178
- var t = MarkerTypes [ plr . vehicle ] ;
179
- _MAP_markerStore [ localCache [ plr . id ] . marker ] . setIcon ( {
180
- url : _MAP_iconURL + t . icon ,
181
- size : t . size ,
182
- origin : t . origin ,
183
- anchor : t . anchor ,
184
- scaledSize : t . scaledSize
185
- } ) ;
186
- }
187
-
188
- localCache [ plr . id ] . player = plr ;
189
-
190
- if ( localCache [ plr . id ] . marker != null || localCache [ plr . id ] . marker != undefined ) {
191
- //update postion
192
- _MAP_markerStore [ localCache [ plr . id ] . marker ] . setPosition ( convertToMapGMAP ( plr . x , plr . y ) ) ;
193
-
194
- //update popup
195
- var html = '<div class="row info-body-row"><strong>Position:</strong> X {' + plr . x . toFixed ( 4 ) + "} Y {" + plr . y . toFixed ( 4 ) + "} Z {" + plr . z . toFixed ( 4 ) + "}</div>"
196
-
197
- if ( plr . vehicle && plr . vehicle != "normal" )
198
- html += '<div class="row info-body-row"><strong>Vehicle:</strong> ' + plr . vehicle_name + '</div>' ;
199
-
200
- var infoContent = '<div class="info-window"><div class="info-header-box"><div class="info-icon"></div><div class="info-header">' + plr . name + '</div></div><div class="clear"></div><div id=info-body>' + html + "</div></div>" ;
201
- var infoBox = new google . maps . InfoWindow ( {
202
- content : infoContent
203
- } ) ;
204
- _MAP_markerStore [ localCache [ plr . id ] . marker ] . popup . setContent ( infoContent ) ;
205
- } else {
206
- var obj = new MarkerObject ( plr . name , new Coordinates ( plr . x , plr . y , plr . z ) , MarkerTypes . normal , "A player" , "" , "" ) ;
207
- createMarker ( false , false , obj , plr . name ) ;
208
-
209
- localCache [ plr . id ] . marker = _MAP_markerStore . length - 1 ;
210
- }
167
+ if ( localCache [ plr . id ] . marker != null || localCache [ plr . id ] . marker != undefined ) {
168
+
169
+ if ( plr . vehicle ) {
170
+ var t = MarkerTypes [ plr . vehicle ] ;
171
+ _MAP_markerStore [ localCache [ plr . id ] . marker ] . setIcon ( {
172
+ url : _MAP_iconURL + t . icon ,
173
+ size : t . size ,
174
+ origin : t . origin ,
175
+ anchor : t . anchor ,
176
+ scaledSize : t . scaledSize
177
+ } ) ;
211
178
}
212
179
180
+ _MAP_markerStore [ localCache [ plr . id ] . marker ] . setPosition ( convertToMapGMAP ( plr . x , plr . y ) ) ;
181
+
182
+ //update popup
183
+ var html = '<div class="row info-body-row"><strong>Position:</strong> X {' + plr . x . toFixed ( 4 ) + "} Y {" + plr . y . toFixed ( 4 ) + "} Z {" + plr . z . toFixed ( 4 ) + "}</div>"
184
+
185
+ if ( plr . vehicle && plr . vehicle != "normal" )
186
+ html += '<div class="row info-body-row"><strong>Vehicle:</strong> ' + plr . vehicle_name + '</div>' ;
187
+
188
+ var infoContent = '<div class="info-window"><div class="info-header-box"><div class="info-icon"></div><div class="info-header">' + plr . name + '</div></div><div class="clear"></div><div id=info-body>' + html + "</div></div>" ;
189
+ var infoBox = new google . maps . InfoWindow ( {
190
+ content : infoContent
191
+ } ) ;
192
+ _MAP_markerStore [ localCache [ plr . id ] . marker ] . popup . setContent ( infoContent ) ;
193
+
194
+
213
195
} else {
214
- localCache [ plr . id ] = { } ;
215
- localCache [ plr . id ] . player = plr ;
216
196
var obj = new MarkerObject ( plr . name , new Coordinates ( plr . x , plr . y , plr . z ) , MarkerTypes . normal , "A player" , "" , "" ) ;
217
197
createMarker ( false , false , obj , plr . name ) ;
218
198
219
199
localCache [ plr . id ] . marker = _MAP_markerStore . length - 1 ;
220
200
}
201
+
221
202
} ) ;
222
203
223
204
console . log ( "Playercount: " + playerCount ) ;
0 commit comments