mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2024-12-23 16:50: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 {
|
||||
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
|
||||
}
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user