Skip to content

Commit

Permalink
v0.1.3.2, cross version compatible
Browse files Browse the repository at this point in the history
Previous player corruption errors are fixed in this release. Your
players should load now.
  • Loading branch information
Jofairden committed Jun 15, 2017
1 parent d8f05ed commit 3207008
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 10 deletions.
63 changes: 54 additions & 9 deletions BouncyCoins.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Terraria.ModLoader;
using System;
using System.Collections.Generic;
using System.Security.Policy;
using Terraria.ModLoader.IO;

namespace BouncyCoins
Expand Down Expand Up @@ -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?
Expand Down Expand Up @@ -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<bool>("bounceEvenly");
bounceModItems = tag.Get<bool>("bounceModItems");
byCosine = tag.Get<bool>("byCosine");
bouncyItems = new List<int>(tag.GetList<int>("bouncyItems"));
amplitude = tag.Get<double>("amplitude");
ampMult = tag.Get<double>("ampMult");
speed = tag.Get<double>("speed");
bounceOffset = tag.Get<double>("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<bool>("bounceEvenly");
if (tag.ContainsKey("disallowModItems"))
bounceModItems = !tag.Get<bool>("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<bool>("bounceEvenly");
if (tag.ContainsKey("bounceModItems"))
bounceModItems = tag.Get<bool>("bounceModItems");
if (tag.ContainsKey("byCosine"))
byCosine = tag.Get<bool>("byCosine");

if (tag.ContainsKey("modVersion"))
modVersion = ConstrucModversion(tag.GetString("modVersion"));
}

if (tag.ContainsKey("bouncyItems"))
bouncyItems = new List<int>(tag.GetList<int>("bouncyItems"));
}
}
}
2 changes: 1 addition & 1 deletion build.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 4 additions & 0 deletions description.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 3207008

Please sign in to comment.