MFA Writing updates, Pame2mfa updates, start working on MMF1.5

master
1987kostya 4 years ago
parent ddff8b19a7
commit 6710b39139

@ -127,6 +127,10 @@
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="zlib.net, Version=1.0.3.0, Culture=neutral, PublicKeyToken=47d7877cb3620160">
<HintPath>..\packages\zlib.net.1.0.4.0\lib\zlib.net.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="GUI\ErrorLogBox.cs">
@ -176,7 +180,10 @@
<Compile Include="MMFParser\MFA\Loaders\mfachunks\Backdrop.cs" />
<Compile Include="MMFParser\MFA\Loaders\mfachunks\Counter.cs" />
<Compile Include="MMFParser\MFA\Loaders\mfachunks\ExtensionObject.cs" />
<Compile Include="MMFParser\MFA\Loaders\mfachunks\Lives.cs" />
<Compile Include="MMFParser\MFA\Loaders\mfachunks\Text.cs" />
<Compile Include="MMFParser\OLD\Loaders\AppHeader.cs" />
<Compile Include="MMFParser\OLD\Loaders\Controls.cs" />
<Compile Include="MMFParser\Translation\MFAGenerator.cs" />
<Compile Include="MMFParser\Translation\PAME2MFA.cs" />
<Compile Include="MMFParser\EXE\ChunkList.cs" />

@ -62,6 +62,7 @@
this.dumpPackButton = new System.Windows.Forms.Button();
this.packDataListBox = new System.Windows.Forms.ListBox();
this.objViewerTab = new System.Windows.Forms.TabPage();
this.dumpSelectedBtn = new System.Windows.Forms.Button();
this.objViewerInfo = new System.Windows.Forms.Label();
this.imageViewerPlayAnim = new System.Windows.Forms.Button();
this.imageViewPictureBox = new System.Windows.Forms.PictureBox();
@ -85,7 +86,6 @@
this.updateSettings = new System.Windows.Forms.Button();
this.colorBox = new System.Windows.Forms.TextBox();
this.packDataDialog = new System.Windows.Forms.SaveFileDialog();
this.dumpSelectedBtn = new System.Windows.Forms.Button();
this.ChunkCombo.SuspendLayout();
this.tabControl1.SuspendLayout();
this.mainTab.SuspendLayout();
@ -184,7 +184,7 @@
this.imageBar.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.imageBar.BackColor = System.Drawing.Color.Black;
this.imageBar.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0)))));
this.imageBar.Location = new System.Drawing.Point(97, 272);
this.imageBar.Location = new System.Drawing.Point(97, 326);
this.imageBar.Name = "imageBar";
this.imageBar.Size = new System.Drawing.Size(126, 24);
this.imageBar.Step = 2;
@ -199,7 +199,7 @@
this.imageLabel.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.imageLabel.Font = new System.Drawing.Font("Courier New", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204)));
this.imageLabel.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0)))));
this.imageLabel.Location = new System.Drawing.Point(229, 272);
this.imageLabel.Location = new System.Drawing.Point(229, 326);
this.imageLabel.Name = "imageLabel";
this.imageLabel.Size = new System.Drawing.Size(126, 24);
this.imageLabel.TabIndex = 9;
@ -214,7 +214,7 @@
this.soundLabel.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.soundLabel.Font = new System.Drawing.Font("Courier New", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204)));
this.soundLabel.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0)))));
this.soundLabel.Location = new System.Drawing.Point(229, 320);
this.soundLabel.Location = new System.Drawing.Point(229, 374);
this.soundLabel.Name = "soundLabel";
this.soundLabel.Size = new System.Drawing.Size(126, 24);
this.soundLabel.TabIndex = 11;
@ -227,7 +227,7 @@
this.soundBar.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.soundBar.BackColor = System.Drawing.Color.Black;
this.soundBar.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0)))));
this.soundBar.Location = new System.Drawing.Point(97, 320);
this.soundBar.Location = new System.Drawing.Point(97, 374);
this.soundBar.Name = "soundBar";
this.soundBar.Size = new System.Drawing.Size(126, 23);
this.soundBar.Step = 2;
@ -242,7 +242,7 @@
this.FolderBTN.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.FolderBTN.Font = new System.Drawing.Font("Courier New", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204)));
this.FolderBTN.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0)))));
this.FolderBTN.Location = new System.Drawing.Point(8, 214);
this.FolderBTN.Location = new System.Drawing.Point(8, 268);
this.FolderBTN.Name = "FolderBTN";
this.FolderBTN.Size = new System.Drawing.Size(83, 42);
this.FolderBTN.TabIndex = 12;
@ -258,7 +258,7 @@
this.soundsButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.soundsButton.Font = new System.Drawing.Font("Courier New", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204)));
this.soundsButton.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0)))));
this.soundsButton.Location = new System.Drawing.Point(8, 310);
this.soundsButton.Location = new System.Drawing.Point(8, 364);
this.soundsButton.Name = "soundsButton";
this.soundsButton.Size = new System.Drawing.Size(83, 42);
this.soundsButton.TabIndex = 14;
@ -274,7 +274,7 @@
this.imagesButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.imagesButton.Font = new System.Drawing.Font("Courier New", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204)));
this.imagesButton.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0)))));
this.imagesButton.Location = new System.Drawing.Point(8, 262);
this.imagesButton.Location = new System.Drawing.Point(8, 316);
this.imagesButton.Name = "imagesButton";
this.imagesButton.Size = new System.Drawing.Size(83, 42);
this.imagesButton.TabIndex = 15;
@ -326,7 +326,7 @@
this.musicsButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.musicsButton.Font = new System.Drawing.Font("Courier New", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204)));
this.musicsButton.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0)))));
this.musicsButton.Location = new System.Drawing.Point(8, 358);
this.musicsButton.Location = new System.Drawing.Point(8, 412);
this.musicsButton.Name = "musicsButton";
this.musicsButton.Size = new System.Drawing.Size(83, 42);
this.musicsButton.TabIndex = 21;
@ -340,7 +340,7 @@
this.musicBar.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.musicBar.BackColor = System.Drawing.Color.Black;
this.musicBar.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0)))));
this.musicBar.Location = new System.Drawing.Point(97, 368);
this.musicBar.Location = new System.Drawing.Point(97, 422);
this.musicBar.Name = "musicBar";
this.musicBar.Size = new System.Drawing.Size(126, 23);
this.musicBar.Step = 2;
@ -355,7 +355,7 @@
this.musicLabel.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.musicLabel.Font = new System.Drawing.Font("Courier New", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (204)));
this.musicLabel.ForeColor = System.Drawing.Color.FromArgb(((int) (((byte) (255)))), ((int) (((byte) (128)))), ((int) (((byte) (0)))));
this.musicLabel.Location = new System.Drawing.Point(229, 368);
this.musicLabel.Location = new System.Drawing.Point(229, 422);
this.musicLabel.Name = "musicLabel";
this.musicLabel.Size = new System.Drawing.Size(126, 24);
this.musicLabel.TabIndex = 23;
@ -535,6 +535,17 @@
this.objViewerTab.TabIndex = 1;
this.objViewerTab.Text = "Objects";
//
// dumpSelectedBtn
//
this.dumpSelectedBtn.Dock = System.Windows.Forms.DockStyle.Bottom;
this.dumpSelectedBtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.dumpSelectedBtn.Location = new System.Drawing.Point(201, 426);
this.dumpSelectedBtn.Name = "dumpSelectedBtn";
this.dumpSelectedBtn.Size = new System.Drawing.Size(731, 25);
this.dumpSelectedBtn.TabIndex = 4;
this.dumpSelectedBtn.Text = "Dump Selected";
this.dumpSelectedBtn.UseVisualStyleBackColor = true;
//
// objViewerInfo
//
this.objViewerInfo.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
@ -786,18 +797,6 @@
//
this.packDataDialog.FileOk += new System.ComponentModel.CancelEventHandler(this.packDataDialog_FileOk);
//
// dumpSelectedBtn
//
this.dumpSelectedBtn.Dock = System.Windows.Forms.DockStyle.Bottom;
this.dumpSelectedBtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.dumpSelectedBtn.Location = new System.Drawing.Point(201, 426);
this.dumpSelectedBtn.Name = "dumpSelectedBtn";
this.dumpSelectedBtn.Size = new System.Drawing.Size(731, 25);
this.dumpSelectedBtn.TabIndex = 4;
this.dumpSelectedBtn.Text = "Dump Selected";
this.dumpSelectedBtn.UseVisualStyleBackColor = true;
this.dumpSelectedBtn.MouseClick += dumpSelectedBtn_Click;
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);

