Exemple #1
0
        public static SubfileBuilder GetBuilder(DatController datController, Patch.Patch patch)
        {
            try
            {
                SubfileBuilder builder;
                switch (patch.ContentType)
                {
                case PatchContentType.Text:
                    builder = new TextSubfileBuilder(datController, patch);
                    break;

                case PatchContentType.Image:
                case PatchContentType.Sound:
                case PatchContentType.Font:
                case PatchContentType.Texture:
                    builder = new BinarySubfileBuilder(datController, patch);
                    break;

                default:
                    throw new ArgumentException($"тип файлов {patch.ContentType} не обрабатывается программой.");
                }

                return(builder.InitResult == -1 ? null : builder);
            }
            catch (Exception e)
            {
                Logger.Write(e.Message);
                return(null);
            }
        }
Exemple #2
0
        public async Task <bool> WriteNinjaMark()
        {
            try
            {
                if (!await ReOpen(false))
                {
                    return(false);
                }

                var fragments = DatPatches.Values.ToDictionary(patch => patch.Token, NinjaMark.ComposeMark);
                fragments.Add(Settings.Default.TurbineLauncherVersionToken, Setup.TurbineLauncherVersion);

                var id   = Settings.Default.MarkId;
                var data = TextSubfileBuilder.CustomData(id, fragments);

                IntPtr buffer = Marshal.AllocHGlobal(data.Length);
                Marshal.Copy(data, 0, buffer, data.Length);

                var purge = Dat.Purge(id);
                var put   = Dat.Put(id, buffer, 0, data.Length, 69, 69);

                Marshal.FreeHGlobal(buffer);

                #if DEBUG
                Logger.Write($"NinjaMark #{id}[{purge} | {put}]");
                #endif

                if (put != data.Length)
                {
                    Logger.Write("ошибка записи метки патчей в файл данных.");
                }

                Close();

                return(true);
            }
            catch (Exception e)
            {
                Logger.Write(e.Message);
                return(false);
            }
        }