diff --git a/server/go.mod b/server/go.mod index ce30c07..c4b034c 100644 --- a/server/go.mod +++ b/server/go.mod @@ -5,6 +5,7 @@ require ( github.com/gorilla/websocket v1.4.0 github.com/lib/pq v1.0.0 github.com/mattn/go-sqlite3 v1.10.0 + github.com/mjibson/esc v0.1.0 // indirect github.com/patrickmn/go-cache v2.1.0+incompatible github.com/sirupsen/logrus v1.3.0 github.com/stretchr/testify v1.2.2 diff --git a/server/go.sum b/server/go.sum index b9915f4..a077206 100644 --- a/server/go.sum +++ b/server/go.sum @@ -10,6 +10,8 @@ github.com/lib/pq v1.0.0 h1:X5PMW56eZitiTeO7tKzZxFCSpbFZJtkMMooicw2us9A= github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/mattn/go-sqlite3 v1.10.0 h1:jbhqpg7tQe4SupckyijYiy0mJJ/pRyHvXf7JdWK860o= github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= +github.com/mjibson/esc v0.1.0 h1:5ch+murgrcwDFLOE2hwj0f7kE4xJfJhkSCAjSLY182o= +github.com/mjibson/esc v0.1.0/go.mod h1:9Hw9gxxfHulMF5OJKCyhYD7PzlSdhzXyaGEBRPH1OPs= github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc= github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= diff --git a/server/mapobjectdb/accessor.go b/server/mapobjectdb/accessor.go index 6d983bb..4b6a97a 100644 --- a/server/mapobjectdb/accessor.go +++ b/server/mapobjectdb/accessor.go @@ -32,12 +32,17 @@ type MapObject struct { } func NewMapObject(MBPos *coords.MapBlockCoords, x int, y int, z int, _type string) *MapObject { + + if x > 16 || y > 16 || z > 16 { + panic("Out of range3!") //XXX + } + o := MapObject{ MBPos: MBPos, Type: _type, - X: MBPos.X + x, - Y: MBPos.Y + y, - Z: MBPos.Z + z, + X: (MBPos.X * 16) + x, + Y: (MBPos.Y * 16) + y, + Z: (MBPos.Z * 16) + z, Mtime: time.Now().Unix(), Attributes: make(map[string]string), } diff --git a/server/static/js/main.js b/server/static/js/main.js index 8272a70..8266406 100644 --- a/server/static/js/main.js +++ b/server/static/js/main.js @@ -32,6 +32,8 @@ api.getConfig().then(function(cfg){ overlays["Players"] = new PlayerOverlay(wsChannel, layerMgr); overlays["Travelnet"] = new TravelnetOverlay(wsChannel, layerMgr); + map.addLayer(overlays["Players"]); + L.control.layers(layers, overlays).addTo(map); var el = new CoordinatesDisplay({ position: 'bottomleft' }); diff --git a/server/static/js/overlays/AbstractIconOverlay.js b/server/static/js/overlays/AbstractIconOverlay.js index 7d9094d..d341764 100644 --- a/server/static/js/overlays/AbstractIconOverlay.js +++ b/server/static/js/overlays/AbstractIconOverlay.js @@ -16,7 +16,7 @@ var AbstractIconOverlay = L.LayerGroup.extend({ }, hashPos: function(x,y,z){ - return x + "/" + y "/" + z; + return x + "/" + y + "/" + z; }, onLayerChange: function(layer){ @@ -69,7 +69,7 @@ var AbstractIconOverlay = L.LayerGroup.extend({ } else { //marker does not exist var marker = L.marker([obj.z, obj.x], {icon: self.icon}); - marker.bindPopup(self.getPopup(obj)); + marker.bindPopup(self.createPopup(obj)); marker.addTo(self); self.currentObjects[hash] = marker; diff --git a/server/static/js/overlays/TravelnetOverlay.js b/server/static/js/overlays/TravelnetOverlay.js index c789626..2649501 100644 --- a/server/static/js/overlays/TravelnetOverlay.js +++ b/server/static/js/overlays/TravelnetOverlay.js @@ -8,9 +8,9 @@ var TravelnetIcon = L.icon({ popupAnchor: [0, -32] }); -var TravelnetOverlay = L.AbstractIconOverlay.extend({ +var TravelnetOverlay = AbstractIconOverlay.extend({ initialize: function(wsChannel, layerMgr) { - L.AbstractIconOverlay.prototype.initialize.call(this, wsChannel, layerMgr, "travelnet", TravelnetIcon); + AbstractIconOverlay.prototype.initialize.call(this, wsChannel, layerMgr, "travelnet", TravelnetIcon); }, createPopup: function(travelnet){