mirror of
https://github.com/sampletext32/ParkanPlayground.git
synced 2025-12-12 05:41:21 +04:00
parse binary varset file
This commit is contained in:
@@ -3,15 +3,23 @@ using Common;
|
|||||||
using MissionTmaLib.Parsing;
|
using MissionTmaLib.Parsing;
|
||||||
using NResLib;
|
using NResLib;
|
||||||
using ParkanPlayground;
|
using ParkanPlayground;
|
||||||
|
using VarsetLib;
|
||||||
|
|
||||||
// var cpDatEntryConverter = new CpDatEntryConverter();
|
// var cpDatEntryConverter = new CpDatEntryConverter();
|
||||||
// cpDatEntryConverter.Convert();
|
// cpDatEntryConverter.Convert();
|
||||||
|
|
||||||
var converter = new MshConverter();
|
// var converter = new MshConverter();
|
||||||
|
|
||||||
// converter.Convert("E:\\ParkanUnpacked\\fortif.rlb\\133_fr_m_bunker.msh");
|
// converter.Convert("E:\\ParkanUnpacked\\fortif.rlb\\133_fr_m_bunker.msh");
|
||||||
converter.Convert("C:\\Program Files (x86)\\Nikita\\Iron Strategy\\DATA\\MAPS\\SC_1\\Land.msh");
|
// converter.Convert("C:\\Program Files (x86)\\Nikita\\Iron Strategy\\DATA\\MAPS\\SC_1\\Land.msh");
|
||||||
// converter.Convert("E:\\ParkanUnpacked\\fortif.rlb\\73_fr_m_brige.msh");
|
// converter.Convert("E:\\ParkanUnpacked\\fortif.rlb\\73_fr_m_brige.msh");
|
||||||
// converter.Convert("E:\\ParkanUnpacked\\intsys.rlb\\277_MESH_o_pws_l_01.msh");
|
// converter.Convert("E:\\ParkanUnpacked\\intsys.rlb\\277_MESH_o_pws_l_01.msh");
|
||||||
// converter.Convert("E:\\ParkanUnpacked\\static.rlb\\2_MESH_s_stn_0_01.msh");
|
// converter.Convert("E:\\ParkanUnpacked\\static.rlb\\2_MESH_s_stn_0_01.msh");
|
||||||
// converter.Convert("E:\\ParkanUnpacked\\bases.rlb\\25_MESH_R_H_02.msh");
|
// converter.Convert("E:\\ParkanUnpacked\\bases.rlb\\25_MESH_R_H_02.msh");
|
||||||
|
|
||||||
|
|
||||||
|
var fs = new FileStream("E:\\ParkanUnpacked\\behpsp.res\\31_00 00 00 00_prof_generator.var", FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||||
|
|
||||||
|
var file = BinaryVarsetFileParser.Parse(fs);
|
||||||
|
|
||||||
|
_ = 5;
|
||||||
3
VarsetLib/BinaryVarsetFile.cs
Normal file
3
VarsetLib/BinaryVarsetFile.cs
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
namespace VarsetLib;
|
||||||
|
|
||||||
|
public record BinaryVarsetFile(int Count, List<BinaryVarsetItem> Items);
|
||||||
46
VarsetLib/BinaryVarsetFileParser.cs
Normal file
46
VarsetLib/BinaryVarsetFileParser.cs
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
using Common;
|
||||||
|
|
||||||
|
namespace VarsetLib;
|
||||||
|
|
||||||
|
public class BinaryVarsetFileParser
|
||||||
|
{
|
||||||
|
public static BinaryVarsetFile Parse(string path)
|
||||||
|
{
|
||||||
|
using FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||||
|
|
||||||
|
return Parse(fs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BinaryVarsetFile Parse(Stream fs)
|
||||||
|
{
|
||||||
|
var count = fs.ReadInt32LittleEndian();
|
||||||
|
|
||||||
|
var items = new List<BinaryVarsetItem>(count);
|
||||||
|
|
||||||
|
Span<byte> buf4 = stackalloc byte[4];
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
var magic1 = fs.ReadInt32LittleEndian();
|
||||||
|
fs.ReadExactly(buf4);
|
||||||
|
var magic2 = new IntFloatValue(buf4);
|
||||||
|
|
||||||
|
fs.ReadExactly(buf4);
|
||||||
|
var magic3 = new IntFloatValue(buf4);
|
||||||
|
var name = fs.ReadLengthPrefixedString();
|
||||||
|
var string2 = fs.ReadLengthPrefixedString();
|
||||||
|
|
||||||
|
fs.ReadExactly(buf4);
|
||||||
|
var magic4 = new IntFloatValue(buf4);
|
||||||
|
fs.ReadExactly(buf4);
|
||||||
|
var magic5 = new IntFloatValue(buf4);
|
||||||
|
fs.ReadExactly(buf4);
|
||||||
|
var magic6 = new IntFloatValue(buf4);
|
||||||
|
fs.ReadExactly(buf4);
|
||||||
|
var magic7 = new IntFloatValue(buf4);
|
||||||
|
|
||||||
|
items.Add(new BinaryVarsetItem(magic1, magic2, magic3, name, string2, magic4, magic5, magic6, magic7));
|
||||||
|
}
|
||||||
|
|
||||||
|
return new BinaryVarsetFile(count, items);
|
||||||
|
}
|
||||||
|
}
|
||||||
15
VarsetLib/BinaryVarsetItem.cs
Normal file
15
VarsetLib/BinaryVarsetItem.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
using Common;
|
||||||
|
|
||||||
|
namespace VarsetLib;
|
||||||
|
|
||||||
|
public record BinaryVarsetItem(
|
||||||
|
int Magic1, // length of something
|
||||||
|
IntFloatValue Magic2,
|
||||||
|
IntFloatValue Magic3,
|
||||||
|
string Name,
|
||||||
|
string String2,
|
||||||
|
IntFloatValue Magic4,
|
||||||
|
IntFloatValue Magic5,
|
||||||
|
IntFloatValue Magic6,
|
||||||
|
IntFloatValue Magic7
|
||||||
|
);
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Common\Common.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
Reference in New Issue
Block a user