Exemplo n.º 1
0
        // sub_47DFC
        internal static void SavePlayer(string arg_0, Player player)
        {
            char input_key;
            Classes.File file = new Classes.File();

            gbl.import_from = ImportSource.Curse;

            string ext_text;
            string file_text;

            if (arg_0 == "")
            {
                ext_text = ".guy";
                file_text = seg042.clean_string(player.name);
            }
            else
            {
                ext_text = ".sav";
                file_text = arg_0;
            }

            input_key = 'N';

            while (input_key == 'N' &&
                arg_0.Length == 0 &&
                seg042.file_find(Path.Combine(Config.GetSavePath(), file_text) + ext_text) == true)
            {
                input_key = ovr027.yes_no(gbl.alertMenuColors, "Overwrite " + file_text + "? ");

                if (input_key == 'N')
                {
                    file_text = string.Empty;

                    while (file_text == string.Empty)
                    {
                        file_text = seg041.getUserInputString(8, 0, 10, "New file name: ");
                    }
                }
            }

            string filePath = Path.Combine(Config.GetSavePath(), file_text);

            file.Assign(filePath + ext_text);

            seg051.Rewrite(file);

            seg051.BlockWrite(Player.StructSize, player.ToByteArray(), file);
            seg051.Close(file);

            seg042.delete_file(filePath + ".swg");

            if (player.items.Count > 0)
            {
                file.Assign(filePath + ".swg");
                seg051.Rewrite(file);

                player.items.ForEach(item => seg051.BlockWrite(Item.StructSize, item.ToByteArray(), file));

                seg051.Close(file);
            }

            seg042.delete_file(filePath + ".fx");

            if (player.affects.Count > 0)
            {
                file.Assign(filePath + ".fx");
                seg051.Rewrite(file);

                foreach (Affect affect in player.affects)
                {
                    seg051.BlockWrite(Affect.StructSize, affect.ToByteArray(), file);
                }

                seg051.Close(file);
            }
        }