Started working on events

master
1987kostya 5 years ago
parent 85d81098b0
commit d248c19715

@ -90,6 +90,23 @@
<ItemGroup>
<Compile Include="MMFParser\ChunkLoaders\AppMenu.cs" />
<Compile Include="MMFParser\ChunkLoaders\banks\DebugImageBank.cs" />
<Compile Include="MMFParser\ChunkLoaders\Events\Events.cs" />
<Compile Include="MMFParser\ChunkLoaders\Events\EventsParts.cs" />
<Compile Include="MMFParser\ChunkLoaders\Events\Parameters\Position.cs" />
<Compile Include="MMFParser\ChunkLoaders\Events\Parameters\Int.cs" />
<Compile Include="MMFParser\ChunkLoaders\Events\Parameters\GlobalValue.cs" />
<Compile Include="MMFParser\ChunkLoaders\Events\Parameters\ParameterCommon.cs" />
<Compile Include="MMFParser\ChunkLoaders\Events\Parameters\Float.cs" />
<Compile Include="MMFParser\ChunkLoaders\Events\Parameters\Every.cs" />
<Compile Include="MMFParser\ChunkLoaders\Events\Parameters\Sample.cs" />
<Compile Include="MMFParser\ChunkLoaders\Events\Parameters\Remark.cs" />
<Compile Include="MMFParser\ChunkLoaders\Events\Parameters\Colour.cs" />
<Compile Include="MMFParser\ChunkLoaders\Events\Parameters\Short.cs" />
<Compile Include="MMFParser\ChunkLoaders\Events\Parameters\AlterableValue.cs" />
<Compile Include="MMFParser\ChunkLoaders\Events\Parameters\Create.cs" />
<Compile Include="MMFParser\ChunkLoaders\Events\Parameters\Time.cs" />
<Compile Include="MMFParser\ChunkLoaders\Events\Parameters\ParamObject.cs" />
<Compile Include="MMFParser\ChunkLoaders\Globals.cs" />
<Compile Include="MMFParser\ChunkLoaders\ObjectInfo.cs" />
<Compile Include="MMFParser\ChunkLoaders\FrameItems.cs" />
<Compile Include="MMFParser\ChunkLoaders\ObjectNames.cs" />
@ -147,5 +164,8 @@
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<Folder Include="MMFParser\ChunkLoaders\Events\Expressions\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

@ -0,0 +1,160 @@
using NetMFAPatcher.chunkloaders;
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events
{
public class Events : ChunkLoader
{
public readonly string Header = "ER>>";
public readonly string EventCount = "ERes";
public readonly string EventgroupData = "ERev";
public readonly string End = "<<ER";
public int MaxObjects;
public int MaxObjectInfo;
public int NumberOfPlayers;
public List<Quailifer> QualifiersList = new List<Quailifer>();
public Quailifer[] Quailifers;
public List<int> NumberOfConditions = new List<int>();
public Events(Chunk chunk) : base(chunk) { }
public override void Print(bool ext)
{
throw new NotImplementedException();
}
public override void Read()
{
while(true)
{
var identifier = reader.ReadAscii(4);
if (identifier == Header)
{
MaxObjects = reader.ReadInt16();
MaxObjectInfo = reader.ReadInt16();
NumberOfPlayers = reader.ReadInt16();
for (int i = 0; i < 17; i++)
{
NumberOfConditions.Add(reader.ReadInt16());
}
var QualifierCount = reader.ReadInt16();//should be 0, so i dont give a fuck
Quailifers = new Quailifer[QualifierCount + 1];
for (int i = 0; i < QualifierCount; i++)
{
var NewQualifier = new Quailifer(reader);
QualifiersList.Add(NewQualifier);//fucking python types
//THIS IS NOT DONE
}
}
else if(identifier==EventCount)
{
var size = reader.ReadInt32();
}
else if(identifier==EventgroupData)
{
var size = reader.ReadInt32();
var end_position = reader.Tell() + size;
while(true)
{
var eg = new EventGroup(reader);
eg.Read();
}
}
}
}
}
public class Quailifer : ChunkLoader
{
public int objectInfo;
public int type;
public Quailifer qualifier;
List<int> Objects = new List<int>();
public Quailifer(Chunk chunk) : base(chunk) { }
public Quailifer(ByteIO reader) : base(reader) { }
public override void Print(bool ext)
{
throw new NotImplementedException();
}
public override void Read()
{
objectInfo = reader.ReadUInt16();
type = reader.ReadInt16();
qualifier = this;
}
}
public class EventGroup : ChunkLoader
{
public int Flags;
public int IsRestricted;
public int restrictCPT;
public int identifier;
public int undo;
public List<Condition> Conditions = new List<Condition>();
public List<Action> Actions = new List<Action>();
public EventGroup(Chunk chunk) : base(chunk) { }
public EventGroup(ByteIO reader) : base(reader) { }
public override void Print(bool ext)
{
throw new NotImplementedException();
}
public override void Read()
{
var currentPosition = reader.Tell();
var size = reader.ReadInt16() * -1;
var NumberOfConditions = reader.ReadByte();
var NumberOfActions = reader.ReadByte();
var flags = reader.ReadUInt16();
var nop = reader.ReadInt16();
IsRestricted = reader.ReadInt32();
restrictCPT = reader.ReadInt32();
for (int i = 0; i < NumberOfConditions; i++)
{
var item = new Condition(reader);
item.Read();
Conditions.Add(item);
}
for (int i = 0; i < NumberOfActions; i++)
{
var item = new Action(reader);
item.Read();
Actions.Add(item);
}
reader.Seek(currentPosition + size);
if(Conditions[0].items[0].loader!=null)
{
Logger.Log(Conditions[0].items[0].loader.ToString());
Console.ReadKey();
}
}
}
}

