Пример #1
0
        public static CheatTableFile loadFromFile(String cheatTableFilePath)
        {
            if (serializer == null)
            {
                serializer = new XmlSerializer(typeof(CheatTableFile));
            }

            CheatTableFile cheatTable = null;

            using (StreamReader reader = new StreamReader(cheatTableFilePath))
                cheatTable = (CheatTableFile)serializer.Deserialize(reader);
            return(cheatTable);
        }
Пример #2
0
        public static CheatTableFile updateOldFormat(String oldFormatFilePath)
        {
            if (!File.Exists(oldFormatFilePath))
            {
                throw new FileNotFoundException("Cheat table file is not found!", oldFormatFilePath);
            }

            String[] lines = File.ReadAllLines(oldFormatFilePath, System.Text.Encoding.UTF8);
            String[] split = lines[0].Split('|');
            if (split[0] != "1.4")
            {
                throw new NotSupportedException($"Only PS4Cheater v1.4 cheat files are supported!\r\nThis cheat file is for v{split[0]}");
            }
            if (split[4] != "FM:505")
            {
                throw new NotSupportedException($"Only 5.05FW cheat files are supported!\r\nThis cheat file is for {split[4].Replace("FM:", "")}FW");
            }

            CheatTableFile cheatTableFile = new CheatTableFile();

            cheatTableFile.targetProcess = split[1];
            cheatTableFile.cusaId        = split[2].Replace("ID:", "");
            cheatTableFile.cusaVersion   = split[3].Replace("VER:", "");
            for (Int32 i = 1; i < lines.Length - 1; i++)
            {
                split = lines[i].Split('|');
                if (lines[0] == "data")
                {
                    ComplexCheatEntry complexCheatEntry = new ComplexCheatEntry()
                    {
                        description   = split[6],
                        sectionIndex  = Convert.ToInt32(split[1]),
                        sectionOffset = Convert.ToUInt32(split[2], 16),
                        valueType     = split[3] == "4 bytes" ? typeof(Int32) : split[3] == "float" ? typeof(Single) : throw new NotImplementedException()
                    };
                    cheatTableFile.cheatEntries.Add(complexCheatEntry);
                }
            }
            return(cheatTableFile);
        }
    }