Example #1
0
            public static AiInfo ReadFrom(PrimitiveReader reader)
            {
                AiInfo info = new AiInfo();

                info.Unknown = reader.ReadUInt16();
                ushort stringsCount = reader.ReadUInt16();

                System.Diagnostics.Debugger.Break();
                info.Unknown2 = reader.ReadUInt32();
                List <string> resources = new List <string>(stringsCount);

                for (int i = 0; i < stringsCount; i++)
                {
                    resources.Add(Utils.ReadUInt32LengthPrefixedString(reader));
                }
                info.Resources = resources;
                info.Unknown3  = reader.ReadBytes(6);
                AiData[] data = new AiData[8];
                for (int i = 0; i < data.Length; i++)
                {
                    data[i] = AiData.ReadFrom(reader);
                }
                info.Data = data;

                info.Unknown4 = reader.ReadBytes(104);
                AiTimer[] timers = new AiTimer[8];
                for (int i = 0; i < timers.Length; i++)
                {
                    timers[i] = AiTimer.ReadFrom(reader);
                }
                info.Timers      = timers;
                info.SharedGoals = reader.ReadUInt32Array(256);
                info.Unknown5    = reader.ReadUInt32Array(1024);
                return(info);
            }
Example #2
0
            public static AiTimer ReadFrom(PrimitiveReader reader)
            {
                AiTimer timer = new AiTimer();

                timer.Timers = reader.ReadUInt32Array(10);
                return(timer);
            }
Example #3
0
        public void ReadData(string path)
        {
            PrimitiveReader reader = new PrimitiveReader(path);
            SaveGameFile    file   = new SaveGameFile();

            file.Version  = reader.ReadASCIIString(8);
            file.Unknown1 = reader.ReadFloat32();

            bool aiDataIncluded = reader.ReadUInt32() != 0;

            if (aiDataIncluded)
            {
                file.AiInfo2 = AiInfo.ReadFrom(reader);
            }
            file.Unknown2   = reader.ReadUInt32();
            file.GameSpeed1 = reader.ReadUInt32();
            file.Unknown3   = reader.ReadUInt32();
            file.GameSpeed2 = reader.ReadUInt32();
            file.Unknown4   = reader.ReadFloat32();
            file.Unknown5   = reader.ReadUInt32();
            file.Unknown6   = reader.ReadBytes(17);
            file.RecordedGamePlayerNumber = reader.ReadUInt16();
            //System.Diagnostics.Debugger.Break();
            file.PlayersCount = reader.ReadUInt8();
            file.Unknown7     = reader.ReadUInt32();
            file.Unknown8     = reader.ReadBytes(12);
            file.Unknown9     = reader.ReadBytes(14);
            file.Unknown10    = reader.ReadUInt32Array(8);

            //System.Diagnostics.Debugger.Break();

            reader.SeekAbsolute(126);
            int mapWidth  = reader.ReadInt32();
            int mapLength = reader.ReadInt32();

            uint unknownDataCount = reader.ReadUInt32();

            ushort unknown2 = reader.ReadUInt16();

            SaveGameMap map = SaveGameMap.ReadFrom(reader, mapWidth, mapLength);


            /*int unknownIntsArrayCount = reader.ReadInt32();
             * uint[][] unknowns = new uint[unknownIntsArrayCount][];
             * for( int i = 0; i < unknowns.Length; i++ ) {
             *      int intsCount = reader.ReadInt32() - 1;
             *      if( intsCount < 0 ) throw new Exception();
             *      unknowns[i] = reader.ReadUInt32Array( intsCount );
             * }*/
            reader.SeekAbsolute(29132);

            int mapWidth2  = reader.ReadInt32();
            int mapLength2 = reader.ReadInt32();

            uint[] unknownMap2 = reader.ReadUInt32Array(mapWidth2 * mapLength2);

            //byte unknownIntsCount1 = reader.ReadUInt8();
            //uint[] unknownInts = reader.ReadUInt32Array( unknownIntsCount1 );

            reader.SeekAbsolute(88779);
            SavePlayerInfo f = SavePlayerInfo.ReadFrom(reader, 2);

            System.Diagnostics.Debugger.Break();
        }
Example #4
0
            public static SavePlayerInfo ReadFrom(PrimitiveReader reader, int pCount)
            {
                SavePlayerInfo p = new SavePlayerInfo();

                byte[] diplomacyFrom = reader.ReadBytes(pCount);
                uint[] diplomacyTo   = reader.ReadUInt32Array(9);
                uint   unknown1      = reader.ReadUInt32();
                byte   unknown2      = reader.ReadUInt8();
                string name          = Utils.ReadUInt16LengthPrefixedString(reader);
                byte   unknown3      = reader.ReadUInt8();
                int    floatsCount   = reader.ReadInt32();
                byte   unknown4      = reader.ReadUInt8();

                float[]   civHeader = reader.ReadFloat32Array(floatsCount);
                FloatTest t         = new FloatTest(civHeader);

                byte unknown5 = reader.ReadUInt8();

                float[] unknown6     = reader.ReadFloat32Array(2);
                byte[]  unknown7     = reader.ReadBytes(9);
                byte    civilization = reader.ReadUInt8();

                byte[] unknown8 = reader.ReadBytes(3);

                byte colour = reader.ReadUInt8();

                byte[] unknown9  = reader.ReadBytes(4183);
                float  unknown10 = reader.ReadFloat32();

                int    researchCount = reader.ReadInt32();
                ushort unknown11     = reader.ReadUInt16();

                ResearchStat[] stats = new ResearchStat[researchCount];
                for (int i = 0; i < stats.Length; i++)
                {
                    stats[i] = ResearchStat.ReadFrom(reader);
                }

                Console.WriteLine("LAST KNOWN POS:" + reader.Position);


                reader.SeekAbsolute(128358);

                int masterObjectsCount = reader.ReadInt32();

                bool[] objectExistsFlags = new bool[masterObjectsCount];
                for (int i = 0; i < objectExistsFlags.Length; i++)
                {
                    objectExistsFlags[i] = reader.ReadUInt32() != 0;
                }
                //System.Diagnostics.Debugger.Break();
                ushort unknownObjects = reader.ReadUInt16();

                Console.WriteLine("BEGIN READ OBJECTS.." + reader.Position);

                MasterObject[] masterObjects = new MasterObject[masterObjectsCount];
                for (int i = 0; i < masterObjects.Length; i++)
                {
                    if (objectExistsFlags[i])
                    {
                        masterObjects[i] = MasterObject.ReadFrom(reader, i);
                    }
                }

                System.Diagnostics.Debugger.Break();
                return(p);
            }