What's new

.NET Terraria Encrypt/Decrypt

  • Thread starter Visual Studio
  • Start date
  • Views 4,931
Visual Studio

Visual Studio

The Original Shiba Inu
Odysseus' Summit Nevar gon' happen in your lifetime Programmer
Messages
2,748
Reaction score
1,488
Points
1,162
Sin$
7
If anyone plans to work on anything related to save modding I have made a version of the application that allows the loading of decrypted files, If you want it PM me.

The encryption and decryption functions for Terraria:
Code:
private static void encryptFile(string inputFile, string outputFile)
{
string s = "h3y_gUyZ";
UnicodeEncoding unicodeEncoding = new UnicodeEncoding();
byte[] bytes = unicodeEncoding.GetBytes(s);
FileStream fileStream = new FileStream(outputFile, FileMode.Create);
RijndaelManaged rijndaelManaged = new RijndaelManaged();
CryptoStream cryptoStream = new CryptoStream(fileStream, rijndaelManaged.CreateEncryptor(bytes, bytes), CryptoStreamMode.Write);
FileStream fileStream2 = new FileStream(inputFile, FileMode.Open);
int num;
while ((num = fileStream2.ReadByte()) != -1)
{
cryptoStream.WriteByte((byte)num);
}
fileStream2.Close();
cryptoStream.Close();
fileStream.Close();
}
Code:
private static bool decryptFile(string inputFile, string outputFile)
{
string s = "h3y_gUyZ";
UnicodeEncoding unicodeEncoding = new UnicodeEncoding();
byte[] bytes = unicodeEncoding.GetBytes(s);
FileStream fileStream = new FileStream(inputFile, FileMode.Open);
RijndaelManaged rijndaelManaged = new RijndaelManaged();
CryptoStream cryptoStream = new CryptoStream(fileStream, rijndaelManaged.CreateDecryptor(bytes, bytes), CryptoStreamMode.Read);
FileStream fileStream2 = new FileStream(outputFile, FileMode.Create);
try
{
int num;
while ((num = cryptoStream.ReadByte()) != -1)
{
fileStream2.WriteByte((byte)num);
}
fileStream2.Close();
cryptoStream.Close();
fileStream.Close();
}
catch
{
fileStream2.Close();
fileStream.Close();
File.Delete(outputFile);
return true;
}
return false;
}
Code:
public static void SavePlayer(Player newPlayer, string playerPath)
{
try
{
Directory.CreateDirectory(Main.PlayerPath);
}
catch
{
}
if (playerPath == null || playerPath == "")
{
return;
}
string destFileName = playerPath + ".bak";
if (File.Exists(playerPath))
{
File.Copy(playerPath, destFileName, true);
}
string text = playerPath + ".dat";
using (FileStream fileStream = new FileStream(text, FileMode.Create))
{
using (BinaryWriter binaryWriter = new BinaryWriter(fileStream))
{
binaryWriter.Write(Main.curRelease);
binaryWriter.Write(newPlayer.name);
binaryWriter.Write(newPlayer.difficulty);
binaryWriter.Write(newPlayer.hair);
binaryWriter.Write(newPlayer.male);
binaryWriter.Write(newPlayer.statLife);
binaryWriter.Write(newPlayer.statLifeMax);
binaryWriter.Write(newPlayer.statMana);
binaryWriter.Write(newPlayer.statManaMax);
binaryWriter.Write(newPlayer.hairColor.R);
binaryWriter.Write(newPlayer.hairColor.G);
binaryWriter.Write(newPlayer.hairColor.B);
binaryWriter.Write(newPlayer.skinColor.R);
binaryWriter.Write(newPlayer.skinColor.G);
binaryWriter.Write(newPlayer.skinColor.B);
binaryWriter.Write(newPlayer.eyeColor.R);
binaryWriter.Write(newPlayer.eyeColor.G);
binaryWriter.Write(newPlayer.eyeColor.B);
binaryWriter.Write(newPlayer.shirtColor.R);
binaryWriter.Write(newPlayer.shirtColor.G);
binaryWriter.Write(newPlayer.shirtColor.B);
binaryWriter.Write(newPlayer.underShirtColor.R);
binaryWriter.Write(newPlayer.underShirtColor.G);
binaryWriter.Write(newPlayer.underShirtColor.B);
binaryWriter.Write(newPlayer.pantsColor.R);
binaryWriter.Write(newPlayer.pantsColor.G);
binaryWriter.Write(newPlayer.pantsColor.B);
binaryWriter.Write(newPlayer.shoeColor.R);
binaryWriter.Write(newPlayer.shoeColor.G);
binaryWriter.Write(newPlayer.shoeColor.B);
for (int i = 0; i < 11; i++)
{
if (newPlayer.armor[i].name == null)
{
newPlayer.armor[i].name = "";
}
binaryWriter.Write(newPlayer.armor[i].netID);
binaryWriter.Write(newPlayer.armor[i].prefix);
}
for (int j = 0; j < 48; j++)
{
if (newPlayer.inventory[j].name == null)
{
newPlayer.inventory[j].name = "";
}
binaryWriter.Write(newPlayer.inventory[j].netID);
binaryWriter.Write(newPlayer.inventory[j].stack);
binaryWriter.Write(newPlayer.inventory[j].prefix);
}
for (int k = 0; k < Chest.maxItems; k++)
{
if (newPlayer.bank[k].name == null)
{
newPlayer.bank[k].name = "";
}
binaryWriter.Write(newPlayer.bank[k].netID);
binaryWriter.Write(newPlayer.bank[k].stack);
binaryWriter.Write(newPlayer.bank[k].prefix);
}
for (int l = 0; l < Chest.maxItems; l++)
{
if (newPlayer.bank2[l].name == null)
{
newPlayer.bank2[l].name = "";
}
binaryWriter.Write(newPlayer.bank2[l].netID);
binaryWriter.Write(newPlayer.bank2[l].stack);
binaryWriter.Write(newPlayer.bank2[l].prefix);
}
for (int m = 0; m < 10; m++)
{
binaryWriter.Write(newPlayer.buffType[m]);
binaryWriter.Write(newPlayer.buffTime[m]);
}
for (int n = 0; n < 200; n++)
{
if (newPlayer.spN[n] == null)
{
binaryWriter.Write(-1);
break;
}
binaryWriter.Write(newPlayer.spX[n]);
binaryWriter.Write(newPlayer.spY[n]);
binaryWriter.Write(newPlayer.spI[n]);
binaryWriter.Write(newPlayer.spN[n]);
}
binaryWriter.Write(newPlayer.hbLocked);
binaryWriter.Close();
}
}
Player.EncryptFile(text, playerPath);
File.Delete(text);
}
Code:
public static Player LoadPlayer(string playerPath)
{
bool flag = false;
if (Main.rand == null)
{
Main.rand = new Random((int)DateTime.Now.Ticks);
}
Player player = new Player();
try
{
string text = playerPath + ".dat";
flag = Player.DecryptFile(playerPath, text);
if (!flag)
{
using (FileStream fileStream = new FileStream(text, FileMode.Open))
{
using (BinaryReader binaryReader = new BinaryReader(fileStream))
{
int num = binaryReader.ReadInt32();
player.name = binaryReader.ReadString();
if (num >= 10)
{
if (num >= 17)
{
player.difficulty = binaryReader.ReadByte();
}
else
{
bool flag2 = binaryReader.ReadBoolean();
if (flag2)
{
player.difficulty = 2;
}
}
}
player.hair = binaryReader.ReadInt32();
if (num <= 17)
{
if (player.hair == 5 || player.hair == 6 || player.hair == 9 || player.hair == 11)
{
player.male = false;
}
else
{
player.male = true;
}
}
else
{
player.male = binaryReader.ReadBoolean();
}
player.statLife = binaryReader.ReadInt32();
player.statLifeMax = binaryReader.ReadInt32();
if (player.statLifeMax > 400)
{
player.statLifeMax = 400;
}
if (player.statLife > player.statLifeMax)
{
player.statLife = player.statLifeMax;
}
player.statMana = binaryReader.ReadInt32();
player.statManaMax = binaryReader.ReadInt32();
if (player.statManaMax > 200)
{
player.statManaMax = 200;
}
if (player.statMana > 400)
{
player.statMana = 400;
}
player.hairColor.R = binaryReader.ReadByte();
player.hairColor.G = binaryReader.ReadByte();
player.hairColor.B = binaryReader.ReadByte();
player.skinColor.R = binaryReader.ReadByte();
player.skinColor.G = binaryReader.ReadByte();
player.skinColor.B = binaryReader.ReadByte();
player.eyeColor.R = binaryReader.ReadByte();
player.eyeColor.G = binaryReader.ReadByte();
player.eyeColor.B = binaryReader.ReadByte();
player.shirtColor.R = binaryReader.ReadByte();
player.shirtColor.G = binaryReader.ReadByte();
player.shirtColor.B = binaryReader.ReadByte();
player.underShirtColor.R = binaryReader.ReadByte();
player.underShirtColor.G = binaryReader.ReadByte();
player.underShirtColor.B = binaryReader.ReadByte();
player.pantsColor.R = binaryReader.ReadByte();
player.pantsColor.G = binaryReader.ReadByte();
player.pantsColor.B = binaryReader.ReadByte();
player.shoeColor.R = binaryReader.ReadByte();
player.shoeColor.G = binaryReader.ReadByte();
player.shoeColor.B = binaryReader.ReadByte();
Main.player[Main.myPlayer].shirtColor = player.shirtColor;
Main.player[Main.myPlayer].pantsColor = player.pantsColor;
Main.player[Main.myPlayer].hairColor = player.hairColor;
if (num >= 38)
{
for (int i = 0; i < 11; i++)
{
player.armor[i].netDefaults(binaryReader.ReadInt32());
player.armor[i].Prefix((int)binaryReader.ReadByte());
}
for (int j = 0; j < 48; j++)
{
player.inventory[j].netDefaults(binaryReader.ReadInt32());
player.inventory[j].stack = binaryReader.ReadInt32();
player.inventory[j].Prefix((int)binaryReader.ReadByte());
}
for (int k = 0; k < Chest.maxItems; k++)
{
player.bank[k].netDefaults(binaryReader.ReadInt32());
player.bank[k].stack = binaryReader.ReadInt32();
player.bank[k].Prefix((int)binaryReader.ReadByte());
}
for (int l = 0; l < Chest.maxItems; l++)
{
player.bank2[l].netDefaults(binaryReader.ReadInt32());
player.bank2[l].stack = binaryReader.ReadInt32();
player.bank2[l].Prefix((int)binaryReader.ReadByte());
}
}
else
{
for (int m = 0; m < 8; m++)
{
player.armor[m].SetDefaults(Item.VersionName(binaryReader.ReadString(), num));
if (num >= 36)
{
player.armor[m].Prefix((int)binaryReader.ReadByte());
}
}
if (num >= 6)
{
for (int n = 8; n < 11; n++)
{
player.armor[n].SetDefaults(Item.VersionName(binaryReader.ReadString(), num));
if (num >= 36)
{
player.armor[n].Prefix((int)binaryReader.ReadByte());
}
}
}
for (int num2 = 0; num2 < 44; num2++)
{
player.inventory[num2].SetDefaults(Item.VersionName(binaryReader.ReadString(), num));
player.inventory[num2].stack = binaryReader.ReadInt32();
if (num >= 36)
{
player.inventory[num2].Prefix((int)binaryReader.ReadByte());
}
}
if (num >= 15)
{
for (int num3 = 44; num3 < 48; num3++)
{
player.inventory[num3].SetDefaults(Item.VersionName(binaryReader.ReadString(), num));
player.inventory[num3].stack = binaryReader.ReadInt32();
if (num >= 36)
{
player.inventory[num3].Prefix((int)binaryReader.ReadByte());
}
}
}
for (int num4 = 0; num4 < Chest.maxItems; num4++)
{
player.bank[num4].SetDefaults(Item.VersionName(binaryReader.ReadString(), num));
player.bank[num4].stack = binaryReader.ReadInt32();
if (num >= 36)
{
player.bank[num4].Prefix((int)binaryReader.ReadByte());
}
}
if (num >= 20)
{
for (int num5 = 0; num5 < Chest.maxItems; num5++)
{
player.bank2[num5].SetDefaults(Item.VersionName(binaryReader.ReadString(), num));
player.bank2[num5].stack = binaryReader.ReadInt32();
if (num >= 36)
{
player.bank2[num5].Prefix((int)binaryReader.ReadByte());
}
}
}
}
if (num >= 11)
{
for (int num6 = 0; num6 < 10; num6++)
{
player.buffType[num6] = binaryReader.ReadInt32();
player.buffTime[num6] = binaryReader.ReadInt32();
}
}
for (int num7 = 0; num7 < 200; num7++)
{
int num8 = binaryReader.ReadInt32();
if (num8 == -1)
{
break;
}
player.spX[num7] = num8;
player.spY[num7] = binaryReader.ReadInt32();
player.spI[num7] = binaryReader.ReadInt32();
player.spN[num7] = binaryReader.ReadString();
}
if (num >= 16)
{
player.hbLocked = binaryReader.ReadBoolean();
}
binaryReader.Close();
}
}
player.PlayerFrame();
File.Delete(text);
Player result = player;
return result;
}
}
catch
{
flag = true;
}
if (flag)
{
try
{
string text2 = playerPath + ".bak";
Player result;
if (File.Exists(text2))
{
File.Delete(playerPath);
File.Move(text2, playerPath);
result = Player.LoadPlayer(playerPath);
return result;
}
result = new Player();
return result;
}
catch
{
Player result = new Player();
return result;
}
}
return new Player();
}
Info:
  • Current Life = 0x12 (Int32)
  • Max Life = 0x16 (Int32) - Max is 400 or 190 in Hex
  • Current Mana = 0x1A (Int32)
  • Max Mana = 0x1E (Int32) - Max is 200 or C8 in Hex
 