@ -494,6 +494,8 @@ namespace CTFAK.GUI
private void dumpMFAButton_Click(object sender, EventArgs e)
{
var msg = MessageBox.Show("By using CTFAK, you agree that you will only used the decompiled MFAs for personal use and educational purposes.\nYou also agree that unless you are the original creator or have been given permission, you will not recompile any games using this tool.","Warning",MessageBoxButtons.OKCancel);
if(msg != DialogResult.OK) Environment.Exit(0);
var worker = new BackgroundWorker();
worker.DoWork += (workSender, workE) => MFAGenerator.BuildMFA();
worker.RunWorkerCompleted += (workSender, workE) =>
@ -624,41 +626,45 @@ namespace CTFAK.GUI
if (common.Parent.ObjectType == 2) //Active
{
if (common.Animations != null)
foreach (var pair in common.Animations.AnimationDict)
foreach (var pair in common.Animations?.AnimationDict)
{
var animNode = new ChunkNode($"Animation {pair.Key}", pair.Value);
objInstNode.Nodes.Add(animNode);
foreach (var dir in pair.Value.DirectionDict)
if (pair.Value.DirectionDict.Count > 1)
{
var dirNode = new ChunkNode(
$"Direction {pair.Value.DirectionDict.ToList().IndexOf(dir)}",
dir.Value);
animNode.Nodes.Add(dirNode);
for (var a = 0; a < dir.Value.Frames.Count; a++)
if (pair.Value?.DirectionDict != null)
if (pair.Value?.DirectionDict != null)
{
foreach (var dir in pair.Value?.DirectionDict)
if (pair.Value.DirectionDict.Count > 1)
{
var animFrame = dir.Value.Frames[a];
bank.Images.TryGetValue(animFrame, out var img);
if (img != null)
var dirNode = new ChunkNode(
$"Direction {pair.Value.DirectionDict.ToList().IndexOf(dir)}",
dir.Value);
animNode.Nodes.Add(dirNode);
for (var a = 0; a < dir.Value.Frames.Count; a++)
{
var animFrameNode = new ChunkNode(a.ToString(), img);
dirNode.Nodes.Add(animFrameNode);
var animFrame = dir.Value.Frames[a];
bank.Images.TryGetValue(animFrame, out var img);
if (img != null)
{
var animFrameNode = new ChunkNode(a.ToString(), img);
dirNode.Nodes.Add(animFrameNode);
}
}
}
}
else
{
for (var a = 0; a < dir.Value.Frames.Count; a++)
else
{
var animFrame = dir.Value.Frames[a];
bank.Images.TryGetValue(animFrame, out var img);
if (img != null)
for (var a = 0; a < dir.Value.Frames.Count; a++)
{
var animFrameNode = new ChunkNode(a.ToString(), img);
animNode.Nodes.Add(animFrameNode);
var animFrame = dir.Value.Frames[a];
bank.Images.TryGetValue(animFrame, out var img);
if (img != null)
{
var animFrameNode = new ChunkNode(a.ToString(), img);
animNode.Nodes.Add(animFrameNode);
}
}
}
}
}
}
}
else if(common.Parent.ObjectType==7)//Counter

@ -4,6 +4,7 @@ using System.IO;
using CTFAK.MMFParser.EXE.Loaders;
using CTFAK.MMFParser.EXE.Loaders.Banks;
using CTFAK.MMFParser.EXE.Loaders.Events;
using CTFAK.Properties.Locale;
using CTFAK.Utils;
namespace CTFAK.MMFParser.EXE
@ -13,33 +14,50 @@ namespace CTFAK.MMFParser.EXE
public List<Chunk> Chunks = new List<Chunk>();
public bool Verbose = false;
public List<Frame> Frames = new List<Frame>();
public void Read(ByteReader reader)
{
Chunks.Clear();
while (true)
if (!Settings.Old)
{
Chunk chunk = new Chunk(Chunks.Count, this);
chunk.Verbose = Verbose;
chunk.Read(reader);
if (chunk.Id == 26214)
while (true)
{
if(!Settings.twofiveplus) chunk.Loader = LoadChunk(chunk);
//LoadChunk(chunk);
}
else
{
chunk.Loader = LoadChunk(chunk);
}
Chunk chunk = new Chunk(Chunks.Count, this);
chunk.Verbose = Verbose;
chunk.Read(reader);
if (chunk.Id == 26214)
{
if(!Settings.twofiveplus) chunk.Loader = LoadModern(chunk);
//LoadChunk(chunk);
}
else
{
chunk.Loader = LoadModern(chunk);
}
Chunks.Add(chunk);
if (chunk.Id == 8750) chunk.BuildKey();
if (chunk.Id == 8788) Settings.twofiveplus = true;
Chunks.Add(chunk);
if (chunk.Id == 8750) chunk.BuildKey();
if (chunk.Id == 8788) Settings.twofiveplus = true;
if (reader.Tell() >= reader.Size()) break;
if (chunk.Id == 32639) break; //LAST chunkID
if (reader.Tell() >= reader.Size()) break;
if (chunk.Id == 32639) break; //LAST chunkID
}
}
else
{
while (true)
{
Chunk chunk = new Chunk(Chunks.Count, this);
chunk.Verbose = Verbose;
chunk.Read(reader);
chunk.Loader = LoadOld(chunk);
if (reader.Tell() >= reader.Size()) break;
if (chunk.Id == 32639) break; //LAST chunkID
}
}
}
public class Chunk
@ -82,6 +100,7 @@ namespace CTFAK.MMFParser.EXE
exeReader.BaseStream.Position -= Size;
//Saving raw data cuz why not
}
if(Settings.Old) Logger.Log("Reading old chunk"+(Constants.ChunkNames)Id);
switch (Flag)
{
@ -92,7 +111,12 @@ namespace CTFAK.MMFParser.EXE
ChunkData = Decryption.DecodeMode3(exeReader.ReadBytes(Size), Size,Id,out DecompressedSize);
break;
case ChunkFlags.Compressed:
ChunkData = Decompressor.Decompress(exeReader,out DecompressedSize);
if (!Settings.Old) ChunkData = Decompressor.Decompress(exeReader, out DecompressedSize);
else
{
Int32 decompSize = exeReader.ReadInt32();
ChunkData = Decompressor.decompressOld(exeReader, Size, decompSize);
}
break;
case ChunkFlags.NotCompressed:
ChunkData = exeReader.ReadBytes(Size);
@ -165,7 +189,7 @@ namespace CTFAK.MMFParser.EXE
CompressedAndEncrypted = 3
}
public ChunkLoader LoadChunk(Chunk chunk)
public ChunkLoader LoadModern(Chunk chunk)
{
ChunkLoader loader = null;
switch (chunk.Id)
@ -272,6 +296,26 @@ namespace CTFAK.MMFParser.EXE
loader?.Read();
return loader;
}
public ChunkLoader LoadOld(Chunk chunk)
{
ChunkLoader loader = null;
switch (chunk.Id)
{
case 8739:
loader = new AppHeader(chunk);
break;
}
loader?.Read();
return loader;
}
public T GetChunk<T>() where T : ChunkLoader
{
foreach (Chunk chunk in Chunks)

@ -62,7 +62,8 @@ namespace CTFAK.MMFParser.EXE
exeReader.Seek(possition);
var firstShort = exeReader.PeekUInt16();
Logger.Log("First Short: " + firstShort.ToString("X2"), true, ConsoleColor.Yellow);
if (firstShort != 0x7777) Settings.Old = true;
if (firstShort == 0x7777) Settings.Old = false;
else if (firstShort == 0x222c) Settings.Old = true;
if (!Settings.Old)
{
PackData = new PackData();
@ -74,13 +75,12 @@ namespace CTFAK.MMFParser.EXE
}
else
{
Logger.Log("Game is too old");
Logger.Log("Using old system");
var oldData = new ChunkList();
oldData.Read(exeReader);
GameData = new GameData();
GameData.Read(exeReader);
Console.ForegroundColor = ConsoleColor.DarkGreen;
Logger.Log("Failed to find PackData header!\n", true, ConsoleColor.Red);
}
}
}

@ -17,7 +17,7 @@ namespace CTFAK.MMFParser.EXE.Loaders.Banks
public bool SaveImages = false;
public Dictionary<int, ImageItem> Images = new Dictionary<int, ImageItem>();
public uint NumberOfItems;
public bool PreloadOnly=false;
public bool PreloadOnly=true;
public ImageBank(ByteReader reader) : base(reader)
{
@ -451,6 +451,7 @@ namespace CTFAK.MMFParser.EXE.Loaders.Banks
}
writer.WriteInt32(Handle);
// writer.WriteInt32(Handle-1);//FNAC3 FIX
writer.WriteWriter(chunk);
}

@ -23,7 +23,7 @@ namespace CTFAK.MMFParser.EXE.Loaders.Events
public override void Write(ByteWriter Writer)
{
ByteWriter newWriter = new ByteWriter(new MemoryStream());
Logger.Log($"{ObjectType}-{Num}-{ObjectInfo}-{ObjectInfoList}-{Flags}-{OtherFlags}-{Items.Count}-{DefType}-{Identifier}");
// Logger.Log($"{ObjectType}-{Num}-{ObjectInfo}-{ObjectInfoList}-{Flags}-{OtherFlags}-{Items.Count}-{DefType}-{Identifier}");
newWriter.WriteInt16((short) ObjectType);
if (Num == -42) Num = -27;
newWriter.WriteInt16((short) Num);
@ -68,7 +68,7 @@ namespace CTFAK.MMFParser.EXE.Loaders.Events
item.Read();
Items.Add(item);
}
Logger.Log(this);
// Logger.Log(this);
Reader.Seek(currentPosition + size);
@ -137,7 +137,7 @@ namespace CTFAK.MMFParser.EXE.Loaders.Events
item.Read();
Items.Add(item);
}
Logger.Log(this);
// Logger.Log(this);
}
public override string ToString()

