Skip to content

Commit

Permalink
Bump world version to remove some bug workarounds
Browse files Browse the repository at this point in the history
  • Loading branch information
Kawa-oneechan committed Mar 24, 2021
1 parent 747daf7 commit fec1bb1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 49 deletions.
28 changes: 0 additions & 28 deletions Character.cs
Original file line number Diff line number Diff line change
Expand Up @@ -787,34 +787,6 @@ public static Character LoadFromFile(BinaryReader stream)
newChar.Tokens.Add(Token.LoadFromFile(stream));
newChar.UpdateTitle();

//Fix the results of a bug that caused multiple a, ispropernamed, and culture tokens to appear, namely the above-commented.
//TODO: bump world version, remove that shit.
var a = false;
var p = false;
var c = false;
foreach (var token in newChar.Tokens)
{
if (token.Name == "a")
{
if (a)
token.Name = "__kill";
a = true;
}
else if (token.Name == "ispropernamed")
{
if (p)
token.Name = "__kill";
p = true;
}
else if (token.Name == "culture")
{
if (c)
token.Name = "__kill";
c = true;
}
}
newChar.Tokens.RemoveAll(t => t.Name == "__kill");

return newChar;
}

Expand Down
23 changes: 2 additions & 21 deletions Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ public void SaveGame(bool noPlayer = false, bool force = false, bool clear = tru
CurrentBoard.SaveToFile(CurrentBoard.BoardNum);

var verCheck = Path.Combine(SavePath, WorldName, "version");
File.WriteAllText(verCheck, "20");
File.WriteAllText(verCheck, "21");
Program.WriteLine("Done.");
Program.WriteLine("--------------------------");
}
Expand All @@ -572,7 +572,7 @@ public void LoadGame()
if (!File.Exists(verCheck))
throw new Exception("Tried to open an old worldsave.");
WorldVersion = int.Parse(File.ReadAllText(verCheck));
if (WorldVersion < 20)
if (WorldVersion < 21)
throw new Exception("Tried to open an old worldsave.");

HostForm.Clear();
Expand Down Expand Up @@ -604,25 +604,6 @@ public void LoadGame()
var currentIndex = bin.ReadInt32();
var boardCount = bin.ReadInt32();

//TODO: remove entirely after bumping version #
var poti = bin.ReadChars(4);
if (new string(poti) == "POTI")
{
Program.WriteLine("Ignoring POTI data...");
for (var i = 0; i < 256; i++)
bin.ReadString();
}
else
{
bin.BaseStream.Seek(-4, SeekOrigin.Current);
}
/*
Toolkit.ExpectFromFile(bin, "POTI", "potion and ring");
Potions = new string[256];
for (var i = 0; i < 256; i++)
Potions[i] = bin.ReadString();
*/

Toolkit.ExpectFromFile(bin, "ITID", "item identification");
var numIDs = bin.ReadInt32();
Identifications.Clear();
Expand Down

0 comments on commit fec1bb1

Please sign in to comment.