示例#1
0
        /// <summary>
        /// Exports all teams from the PES database and creates clubs and teams.
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public async Task <List <Club> > ReadClubsAsync(string path)
        {
            MemoryStream memory = await this.CreateMemoryStreamAsync(path + teamsPath);

            var reader = new BinaryReader(memory);

            int index;
            int length = Convert.ToInt32(reader.BaseStream.Length / teamsBlock);

            //reader.BaseStream.Position = 0;
            //string one = System.Text.Encoding.UTF8.GetString(reader.ReadBytes(teamsBlock));

            List <PESTeam> tempList = new List <PESTeam>();

            for (int i = 0; i < length; i++)
            {
                index = (i * teamsBlock);
                reader.BaseStream.Position = index;

                // Read the 11 4-Byte uint values which contain all the player data.
                uint coach     = reader.ReadUInt32();
                uint feeder    = reader.ReadUInt32();
                uint idXparent = reader.ReadUInt32();
                uint temp      = reader.ReadUInt32();
                uint stadium16 = reader.ReadUInt16();
                uint temp2     = reader.ReadUInt16();

                uint checks = reader.ReadUInt32();


                reader.BaseStream.Position = index + 24;
                string japName = System.Text.Encoding.UTF8.GetString(reader.ReadBytes(45)).TrimEnd('\0');

                reader.BaseStream.Position = index + 94;
                string spanish = System.Text.Encoding.UTF8.GetString(reader.ReadBytes(45)).TrimEnd('\0');

                reader.BaseStream.Position = index + 234;
                string english = System.Text.Encoding.UTF8.GetString(reader.ReadBytes(45)).TrimEnd('\0');

                PESTeam team = new PESTeam()
                {
                    ManagerId    = coach,
                    Id           = idXparent,
                    StadiumId    = stadium16,
                    FeederTeamId = feeder,
                    Name         = english,
                    National     = (uint)(idXparent < 100 ? 1 : 0), // ToDo: (checks << 7) >> 26,
                    CountryId    = (checks << 23) >> 23
                };

                tempList.Add(team);
            }

            return(await ClubConverter.ConvertMany(tempList));
        }
示例#2
0
        public static Dictionary <int, Club> GetDataFileClubDictionary(SaveGameFile savegame)
        {
            Dictionary <int, Club> dic = new Dictionary <int, Club>();
            var fileFacts = DataFileFacts.GetDataFileFacts().First(x => x.Type == DataFileType.Clubs);
            var bytes     = GetDataFileBytes(savegame, fileFacts.Type, fileFacts.DataSize);

            ClubConverter converter = new ClubConverter();

            foreach (var item in bytes)
            {
                var club = converter.Convert(item);

                if (club.ClubId != -1)
                {
                    if (!dic.ContainsKey(club.ClubId))
                    {
                        dic.Add(club.ClubId, club);
                    }
                }
            }

            return(dic);
        }