@ -27,6 +27,7 @@ namespace CTFAK.MMFParser.EXE.Loaders.Events.Expressions
if (ObjectType == Constants.ObjectType.System &&
(Num == 0 || Num == 3 || Num == 23 || Num == 24 || Num == 50))
{
if(Loader==null) throw new NotImplementedException("Broken expression: "+Num);
Loader.Write(newWriter);
}
else if ((int) ObjectType >= 2 || (int) ObjectType == -7)
@ -34,15 +35,13 @@ namespace CTFAK.MMFParser.EXE.Loaders.Events.Expressions
newWriter.WriteInt16((short) ObjectInfo);
newWriter.WriteInt16((short) ObjectInfoList);
if(Num==16||Num==19)Loader.Write(newWriter);
}
newWriter.WriteInt32(0);
newWriter.WriteUInt16(0);
Writer.WriteInt16((short) ((newWriter.Size())));
Writer.WriteWriter(newWriter);
}
public override void Print()
@ -64,8 +63,8 @@ namespace CTFAK.MMFParser.EXE.Loaders.Events.Expressions
{
if(Num==0) Loader=new LongExp(Reader);
else if(Num==3) Loader= new StringExp(Reader);
else if (Num == 23) Loader = null;
else if (Num == 24) Loader = null;
else if (Num == 23) Loader = new DoubleExp(Reader);
else if (Num == 24) Loader = new GlobalCommon(Reader);
else if (Num == 50) Loader = null;
else if((int)ObjectType>=2|| (int)ObjectType==-7)
{
@ -196,4 +195,50 @@ namespace CTFAK.MMFParser.EXE.Loaders.Events.Expressions
Writer.WriteInt16((short) Value);
}
}
public class DoubleExp:ExpressionLoader
{
public float FloatValue;
public DoubleExp(ByteReader reader) : base(reader)
{
}
public DoubleExp(ChunkList.Chunk chunk) : base(chunk)
{
}
public override void Read()
{
Value = Reader.ReadDouble();
FloatValue = Reader.ReadSingle();
}
public override void Write(ByteWriter Writer)
{
Writer.WriteDouble((double) Value);
Writer.WriteSingle(FloatValue);
}
}
public class GlobalCommon:ExpressionLoader
{
public GlobalCommon(ByteReader reader) : base(reader)
{
}
public GlobalCommon(ChunkList.Chunk chunk) : base(chunk)
{
}
public override void Read()
{
Reader.ReadInt32();
Value = Reader.ReadInt32();
}
public override void Write(ByteWriter Writer)
{
Writer.WriteInt32(0);
Writer.WriteInt32((int) Value);
}
}
}