Last edited:
Z61

Z61

Some times our saints are sinners
Retired
Programmer Forum Addict Odysseus' Summit
Messages
5,468
Reaction score
3,429
Points
1,042
Sin$
0
Nice job!
I may have to try this at some point to keep my self from sucking at loading files.
 
XBLToothPik

XBLToothPik

Contributor
Programmer Modder Frame In Gold
Messages
577
Reaction score
1,068
Points
350
Sin$
7
Cool, might help even more when the Xbox version is released; if they don't change the encryption methods or the save layout, I'm sure it will be similar though.
 
Visual Studio

Visual Studio

The Original Shiba Inu
Odysseus' Summit Nevar gon' happen in your lifetime Programmer
Messages
2,748
Reaction score
1,488
Points
1,162
Sin$
7
Cool, might help even more when the Xbox version is released; if they don't change the encryption methods or the save layout, I'm sure it will be similar though.
Well if it is an Indie game then it should be the same but if it is an arcade game then they will change it.
 
Jbro129

Jbro129

Newbie
Messages
4
Reaction score
0
Points
35
Sin$
7
If anyone plans to work on anything related to save modding I have made a version of the application that allows the loading of decrypted files, If you want it PM me.

The encryption and decryption functions for Terraria:
Code:
private static void encryptFile(string inputFile, string outputFile)
{
string s = "h3y_gUyZ";
UnicodeEncoding unicodeEncoding = new UnicodeEncoding();
byte[] bytes = unicodeEncoding.GetBytes(s);
FileStream fileStream = new FileStream(outputFile, FileMode.Create);
RijndaelManaged rijndaelManaged = new RijndaelManaged();
CryptoStream cryptoStream = new CryptoStream(fileStream, rijndaelManaged.CreateEncryptor(bytes, bytes), CryptoStreamMode.Write);
FileStream fileStream2 = new FileStream(inputFile, FileMode.Open);
int num;
while ((num = fileStream2.ReadByte()) != -1)
{
cryptoStream.WriteByte((byte)num);
}
fileStream2.Close();
cryptoStream.Close();
fileStream.Close();
}
Code:
private static bool decryptFile(string inputFile, string outputFile)
{
string s = "h3y_gUyZ";
UnicodeEncoding unicodeEncoding = new UnicodeEncoding();
byte[] bytes = unicodeEncoding.GetBytes(s);
FileStream fileStream = new FileStream(inputFile, FileMode.Open);
RijndaelManaged rijndaelManaged = new RijndaelManaged();
CryptoStream cryptoStream = new CryptoStream(fileStream, rijndaelManaged.CreateDecryptor(bytes, bytes), CryptoStreamMode.Read);
FileStream fileStream2 = new FileStream(outputFile, FileMode.Create);
try
{
int num;
while ((num = cryptoStream.ReadByte()) != -1)
{
fileStream2.WriteByte((byte)num);
}
fileStream2.Close();
cryptoStream.Close();
fileStream.Close();
}
catch
{
fileStream2.Close();
fileStream.Close();
File.Delete(outputFile);
return true;
}
return false;
}
Code:
public static void SavePlayer(Player newPlayer, string playerPath)
{
try
{
Directory.CreateDirectory(Main.PlayerPath);
}
catch
{
}
if (playerPath == null || playerPath == "")
{
return;
}
string destFileName = playerPath + ".bak";
if (File.Exists(playerPath))
{
File.Copy(playerPath, destFileName, true);
}
string text = playerPath + ".dat";
using (FileStream fileStream = new FileStream(text, FileMode.Create))
{
using (BinaryWriter binaryWriter = new BinaryWriter(fileStream))
{
binaryWriter.Write(Main.curRelease);
binaryWriter.Write(newPlayer.name);
binaryWriter.Write(newPlayer.difficulty);
binaryWriter.Write(newPlayer.hair);
binaryWriter.Write(newPlayer.male);
binaryWriter.Write(newPlayer.statLife);
binaryWriter.Write(newPlayer.statLifeMax);
binaryWriter.Write(newPlayer.statMana);
binaryWriter.Write(newPlayer.statManaMax);
binaryWriter.Write(newPlayer.hairColor.R);
binaryWriter.Write(newPlayer.hairColor.G);
binaryWriter.Write(newPlayer.hairColor.B);
binaryWriter.Write(newPlayer.skinColor.R);
binaryWriter.Write(newPlayer.skinColor.G);
binaryWriter.Write(newPlayer.skinColor.B);
binaryWriter.Write(newPlayer.eyeColor.R);
binaryWriter.Write(newPlayer.eyeColor.G);
binaryWriter.Write(newPlayer.eyeColor.B);
binaryWriter.Write(newPlayer.shirtColor.R);
binaryWriter.Write(newPlayer.shirtColor.G);
binaryWriter.Write(newPlayer.shirtColor.B);
binaryWriter.Write(newPlayer.underShirtColor.R);
binaryWriter.Write(newPlayer.underShirtColor.G);
binaryWriter.Write(newPlayer.underShirtColor.B);
binaryWriter.Write(newPlayer.pantsColor.R);
binaryWriter.Write(newPlayer.pantsColor.G);
binaryWriter.Write(newPlayer.pantsColor.B);
binaryWriter.Write(newPlayer.shoeColor.R);
binaryWriter.Write(newPlayer.shoeColor.G);
binaryWriter.Write(newPlayer.shoeColor.B);
for (int i = 0; i < 11; i++)
{
if (newPlayer.armor[i].name == null)
{
newPlayer.armor[i].name = "";
}
binaryWriter.Write(newPlayer.armor[i].netID);
binaryWriter.Write(newPlayer.armor[i].prefix);
}
for (int j = 0; j < 48; j++)
{
if (newPlayer.inventory[j].name == null)
{
newPlayer.inventory[j].name = "";
}
binaryWriter.Write(newPlayer.inventory[j].netID);
binaryWriter.Write(newPlayer.inventory[j].stack);
binaryWriter.Write(newPlayer.inventory[j].prefix);
}
for (int k = 0; k < Chest.maxItems; k++)
{
if (newPlayer.bank[k].name == null)
{
newPlayer.bank[k].name = "";
}
binaryWriter.Write(newPlayer.bank[k].netID);
binaryWriter.Write(newPlayer.bank[k].stack);
binaryWriter.Write(newPlayer.bank[k].prefix);
}
for (int l = 0; l < Chest.maxItems; l++)
{
if (newPlayer.bank2[l].name == null)
{
newPlayer.bank2[l].name = "";
}
binaryWriter.Write(newPlayer.bank2[l].netID);
binaryWriter.Write(newPlayer.bank2[l].stack);
binaryWriter.Write(newPlayer.bank2[l].prefix);
}
for (int m = 0; m < 10; m++)
{
binaryWriter.Write(newPlayer.buffType[m]);
binaryWriter.Write(newPlayer.buffTime[m]);
}
for (int n = 0; n < 200; n++)
{
if (newPlayer.spN[n] == null)
{
binaryWriter.Write(-1);
break;
}
binaryWriter.Write(newPlayer.spX[n]);
binaryWriter.Write(newPlayer.spY[n]);
binaryWriter.Write(newPlayer.spI[n]);
binaryWriter.Write(newPlayer.spN[n]);
}
binaryWriter.Write(newPlayer.hbLocked);
binaryWriter.Close();
}
}
Player.EncryptFile(text, playerPath);
File.Delete(text);
}
Code:
public static Player LoadPlayer(string playerPath)
{
bool flag = false;
if (Main.rand == null)
{
Main.rand = new Random((int)DateTime.Now.Ticks);
}
Player player = new Player();
try
{
string text = playerPath + ".dat";
flag = Player.DecryptFile(playerPath, text);
if (!flag)
{
using (FileStream fileStream = new FileStream(text, FileMode.Open))
{
using (BinaryReader binaryReader = new BinaryReader(fileStream))
{
int num = binaryReader.ReadInt32();
player.name = binaryReader.ReadString();
if (num >= 10)
{
if (num >= 17)
{
player.difficulty = binaryReader.ReadByte();
}
else
{
bool flag2 = binaryReader.ReadBoolean();
if (flag2)
{
player.difficulty = 2;
}
}
}
player.hair = binaryReader.ReadInt32();
if (num <= 17)
{
if (player.hair == 5 || player.hair == 6 || player.hair == 9 || player.hair == 11)
{
player.male = false;
}
else
{
player.male = true;
}
}
else
{
player.male = binaryReader.ReadBoolean();
}
player.statLife = binaryReader.ReadInt32();
player.statLifeMax = binaryReader.ReadInt32();
if (player.statLifeMax > 400)
{
player.statLifeMax = 400;
}
if (player.statLife > player.statLifeMax)
{
player.statLife = player.statLifeMax;
}
player.statMana = binaryReader.ReadInt32();
player.statManaMax = binaryReader.ReadInt32();
if (player.statManaMax > 200)
{
player.statManaMax = 200;
}
if (player.statMana > 400)
{
player.statMana = 400;
}
player.hairColor.R = binaryReader.ReadByte();
player.hairColor.G = binaryReader.ReadByte();
player.hairColor.B = binaryReader.ReadByte();
player.skinColor.R = binaryReader.ReadByte();
player.skinColor.G = binaryReader.ReadByte();
player.skinColor.B = binaryReader.ReadByte();
player.eyeColor.R = binaryReader.ReadByte();
player.eyeColor.G = binaryReader.ReadByte();
player.eyeColor.B = binaryReader.ReadByte();
player.shirtColor.R = binaryReader.ReadByte();
player.shirtColor.G = binaryReader.ReadByte();
player.shirtColor.B = binaryReader.ReadByte();
player.underShirtColor.R = binaryReader.ReadByte();
player.underShirtColor.G = binaryReader.ReadByte();
player.underShirtColor.B = binaryReader.ReadByte();
player.pantsColor.R = binaryReader.ReadByte();
player.pantsColor.G = binaryReader.ReadByte();
player.pantsColor.B = binaryReader.ReadByte();
player.shoeColor.R = binaryReader.ReadByte();
player.shoeColor.G = binaryReader.ReadByte();
player.shoeColor.B = binaryReader.ReadByte();
Main.player[Main.myPlayer].shirtColor = player.shirtColor;
Main.player[Main.myPlayer].pantsColor = player.pantsColor;
Main.player[Main.myPlayer].hairColor = player.hairColor;
if (num >= 38)
{
for (int i = 0; i < 11; i++)
{
player.armor[i].netDefaults(binaryReader.ReadInt32());
player.armor[i].Prefix((int)binaryReader.ReadByte());
}
for (int j = 0; j < 48; j++)
{
player.inventory[j].netDefaults(binaryReader.ReadInt32());
player.inventory[j].stack = binaryReader.ReadInt32();
player.inventory[j].Prefix((int)binaryReader.ReadByte());
}
for (int k = 0; k < Chest.maxItems; k++)
{
player.bank[k].netDefaults(binaryReader.ReadInt32());
player.bank[k].stack = binaryReader.ReadInt32();
player.bank[k].Prefix((int)binaryReader.ReadByte());
}
for (int l = 0; l < Chest.maxItems; l++)
{
player.bank2[l].netDefaults(binaryReader.ReadInt32());
player.bank2[l].stack = binaryReader.ReadInt32();
player.bank2[l].Prefix((int)binaryReader.ReadByte());
}
}
else
{
for (int m = 0; m < 8; m++)
{
player.armor[m].SetDefaults(Item.VersionName(binaryReader.ReadString(), num));
if (num >= 36)
{
player.armor[m].Prefix((int)binaryReader.ReadByte());
}
}
if (num >= 6)
{
for (int n = 8; n < 11; n++)
{
player.armor[n].SetDefaults(Item.VersionName(binaryReader.ReadString(), num));
if (num >= 36)
{
player.armor[n].Prefix((int)binaryReader.ReadByte());
}
}
}
for (int num2 = 0; num2 < 44; num2++)
{
player.inventory[num2].SetDefaults(Item.VersionName(binaryReader.ReadString(), num));
player.inventory[num2].stack = binaryReader.ReadInt32();
if (num >= 36)
{
player.inventory[num2].Prefix((int)binaryReader.ReadByte());
}
}
if (num >= 15)
{
for (int num3 = 44; num3 < 48; num3++)
{
player.inventory[num3].SetDefaults(Item.VersionName(binaryReader.ReadString(), num));
player.inventory[num3].stack = binaryReader.ReadInt32();
if (num >= 36)
{
player.inventory[num3].Prefix((int)binaryReader.ReadByte());
}
}
}
for (int num4 = 0; num4 < Chest.maxItems; num4++)
{
player.bank[num4].SetDefaults(Item.VersionName(binaryReader.ReadString(), num));
player.bank[num4].stack = binaryReader.ReadInt32();
if (num >= 36)
{
player.bank[num4].Prefix((int)binaryReader.ReadByte());
}
}
if (num >= 20)
{
for (int num5 = 0; num5 < Chest.maxItems; num5++)
{
player.bank2[num5].SetDefaults(Item.VersionName(binaryReader.ReadString(), num));
player.bank2[num5].stack = binaryReader.ReadInt32();
if (num >= 36)
{
player.bank2[num5].Prefix((int)binaryReader.ReadByte());
}
}
}
}
if (num >= 11)
{
for (int num6 = 0; num6 < 10; num6++)
{
player.buffType[num6] = binaryReader.ReadInt32();
player.buffTime[num6] = binaryReader.ReadInt32();
}
}
for (int num7 = 0; num7 < 200; num7++)
{
int num8 = binaryReader.ReadInt32();
if (num8 == -1)
{
break;
}
player.spX[num7] = num8;
player.spY[num7] = binaryReader.ReadInt32();
player.spI[num7] = binaryReader.ReadInt32();
player.spN[num7] = binaryReader.ReadString();
}
if (num >= 16)
{
player.hbLocked = binaryReader.ReadBoolean();
}
binaryReader.Close();
}
}
player.PlayerFrame();
File.Delete(text);
Player result = player;
return result;
}
}
catch
{
flag = true;
}
if (flag)
{
try
{
string text2 = playerPath + ".bak";
Player result;
if (File.Exists(text2))
{
File.Delete(playerPath);
File.Move(text2, playerPath);
result = Player.LoadPlayer(playerPath);
return result;
}
result = new Player();
return result;
}
catch
{
Player result = new Player();
return result;
}
}
return new Player();
}
Info:
  • Current Life = 0x12 (Int32)
  • Max Life = 0x16 (Int32) - Max is 400 or 190 in Hex
  • Current Mana = 0x1A (Int32)
  • Max Mana = 0x1E (Int32) - Max is 200 or C8 in Hex
Do you still have the tool? If so can you please send it to me? :smile:
 
M

mimossss

Newbie
Messages
1
Reaction score
0
Points
10
Sin$
0
hello,I have used your decryption code,but it does not work. Is your code open source? if so, can you please send it to me? my Terraira version is 1.3(pc)
 
Top Bottom
Login
Register