forked from MTSR/mapserver
trains in bridge
This commit is contained in:
parent
dabc52fbe8
commit
118762b19d
@ -38,6 +38,9 @@ function send_stats()
|
||||
{"id":"243215","pos_in_train":2.5,"train_id":"973462","type":"advtrains:engine_japan"}
|
||||
]}
|
||||
|
||||
{"max_lag":0.38148100000000001,"players":[{"breath":11,"hp":20,"name":"BuckarooBanzai","pos":{"x":-114.66400146484375,"y":3.5,"z":-66.122001647949219},"velocity":{"x":0,"y":0,"z":0}}],"time":18530.00020980835,"trains":[{"id":"261557","off_track":true,"pos":{"x":-125,"y":5,"z":-56},"velocity":0,"wagons":[{"id":"423954","pos_in_train":6,"type":"advtrains:subway_wagon"},{"id":"635309","pos_in_train":10,"type":"advtrains:subway_wagon"},{"id":"253216","pos_in_train":2,"type":"advtrains:subway_wagon"}]},{"id":"690096","off_track":false,"pos":{"x":-125,"y":6,"z":-46},"velocity":0,"wagons":[{"id":"980189","pos_in_train":2,"type":"advtrains:subway_wagon"}]}],"uptime":235.100003503263}
|
||||
|
||||
|
||||
--]]
|
||||
|
||||
if has_advtrains then
|
||||
@ -45,6 +48,7 @@ function send_stats()
|
||||
|
||||
data.trains = {}
|
||||
for _, train in pairs(advtrains.trains) do
|
||||
print(dump(train))--XXX
|
||||
|
||||
local t = {
|
||||
pos = train.last_pos,
|
||||
|
11
server/web/logger.go
Normal file
11
server/web/logger.go
Normal file
@ -0,0 +1,11 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
var log *logrus.Entry
|
||||
|
||||
func init() {
|
||||
log = logrus.WithFields(logrus.Fields{"prefix": "mapobjectdb"})
|
||||
}
|
@ -4,6 +4,8 @@ import (
|
||||
"encoding/json"
|
||||
"mapserver/app"
|
||||
"net/http"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
type GenericPos struct {
|
||||
@ -13,17 +15,17 @@ type GenericPos struct {
|
||||
}
|
||||
|
||||
type Wagon struct {
|
||||
Id int `json:"id"`
|
||||
PosInTrain int `json:"pos_in_train"`
|
||||
Type string `json:"type"`
|
||||
Id string `json:"id"`
|
||||
PosInTrain float64 `json:"pos_in_train"`
|
||||
Type string `json:"type"`
|
||||
}
|
||||
|
||||
type Train struct {
|
||||
Pos GenericPos `json:"pos"`
|
||||
Id int `json:"id"`
|
||||
Id string `json:"id"`
|
||||
Wagons []*Wagon `json:"wagons"`
|
||||
OffTrack bool `json:"off_track"`
|
||||
Velocity int `json:"velocity"`
|
||||
Velocity float64 `json:"velocity"`
|
||||
}
|
||||
|
||||
type Player struct {
|
||||
@ -62,6 +64,8 @@ func (this *Minetest) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
|
||||
if err != nil {
|
||||
resp.WriteHeader(500)
|
||||
resp.Write([]byte(err.Error()))
|
||||
log.WithFields(logrus.Fields{"error": err}).Error("Json unmarshal")
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user