@ -6,8 +6,7 @@ namespace CTFAK.MMFParser.EXE.Loaders.Events.Parameters
{
public int Delay;
public int Compteur;
public Every(ByteReader reader) : base(reader) { }
public override void Read()
{
@ -15,6 +14,13 @@ namespace CTFAK.MMFParser.EXE.Loaders.Events.Parameters
Compteur = Reader.ReadInt32();
}
public override void Write(ByteWriter Writer)
{
Writer.WriteInt32(Delay);
Writer.WriteInt32(Compteur);
}
public override string ToString()
{
return $"Every {Delay/1000} sec";

@ -22,7 +22,7 @@ namespace CTFAK.MMFParser.EXE.Loaders.Events.Parameters
{
var expression = new Expression(Reader);
expression.Read();
Logger.Log($"Found expression {expression.ObjectType}-{expression.Num}=={((ExpressionLoader)expression.Loader)?.Value}");
// Logger.Log($"Found expression {expression.ObjectType}-{expression.Num}=={((ExpressionLoader)expression.Loader)?.Value}");
if (expression.ObjectType == 0&& expression.Num==0)
{
break;
@ -37,10 +37,10 @@ namespace CTFAK.MMFParser.EXE.Loaders.Events.Parameters
public override void Write(ByteWriter Writer)
{
Writer.WriteInt16(Comparsion);
Logger.Log("ExpressionCount: "+Items.Count);
// Logger.Log("ExpressionCount: "+Items.Count);
foreach (Expression item in Items)
{
Logger.Log("Writing expression: "+item.Num);
// Logger.Log("Writing expression: "+item.Num);
item.Write(Writer);
}

@ -13,7 +13,6 @@ namespace CTFAK.MMFParser.EXE.Loaders.Events.Parameters
public override void Read()
{
base.Read();
Pointer = Reader.ReadInt32();
Id = Reader.ReadInt16();
@ -21,7 +20,6 @@ namespace CTFAK.MMFParser.EXE.Loaders.Events.Parameters
public override void Write(ByteWriter Writer)
{
base.Write(Writer);
Writer.WriteInt32(Pointer);
Writer.WriteInt32(Id);
}

@ -15,7 +15,6 @@ namespace CTFAK.MMFParser.EXE.Loaders.Events.Parameters
public override void Read()
{
base.Read();
X1 = Reader.ReadInt16();
Y1 = Reader.ReadInt16();
X2 = Reader.ReadInt16();
@ -24,7 +23,6 @@ namespace CTFAK.MMFParser.EXE.Loaders.Events.Parameters
public override void Write(ByteWriter Writer)
{
base.Write(Writer);
Writer.WriteInt16(X1);
Writer.WriteInt16(Y1);
Writer.WriteInt16(X2);

@ -87,6 +87,7 @@ namespace CTFAK.MMFParser.EXE.Loaders
Flags.flag = actualLoader.Flags;
UInt32 inkEffect = actualLoader.InkEffect;
InkEffectValue = (int) actualLoader.InkEffectParameter;
Transparent = ByteFlag.GetFlag(inkEffect, 28);
Antialias = ByteFlag.GetFlag(inkEffect, 29);
}
@ -136,6 +137,7 @@ namespace CTFAK.MMFParser.EXE.Loaders
}
else if (ObjectType==0)//QuickBackdrop
{
}
@ -189,8 +191,7 @@ namespace CTFAK.MMFParser.EXE.Loaders
//TODO: Fix shit
if(ObjectType==0)//QuickBackdrop
{
Loader=new Quickbackdrop(Reader);
}
else if (ObjectType == 1)//Backdrop
{

@ -39,6 +39,10 @@ namespace CTFAK.MMFParser.EXE.Loaders.Objects
AnimationDict.Add(i,anim);
}
else
{
AnimationDict.Add(i,new Animation((ByteReader) null));
}
}
@ -89,6 +93,7 @@ namespace CTFAK.MMFParser.EXE.Loaders.Objects
dir.Read();
DirectionDict.Add(i,dir);
}
}
}

@ -1,4 +1,5 @@
using CTFAK.Utils;
using System.Drawing;
using CTFAK.Utils;
namespace CTFAK.MMFParser.EXE.Loaders.Objects
{
@ -50,6 +51,101 @@ namespace CTFAK.MMFParser.EXE.Loaders.Objects
throw new System.NotImplementedException();
}
public override string[] GetReadableData()
{
throw new System.NotImplementedException();
}
}
public class Quickbackdrop:ChunkLoader
{
public int Size;
public Obstacle ObstacleType;
public Collision CollisionType;
public int Width;
public int Height;
public int Image;
public Shape Shape;
public Quickbackdrop(ByteReader reader) : base(reader)
{
}
public Quickbackdrop(ChunkList.Chunk chunk) : base(chunk)
{
}
public override void Read()
{
Size = Reader.ReadInt32();
ObstacleType = (Obstacle) Reader.ReadInt16();
CollisionType = (Collision) Reader.ReadInt16();
Width = Reader.ReadInt32();
Height = Reader.ReadInt32();
Shape = new Shape(Reader);
Shape.Read();
}
public override void Print(bool ext)
{
throw new System.NotImplementedException();
}
public override string[] GetReadableData()
{
throw new System.NotImplementedException();
}
}
public class Shape:ChunkLoader
{
public short BorderSize;
public Color BorderColor;
public short ShapeType;
public short FillType;
public short LineFlags;
public Color Color1;
public Color Color2;
public short GradFlags;
public short Image=15;
public Shape(ByteReader reader) : base(reader)
{
}
public Shape(ChunkList.Chunk chunk) : base(chunk)
{
}
public override void Read()
{
BorderSize = Reader.ReadInt16();
BorderColor = Reader.ReadColor();
ShapeType = Reader.ReadInt16();
FillType = Reader.ReadInt16();
if (ShapeType == 1)
{
LineFlags = Reader.ReadInt16();
}
else if (FillType == 1)
{
Color1 = Reader.ReadColor();
}
else if (FillType == 2)
{
Color1 = Reader.ReadColor();
Color2 = Reader.ReadColor();
GradFlags = Reader.ReadInt16();
}
else if(FillType==3)
{
Image = Reader.ReadInt16();
}
}
public override void Print(bool ext)
{
throw new System.NotImplementedException();
}
public override string[] GetReadableData()
{
throw new System.NotImplementedException();

@ -64,7 +64,6 @@ namespace CTFAK.MMFParser.MFA.Loaders
{
string name = Reader.ReadAscii(4);
Console.WriteLine(name);
if (name == EventData)
{
EventDataLen = Reader.ReadUInt32();
@ -158,7 +157,7 @@ namespace CTFAK.MMFParser.MFA.Loaders
}
else if (name == EditorPositionData)
{
if(Reader.ReadUInt16()!=1) throw new NotImplementedException("Invalid chunkversion");
if(Reader.ReadUInt16()!=1)throw new NotImplementedException("Invalid chunkversion");
X = Reader.ReadUInt32();
Y = Reader.ReadUInt32();
CaretType = Reader.ReadUInt32();
@ -167,7 +166,7 @@ namespace CTFAK.MMFParser.MFA.Loaders
}
else if (name == EditorLineData)
{
if(Reader.ReadUInt16()!=1) throw new NotImplementedException("Invalid chunkversion");
if(Reader.ReadUInt16()!=1)throw new NotImplementedException("Invalid chunkversion");
LineY = Reader.ReadUInt32();
LineItemType = Reader.ReadUInt32();
EventLine = Reader.ReadUInt32();
@ -176,6 +175,7 @@ namespace CTFAK.MMFParser.MFA.Loaders
else if (name == EventEnd)
{
_cache = Reader.ReadBytes(122);
break;
}
else throw new NotImplementedException("Fuck Something is Broken");
@ -209,7 +209,7 @@ namespace CTFAK.MMFParser.MFA.Loaders
}
if (Objects.Count>0)
if (Objects?.Count>0)
{
Console.WriteLine("Writing EventObjects");
Writer.WriteAscii(ObjectData);
@ -278,9 +278,10 @@ namespace CTFAK.MMFParser.MFA.Loaders
Writer.WriteAscii(EventEnd);
Writer.WriteBytes(_cache);
Writer.WriteBytes(_cache);
//TODO: Fix commented part
//

@ -19,8 +19,6 @@ namespace CTFAK.MMFParser.MFA.Loaders
public int LastViewedY;
public List<ItemFolder> Folders = new List<ItemFolder>();
public List<FrameInstance> Instances = new List<FrameInstance>();
public List<byte[]> UnkBlocks = new List<byte[]>();
public BitDict Flags = new BitDict(new string[]
{
"GrabDesktop",
@ -41,11 +39,12 @@ namespace CTFAK.MMFParser.MFA.Loaders
public List<Color> Palette;
public int StampHandle;
public int ActiveLayer;
public List<Layer> Layers;
public List<Layer> Layers = new List<Layer>();
public Events Events;
public ChunkList Chunks;
public Transition FadeIn;
public Transition FadeOut;
public int PaletteSize;
public Frame(ByteReader reader) : base(reader)
{
@ -94,12 +93,11 @@ namespace CTFAK.MMFParser.MFA.Loaders
}
else Writer.Skip(1);
Writer.WriteInt32(Items.Count);
foreach (var item in Items)
{
item.Write(Writer);
var bytes = new byte[] {0x01,0x01,0x00,0x00, 0x00,0x00,0x00,0x00, 0x80,0x01,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x32,0x00, 0x00,0x00,0x32,0x00, 0x00,0x00,0x01,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x01,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00};
}
Writer.WriteInt32(Folders.Count);
@ -113,20 +111,16 @@ namespace CTFAK.MMFParser.MFA.Loaders
{
item.Write(Writer);
}
// Writer.WriteAscii("AI");
/*if (UnkBlocks != null)
{
Writer.WriteInt32(UnkBlocks.Count);
foreach (var item in UnkBlocks)
{
Writer.WriteBytes(item);
}
}*/
Events.Write(Writer);
// for (int i=0;i<Layers.Count;i++)
// {
// Writer.WriteInt32(0);
// Writer.WriteInt32(0);
// Writer.WriteInt16(0);
// }
// Writer.WriteInt32(0);
Chunks.Write(Writer);
}
@ -152,7 +146,7 @@ namespace CTFAK.MMFParser.MFA.Loaders
LastViewedX = Reader.ReadInt32();
LastViewedY = Reader.ReadInt32();
//var paletteSize = Reader.ReadInt32();
// PaletteSize = Reader.ReadInt32();
Palette = new List<Color>();
for (int i = 0; i < 257; i++)
{
@ -162,7 +156,6 @@ namespace CTFAK.MMFParser.MFA.Loaders
StampHandle = Reader.ReadInt32();
ActiveLayer = Reader.ReadInt32();
int layersCount = Reader.ReadInt32();
Layers = new List<Layer>();
for (int i = 0; i < layersCount; i++)
{
var layer = new Layer(Reader);
@ -181,8 +174,6 @@ namespace CTFAK.MMFParser.MFA.Loaders
FadeOut = new Transition(Reader);
FadeOut.Read();
}
Items = new List<FrameItem>();
var frameItemsCount = Reader.ReadInt32();
for (int i = 0; i < frameItemsCount; i++)
{
@ -191,8 +182,6 @@ namespace CTFAK.MMFParser.MFA.Loaders
Items.Add(frameitem);
}
Folders = new List<ItemFolder>();
var folderCount = Reader.ReadInt32();
for (int i = 0; i < folderCount; i++)
{
@ -200,8 +189,6 @@ namespace CTFAK.MMFParser.MFA.Loaders
folder.Read();
Folders.Add(folder);
}
Instances = new List<FrameInstance>();
var instancesCount = Reader.ReadInt32();
for (int i = 0; i < instancesCount; i++)
{
@ -210,14 +197,15 @@ namespace CTFAK.MMFParser.MFA.Loaders
Instances.Add(inst);
}
//var unkCount = Reader.ReadInt32();
//for (int i = 0; i < unkCount; i++)
//{
// UnkBlocks.Add(Reader.ReadBytes(32));
//}
// var unkCount = Reader.ReadInt32();
// for (int i = 0; i < unkCount; i++)
// {
// UnkBlocks.Add(Reader.ReadBytes(32));
// }
Events = new Events(Reader);
Events.Read();
Chunks = new ChunkList(Reader);
Chunks.Read();
if(Events.Items.Count==0)MFA.emptyEvents = Events;

@ -79,11 +79,14 @@ namespace CTFAK.MMFParser.MFA.Loaders
Loader = new ExtensionObject(Reader);
}
else if(ObjectType==7)
{
Loader = new Counter(Reader);
}
else if(ObjectType==2)
{
Loader = new Active(Reader);
}
Loader?.Read();

@ -43,6 +43,7 @@ namespace CTFAK.MMFParser.MFA.Loaders
Flags.flag = (uint) Reader.ReadInt32();
XCoefficient = Reader.ReadSingle();
YCoefficient = Reader.ReadSingle();

@ -1,4 +1,5 @@
using CTFAK.MMFParser.EXE;
using System.Drawing;
using CTFAK.MMFParser.EXE;
using CTFAK.Utils;
namespace CTFAK.MMFParser.MFA.Loaders.mfachunks
@ -27,6 +28,59 @@ namespace CTFAK.MMFParser.MFA.Loaders.mfachunks
Writer.WriteInt32(Handle);
}
}
public class QuickBackdrop:BackgroundLoader
{
public int Width;
public int Height;
public int Shape;
public int BorderSize;
public Color BorderColor;
public int FillType;
public Color Color1;
public Color Color2;
public int Flags;
public int Image;
public QuickBackdrop(ByteReader reader) : base(reader)
{
}
public QuickBackdrop(EXE.ChunkList.Chunk chunk) : base(chunk)
{
}
public override void Read()
{
base.Read();
Width = Reader.ReadInt32();
Height = Reader.ReadInt32();
Shape = Reader.ReadInt32();
BorderSize = Reader.ReadInt32();
BorderColor = Reader.ReadColor();
FillType = Reader.ReadInt32();
Color1 = Reader.ReadColor();
Color2 = Reader.ReadColor();
Flags = Reader.ReadInt32();
Image = Reader.ReadInt32();
}
public override void Write(ByteWriter Writer)
{
base.Write(Writer);
Writer.WriteInt32(Width);
Writer.WriteInt32(Height);
Writer.WriteInt32(Shape);
Writer.WriteInt32(BorderSize);
Writer.WriteColor(BorderColor);
Writer.WriteInt32(FillType);
Writer.WriteColor(Color1);
Writer.WriteColor(Color2);
Writer.WriteInt32(Flags);
Writer.WriteInt32(Image);
}
}
public class BackgroundLoader : DataLoader
{

@ -0,0 +1,55 @@
using System.Collections.Generic;
using CTFAK.Utils;
namespace CTFAK.MMFParser.MFA.Loaders.mfachunks
{
public class Lives:ObjectLoader
{
public uint Player;
public List<int> Images;
public int Flags;
public int DisplayType;
public int Font;
public int Width;
public int Height;
public Lives(ByteReader reader) : base(reader)
{
}
public override void Read()
{
base.Read();
Player = Reader.ReadUInt32();
Images = new List<int>();
var imgCount = Reader.ReadInt32();
for (int i = 0; i < imgCount; i++)
{
Images.Add(Reader.ReadInt32());
}
DisplayType = Reader.ReadInt32();
Flags = Reader.ReadInt32();
Font = Reader.ReadInt32();
Width = Reader.ReadInt32();
Height = Reader.ReadInt32();
}
public override void Write(ByteWriter Writer)
{
base.Write(Writer);
Writer.WriteInt32((int) Player);
Writer.WriteInt32(Images.Count);
foreach (int i in Images)
{
Writer.WriteInt32(i);
}
Writer.WriteInt32(DisplayType);
Writer.WriteInt32(Flags);
Writer.WriteInt32(Font);
Writer.WriteInt32(Width);
Writer.WriteInt32(Height);
}
}
}

@ -395,6 +395,7 @@ namespace CTFAK.MMFParser.MFA
List<int> frameOffsets = new List<int>();
var offCount = Reader.ReadInt32();
Logger.Log("FRAME COUNT: "+offCount);
for (int i = 0; i < offCount; i++)
{
frameOffsets.Add(Reader.ReadInt32());

@ -0,0 +1,44 @@
using CTFAK.MMFParser.EXE;
using CTFAK.MMFParser.EXE.Loaders;
using CTFAK.Utils;
namespace CTFAK.MMFParser.OLD.Loaders
{
public class AppHeader:ChunkLoader
{
public AppHeader(ByteReader reader) : base(reader)
{
}
public AppHeader(ChunkList.Chunk chunk) : base(chunk)
{
}
public override void Read()
{
var flags = Reader.ReadUInt16();
var newFlags = Reader.ReadUInt16();
var mode = Reader.ReadUInt16();
var otherFlags = Reader.ReadUInt16();
var windowWidth = Reader.ReadUInt16();
var windowHeight = Reader.ReadUInt16();
var initialScore = Reader.ReadUInt32() ^ 0xffffffff;
var initialLives = Reader.ReadUInt32() ^ 0xffffffff;
var controls = new Controls(Reader);
controls.Read();
var borderColor = Reader.ReadColor();
var frameCount = Reader.ReadInt32();
}
public override void Print(bool ext)
{
throw new System.NotImplementedException();
}
public override string[] GetReadableData()
{
throw new System.NotImplementedException();
}
}
}

@ -0,0 +1,99 @@
using System.Collections.Generic;
using CTFAK.MMFParser.EXE;
using CTFAK.MMFParser.EXE.Loaders;
using CTFAK.Utils;
namespace CTFAK.MMFParser.OLD.Loaders
{
public class Controls:ChunkLoader
{
public List<PlayerControl> Items;
public Controls(ByteReader reader) : base(reader)
{
}
public Controls(ChunkList.Chunk chunk) : base(chunk)
{
}
public override void Read()
{
Items = new List<PlayerControl>();
for (int i = 0; i < 4; i++)
{
var control = new PlayerControl(Reader);
control.Read();
Items.Add(control);
}
}
public override void Print(bool ext)
{
throw new System.NotImplementedException();
}
public override string[] GetReadableData()
{
throw new System.NotImplementedException();
}
}
public class PlayerControl:ChunkLoader
{
public Keys Keys;
public PlayerControl(ByteReader reader) : base(reader)
{
}
public PlayerControl(ChunkList.Chunk chunk) : base(chunk)
{
}
public override void Read()
{
Keys = new Keys(Reader);
Keys.Read();
}
public override void Print(bool ext)
{
throw new System.NotImplementedException();
}
public override string[] GetReadableData()
{
throw new System.NotImplementedException();
}
}
public class Keys:ChunkLoader
{
public Keys(ByteReader reader) : base(reader)
{
}
public Keys(ChunkList.Chunk chunk) : base(chunk)
{
}
public override void Read()
{
var up = Reader.ReadUInt16();
var down = Reader.ReadUInt16();
var left = Reader.ReadUInt16();
var right = Reader.ReadUInt16();
var btn1 = Reader.ReadUInt16();
var btn2 = Reader.ReadUInt16();
}
public override void Print(bool ext)
{
throw new System.NotImplementedException();
}
public override string[] GetReadableData()
{
throw new System.NotImplementedException();
}
}
}

@ -1,8 +1,15 @@
using System.IO;
using System.Linq;
using System.Net;
using System.Windows.Forms;
using CTFAK.MMFParser.EXE;
using CTFAK.MMFParser.EXE.Loaders;
using CTFAK.MMFParser.EXE.Loaders.Banks;
using CTFAK.MMFParser.MFA.Loaders;
using CTFAK.Utils;
using ChunkList = CTFAK.MMFParser.MFA.Loaders.ChunkList;
using Frame = CTFAK.MMFParser.MFA.Loaders.Frame;
using Layer = CTFAK.MMFParser.MFA.Loaders.Layer;
namespace CTFAK.MMFParser.Translation
{
@ -36,6 +43,9 @@ namespace CTFAK.MMFParser.Translation
else return null;
}
else mfaReader = new ByteReader(TemplatePath, FileMode.Open);
Logger.Log("Loading images");
Exe.Instance.GameData.GameChunks.GetChunk<ImageBank>().PreloadOnly = false;
Exe.Instance.GameData.GameChunks.GetChunk<ImageBank>().Read(true,false);
Settings.DoMFA = true;
var template = new MFA.MFA(mfaReader);
@ -46,7 +56,7 @@ namespace CTFAK.MMFParser.Translation
var mfaWriter =
new ByteWriter(
Settings.GameName.Length > 0 ? $"{Settings.DumpPath}\\{Exe.Instance.GameData.Name}-decompiled.mfa" : "out.mfa",
Settings.GameName.Length > 0 ? $"{Settings.DumpPath}\\{Path.GetFileNameWithoutExtension(Exe.Instance.GameData.GameChunks.GetChunk<EditorFilename>().Value)}.mfa" : "out.mfa",
FileMode.Create); //New writer for new MFA
Pame2Mfa.Message("");
Pame2Mfa.Message("Writing MFA");
@ -68,6 +78,37 @@ namespace CTFAK.MMFParser.Translation
//Add modifications
var mfaWriter = new ByteWriter(outputPath, FileMode.Create);
template.Write(mfaWriter);
}public static void WriteTestMFA()
{
var outputPath = Path.Combine(Path.GetDirectoryName(TemplatePath), "patchNew.mfa");
var mfaReader = new ByteReader(TemplatePath, FileMode.Open);
var template = new MFA.MFA(mfaReader);
Settings.DoMFA = true;
template.Read();
var refer = template.Frames.FirstOrDefault();
// template.Frames.Clear();
for (int i = 0; i < 25; i++)
{
var frame = refer;
frame.Handle = i;
frame.Name = "Frame " + i;
frame.Chunks = new ChunkList(null);
frame.Events = MFA.MFA.emptyEvents;
frame.Palette = refer.Palette;
// frame.Layers.Add(new Layer(null)
// {
// Name="Layer"
// });
template.Frames.Add(frame);
}
//Add modifications
var mfaWriter = new ByteWriter(outputPath, FileMode.Create);
template.Write(mfaWriter);
}

@ -30,16 +30,15 @@ namespace CTFAK.MMFParser.Translation
public static Dictionary<int, FrameItem> FrameItems;
public static event Program.DumperEvent OnMessage;
public static void Translate(ref MFA.MFA mfa, GameData game)
{
Message("Running Pame2MFA");
Message("Original MFA Build: " + mfa.BuildVersion);
Message("");
// mfa.MfaBuild = 4;
// mfa.Product = (int) game.ProductVersion;
// mfa.BuildVersion = 283;
mfa.Name = game.Name;
mfa.LangId = 8192;
mfa.LangId = 0;//8192;
mfa.Description = "";
mfa.Path = game.EditorFilename;
@ -68,12 +67,15 @@ namespace CTFAK.MMFParser.Translation
var flags = game.Header.Flags;
var newFlags = game.Header.NewFlags;
mfa.Extensions.Clear();
//TODO:Flags, no setter
displaySettings["MDI"] = newFlags["MDI"];
displaySettings["MenuBar"] = flags["MenuBar"];
displaySettings["MenuOnBoot"] = !flags["MenuHidden"];
graphicSettings["MultiSamples"] = flags["MultiSamples"];
mfa.DisplayFlags = displaySettings;
mfa.WindowX = game.Header.WindowWidth;
mfa.WindowY = game.Header.WindowHeight;
mfa.BorderColor = game.Header.BorderColor;
mfa.HelpFile = "";
mfa.VitalizePreview = new byte[] {0x0};
mfa.InitialScore = game.Header.InitialScore;
mfa.InitialLifes = game.Header.InitialLives;
mfa.FrameRate = game.Header.FrameRate;
@ -91,248 +93,28 @@ namespace CTFAK.MMFParser.Translation
{
var key = game.Frameitems.ItemDict.Keys.ToArray()[i];
var item = game.Frameitems.ItemDict[key];
//if (item.ObjectType != 2 && item.ObjectType != 1 && item.ObjectType != 3) break;
var newItem = new FrameItem(null);
newItem.Name = item.Name;
newItem.ObjectType = item.ObjectType;
newItem.Handle = item.Handle;
newItem.Transparent = item.Transparent ? 1 : 0;
newItem.InkEffect = item.InkEffect;
newItem.InkEffectParameter = item.InkEffectValue;
newItem.AntiAliasing = item.Antialias ? 1 : 0;
newItem.Flags = (int) item.Flags.flag; //32 TODO:Fix this
newItem.IconHandle = 12;
newItem.Chunks = new ChunkList(null);
if (item.ObjectType == 1)
{
var backdropLoader = (EXE.Loaders.Objects.Backdrop) item.Properties.Loader;
var backdrop = new Backdrop((ByteReader) null);
backdrop.ObstacleType = (uint) backdropLoader.ObstacleType;
backdrop.CollisionType = (uint) backdropLoader.CollisionType;
backdrop.Handle = backdropLoader.Image;
//TODO:Implement QuickBackdrops
newItem.Loader = backdrop;
}
else
{
var itemLoader = (ObjectCommon) item?.Properties?.Loader;
if (itemLoader == null) continue;
Logger.Log("Translating Object: "+itemLoader.Parent.Name);
//CommonSection
var newObject = new ObjectLoader(null);
newObject.ObjectFlags = (int) (itemLoader?.Flags?.flag ?? 820);
newObject.NewObjectFlags =(int) (itemLoader?.NewFlags?.flag ?? 8);
newObject.BackgroundColor = Color.Black;//itemLoader.BackColor;
//newLoader.Qualifiers;
newObject.Strings = ConvertStrings(itemLoader.Strings);
newObject.Values = ConvertValue(itemLoader.Values);
newObject.Movements = new MFA.Loaders.mfachunks.Movements(null);
for (int j = 0; j < itemLoader.Movements.Items.Count; j++)
{
var mov = itemLoader.Movements.Items[j];
var newMov = new Movement(null);
newMov.Name = $"Movement #{j}";
newMov.Extension = "";
newMov.Identifier = 0;//(uint) mov.Type;
if(newMov.Identifier!=0)throw new Exception("Unknown Movement: "+newMov.Identifier);
newMov.Player = mov.Player;
newMov.MovingAtStart = mov.MovingAtStart;
newMov.DirectionAtStart = mov.DirectionAtStart;
newObject.Movements.Items.Add(newMov);
}
newObject.Behaviours = new Behaviours(null);
if (item.ObjectType == 2)
{
var active = new Active(null);
//Shit Section
{
active.ObjectFlags = newObject.ObjectFlags;
active.NewObjectFlags = newObject.NewObjectFlags;
active.BackgroundColor = newObject.BackgroundColor;
active.Strings = newObject.Strings;
active.Values = newObject.Values;
active.Movements = newObject.Movements;
active.Behaviours = newObject.Behaviours;
}
//TODO: Transitions
if (itemLoader.Animations != null)
{
var animHeader = itemLoader.Animations;
for (int j = 0; j < animHeader.AnimationDict.Count; j++)
{
var origAnim = animHeader.AnimationDict.ToArray()[j];
var newAnimation = new Animation(null);
var newDirections = new List<AnimationDirection>();
EXE.Loaders.Objects.Animation animation = null;
try
{
if (animHeader.AnimationDict.ContainsKey(origAnim.Key))
{
animation = animHeader.AnimationDict[origAnim.Key];
}
else break;
}
catch
{
}
if (animation != null)
{
for (int n = 0; n < animation.DirectionDict.Count; n++)
{
var direction = animation.DirectionDict.ToArray()[n].Value;
var newDirection = new AnimationDirection(null);
newDirection.MinSpeed = direction.MinSpeed;
newDirection.MaxSpeed = direction.MaxSpeed;
newDirection.Index = n;
newDirection.Repeat = direction.Repeat;
newDirection.BackTo = direction.BackTo;
newDirection.Frames = direction.Frames;
newDirections.Add(newDirection);
}
newAnimation.Directions = newDirections;
}
active.Items.Add(j, newAnimation);
}
}
newItem.Loader = active;
}
if (item.ObjectType >= 32)
{
var newExt = new ExtensionObject(null);
{
newExt.ObjectFlags = newObject.ObjectFlags;
newExt.NewObjectFlags = newObject.NewObjectFlags;
newExt.BackgroundColor = newObject.BackgroundColor;
newExt.Strings = newObject.Strings;
newExt.Values = newObject.Values;
newExt.Movements = newObject.Movements;
newExt.Behaviours = newObject.Behaviours;
}
var exts = Exe.Instance.GameData.GameChunks.GetChunk<Extensions>();
Extension ext = null;
foreach (var testExt in exts.Items)
{
if (testExt.Handle==item.ObjectType-32) ext = testExt;
}
newExt.ExtensionType = -1;
newExt.ExtensionName = "";
newExt.Filename = $"{ext.Name}.mfx";
newExt.Magic = (uint) ext.MagicNumber;
newExt.SubType = ext.SubType;
newExt.ExtensionVersion = itemLoader.ExtensionVersion;
newExt.ExtensionId = itemLoader.ExtensionId;
newExt.ExtensionPrivate = itemLoader.ExtensionPrivate;
newExt.ExtensionData = itemLoader.ExtensionData;
newItem.Loader = newExt;
var tuple = new Tuple<int, string, string, int, string>(ext.Handle, ext.Name, "",
ext.MagicNumber, ext.SubType);
// mfa.Extensions.Add(tuple);
}
else if (item.ObjectType == 3)
{
var text = itemLoader.Text;
var newText = new Text(null);
//Shit Section
{
newText.ObjectFlags = newObject.ObjectFlags;
newText.NewObjectFlags = newObject.NewObjectFlags;
newText.BackgroundColor = newObject.BackgroundColor;
newText.Strings = newObject.Strings;
newText.Values = newObject.Values;
newText.Movements = newObject.Movements;
newText.Behaviours = newObject.Behaviours;
}
newText.Width = (uint) text.Width;
newText.Height = (uint) text.Height;
var paragraph = text.Items[0];
newText.Font = paragraph.FontHandle;
newText.Color = paragraph.Color;
newText.Flags = 0;
newText.Items = new List<Paragraph>();
foreach (EXE.Loaders.Objects.Paragraph exePar in text.Items)
{
var newPar = new Paragraph((ByteReader) null);
newPar.Value = exePar.Value;
newPar.Flags = exePar.Flags.flag;
newText.Items.Add(newPar);
}
newItem.Loader = newText;
}
else if (item.ObjectType == 7)
{
var counter = itemLoader.Counters;
var newCount = new Counter(null);
{
newCount.ObjectFlags = newObject.ObjectFlags;
newCount.NewObjectFlags = newObject.NewObjectFlags;
newCount.BackgroundColor = newObject.BackgroundColor;
newCount.Strings = newObject.Strings;
newCount.Values = newObject.Values;
newCount.Movements = newObject.Movements;
newCount.Behaviours = newObject.Behaviours;
}
newCount.Value = itemLoader.Counter.Initial;
newCount.Maximum = itemLoader.Counter.Maximum;
newCount.Minimum = itemLoader.Counter.Minimum;
newCount.Images=new List<int>(){0};
if (counter == null)
{
newCount.DisplayType = 0;
newCount.CountType = 0;
newCount.Width = 0;
newCount.Height = 0;
newCount.Font = 0;
}
else
{
newCount.DisplayType = counter.DisplayType;
newCount.CountType = counter.Inverse ? 1:0;
newCount.Width = (int) counter.Width;
newCount.Height = (int) counter.Height;
newCount.Images = counter.Frames;
newCount.Font = counter.Font;
}
newCount.Color1=Color.White;
newCount.Color2=Color.White;
newCount.Flags = 0;
newCount.VerticalGradient = 0;
newItem.Loader = newCount;
}
}
// if(newItem.Loader==null) throw new NotImplementedException("Unsupported Object");
var newItem = TranslateObject(item);
if(newItem.Loader==null) throw new NotImplementedException("Unsupported Object: "+newItem.ObjectType);
FrameItems.Add(newItem.Handle, newItem);
}
// var reference = mfa.Frames.FirstOrDefault();
mfa.Frames.Clear();
foreach (Frame frame in game.Frames)
{
if(frame.Palette==null|| frame.Events==null|| frame.Objects==null) continue;
var newFrame = new MFA.Loaders.Frame(null);
//FrameInfo
newFrame.Handle = game.Frames.IndexOf(frame);
newFrame.Handle = game.Frames.IndexOf(frame)+1;
newFrame.Name = frame.Name;
newFrame.SizeX = frame.Width;
newFrame.SizeY = frame.Height;
newFrame.Background = frame.Background;
newFrame.FadeIn = frame.FadeIn != null ? ConvertTransition(frame.FadeIn) : null;
newFrame.FadeOut = frame.FadeOut != null ? ConvertTransition(frame.FadeOut) : null;
newFrame.FadeIn = null;
newFrame.FadeOut = null;
// newFrame.UnkString = " ";
var mfaFlags = newFrame.Flags;
var originalFlags = frame.Flags;
@ -344,8 +126,7 @@ namespace CTFAK.MMFParser.Translation
mfaFlags["NoDisplaySurface"] = false;
mfaFlags["TimerBasedMovements"] = originalFlags["TimedMovements"];
newFrame.Flags = mfaFlags;
newFrame.Flags.flag = 260;
newFrame.MaxObjects = frame.Events?.MaxObjects ?? 1000;
newFrame.MaxObjects = frame.Events?.MaxObjects ?? 10000;
newFrame.Password = "";
newFrame.LastViewedX = 320;
newFrame.LastViewedY = 240;
@ -353,20 +134,24 @@ namespace CTFAK.MMFParser.Translation
newFrame.StampHandle = 13;
newFrame.ActiveLayer = 0;
//LayerInfo
newFrame.Layers = new List<Layer>();
foreach (EXE.Loaders.Layer layer in frame.Layers.Items)
var count = frame.Layers.Items.Count;
Logger.Log($"{newFrame.Name} - {count}");
for (int i=0;i<count;i++)
{
var newLayer = new Layer(null);
var layer = frame.Layers.Items[i];
var newLayer = new MFA.Loaders.Layer(null);
newLayer.Name = layer.Name;
newLayer.Flags["HideAtStart"] = originalFlags["ToHide"];
newLayer.Flags["HideAtStart"] = layer.Flags["ToHide"];
newLayer.Flags["Visible"] = true;
newLayer.Flags["NoBackground"] = originalFlags["DoNotSaveBackground"];
newLayer.Flags["WrapHorizontally"] = originalFlags["WrapHorizontally"];
newLayer.Flags["WrapVertically"] = originalFlags["WrapVertically"];
newLayer.Flags["NoBackground"] = layer.Flags["DoNotSaveBackground"];
newLayer.Flags["WrapHorizontally"] = layer.Flags["WrapHorizontally"];
newLayer.Flags["WrapVertically"] = layer.Flags["WrapVertically"];
// newLayer.Flags.flag = 0;
newLayer.XCoefficient = layer.XCoeff;
newLayer.YCoefficient = layer.YCoeff;
newFrame.Layers.Add(newLayer);
if(frame.Layers.Items.IndexOf(layer)==1)break;
// break;
//
}
@ -394,9 +179,9 @@ namespace CTFAK.MMFParser.Translation
newInstance.ParentType = (uint) instance.ParentType;
newInstance.ItemHandle = (uint) (instance.ObjectInfo);
newInstance.ParentHandle = (uint) instance.ParentHandle;
newInstance.Layer = 0;//(uint) instance.Layer;
newInstance.Layer = 0;//(uint) (instance.Layer);
newInstances.Add(newInstance);
Logger.Log($"{instance.FrameItem.Name} - {i}");
// Logger.Log($"{instance.FrameItem.Name} - {i}");
}
}
@ -416,67 +201,72 @@ namespace CTFAK.MMFParser.Translation
}
newFrame.Events = new Events((ByteReader) null);//MFA.MFA.emptyEvents;
newFrame.Events.Items = new List<EventGroup>();
newFrame.Events.Objects=new List<EventObject>();
newFrame.Events._cache = MFA.MFA.emptyEvents._cache;
newFrame.Events._ifMFA = true;
newFrame.Events.Version = 1028;
// if (frame.Name == "anus")
if (frame.Events != null)
{
foreach (var item in newFrame.Items)
newFrame.Events = new Events((ByteReader) null); //MFA.MFA.emptyEvents;
newFrame.Events.Items = new List<EventGroup>();
newFrame.Events.Objects = new List<EventObject>();
newFrame.Events._cache = MFA.MFA.emptyEvents._cache;
newFrame.Events._ifMFA = true;
newFrame.Events.Version = 1028;
if (frame.Name == "jopajopaher")
{
var newObject = new EventObject((ByteReader) null);
newObject.Handle = (uint) item.Handle;
newObject.Name = item.Name ?? "";
newObject.TypeName = "";
newObject.ItemType = (ushort) item.ObjectType;
newObject.ObjectType = 1;
newObject.Flags = 0;
newObject.ItemHandle = (uint) item.Handle;
newObject.InstanceHandle = 0xFFFFFFFF;
newFrame.Events.Objects.Add(newObject);
}
foreach (EventGroup item in frame.Events.Items)
{
/*foreach (Action itemAction in item.Actions)
foreach (var item in newFrame.Items)
{
for (int a=0;a<itemAction.Items.Count;a++)
{
if (itemAction.Items[a].Loader is ExpressionParameter exp)
{
// itemAction.Items.Remove(itemAction.Items[a]);
}
else if (itemAction.Items[a].Loader is Sample)
{
itemAction.Items.Remove(itemAction.Items[a]);
}
}
var newObject = new EventObject((ByteReader) null);
newObject.Handle = (uint) item.Handle;
newObject.Name = item.Name ?? "";
newObject.TypeName = "";
newObject.ItemType = (ushort) item.ObjectType;
newObject.ObjectType = 1;
newObject.Flags = 0;
newObject.ItemHandle = (uint) item.Handle;
newObject.InstanceHandle = 0xFFFFFFFF;
newFrame.Events.Objects.Add(newObject);
}
foreach (Condition itemAction in item.Conditions)
foreach (EventGroup item in frame.Events.Items)
{
for (int a=0;a<itemAction.Items.Count;a++)
/*foreach (Action itemAction in item.Actions)
{
if (itemAction.Items[a].Loader is ExpressionParameter exp)
for (int a=0;a<itemAction.Items.Count;a++)
{
// itemAction.Items.Remove(itemAction.Items[a]);
if (itemAction.Items[a].Loader is ExpressionParameter exp)
{
// itemAction.Items.Remove(itemAction.Items[a]);
}
else if (itemAction.Items[a].Loader is Sample)
{
itemAction.Items.Remove(itemAction.Items[a]);
}
}
else if (itemAction.Items[a].Loader is Sample)
}
foreach (Condition itemAction in item.Conditions)
{
for (int a=0;a<itemAction.Items.Count;a++)
{
itemAction.Items.Remove(itemAction.Items[a]);
if (itemAction.Items[a].Loader is ExpressionParameter exp)
{
// itemAction.Items.Remove(itemAction.Items[a]);
}
else if (itemAction.Items[a].Loader is Sample)
{
itemAction.Items.Remove(itemAction.Items[a]);
}
}
}
}*/
newFrame.Events.Items.Add(item);
}*/
newFrame.Events.Items.Add(item);
}
}
}
newFrame.Chunks = new ChunkList(null);
mfa.Frames.Add(newFrame);
}
@ -539,6 +329,283 @@ namespace CTFAK.MMFParser.Translation
return alterables;
}
public static FrameItem TranslateObject(ObjectInfo item)
{
var newItem = new FrameItem(null);
newItem.Name = item.Name;
newItem.ObjectType = item.ObjectType;
newItem.Handle = item.Handle;
newItem.Transparent = item.Transparent ? 1 : 0;
newItem.InkEffect = item.InkEffect;
newItem.InkEffectParameter = item.InkEffectValue;
newItem.AntiAliasing = item.Antialias ? 1 : 0;
newItem.Flags = (int) item.Flags.flag; //32 TODO:Fix this
newItem.IconHandle = 12;
newItem.Chunks = new ChunkList(null);
if (item.ObjectType == 0)
{
var backdropLoader = (EXE.Loaders.Objects.Quickbackdrop) item.Properties.Loader;
var backdrop = new QuickBackdrop((ByteReader) null);
backdrop.ObstacleType = (uint) backdropLoader.ObstacleType;
backdrop.CollisionType = (uint) backdropLoader.CollisionType;
backdrop.Width = backdropLoader.Width;
backdrop.Height = backdropLoader.Height;
backdrop.Shape = backdropLoader.Shape.ShapeType;
backdrop.BorderSize = backdropLoader.Shape.BorderSize;
backdrop.FillType = backdropLoader.Shape.FillType;
backdrop.Color1 = backdropLoader.Shape.Color1;
backdrop.Color2 = backdropLoader.Shape.Color2;
backdrop.Flags = backdropLoader.Shape.GradFlags;
backdrop.Image = backdropLoader.Image;
newItem.Loader = backdrop;
}
else if (item.ObjectType == 1)
{
var backdropLoader = (EXE.Loaders.Objects.Backdrop) item.Properties.Loader;
var backdrop = new Backdrop((ByteReader) null);
backdrop.ObstacleType = (uint) backdropLoader.ObstacleType;
backdrop.CollisionType = (uint) backdropLoader.CollisionType;
backdrop.Handle = backdropLoader.Image;
newItem.Loader = backdrop;
}
else
{
var itemLoader = (ObjectCommon) item?.Properties?.Loader;
if (itemLoader == null) throw new NotImplementedException("Null loader");
Logger.Log("Translating Object: " + itemLoader.Parent.Name);
//CommonSection
var newObject = new ObjectLoader(null);
newObject.ObjectFlags = (int) (itemLoader?.Flags?.flag ?? 820);
newObject.NewObjectFlags = (int) (itemLoader?.NewFlags?.flag ?? 8);
newObject.BackgroundColor = Color.Black; //itemLoader.BackColor;
//newLoader.Qualifiers;
newObject.Strings = ConvertStrings(itemLoader.Strings);
newObject.Values = ConvertValue(itemLoader.Values);
newObject.Movements = new MFA.Loaders.mfachunks.Movements(null);
for (int j = 0; j < itemLoader.Movements.Items.Count; j++)
{
var mov = itemLoader.Movements.Items[j];
var newMov = new Movement(null);
newMov.Name = $"Movement #{j}";
newMov.Extension = "";
newMov.Identifier = 0; //(uint) mov.Type;
if (newMov.Identifier != 0) throw new Exception("Unknown Movement: " + newMov.Identifier);
newMov.Player = mov.Player;
newMov.MovingAtStart = mov.MovingAtStart;
newMov.DirectionAtStart = mov.DirectionAtStart;
newObject.Movements.Items.Add(newMov);
}
newObject.Behaviours = new Behaviours(null);
if (item.ObjectType == 2)
{
var active = new Active(null);
//Shit Section
{
active.ObjectFlags = newObject.ObjectFlags;
active.NewObjectFlags = newObject.NewObjectFlags;
active.BackgroundColor = newObject.BackgroundColor;
active.Strings = newObject.Strings;
active.Values = newObject.Values;
active.Movements = newObject.Movements;
active.Behaviours = newObject.Behaviours;
}
//TODO: Transitions
if (itemLoader.Animations != null)
{
var animHeader = itemLoader.Animations;
for (int j = 0; j < animHeader.AnimationDict.Count; j++)
{
var origAnim = animHeader.AnimationDict.ToArray()[j];
var newAnimation = new Animation(null);
newAnimation.Name = $"User Defined {j}";
var newDirections = new List<AnimationDirection>();
EXE.Loaders.Objects.Animation animation = null;
try
{
if (animHeader.AnimationDict.ContainsKey(origAnim.Key))
{
animation = animHeader.AnimationDict[origAnim.Key];
}
else break;
}
catch
{
}
if (animation != null)
{
if (animation.DirectionDict != null)
{
for (int n = 0; n < animation.DirectionDict.Count; n++)
{
var direction = animation.DirectionDict.ToArray()[n].Value;
var newDirection = new AnimationDirection(null);
newDirection.MinSpeed = direction.MinSpeed;
newDirection.MaxSpeed = direction.MaxSpeed;
newDirection.Index = n;
newDirection.Repeat = direction.Repeat;
newDirection.BackTo = direction.BackTo;
newDirection.Frames = direction.Frames;
newDirections.Add(newDirection);
}
}
else
{
}
newAnimation.Directions = newDirections;
}
active.Items.Add(j, newAnimation);
}
}
newItem.Loader = active;
}
if (item.ObjectType >= 32)
{
var newExt = new ExtensionObject(null);
{
newExt.ObjectFlags = newObject.ObjectFlags;
newExt.NewObjectFlags = newObject.NewObjectFlags;
newExt.BackgroundColor = newObject.BackgroundColor;
newExt.Strings = newObject.Strings;
newExt.Values = newObject.Values;
newExt.Movements = newObject.Movements;
newExt.Behaviours = newObject.Behaviours;
}
var exts = Exe.Instance.GameData.GameChunks.GetChunk<Extensions>();
Extension ext = null;
foreach (var testExt in exts.Items)
{
if (testExt.Handle == item.ObjectType - 32) ext = testExt;
}
newExt.ExtensionType = -1;
newExt.ExtensionName = "";
newExt.Filename = $"{ext.Name}.mfx";
newExt.Magic = (uint) ext.MagicNumber;
newExt.SubType = ext.SubType;
newExt.ExtensionVersion = itemLoader.ExtensionVersion;
newExt.ExtensionId = itemLoader.ExtensionId;
newExt.ExtensionPrivate = itemLoader.ExtensionPrivate;
newExt.ExtensionData = itemLoader.ExtensionData;
newItem.Loader = newExt;
var tuple = new Tuple<int, string, string, int, string>(ext.Handle, ext.Name, "",
ext.MagicNumber, ext.SubType);
// mfa.Extensions.Add(tuple);
}
else if (item.ObjectType == 3)
{
var text = itemLoader.Text;
var newText = new Text(null);
//Shit Section
{
newText.ObjectFlags = newObject.ObjectFlags;
newText.NewObjectFlags = newObject.NewObjectFlags;
newText.BackgroundColor = newObject.BackgroundColor;
newText.Strings = newObject.Strings;
newText.Values = newObject.Values;
newText.Movements = newObject.Movements;
newText.Behaviours = newObject.Behaviours;
}
newText.Width = (uint) text.Width;
newText.Height = (uint) text.Height;
var paragraph = text.Items[0];
newText.Font = paragraph.FontHandle;
newText.Color = paragraph.Color;
newText.Flags = 0;
newText.Items = new List<Paragraph>();
foreach (EXE.Loaders.Objects.Paragraph exePar in text.Items)
{
var newPar = new Paragraph((ByteReader) null);
newPar.Value = exePar.Value;
newPar.Flags = exePar.Flags.flag;
newText.Items.Add(newPar);
}
newItem.Loader = newText;
}
else if (item.ObjectType == 6)
{
var counter = itemLoader.Counters;
var lives = new Lives(null);
{
lives.ObjectFlags = newObject.ObjectFlags;
lives.NewObjectFlags = newObject.NewObjectFlags;
lives.BackgroundColor = newObject.BackgroundColor;
lives.Strings = newObject.Strings;
lives.Values = newObject.Values;
lives.Movements = newObject.Movements;
lives.Behaviours = newObject.Behaviours;
}
lives.Player = counter?.Player ?? 0;
lives.Images = counter?.Frames ?? new List<int>() {0};
lives.DisplayType = counter?.DisplayType ?? 0;
lives.Flags = counter?.Flags ?? 0;
lives.Font = counter?.Font ?? 0;
lives.Width = (int) (counter?.Width ?? 0);
lives.Height = (int) (counter?.Height ?? 0);
newItem.Loader = lives;
}
else if (item.ObjectType == 7)
{
var counter = itemLoader.Counters;
var newCount = new Counter(null);
{
newCount.ObjectFlags = newObject.ObjectFlags;
newCount.NewObjectFlags = newObject.NewObjectFlags;
newCount.BackgroundColor = newObject.BackgroundColor;
newCount.Strings = newObject.Strings;
newCount.Values = newObject.Values;
newCount.Movements = newObject.Movements;
newCount.Behaviours = newObject.Behaviours;
}
newCount.Value = itemLoader.Counter.Initial;
newCount.Maximum = itemLoader.Counter.Maximum;
newCount.Minimum = itemLoader.Counter.Minimum;
newCount.Images = new List<int>() {0};
if (counter == null)
{
newCount.DisplayType = 0;
newCount.CountType = 0;
newCount.Width = 0;
newCount.Height = 0;
newCount.Font = 0;
}
else
{
newCount.DisplayType = counter.DisplayType;
newCount.CountType = counter.Inverse ? 1 : 0;
newCount.Width = (int) counter.Width;
newCount.Height = (int) counter.Height;
newCount.Images = counter.Frames;
newCount.Font = counter.Font;
}
newCount.Color1 = Color.White;
newCount.Color2 = Color.White;
newCount.Flags = 0;
newCount.VerticalGradient = 0;
newItem.Loader = newCount;
}
}
return newItem;
}
public static void Message(string msg)
{

@ -32,7 +32,7 @@ namespace CTFAK
}
LoadableSettings.FromFile("settings.sav");
//
// MFAGenerator.WriteTestMFA();
// MFAGenerator.ReadTestMFA();
// Environment.Exit(0);
AppDomain.CurrentDomain.FirstChanceException += (sender, eventArgs) =>

