void ReadPlayerInfoFile(string playerFile)
        {
            if (!File.Exists(playerFile))
            {
                throw new FileNotFoundException("Player info file not found!");
            }

            if (transferPath != null)
            {
                throw new NotSupportedException("Session already has a transfer path!");
            }

            string str;

            using (FileStream fs = new FileStream(playerFile, FileMode.Open, FileAccess.Read))
                using (WatcherStream ws = new WatcherStream(fs))
                {
                    ws.Read(out str);
                    ws.Read(out installation);

                    ws.Read(out playerFactionIndex);
                }

            this.name         = Path.GetFileName(str);
            this.transferPath = Path.GetDirectoryName(str);
        }
        void ReadFactionsFile()
        {
            freeFactionIndices.Clear();
            takenFactionIndices.Clear();

            if (File.Exists(FactionsFile))
            {
                using (WatcherStream ws = new WatcherStream(factionsFileWatcher, FileMode.Open, FileAccess.Read))
                {
                    byte count, index;

                    ws.Read(out count);
                    for (int i = 0; i < count; i++)
                    {
                        ws.Read(out index);
                        freeFactionIndices.Add(index);
                    }

                    ws.Read(out count);
                    for (int i = 0; i < count; i++)
                    {
                        ws.Read(out index);
                        takenFactionIndices.Add(index);
                    }
                }
            }

            // in case of desyncs // fixme: warning
            if (playerFactionIndex != 0)
            {
                if (freeFactionIndices.Contains(playerFactionIndex))
                {
                    playerFactionIndex = 0;
                }
                if (!takenFactionIndices.Contains(playerFactionIndex))
                {
                    takenFactionIndices.Add(playerFactionIndex);
                }
            }

            if (OnFactionsChange != null)
            {
                OnFactionsChange(this);
            }

            UpdateCurrentFaction();
        }
        void ReadGameFile()
        {
            if (File.Exists(GameFile))
            {
                CodeVersion newVersion;
                string      newMod, newCampaign;
                using (WatcherStream ws = new WatcherStream(sessionFileWatcher, FileMode.Open, FileAccess.Read))
                {
                    ws.Read(out newVersion);
                    ws.Read(out newMod);
                    ws.Read(out newCampaign);

                    ws.Read(out difficulty);
                    ws.Read(out autoSolve);
                    ws.Read(out autoManage);
                    ws.Read(out shortCampaign);
                    ws.Read(out arcadeBattles);
                    ws.Read(out noBattleTimeLimit);
                    ws.Read(out startFactionIndex);
                    ws.Read(out lastPlayedFactionIndex);
                    ws.Read(out turn);
                }

                if ((version != null && newVersion != version) ||
                    (modName != null && !string.Equals(newMod, modName, StringComparison.OrdinalIgnoreCase)) ||
                    (campaignName != null && !string.Equals(newCampaign, campaignName, StringComparison.OrdinalIgnoreCase)))    // version, mod or campaign changed
                {
                    installation = null;
                    throw new NotSupportedException("Player faction should change too!");
                }

                version      = newVersion;
                modName      = newMod;
                campaignName = newCampaign;
            }
            else
            {
                version      = null;
                installation = null;
                modName      = null;
                campaignName = null;

                difficulty             = Difficulty.Unset;
                autoSolve              = false;
                autoManage             = false;
                shortCampaign          = false;
                startFactionIndex      = 0;
                lastPlayedFactionIndex = 0;
            }

            UpdateCurrentFaction();
        }