@ -0,0 +1,143 @@
using mmfparser;
using NetMFAPatcher.chunkloaders;
using NetMFAPatcher.MMFParser.Data;
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static NetMFAPatcher.mmfparser.Constants;
namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events
{
public class Condition : DataLoader
{
public int Flags;
public int OtherFlags;
public int DefType;
public int NumberOfParameters;
public ObjectType ObjectType;
public int num;
public int ObjectInfo;
public int Identifier;
public int ObjectInfoList;
public List<Parameter> items = new List<Parameter>();
public Condition(ByteIO reader) : base(reader) { }
public override void Print()
{
throw new NotImplementedException();
}
public override void Read()
{
var currentPosition = reader.Tell();
var size = reader.ReadUInt16();
ObjectType = (ObjectType)reader.ReadInt16();
num = reader.ReadInt16();
ObjectInfo = reader.ReadUInt16();
ObjectInfoList = reader.ReadInt16();
Flags = reader.ReadSByte();
OtherFlags = reader.ReadSByte();
NumberOfParameters = reader.ReadByte();
DefType = reader.ReadByte();
Identifier = reader.ReadInt16();
for (int i = 0; i < NumberOfParameters; i++)
{
var item = new Parameter(reader);
item.Read();
items.Add(item);
}
reader.Seek(currentPosition + size);
}
}
public class Action : DataLoader
{
public int Flags;
public int OtherFlags;
public int DefType;
public ObjectType ObjectType;
public int num;
public int ObjectInfo;
public int ObjectInfoList;
public List<Parameter> items = new List<Parameter>();
public Action(ByteIO reader) : base(reader) { }
public override void Print( )
{
throw new NotImplementedException();
}
public override void Read()
{
var currentPosition = reader.Tell();
var size = reader.ReadUInt16();
ObjectType = (ObjectType)reader.ReadInt16();
num = reader.ReadInt16();
ObjectInfo = reader.ReadUInt16();
ObjectInfoList = reader.ReadInt16();
Flags = reader.ReadSByte();
OtherFlags = reader.ReadSByte();
var number_of_parameters=reader.ReadByte();
DefType = reader.ReadByte();
for (int i = 0; i < DefType; i++)
{
var item = new Parameter(reader);
item.Read();
items.Add(item);
}
}
}
public class Parameter : DataLoader
{
public int Code;
public DataLoader loader;
public Parameter(ByteIO reader) : base(reader) { }
public override void Print()
{
throw new NotImplementedException();
}
public override void Read()
{
var current_position = reader.Tell();
var size = reader.ReadInt16();
Code = reader.ReadInt16();
Logger.Log(Code.ToString());
var ActualLoader = Helper.LoadParameter(Code,reader);
if(loader!=null)
{
this.loader = ActualLoader;
}
reader.Seek(current_position+size);
}
public object value
{
get
{
if(loader.GetType().GetField("value")!=null)
{
return loader.GetType().GetField("value").GetValue(loader);
}
else
{
return null;
}
}
}
public override string ToString()
{
if (value != null) return (string)value;
else return "UNKNOWN-PARAM";
}
}
}

