Fixes small errors in handling players detection in mtwebmapper.

This commit is contained in:
Sascha L. Teichmann 2015-03-10 12:49:10 +01:00
parent d242fb5cf1
commit 524fe451b1
2 changed files with 7 additions and 2 deletions

View File

@ -92,7 +92,7 @@ func (ps *players) readFromFIFO() ([]*player, error) {
func samePlayers(a, b []*player) bool {
if len(a) != len(b) {
return true
return false
}
for i, p := range a {
if !p.same(b[i]) {
@ -106,15 +106,20 @@ func (ps *players) run() {
for {
pls, err := ps.readFromFIFO()
if err != nil {
//log.Printf("err: %s\n", err)
time.Sleep(sleepInterval)
continue
}
if pls == nil {
//log.Println("no players")
continue
}
//log.Printf("%+q\n", pls)
sort.Sort(sortPlayersByName(pls))
var change bool
ps.mu.Lock()
//log.Printf("%+q\n", pls)
//log.Printf("%+q\n", ps.pls)
if change = !samePlayers(pls, ps.pls); change {
ps.pls = pls
}

View File

@ -2,7 +2,7 @@ local time_interval = 1.0
local fifo_path = "/tmp/mt_players_fifo"
function players_data()
ps = {}
local ps = {}
for _, player in ipairs(minetest.get_connected_players()) do
local pos = player:getpos()
local pname = player:get_player_name()