From 8bd11d24945211f3773ea83d11c8420886d6564b Mon Sep 17 00:00:00 2001 From: Vladimir Hodakov Date: Sat, 17 Feb 2018 17:27:30 +0400 Subject: [PATCH] Fixed typo and added more debug to squads DataCache --- lib/datacache/squads.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/datacache/squads.go b/lib/datacache/squads.go index d2f59a9..e5db4f3 100644 --- a/lib/datacache/squads.go +++ b/lib/datacache/squads.go @@ -50,7 +50,7 @@ func (dc *DataCache) loadSquads() { for i := range squadsPlayersRelations { sPlayer := dc.players[squadsPlayersRelations[i].PlayerID] sProfile := dc.currentProfiles[squadsPlayersRelations[i].PlayerID] - sSquad := dc.squadsWithChats[squadsPlayersRelations[i].PlayerID] + sSquad := dc.squadsWithChats[squadsPlayersRelations[i].SquadID] if sPlayer != nil && sProfile != nil && sSquad != nil { dc.squadPlayersRelations[squadsPlayersRelations[i].ID] = &squadsPlayersRelations[i] @@ -61,16 +61,20 @@ func (dc *DataCache) loadSquads() { squadPlayer.UserRole = squadsPlayersRelations[i].UserType dc.squadPlayers[sSquad.Squad.ID][sPlayer.ID] = &squadPlayer + } else { + if sPlayer == nil { + c.Log.Debug("Alert: player with ID=" + strconv.Itoa(squadsPlayersRelations[i].PlayerID) + "is nil") + } + if sProfile == nil { + c.Log.Debug("Alert: player with ID=" + strconv.Itoa(squadsPlayersRelations[i].PlayerID) + "has no current profile") + } + if sSquad == nil { + c.Log.Debug("Alert: squad with ID=" + strconv.Itoa(squadsPlayersRelations[i].SquadID) + "is nil") + } } } c.Log.Info("Loaded squads in DataCache: " + strconv.Itoa(len(dc.squads))) c.Log.Info("Loaded players relations to squads in DataCache: " + strconv.Itoa(len(dc.squadPlayers))) - // More debug!!! - for i := range dc.squadPlayers { - for j := range dc.squadPlayers[i] { - c.Log.Debugln(dc.squadPlayers[i][j]) - } - } dc.squadsMutex.Unlock() }