@ -0,0 +1,23 @@
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
{
class AlterableValue : Short
{
public AlterableValue(ByteIO reader) : base(reader) { }
public override void Read()
{
base.Read();
}
public override string ToString()
{
return $"AlterableValue{Convert.ToChar(value).ToString().ToUpper()}";
}
}
}

@ -0,0 +1,24 @@
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
{
class Colour : ParameterCommon
{
public Color value;
public Colour(ByteIO reader) : base(reader) { }
public override void Read()
{
var bytes = reader.ReadBytes(4);
value = Color.FromArgb(bytes[0], bytes[1], bytes[2]);
}
}
}

@ -0,0 +1,31 @@
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
{
class Create : ParameterCommon
{
public int ObjectInstances;
public int ObjectInfo;
public Position Position;
public Create(ByteIO reader) : base(reader) { }
public override void Read()
{
Position = new Position(reader);
Position.Read();
ObjectInstances = reader.ReadUInt16();
ObjectInfo = reader.ReadUInt16();
}
public override string ToString()
{
return $"Create obj instance:{ObjectInstances} info:{ObjectInfo} pos:({Position.ToString()})";
}
}
}

@ -0,0 +1,28 @@
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
{
class Every : ParameterCommon
{
public int Delay;
public int Compteur;
public Every(ByteIO reader) : base(reader) { }
public override void Read()
{
Delay = reader.ReadInt32();
Compteur = reader.ReadInt32();
}
public override string ToString()
{
return $"Every {Delay/1000} sec";
}
}
}

@ -0,0 +1,25 @@
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
{
class Float : ParameterCommon
{
public float value;
public Float(ByteIO reader) : base(reader) { }
public override void Read()
{
value = reader.ReadSingle();
}
public override string ToString()
{
return $"{this.GetType().Name} value: {value}";
}
}
}

@ -0,0 +1,25 @@
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
{
class GlobalValue : Short
{
public GlobalValue(ByteIO reader) : base(reader) { }
public override void Read()
{
base.Read();
}
public override string ToString()
{
if(value>26) return $"GlobalValue{value}";
return $"GlobalValue{Convert.ToChar(value).ToString().ToUpper()}";
}
}
}

@ -0,0 +1,21 @@
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
{
class Int : Short
{
public Int(ByteIO reader) : base(reader) { }
public override void Read()
{
value = (short)reader.ReadInt32();
}
}
}

@ -0,0 +1,27 @@
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
{
class ParamObject : ParameterCommon
{
public int ObjectInfoList;
public int ObjectInfo;
public int ObjectType;
public ParamObject(ByteIO reader) : base(reader) { }
public override void Read()
{
ObjectInfoList = reader.ReadInt16();
ObjectInfo = reader.ReadUInt16();
ObjectType = reader.ReadInt16();
}
public override string ToString()
{
return $"Object {ObjectInfoList} {ObjectInfo} {ObjectType}";
}
}
}

@ -0,0 +1,27 @@
using mmfparser;
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
{
class ParameterCommon : DataLoader
{
public ParameterCommon(ByteIO reader) : base(reader) { }
public override void Print()
{
throw new NotImplementedException();
}
public override void Read()
{
}
}
}

