diff --git a/common/game_list.go b/common/game_list.go index 6354052..230697d 100644 --- a/common/game_list.go +++ b/common/game_list.go @@ -19,6 +19,7 @@ type GameInfo struct { var ( gameList []GameInfo + readGameList = false gameListIDLookup = map[int]int{} gameListNameLookup = map[string]int{} mutex = sync.RWMutex{} @@ -47,6 +48,13 @@ func GetGameInfoByName(name string) *GameInfo { } func ReadGameList() { + mutex.Lock() + defer mutex.Unlock() + + if readGameList { + return + } + file, err := os.Open("game_list.tsv") if err != nil { panic(err) @@ -97,6 +105,8 @@ func ReadGameList() { } gameListNameLookup[entry[1]] = index } + + readGameList = true } func GetExpectedUnitCode(gameName string) byte { diff --git a/main.go b/main.go index a4eae9f..6fde69c 100644 --- a/main.go +++ b/main.go @@ -4,6 +4,7 @@ import ( "sync" "wwfc/api" "wwfc/common" + "wwfc/gamestats" "wwfc/gpcm" "wwfc/gpsp" "wwfc/logging" @@ -19,7 +20,7 @@ func main() { logging.SetLevel(*config.LogLevel) wg := &sync.WaitGroup{} - actions := []func(){nas.StartServer, gpcm.StartServer, qr2.StartServer, gpsp.StartServer, serverbrowser.StartServer, sake.StartServer, natneg.StartServer, api.StartServer} + actions := []func(){nas.StartServer, gpcm.StartServer, qr2.StartServer, gpsp.StartServer, serverbrowser.StartServer, sake.StartServer, natneg.StartServer, api.StartServer, gamestats.StartServer} wg.Add(5) for _, action := range actions { go func(ac func()) {