mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2024-12-24 01:00:18 +01:00
Fixes small errors in handling players detection in mtwebmapper.
This commit is contained in:
parent
d242fb5cf1
commit
524fe451b1
@ -92,7 +92,7 @@ func (ps *players) readFromFIFO() ([]*player, error) {
|
|||||||
|
|
||||||
func samePlayers(a, b []*player) bool {
|
func samePlayers(a, b []*player) bool {
|
||||||
if len(a) != len(b) {
|
if len(a) != len(b) {
|
||||||
return true
|
return false
|
||||||
}
|
}
|
||||||
for i, p := range a {
|
for i, p := range a {
|
||||||
if !p.same(b[i]) {
|
if !p.same(b[i]) {
|
||||||
@ -106,15 +106,20 @@ func (ps *players) run() {
|
|||||||
for {
|
for {
|
||||||
pls, err := ps.readFromFIFO()
|
pls, err := ps.readFromFIFO()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
//log.Printf("err: %s\n", err)
|
||||||
time.Sleep(sleepInterval)
|
time.Sleep(sleepInterval)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if pls == nil {
|
if pls == nil {
|
||||||
|
//log.Println("no players")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
//log.Printf("%+q\n", pls)
|
||||||
sort.Sort(sortPlayersByName(pls))
|
sort.Sort(sortPlayersByName(pls))
|
||||||
var change bool
|
var change bool
|
||||||
ps.mu.Lock()
|
ps.mu.Lock()
|
||||||
|
//log.Printf("%+q\n", pls)
|
||||||
|
//log.Printf("%+q\n", ps.pls)
|
||||||
if change = !samePlayers(pls, ps.pls); change {
|
if change = !samePlayers(pls, ps.pls); change {
|
||||||
ps.pls = pls
|
ps.pls = pls
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ local time_interval = 1.0
|
|||||||
local fifo_path = "/tmp/mt_players_fifo"
|
local fifo_path = "/tmp/mt_players_fifo"
|
||||||
|
|
||||||
function players_data()
|
function players_data()
|
||||||
ps = {}
|
local ps = {}
|
||||||
for _, player in ipairs(minetest.get_connected_players()) do
|
for _, player in ipairs(minetest.get_connected_players()) do
|
||||||
local pos = player:getpos()
|
local pos = player:getpos()
|
||||||
local pname = player:get_player_name()
|
local pname = player:get_player_name()
|
||||||
|
Loading…
Reference in New Issue
Block a user