@ -0,0 +1,44 @@
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
{
class Position : ParameterCommon
{
public int ObjectInfoParent;
public int Flags;
public int X;
public int Y;
public int Slope;
public int Angle;
public float Direction;
public int TypeParent;
public int ObjectInfoList;
public int Layer;
public Position(ByteIO reader) : base(reader) { }
public override void Read()
{
ObjectInfoParent = reader.ReadInt16();
Flags = reader.ReadUInt16();
X = reader.ReadInt16();
Y = reader.ReadInt16();
Slope = reader.ReadInt16();
Angle = reader.ReadInt16();
Direction = reader.ReadSingle();
TypeParent = reader.ReadInt16();
ObjectInfoList = reader.ReadInt16();
Layer = reader.ReadInt16();
}
public override string ToString()
{
return $"Object X:{X} Y:{Y} Angle:{Angle} Direction:{Direction} Parent:{ObjectInfoList}";
}
}
}

@ -0,0 +1,22 @@
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
{
class Remark : ParameterCommon
{
public Remark(ByteIO reader) : base(reader) { }
public override void Read()
{
//TODO
}
}
}

@ -0,0 +1,28 @@
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
{
class Sample : ParameterCommon
{
public int handle;
public string name;
public int flags;
public Sample(ByteIO reader) : base(reader) { }
public override void Read()
{
handle = reader.ReadInt16();
flags = reader.ReadUInt16();
name = reader.ReadWideString();
}
public override string ToString()
{
return $"Sample '{name}' handle: {handle}";
}
}
}

@ -0,0 +1,25 @@
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
{
class Short : ParameterCommon
{
public short value;
public Short(ByteIO reader) : base(reader) { }
public override void Read()
{
value = reader.ReadInt16();
}
public override string ToString()
{
return $"{this.GetType().Name} value: {value}";
}
}
}

@ -0,0 +1,28 @@
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters
{
class Time : ParameterCommon
{
public int Timer;
public int Loops;
public Time(ByteIO reader) : base(reader) { }
public override void Read()
{
Timer = reader.ReadInt32();
Loops = reader.ReadInt32();
Logger.Log($"Time time: {Timer} loops: {Loops}");
}
public override string ToString()
{
return $"Time time: {Timer} loops: {Loops}";
}
}
}

@ -0,0 +1,71 @@
using NetMFAPatcher.chunkloaders;
using NetMFAPatcher.mmfparser;
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.MMFParser.ChunkLoaders
{
public class GlobalValues : ChunkLoader
{
public List<float> items = new List<float>();
public GlobalValues(Chunk chunk) : base(chunk) { }
public override void Print(bool ext)
{
}
public override void Read()
{
var numberOfItems = reader.ReadUInt16();
var templist = new List<ByteIO>();
for (int i = 0; i < numberOfItems; i++)
{
templist.Add(new ByteIO(reader.ReadBytes(4)));
}
foreach (var item in templist)
{
var globalType = reader.ReadSByte();
float newGlobal = 0f;
if((Constants.ValueType)globalType==Constants.ValueType.Float)
{
newGlobal = item.ReadSingle();
}
else if ((Constants.ValueType)globalType == Constants.ValueType.Int)
{
newGlobal = item.ReadInt32();
}
else
{
throw new Exception("unknown global type");
}
items.Add(newGlobal);
}
}
}
public class GlobalStrings : ChunkLoader
{
public List<string> items = new List<string>();
public GlobalStrings(Chunk chunk) : base(chunk) { }
public override void Print(bool ext)
{
}
public override void Read()
{
var count = reader.ReadUInt32();
for (int i = 0; i < count; i++)
{
items.Add(reader.ReadAscii());
}
}
}
}

