private static int HandleIW4Stats(byte[] data, byte[] fileData, out string backupName) { var newData = new StructuredData("data/playerdata.xml"); newData.SetData(data); backupName = null; if (true) { // TODO: more extensive checks than just experience var oldData = new StructuredData("data/playerdata.xml"); oldData.SetData(fileData); var oldExperience = oldData.Get("experience").Get <int>(); var newExperience = newData.Get("experience").Get <int>(); var difference = newExperience - oldExperience; if (difference > 200000) { //return 1; } var oldPrestige = oldData.Get("prestige").Get <int>(); var newPrestige = newData.Get("prestige").Get <int>(); difference = newPrestige - oldPrestige; if (newPrestige > 10) { return(1); } //backupName = string.Format("{2}/iw4_{0}_{1}.stat", newPrestige, DateTime.UtcNow.ToString("yyyyMMdd"), Path.GetDirectoryName(fileName)); } var has10th = newData.Get("iconUnlocked.cardicon_prestige10_02").Get <bool>(); if (has10th) { return(1); } return(0); }
public void Start() { try { Server = MongoServer.Create("mongodb://localhost"); var credentials = new MongoCredentials("alterops", "tsd8hdASD"); ADatabase = Server.GetDatabase("alterops", credentials); Data = new StructuredData("data/matchdata_iw5.xml"); Data.IW5 = true; _thread = new Thread(Run); _thread.Start(); } catch (Exception ex) { Log.Error(ex.ToString()); } }
public ProfileData() { _requestQueue = new Queue <UpdateRequest>(); _event = new ManualResetEvent(false); _structuredData = new StructuredData("data/playerdata.xml"); }
private static int HandleIW5Stats(byte[] data, byte[] fileData, out string backupName) { var newData = new StructuredData("data/playerdata_iw5.xml"); newData.SetData(data); backupName = null; if (true) { // TODO: more extensive checks than just experience var oldData = new StructuredData("data/playerdata_iw5.xml"); oldData.SetData(fileData); var oldExperience = oldData.Get("experience").Get <int>(); var newExperience = newData.Get("experience").Get <int>(); var difference = newExperience - oldExperience; if (difference > 200000) { return(1); } var oldPrestige = oldData.Get("prestige").Get <int>(); var newPrestige = newData.Get("prestige").Get <int>(); difference = newPrestige - oldPrestige; if (difference > 1 || newPrestige > 20) { return(1); } if (difference == 1 && oldExperience < 1695700) { return(1); } //backupName = string.Format("{2}/mpdata_{0}_{1}", newPrestige, DateTime.UtcNow.ToString("yyyyMMdd"), Path.GetDirectoryName(fileName)); } var element = newData.Trace(new[] { "extraCustomClassesEntitlement" }); data[element.Offset + 4] = 10; new[] { "weaponXPMultiplier", "xpMultiplier" }.ToList().ForEach(key => { for (int i = 0; i < 1; i++) { var el = newData.Trace(new[] { key, i.ToString() }); Array.Copy(BitConverter.GetBytes(4), 0, data, el.Offset + 4, 4); el = newData.Trace(new[] { key + "TimePlayed", i.ToString() }); Array.Copy(BitConverter.GetBytes(0), 0, data, el.Offset + 4, 4); el = newData.Trace(new[] { key.Replace("Multiplier", "MaxMultiplier") + "TimePlayed", i.ToString() }); Array.Copy(BitConverter.GetBytes(int.MaxValue), 0, data, el.Offset + 4, 4); } }); element = newData.Trace(new[] { "challengeXPMultiplier", "0" }); Array.Copy(BitConverter.GetBytes(1), 0, data, element.Offset + 4, 4); element = newData.Trace(new[] { "xpMultiplier", "1" }); Array.Copy(BitConverter.GetBytes(0), 0, data, element.Offset + 4, 4); element = newData.Trace(new[] { "xpMultiplier", "2" }); Array.Copy(BitConverter.GetBytes(0), 0, data, element.Offset + 4, 4); //element = newData.Trace(new[] { "experience" }); //Array.Copy(BitConverter.GetBytes(1000000), 0, data, element.Offset + 4, 4); var checksumBytes = new byte[data.Length - 4]; Array.Copy(data, 4, checksumBytes, 0, checksumBytes.Length); var checksum = Crc32.Compute(checksumBytes); Array.Copy(BitConverter.GetBytes(checksum), 0, data, 0, 4); return(0); }