@ -71,6 +71,7 @@ namespace CTFAK.Utils
public void WriteSingle(float value) => Write(value);
public void WriteBytes(byte[] value) => Write(value);
public void WriteDouble(double value) => Write(value);
public void WriteAscii(string value)

@ -1,6 +1,9 @@
using System;
using System.IO;
using System.IO.Compression;
using Joveler.Compression.ZLib;
using DeflateStream = System.IO.Compression.DeflateStream;
using GZipStream = Joveler.Compression.ZLib.GZipStream;
namespace CTFAK.Utils
{
@ -36,6 +39,19 @@ namespace CTFAK.Utils
Array.Resize<byte>(ref decompressedData, decompSize);
return decompressedData;
}
public static byte[] decompressOld(ByteReader reader, int size, int decompSize)
{
ZLibDecompressOptions decompOpts = new ZLibDecompressOptions();
MemoryStream compressedStream = new MemoryStream(reader.ReadBytes(size));
MemoryStream decompressedStream = new MemoryStream();
byte[] decompressedData = decompressedStream.GetBuffer();
// Trimming array to decompSize,
// because ZlibStream always pads to 0x100
Array.Resize<byte>(ref decompressedData, decompSize);
return decompressedData;
}
public static byte[] compress_block(byte[] data)

@ -2,7 +2,6 @@
<packages>
<package id="Be.Windows.Forms.HexBox" version="1.6.1" targetFramework="net472" />
<package id="DotNetZip" version="1.15.0" targetFramework="net472" />
<package id="Ionic.Zlib" version="1.9.1.5" targetFramework="net472" />
<package id="Joveler.Compression.ZLib" version="4.0.0" targetFramework="net472" />
<package id="Joveler.DynLoader" version="2.0.0" targetFramework="net472" />
<package id="Joveler.ZLibWrapper" version="1.3.1" targetFramework="net472" />
@ -12,4 +11,5 @@
<package id="System.Memory" version="4.5.4" targetFramework="net472" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.3" targetFramework="net472" />
<package id="zlib.net" version="1.0.4.0" targetFramework="net472" />
</packages>
Loading…
Cancel
Save