@ -1,5 +1,7 @@
using NetMFAPatcher.chunkloaders;
using NetMFAPatcher.mmfparser.chunkloaders;
using NetMFAPatcher.MMFParser.ChunkLoaders;
using NetMFAPatcher.MMFParser.ChunkLoaders.Events;
using NetMFAPatcher.utils;
using NetMFAPatcher.Utils;
using System;
@ -13,6 +15,7 @@ namespace NetMFAPatcher.MMFParser.Data
{
public List<Chunk> chunks = new List<Chunk>();
public bool verbose = false;
public List<Frame> Frames = new List<Frame>();
public void Read(ByteIO exeReader)
{
@ -27,7 +30,7 @@ namespace NetMFAPatcher.MMFParser.Data
{
if (chunk.loader.verbose)
{
chunk.loader.Print(Program.LogAll);
//chunk.loader.Print(Program.LogAll);
}
}
if (chunk.verbose)
@ -45,6 +48,11 @@ namespace NetMFAPatcher.MMFParser.Data
{
chunk.BuildKey();
}
if (chunk.id == 8755)
{
Console.WriteLine("Fisting Found");
Console.ReadKey();
}
if (chunk.id == 32639) break; //LAST chunkID
@ -227,6 +235,7 @@ namespace NetMFAPatcher.MMFParser.Data
break;
case 13107:
loader = new Frame(chunk);
Frames.Add((Frame)loader);
break;
case 13108:
loader = new FrameHeader(chunk);
@ -249,7 +258,15 @@ namespace NetMFAPatcher.MMFParser.Data
case 8788:
loader = new ObjectNames(chunk);
break;
case 8754:
loader = new GlobalValues(chunk);
break;
case 8755:
loader = new GlobalStrings(chunk);
break;
case 13117:
loader = new Events(chunk);
break;
}
if (loader != null)
@ -272,7 +289,7 @@ namespace NetMFAPatcher.MMFParser.Data
}
}
}
//Logger.Log($"ChunkLoader {typeof(T).Name} not found", true, ConsoleColor.Red);
return null; //I hope this wont happen
}
public T get_loader<T>(ChunkLoader loader) where T : ChunkLoader

