Skip to content

Commit

Permalink
Собирал ArtId в кучу. Возьмите Program.cs из прошлого коммита
Browse files Browse the repository at this point in the history
  • Loading branch information
iamkisly committed Aug 21, 2017
1 parent 255037e commit 745f8a4
Show file tree
Hide file tree
Showing 10 changed files with 154 additions and 83 deletions.
4 changes: 1 addition & 3 deletions DumpFacWalk/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ private static void DumpFile(string filename, StreamWriter w)
{
obj = new FacWalkReader(reader).Read();
}

w.WriteLine(new Export<FacWalk>(obj).GetText());

w.WriteLine(new Export<FacWalk>(obj).GetText());
}
}
}
68 changes: 50 additions & 18 deletions DumpMob/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Program

static void Main(string[] args)
{
args = new string[] { "G_6051CDAF_9BCF_4FE2_97C4_48F3ACB248AE.mob", @"E:\Новая папка (1)\workspace\proto_1" };
args = new string[] { "G_6051CDAF_9BCF_4FE2_97C4_48F3ACB248AE.mob", @"E:\Новая папка (1)\workspace\proto_1" };

if (args.Length != 1)
{
Expand All @@ -43,12 +43,13 @@ static void Main(string[] args)
obj.Header.filename = file;

ObjectConfig.ObjectList.Add (obj);
/*
Console.Write (file + " ");
Console.Write (obj.Header.ObjectId.ToString () + " ");
*/



Console.WriteLine((reader.BaseStream.Position == reader.BaseStream.Length).ToString() + " " + reader.BaseStream.Position.ToString() + " " + reader.BaseStream.Length.ToString());
//Console.WriteLine((reader.BaseStream.Position == reader.BaseStream.Length).ToString() + " " + reader.BaseStream.Position.ToString() + " " + reader.BaseStream.Length.ToString());

if (reader.BaseStream.Position != reader.BaseStream.Length) {
Console.WriteLine(" !!! not full reading !!!");
Expand All @@ -60,8 +61,8 @@ static void Main(string[] args)
}
}



DumpAllIn(path);
/*
if (Directory.Exists(path))
{
DumpAllIn(path);
Expand All @@ -75,26 +76,29 @@ static void Main(string[] args)
w.Close();
}
}

*/
Console.WriteLine("Done. Reading {0} object.", ObjRead);
Console.ReadKey();
File.WriteAllLines(@"E:\mob_decode_art.txt", TempleFileFormats.Utils.temp.list_art_id.Distinct().ToArray());
//Console.ReadKey();
}

private static void DumpAllIn(string dirname)
{
foreach (var file in Directory.EnumerateFiles(dirname, "*.mob", SearchOption.AllDirectories))
foreach (string file in File.ReadLines(@"E:\mob.txt", Encoding.GetEncoding("windows-1251")))
//foreach (var file in Directory.EnumerateFiles(dirname, "*.mob", SearchOption.AllDirectories))
{
using (var w1 = new StreamWriter(file + ".json", false, Encoding.UTF8, 8192))
//using (var w1 = new StreamWriter(file + ".json", false, Encoding.UTF8, 8192))
{
DumpFile(file, w1);
w1.Flush();
w1.Close();
DumpFile(file, null);
//w1.Flush();
//w1.Close();
}
}

}
}


private static void DumpFile(string filename, StreamWriter w)
private static void DumpFile(string filename, StreamWriter w)
{
ObjRead++;

Expand All @@ -103,12 +107,40 @@ private static void DumpFile(string filename, StreamWriter w)
{
obj = reader.GameObjectReader();
}

/*
Console.WriteLine("{0}", obj.Header.GameObjectType);
Console.WriteLine(" ObjectID {0}", obj.Header.ObjectId.ToString());
Console.WriteLine(" Proto_ID {0}", obj.Header.ProtoId.ToString());
Console.WriteLine("\n");
*/
/*
string[] dictionary = new string[] {
"obj_f_armor_paper_doll_aid",
"obj_f_current_aid",
"obj_f_light_aid",
"obj_f_shadow",
"obj_f_aid",
"obj_f_destroyed_aid",
"obj_f_critter_portrait",
"obj_f_item_inv_aid",
"obj_f_item_use_aid_fragment",
"obj_f_weapon_paper_doll_aid",
"obj_f_weapon_missile_aid",
"obj_f_weapon_visual_effect_aid"
};
foreach (var s in dictionary)
{
if(obj.GetType().GetProperty(s) != null)
{
ArtId o = (ArtId)GetPropValue(obj, s);
list_art_id.Add(o.path);
}
}
*/

/*
w.WriteLine(new Export<GameObject>(obj).GetText());
Expand All @@ -119,7 +151,7 @@ private static void DumpFile(string filename, StreamWriter w)
writer.Close ();
writer.Dispose ();
}

}
}
*/
}
}
}
14 changes: 12 additions & 2 deletions DumpSectors/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Program
private static int sectorsRead = 0;

static void Main(string[] args)
{
{ /*
if (args.Length != 1)
{
Console.WriteLine("Usage: DumpSector <sec-filename|directory>");
Expand All @@ -25,6 +25,8 @@ static void Main(string[] args)
// var filename = args[0];
var filename = "0.sec";
using (var w = new StreamWriter("sector.log", false, Encoding.UTF8, 8192))
{
Expand All @@ -37,7 +39,10 @@ static void Main(string[] args)
DumpFile(filename, w);
}
}
*/

DumpAllIn("", new StreamWriter("E:\\sector.log", false, Encoding.UTF8, 8192));
File.WriteAllLines(@"E:\sec_decode_art.txt", TempleFileFormats.Utils.temp.list_art_id.Distinct().ToArray());
Console.WriteLine("Done. Written {0} sectors to sector.log.", sectorsRead);
Console.ReadKey();

Expand All @@ -47,7 +52,12 @@ static void Main(string[] args)

private static void DumpAllIn(string filename, StreamWriter w)
{
foreach (var file in Directory.EnumerateFiles(filename, "*.sec", SearchOption.AllDirectories)) {
{
//DumpFile("e:\\Новая папка (1)\\virtualbox_share\\Arcanum Multiverse Edition\\DATS\\Arcanum\\maps\\Arcanum1-024-fixed\\68920804301.sec", w);
}
foreach (string file in File.ReadLines(@"E:\sec.txt", Encoding.GetEncoding("windows-1251"))) {
//foreach (var file in Directory.EnumerateFiles(filename, "*.sec", SearchOption.AllDirectories)) {

DumpFile(file, w);
}
}
Expand Down
1 change: 1 addition & 0 deletions TempleFileFormats/ArcanumFileFormats.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
<Compile Include="ObjectsNew\ObjectClass\Written.cs" />
<Compile Include="ObjectsNew\GameObjectHeader.cs" />
<Compile Include="Utils\OrderFields.cs" />
<Compile Include="Utils\temp.cs" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion TempleFileFormats/Maps/Sector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static uint GetSectorLoc(int x, int y)

public struct SectorTile
{
public byte[] Data { get; set; }
public UInt32 Data { get; set; }
}

public class SectorLight
Expand Down
23 changes: 11 additions & 12 deletions TempleFileFormats/Maps/SectorIo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,14 @@ public Sector ReadSector(BinaryReader reader)
reader.ReadInt32(); // Aptitude Adjustment
reader.ReadInt32(); // Light Scheme
reader.ReadBytes(12);// Sound List
reader.ReadBytes(512);
}
if (placeholder >= 0xAA0004)
{
reader.ReadBytes(512);
}
ReadObjects(reader, sector);

ReadObjects(reader, sector);
if (reader.BaseStream.Position + 4 != reader.BaseStream.Length) throw new Exception();

return sector;
}
Expand All @@ -99,7 +103,7 @@ private SectorLight ReadLight(BinaryReader reader)

// Read the basic light information first
result.Handle = handle;
result.Position = reader.ReadLocation();
result.Position = reader.ReadLocation_(true);
result.offset_X = reader.ReadInt32();
result.offset_Y = reader.ReadInt32();
result.FLAGS_0 = reader.ReadInt32();
Expand Down Expand Up @@ -143,7 +147,8 @@ private void ReadTiles(BinaryReader reader, SectorTile[] tiles)
{
for (int i = 0; i < tiles.Length; ++i)
{
tiles[i].Data = reader.ReadBytes(4);
tiles[i].Data = reader.ReadUInt32();
TempleFileFormats.Utils.temp.list_art_id.Add(tiles[i].Data.ToString("X2"));
}
}

Expand All @@ -162,8 +167,8 @@ private void SkipRoofList(BinaryReader reader)
private void ReadTileScripts(BinaryReader reader, Sector sector)
{
var count = reader.ReadInt32();

for (int i = 0; i < count; ++i)
//TODO: count > 0
for (int i = 0; i < count; ++i)
{
var script = new TileScript()
{
Expand Down Expand Up @@ -212,12 +217,6 @@ private void ReadObjects(BinaryReader reader, Sector sector)

for (var i = 0; i < count; ++i)
{
Console.Write(i.ToString() + " ->");
Console.WriteLine(reader.BaseStream.Position.ToString("X4"));
if(i == count -2)
{
Console.Read();
}
sector.Objects.Add(reader.GameObjectReader());
}
}
Expand Down
1 change: 0 additions & 1 deletion TempleFileFormats/NewMes/ArcText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ public bool DelEntry(int index)
protected int index = 0;
protected bool loaded = false;
protected int itemCount = 0;
private string temp;
}

}
15 changes: 6 additions & 9 deletions TempleFileFormats/ObjectsNew/GameObjectReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,33 +44,30 @@ orderby p.PropertyOrder()
if (readMethod.IsGenericMethod)
{
string generic_type_name = prop[i].PropertyType.FullName.Replace ("System.Tuple`2[[", "").Split (new char[]{ ',' })[0].Replace("[]","");
readMethod = readMethod.MakeGenericMethod (Type.GetType(generic_type_name));
readMethod = readMethod.MakeGenericMethod (Type.GetType(generic_type_name));
}


List<Object> parameters = new List<Object>() { reader };
/*
if (readMethod.GetParameters ().Length > 1) {
parameters.Add (false);
}
*/

if (g.Header.bitmap.Get (bit, g.Header.IsPrototype ()))
{
prop[i].SetValue(g.Obj, readMethod.Invoke (binary_reader, parameters.ToArray()));
}
else
{
if (prototype != null)
if (prototype != null && prototype.Header.GameObjectType.ToString() == gameobject_obj_type.ToString())
{
Type temp_type = prototype.Obj.GetType ();
PropertyInfo temp_property = temp_type.GetProperty (prop [i].Name);
Object temp_obj = temp_property.GetValue (prototype.Obj);
prop [i].SetValue (g.Obj, temp_obj);
//Console.Read ();
}
}
}
foreach (var p in props.Where(item => item.PropertyType.ToString() == "ArcanumFileFormats.Common.ArtId" && item.GetValue(g.Obj) != null).Select(item => ((ArtId)item.GetValue(g.Obj)).path))
{
TempleFileFormats.Utils.temp.list_art_id.Add(p);
}
return g;
}

Expand Down
Loading

0 comments on commit 745f8a4

Please sign in to comment.