TModLoader v1.4.4.9
TModLoader source code documentation
Loading...
Searching...
No Matches

◆ LoadPlayer()

static PlayerFileData Terraria.Player.LoadPlayer ( string playerPath,
bool cloudSave )
inlinestatic

Definition at line 55696 of file Player.cs.

55697 {
55699 if (cloudSave && SocialAPI.Cloud == null)
55700 {
55701 return playerFileData;
55702 }
55703 if (Main.rand == null)
55704 {
55705 Main.rand = new UnifiedRandom((int)DateTime.Now.Ticks);
55706 }
55707 Player player = new Player();
55708 bool gotToReadName = false;
55709 using (new Main.CurrentPlayerOverride(player))
55710 {
55711 try
55712 {
55714 rijndaelManaged.Padding = PaddingMode.None;
55715 using (MemoryStream stream = new MemoryStream(FileUtilities.ReadAllBytes(playerPath, cloudSave)))
55716 {
55718 using BinaryReader binaryReader = new BinaryReader(input);
55719 int num = binaryReader.ReadInt32();
55720 if (num >= 135)
55721 {
55722 playerFileData.Metadata = FileMetadata.Read(binaryReader, FileType.Player);
55723 }
55724 else
55725 {
55726 playerFileData.Metadata = FileMetadata.FromCurrentSettings(FileType.Player);
55727 }
55728 if (num > 279)
55729 {
55730 player.loadStatus = 1;
55731 player.name = binaryReader.ReadString();
55732 playerFileData.Player = player;
55733 return playerFileData;
55734 }
55736 }
55737 player.PlayerFrame();
55738 player.loadStatus = 0;
55739 playerFileData.Player = player;
55740 return playerFileData;
55741 }
55743 {
55744 playerFileData.customDataFail = e;
55745 }
55746 catch
55747 {
55748 }
55749 Player player2 = new Player();
55750 player2.loadStatus = 2;
55751 if (gotToReadName && player.name.Length <= nameLen)
55752 {
55753 player2.name = player.name;
55754 }
55755 else
55756 {
55757 player2.name = playerPath.Replace('/', Path.DirectorySeparatorChar).Split(Path.DirectorySeparatorChar)[^1].Split('.')[0];
55758 }
55759 playerFileData.Player = player2;
55760 return playerFileData;
55761 }
55762 }
static FileMetadata Read(BinaryReader reader, FileType expectedType)
static FileMetadata FromCurrentSettings(FileType type)
static void Deserialize(PlayerFileData data, Player newPlayer, BinaryReader fileIO, int release, out bool gotToReadName)
Definition Player.cs:55774
static byte[] ENCRYPTION_KEY
Definition Player.cs:987
static int nameLen
Definition Player.cs:1600
static Terraria.Social.Base.CloudSocialModule Cloud
Definition SocialAPI.cs:20
static byte[] ReadAllBytes(string path, bool cloud)

References Terraria.Player.Player(), Terraria.Social.SocialAPI.Cloud, Terraria.Player.Deserialize(), Terraria.Player.ENCRYPTION_KEY, Terraria.IO.FileMetadata.FromCurrentSettings(), Terraria.Player.name, Terraria.Player.nameLen, Terraria.Player.PlayerFrame(), Terraria.Main.rand, Terraria.IO.FileMetadata.Read(), and Terraria.Utilities.FileUtilities.ReadAllBytes().

Referenced by Terraria.Player.GetFileData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: