protected override bool IsObject(AmfObject obj) { var id = obj.GetString("id"); // Save format fixup, only needed when editing older saves if (id == null && obj.Contains("perkName")) { obj["id"] = obj["perkName"]; obj["perkName"] = null; obj["perkDesc"] = null; id = obj.GetString("id"); } // Fixes saves which have NaNs for some perk values, which crashes CoC if (double.IsNaN(obj.GetDouble("value1"))) { obj["value1"] = 0; } if (double.IsNaN(obj.GetDouble("value2"))) { obj["value2"] = 0; } if (double.IsNaN(obj.GetDouble("value3"))) { obj["value3"] = 0; } if (double.IsNaN(obj.GetDouble("value4"))) { obj["value4"] = 0; } return(id == _xml.Name); }
public static void fixup(AmfObject obj) { PerkVM.initialize(obj, false); // Fixes saves which have NaNs for some perk values if (double.IsNaN(obj.GetDouble("value1"))) { obj["value1"] = 0; } if (double.IsNaN(obj.GetDouble("value2"))) { obj["value2"] = 0; } if (double.IsNaN(obj.GetDouble("value3"))) { obj["value3"] = 0; } if (double.IsNaN(obj.GetDouble("value4"))) { obj["value4"] = 0; } }
public double GetDouble(object key) { return(_obj.GetDouble(key)); }
public double GetDouble(object key, double?defaultValue = 0) { return(_obj.GetDouble(key, defaultValue)); }
protected override bool IsObject(AmfObject obj) { var id = obj.GetString("id"); // Save format fixup, only needed when editing older saves if (id == null && obj.Contains("perkName")) { obj["id"] = obj["perkName"]; obj["perkName"] = null; obj["perkDesc"] = null; id = obj.GetString("id"); } // Fixes saves which have NaNs for some perk values, which crashes CoC if (double.IsNaN(obj.GetDouble("value1"))) obj["value1"] = 0; if (double.IsNaN(obj.GetDouble("value2"))) obj["value2"] = 0; if (double.IsNaN(obj.GetDouble("value3"))) obj["value3"] = 0; if (double.IsNaN(obj.GetDouble("value4"))) obj["value4"] = 0; return id == _xml.Name; }