@ -1,5 +1,7 @@
using NetMFAPatcher.chunkloaders;
using NetMFAPatcher.mmfparser;
using NetMFAPatcher.mmfparser.chunkloaders;
using NetMFAPatcher.MMFParser.ChunkLoaders;
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
@ -18,41 +20,135 @@ namespace NetMFAPatcher.MMFParser.Data
public int product_version;
public Products build;
public ChunkList gameChunks;
public void Read(ByteIO exeReader)
{
string magic = exeReader.ReadAscii(4);
public string Name;
public string Author;
public string Copyright;
public string aboutText;
public string Doc;
public string EditorFilename;
public string TargetFilename;
//public ExeOnly Exe_Only;
public AppMenu Menu;
public AppIcon Icon;
public AppHeader Header;
//public ExtentedHeader ExtHeader;
public FontBank Fonts;
public SoundBank Sounds;
public MusicBank Music;
public ImageBank Images;
public GlobalValues GValues;
public GlobalStrings GStrings;
public static FrameItems testItems;
//public Extensions Ext;
public FrameItems Frameitems;
public List<Frame> Frames = new List<Frame>();
if (magic == Constants.UNICODE_GAME_HEADER) Constants.isUnicode = true;
else if (magic == Constants.GAME_HEADER) Constants.isUnicode = false;
else
public void Read(ByteIO exeReader)
{
Logger.Log("Header Fucked Up", true, ConsoleColor.Red);
}
string magic = exeReader.ReadAscii(4); //Reading header
runtime_version = exeReader.ReadUInt16();
runtime_subversion = exeReader.ReadUInt16();
product_version = exeReader.ReadInt32();
product_build = exeReader.ReadInt32();
build = (Products)runtime_version;
//Checking for header
if (magic == Constants.UNICODE_GAME_HEADER) Constants.isUnicode = true;//PAMU
else if (magic == Constants.GAME_HEADER) Constants.isUnicode = false;//PAME
else Logger.Log("Header Fucked Up", true, ConsoleColor.Red);//Header not found
runtime_version = exeReader.ReadUInt16(); //
runtime_subversion = exeReader.ReadUInt16(); //0
product_version = exeReader.ReadInt32(); //CTF/MMF2/MMF1.5/CNC
product_build = exeReader.ReadInt32(); //CTF Build
build = (Products)runtime_version;
Print();
Logger.Log("Press any key to continue",true,ConsoleColor.Magenta);
//Print();
//Logger.Log("Press any key to continue", true, ConsoleColor.Magenta);
//Console.ReadKey();
gameChunks = new ChunkList();
gameChunks = new ChunkList(); //Reading game chunks
gameChunks.Read(exeReader);
//Load chunks into gamedata for easier access
if (gameChunks.get_chunk<AppName>() != null) Name = gameChunks.get_chunk<AppName>().value;
if (gameChunks.get_chunk<Copyright>() != null) Copyright = gameChunks.get_chunk<Copyright>().value;
if(gameChunks.get_chunk<AppAuthor>()!=null) Author = gameChunks.get_chunk<AppAuthor>().value;
if (gameChunks.get_chunk<EditorFilename>() != null) EditorFilename = gameChunks.get_chunk<EditorFilename>().value;
if (gameChunks.get_chunk<TargetFilename>() != null) TargetFilename = gameChunks.get_chunk<TargetFilename>().value;
if (gameChunks.get_chunk<AppMenu>() != null) Menu = gameChunks.get_chunk<AppMenu>();
if (gameChunks.get_chunk<AppHeader>() != null) Header = gameChunks.get_chunk<AppHeader>();
if (gameChunks.get_chunk<SoundBank>() != null) Sounds = gameChunks.get_chunk<SoundBank>();
if (gameChunks.get_chunk<MusicBank>() != null) Music = gameChunks.get_chunk<MusicBank>();
if (gameChunks.get_chunk<FontBank>() != null) Fonts = gameChunks.get_chunk<FontBank>();
if (gameChunks.get_chunk<ImageBank>() != null) Images = gameChunks.get_chunk<ImageBank>();
if (gameChunks.get_chunk<AppIcon>() != null) Icon = gameChunks.get_chunk<AppIcon>();
if (gameChunks.get_chunk<GlobalStrings>() != null) GStrings = gameChunks.get_chunk<GlobalStrings>();
if (gameChunks.get_chunk<GlobalValues>() != null) GValues = gameChunks.get_chunk<GlobalValues>();
if (gameChunks.get_chunk<FrameItems>() != null) Frameitems = gameChunks.get_chunk<FrameItems>();
Frames = gameChunks.Frames;
Print();
}
public void Print()
{
Logger.Log("GameData Info:", true, ConsoleColor.DarkGreen);
Logger.Log($"GameData Info:", true, ConsoleColor.DarkGreen);
Logger.Log($" Runtime Version: {runtime_version}", true, ConsoleColor.DarkGreen);
Logger.Log($" Runtime Subversion: { runtime_subversion}", true, ConsoleColor.DarkGreen);
Logger.Log($" Product Version: { product_version}", true, ConsoleColor.DarkGreen);
Logger.Log($" Product Version: { ((Products)product_version).ToString()}", true, ConsoleColor.DarkGreen);
Logger.Log($" Product Build: {product_build}", true, ConsoleColor.DarkGreen);
Logger.Log($" {(isUnicode ? "Unicode" : "NonUnicode")} Game", true, ConsoleColor.DarkGreen);
Logger.Log($"Game Info:", true, ConsoleColor.Cyan);
Logger.Log($" Name:{Name}", true, ConsoleColor.Cyan);
Logger.Log($" Author:{Author}", true, ConsoleColor.Cyan);
Logger.Log($" Copyright:{Copyright}", true, ConsoleColor.Cyan);
Logger.Log($" Editor Filename:{EditorFilename}", true, ConsoleColor.Cyan);
Logger.Log($" Target Filename:{TargetFilename}", true, ConsoleColor.Cyan);
Logger.Log($" Screen Resolution: {Header.windowWidth}x{Header.windowHeight}", true, ConsoleColor.Cyan);
Logger.Log($" Frame Count:{Header.numberOfFrames}", true, ConsoleColor.Cyan);
if (GStrings != null && GStrings.items.Count > 0)
{
Logger.Log($" Global Strings:", true, ConsoleColor.Cyan);
foreach (var item in GStrings.items)
{
Logger.Log($" {item}");
}
}
if (GValues != null && GValues.items.Count > 0)
{
Logger.Log($" Global Values:", true, ConsoleColor.Cyan);
foreach (var item in GValues.items)
{
Logger.Log($" {item.ToString()}");
}
}
if(Frames!=null&&Frames.Count>0)
{
Logger.Log("Frames: ", true, ConsoleColor.Cyan);
foreach (var item in Frames)
{
Logger.Log($" Frame: {item.name}, Size: {item.width}x{item.height}, Number of objects: {item.CountOfObjs}", true, ConsoleColor.Cyan);
}
}
}

