Exemple #1
0
        //add near end of Terraria.Player.LoadPlayer before accessory check
        internal static void Load(Player player, string path, bool isCloudSave)
        {
            path = Path.ChangeExtension(path, ".tplr");
            if (!FileUtilities.Exists(path, isCloudSave))
            {
                return;
            }

            var buf = FileUtilities.ReadAllBytes(path, isCloudSave);

            if (buf[0] != 0x1F || buf[1] != 0x8B)
            {
                LoadLegacy(player, buf);
                return;
            }

            var tag = TagIO.FromStream(new MemoryStream(buf));

            LoadInventory(player.armor, tag.GetList <TagCompound>("armor"));
            LoadInventory(player.dye, tag.GetList <TagCompound>("dye"));
            LoadInventory(player.inventory, tag.GetList <TagCompound>("inventory"));
            LoadInventory(player.miscEquips, tag.GetList <TagCompound>("miscEquips"));
            LoadInventory(player.miscDyes, tag.GetList <TagCompound>("miscDyes"));
            LoadInventory(player.bank.item, tag.GetList <TagCompound>("bank"));
            LoadInventory(player.bank2.item, tag.GetList <TagCompound>("bank2"));
            LoadInventory(player.bank3.item, tag.GetList <TagCompound>("bank3"));
            LoadHairDye(player, tag.GetString("hairDye"));
            LoadModData(player, tag.GetList <TagCompound>("modData"));
            LoadModBuffs(player, tag.GetList <TagCompound>("modBuffs"));
            LoadUsedMods(player, tag.GetList <string>("usedMods"));
        }
Exemple #2
0
        //add near end of Terraria.IO.WorldFile.loadWorld before setting failure and success
        internal static void Load(string path, bool isCloudSave)
        {
            customDataFail = null;
            path           = Path.ChangeExtension(path, ".twld");
            if (!FileUtilities.Exists(path, isCloudSave))
            {
                return;
            }

            var buf = FileUtilities.ReadAllBytes(path, isCloudSave);

            if (buf[0] != 0x1F || buf[1] != 0x8B)
            {
                LoadLegacy(buf);
                return;
            }

            var tag = TagIO.FromStream(new MemoryStream(buf));

            LoadChests(tag.GetList <TagCompound>("chests"));
            TileIO.LoadTiles(tag.GetCompound("tiles"));
            TileIO.LoadContainers(tag.GetCompound("containers"));
            LoadNPCs(tag.GetList <TagCompound>("npcs"));
            try
            {
                TileIO.LoadTileEntities(tag.GetList <TagCompound>("tileEntities"));
            }
            catch (CustomModDataException e)
            {
                customDataFail = e;
                throw;
            }
            LoadNPCKillCounts(tag.GetList <TagCompound>("killCounts"));
            LoadAnglerQuest(tag.GetCompound("anglerQuest"));
            LoadTownManager(tag.GetList <TagCompound>("townManager"));
            try
            {
                LoadModData(tag.GetList <TagCompound>("modData"));
            }
            catch (CustomModDataException e)
            {
                customDataFail = e;
                throw;
            }
        }
Exemple #3
0
        public static Item FromBase64(string base64)
        {
            MemoryStream ms = new MemoryStream(Convert.FromBase64String(base64));

            return(ItemIO.Load(TagIO.FromStream(ms, true)));
        }