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

◆ InternalSavePlayerFile()

static void Terraria.Player.InternalSavePlayerFile ( PlayerFileData playerFile)
inlinestaticprivate

Definition at line 55383 of file Player.cs.

55384 {
55385 if (playerFile.ServerSideCharacter)
55386 {
55387 return;
55388 }
55389 string path = playerFile.Path;
55390 Player player = playerFile.Player;
55391 bool isCloudSave = playerFile.IsCloudSave;
55392 if (string.IsNullOrEmpty(path))
55393 {
55394 return;
55395 }
55397 using Stream stream = new MemoryStream(2000);
55399 using BinaryWriter binaryWriter = new BinaryWriter(cryptoStream);
55401 binaryWriter.Write(279);
55402 playerFile.Metadata.Write(binaryWriter);
55404 binaryWriter.Flush();
55405 cryptoStream.FlushFinalBlock();
55406 stream.Flush();
55407 byte[] bytes = ((MemoryStream)stream).ToArray();
55409 TagCompound tag = PlayerIO.SaveData(player);
55411 if (FileUtilities.Exists(path, isCloudSave))
55412 {
55413 FileUtilities.Copy(path, path + ".bak", isCloudSave);
55414 }
55416 PlayerIO.Save(tag, path, isCloudSave);
55417 }
static void ArchivePlayer(string path, bool isCloudSave)
Definition BackupIO.cs:53
Responsible for archiving player backups.
Definition BackupIO.cs:48
static TagCompound SaveData(Player player)
Definition PlayerIO.cs:38
static void Save(TagCompound tag, string path, bool isCloudSave)
Definition PlayerIO.cs:28
Tag compounds contained named values, serialisable as per the NBT spec: NBT spec wiki page All primi...
static void PreSavePlayer(Player player)
static void PostSavePlayer(Player player)
This is where all ModPlayer hooks are gathered and called.
static byte[] ENCRYPTION_KEY
Definition Player.cs:987
static void Serialize(PlayerFileData playerFile, Player newPlayer, BinaryWriter fileIO)
Definition Player.cs:55419
static bool Exists(string path, bool cloud)
static void Copy(string source, string destination, bool cloud, bool overwrite=true)
static void WriteAllBytes(string path, byte[] data, bool cloud)

References Terraria.ModLoader.BackupIO.Player.ArchivePlayer(), Terraria.Utilities.FileUtilities.Copy(), Terraria.Player.ENCRYPTION_KEY, Terraria.Utilities.FileUtilities.Exists(), Terraria.ModLoader.PlayerLoader.PostSavePlayer(), Terraria.ModLoader.PlayerLoader.PreSavePlayer(), Terraria.ModLoader.IO.PlayerIO.Save(), Terraria.ModLoader.IO.PlayerIO.SaveData(), Terraria.Player.Serialize(), and Terraria.Utilities.FileUtilities.WriteAllBytes().

Referenced by Terraria.Player.SavePlayer().

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