@ -39,7 +39,7 @@ namespace NetMFAPatcher.utils
Marshal.FreeHGlobal(copyright);
Marshal.FreeHGlobal(pathfilename);
key = Key;
//key.Log(true, "X2");
key.Log(true, "X2");

@ -1,4 +1,8 @@
using NetMFAPatcher.chunkloaders;
using mmfparser;
using NetMFAPatcher.chunkloaders;
using NetMFAPatcher.mmfparser.mfaloaders;
using NetMFAPatcher.MMFParser.ChunkLoaders.Events.Parameters;
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
@ -51,6 +55,26 @@ namespace NetMFAPatcher
return Temp;
}
public static DataLoader LoadParameter(int code, ByteIO reader)
{
DataLoader item = null;
if(code==13)
{
item = new Every(reader);
}
if (code == 2)
{
item = new Time(reader);
}
if(item!=null) item.Read();
return item;
}

@ -13,10 +13,43 @@ namespace NetMFAPatcher.mmfparser
public static bool isUnicode;
public enum Products
{
MMF1,
MMF15,
MMF2,
CNC1
MMF1=1,
MMF15=2,
MMF2=3,
CNC1=0
}
public enum ValueType
{
Long=0,
Int=0,
String=1,
Float=2,
Double=2
}
public enum ObjectType
{
Player=-7,
Keyboard=-6,
Create=-5,
Timer=-4,
Game=-3,
Speaker=-2,
System=-1,
QuickBackdrop=0,
Backdrop=1,
Active=2,
Text=3,
Question=4,
Score=5,
Lives = 6,
Counter=7,
RTF=8,
SubApplication=9,
INI=33,
IniPp=32,
File=34,
TextEntry=35
}
public enum ChunkNames

