diff --git a/BouncyCoins.cs b/BouncyCoins.cs index be9eebf..b7cf661 100644 --- a/BouncyCoins.cs +++ b/BouncyCoins.cs @@ -6,6 +6,7 @@ using Terraria.ModLoader; using System; using System.Collections.Generic; +using System.Security.Policy; using Terraria.ModLoader.IO; namespace BouncyCoins @@ -281,6 +282,19 @@ public bool RemoveBouncyItem(int type) return keyFrameActions.Remove(type) && b; } + internal Version modVersion = new Version(0, 1, 3, 2); + + internal string DeconstructModversion(Version v) + => $"{v.Major}.{v.Minor}.{v.Build}.{v.Revision}"; + + internal Version ConstrucModversion(string v) + { + if (v.Length < 4) + throw new Exception("Version length was invalid."); + + return new Version(v); + } + internal bool bounceEvenly; // bounce evenly? internal bool bounceModItems; // do not bounce moditems? internal bool byCosine; // bounce by cosine? @@ -315,20 +329,51 @@ public override TagCompound Save() ["amplitude"] = amplitude, ["ampMult"] = ampMult, ["speed"] = speed, - ["bounceOffset"] = bounceOffset + ["bounceOffset"] = bounceOffset, + ["modVersion"] = DeconstructModversion(modVersion), }; } public override void Load(TagCompound tag) { - bounceEvenly = tag.Get("bounceEvenly"); - bounceModItems = tag.Get("bounceModItems"); - byCosine = tag.Get("byCosine"); - bouncyItems = new List(tag.GetList("bouncyItems")); - amplitude = tag.Get("amplitude"); - ampMult = tag.Get("ampMult"); - speed = tag.Get("speed"); - bounceOffset = tag.Get("bounceOffset"); + // cross compat. from 0.1.3 + if (tag.Any(x => x.Value is float)) + { + if (tag.ContainsKey("amplitude")) + amplitude = (double)tag.GetAsShort("amplitude"); + if (tag.ContainsKey("speed")) + speed = (double)tag.GetAsShort("speed"); + if (tag.ContainsKey("universalOffset")) + bounceOffset = (double)tag.GetAsShort("universalOffset"); + if (tag.ContainsKey("bounceEvenly")) + bounceEvenly = tag.Get("bounceEvenly"); + if (tag.ContainsKey("disallowModItems")) + bounceModItems = !tag.Get("disallowModItems"); + } + else + { + if (tag.ContainsKey("amplitude")) + amplitude = tag.GetAsDouble("amplitude"); + if (tag.ContainsKey("ampMult")) + ampMult = tag.GetAsDouble("ampMult"); + if (tag.ContainsKey("speed")) + speed = tag.GetAsDouble("speed"); + if (tag.ContainsKey("bounceOffset")) + bounceOffset = tag.GetAsDouble("bounceOffset"); + + if (tag.ContainsKey("bounceEvenly")) + bounceEvenly = tag.Get("bounceEvenly"); + if (tag.ContainsKey("bounceModItems")) + bounceModItems = tag.Get("bounceModItems"); + if (tag.ContainsKey("byCosine")) + byCosine = tag.Get("byCosine"); + + if (tag.ContainsKey("modVersion")) + modVersion = ConstrucModversion(tag.GetString("modVersion")); + } + + if (tag.ContainsKey("bouncyItems")) + bouncyItems = new List(tag.GetList("bouncyItems")); } } } diff --git a/build.txt b/build.txt index c9b4ecd..0a77958 100644 --- a/build.txt +++ b/build.txt @@ -1,5 +1,5 @@ author = Jofairden -version = 0.1.3.1 +version = 0.1.3.2 displayName = Bouncy Coins buildIgnore = *.csproj, *.user, obj\*, bin\*, .vs\*, *.sln, *.psd, \*.psd, *\*.psd, resources\*, modrelease\*, *.git, *.gitignore, *.git*, .travis.yml includePDB = true diff --git a/description.txt b/description.txt index df43de4..fb09e4e 100644 --- a/description.txt +++ b/description.txt @@ -2,6 +2,10 @@ Makes coins bounce, because it looks fancy. <3 The settings are now also configurable, if you use Flash Kirby's Mod Settings Configurator mod. This mod REQUIRES tModLoader v0.8.3.5 or higher! +v0.1.3.2: + * Fixed mod corrupting player save data + * Fixed some spelling errors in config + v0.1.3.1: * Updated bounceSpeed to work with units of a thousand, way easier to control now