@ -10,13 +10,13 @@ using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.chunkloaders
{
class AppHeader : ChunkLoader
public class AppHeader : ChunkLoader
{
int size;
int windowWidth;
int windowHeight;
int initialScore;
int initialLives;
public int size;
public int windowWidth;
public int windowHeight;
public int initialScore;
public int initialLives;
public int numberOfFrames;
@ -34,7 +34,7 @@ namespace NetMFAPatcher.chunkloaders
initialLives = (int) (reader.ReadUInt32() ^ 0xffffffff);
var controls = new Controls(reader);
controls.Read();
controls.Print(false);
// controls.Print(false);
var borderColor = reader.ReadBytes(4);
numberOfFrames = reader.ReadInt32();

@ -10,7 +10,7 @@ using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.mmfparser.chunkloaders
{
class AppMenu : ChunkLoader
public class AppMenu : ChunkLoader
{
public List<AppMenuItem> items = new List<AppMenuItem>();
public AppMenu(ByteIO reader) : base(reader)
@ -78,7 +78,7 @@ namespace NetMFAPatcher.mmfparser.chunkloaders
}
}
class AppMenuItem : ChunkLoader
public class AppMenuItem : ChunkLoader
{
public string name = "";
public int flags = 0;

@ -13,7 +13,7 @@ namespace NetMFAPatcher.chunkloaders
{
public Chunk chunk;
public ByteIO reader;
public bool verbose = true;
public bool verbose = false;
protected ChunkLoader(ByteIO reader)
{

@ -66,12 +66,12 @@ namespace NetMFAPatcher.chunkloaders
chunks.Read(FrameReader);
var name = chunks.get_chunk<FrameName>();
if (name != null)
if (name != null) //Just to be sure
{
this.name = name.value;
}
var password = chunks.get_chunk<FramePassword>();
if (password != null)
if (password != null) //Just to be sure
{
this.password = password.value;
}
@ -84,7 +84,6 @@ namespace NetMFAPatcher.chunkloaders
if(objects!=null)
{
CountOfObjs = objects.CountOfObjects;
}
@ -147,7 +146,7 @@ namespace NetMFAPatcher.chunkloaders
class ObjectInstances : ChunkLoader
{
public int CountOfObjects;
public int CountOfObjects=0;
public List<ObjectInstances> items = new List<ObjectInstances>();
public ObjectInstances(ByteIO reader) : base(reader)
@ -165,8 +164,9 @@ namespace NetMFAPatcher.chunkloaders
public override void Read()
{
return;
CountOfObjects = (int)reader.ReadUInt32();
return;
for (int i = 0; i < CountOfObjects; i++)
{
var item = new ObjectInstances(reader);

@ -1,4 +1,5 @@
using NetMFAPatcher.chunkloaders;
using NetMFAPatcher.MMFParser.Data;
using NetMFAPatcher.Utils;
using System;
using System.Collections.Generic;
@ -9,9 +10,9 @@ using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.mmfparser.chunkloaders
{
class FrameItems : ChunkLoader
public class FrameItems : ChunkLoader
{
public Dictionary<int, ObjectInfo> itemDict = new Dictionary<int, ObjectInfo>();
public Dictionary<int, ObjectInfo> ItemDict = new Dictionary<int, ObjectInfo>();
public List<string> names = new List<string>();
public FrameItems(Chunk chunk) : base(chunk) { }
public FrameItems(ByteIO reader) : base(reader) { }
@ -30,10 +31,11 @@ namespace NetMFAPatcher.mmfparser.chunkloaders
var item = new ObjectInfo(reader);
item.verbose = false;
item.Read();
itemDict.Add(item.handle, item);
ItemDict.Add(item.handle, item);
names.Add(item.name);
Logger.Log($"Found FrameItem: '{item.name}' with handle ({item.handle})", true, ConsoleColor.Magenta);
//Logger.Log($"Found FrameItem: '{item.name}' with handle ({item.handle})", true, ConsoleColor.Magenta);
}
GameData.testItems = this;
}
}

@ -7,7 +7,7 @@ using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.mmfparser.chunkloaders
{
class ObjectInfo : ChunkLoader
public class ObjectInfo : ChunkLoader
{
public List<Chunk> chunks = new List<Chunk>();
public int properties = 0;

@ -10,9 +10,9 @@ using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.chunkloaders
{
class FontBank : ChunkLoader
public class FontBank : ChunkLoader
{
int numberOfItems;
public int numberOfItems;
public override void Print(bool ext)
{
Logger.Log($"FontCount:{numberOfItems.ToString()}");

@ -14,7 +14,7 @@ using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.chunkloaders
{
class ImageBank : ChunkLoader
public class ImageBank : ChunkLoader
{
Dictionary<int, ImageItem> images = new Dictionary<int, ImageItem>();
public ImageBank(ByteIO reader) : base(reader)
@ -51,7 +51,7 @@ namespace NetMFAPatcher.chunkloaders
}
}
class ImageItem : ChunkLoader
public class ImageItem : ChunkLoader
{
public int handle;

@ -10,7 +10,7 @@ using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.chunkloaders
{
class MusicBank : ChunkLoader
public class MusicBank : ChunkLoader
{
public int num_of_items = 0;
public int references = 0;

@ -10,7 +10,7 @@ using static NetMFAPatcher.MMFParser.Data.ChunkList;
namespace NetMFAPatcher.chunkloaders
{
class SoundBank : ChunkLoader
public class SoundBank : ChunkLoader
{
public int num_of_items = 0;
public int references = 0;
@ -26,6 +26,7 @@ namespace NetMFAPatcher.chunkloaders
//Implementing for standalone-only because of my lazyness
items = new List<SoundItem>();
num_of_items = reader.ReadInt32();
return;
for (int i = 0; i < num_of_items; i++)
{
var item = new SoundItem(reader);

@ -8,7 +8,7 @@ using System.Threading.Tasks;
namespace NetMFAPatcher.mmfparser.mfaloaders
{
class ChunkList : DataLoader
class ChunkList : DataLoader//This is used for MFA reading/writing
{
List<DataLoader> items = new List<DataLoader>();
public override void Print()

Loading…
Cancel
Save