Skip to content

Commit 745f8a4

Browse files
author
iamkisly
committed
Собирал ArtId в кучу. Возьмите Program.cs из прошлого коммита
1 parent 255037e commit 745f8a4

File tree

10 files changed

+154
-83
lines changed

10 files changed

+154
-83
lines changed

DumpFacWalk/Program.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,7 @@ private static void DumpFile(string filename, StreamWriter w)
6565
{
6666
obj = new FacWalkReader(reader).Read();
6767
}
68-
69-
w.WriteLine(new Export<FacWalk>(obj).GetText());
70-
68+
w.WriteLine(new Export<FacWalk>(obj).GetText());
7169
}
7270
}
7371
}

DumpMob/Program.cs

Lines changed: 50 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Program
2020

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

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

4545
ObjectConfig.ObjectList.Add (obj);
46+
/*
4647
Console.Write (file + " ");
4748
Console.Write (obj.Header.ObjectId.ToString () + " ");
49+
*/
4850

4951

50-
51-
Console.WriteLine((reader.BaseStream.Position == reader.BaseStream.Length).ToString() + " " + reader.BaseStream.Position.ToString() + " " + reader.BaseStream.Length.ToString());
52+
//Console.WriteLine((reader.BaseStream.Position == reader.BaseStream.Length).ToString() + " " + reader.BaseStream.Position.ToString() + " " + reader.BaseStream.Length.ToString());
5253

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

63-
64-
64+
DumpAllIn(path);
65+
/*
6566
if (Directory.Exists(path))
6667
{
6768
DumpAllIn(path);
@@ -75,26 +76,29 @@ static void Main(string[] args)
7576
w.Close();
7677
}
7778
}
78-
79+
*/
7980
Console.WriteLine("Done. Reading {0} object.", ObjRead);
80-
Console.ReadKey();
81+
File.WriteAllLines(@"E:\mob_decode_art.txt", TempleFileFormats.Utils.temp.list_art_id.Distinct().ToArray());
82+
//Console.ReadKey();
8183
}
8284

8385
private static void DumpAllIn(string dirname)
8486
{
85-
foreach (var file in Directory.EnumerateFiles(dirname, "*.mob", SearchOption.AllDirectories))
87+
foreach (string file in File.ReadLines(@"E:\mob.txt", Encoding.GetEncoding("windows-1251")))
88+
//foreach (var file in Directory.EnumerateFiles(dirname, "*.mob", SearchOption.AllDirectories))
8689
{
87-
using (var w1 = new StreamWriter(file + ".json", false, Encoding.UTF8, 8192))
90+
//using (var w1 = new StreamWriter(file + ".json", false, Encoding.UTF8, 8192))
8891
{
89-
DumpFile(file, w1);
90-
w1.Flush();
91-
w1.Close();
92+
DumpFile(file, null);
93+
//w1.Flush();
94+
//w1.Close();
9295
}
9396
}
9497

95-
}
98+
}
99+
96100

97-
private static void DumpFile(string filename, StreamWriter w)
101+
private static void DumpFile(string filename, StreamWriter w)
98102
{
99103
ObjRead++;
100104

@@ -103,12 +107,40 @@ private static void DumpFile(string filename, StreamWriter w)
103107
{
104108
obj = reader.GameObjectReader();
105109
}
106-
110+
/*
107111
Console.WriteLine("{0}", obj.Header.GameObjectType);
108112
Console.WriteLine(" ObjectID {0}", obj.Header.ObjectId.ToString());
109113
Console.WriteLine(" Proto_ID {0}", obj.Header.ProtoId.ToString());
110114
Console.WriteLine("\n");
115+
*/
116+
/*
117+
string[] dictionary = new string[] {
118+
"obj_f_armor_paper_doll_aid",
119+
"obj_f_current_aid",
120+
"obj_f_light_aid",
121+
"obj_f_shadow",
122+
"obj_f_aid",
123+
"obj_f_destroyed_aid",
124+
"obj_f_critter_portrait",
125+
"obj_f_item_inv_aid",
126+
"obj_f_item_use_aid_fragment",
127+
"obj_f_weapon_paper_doll_aid",
128+
"obj_f_weapon_missile_aid",
129+
"obj_f_weapon_visual_effect_aid"
130+
};
131+
132+
foreach (var s in dictionary)
133+
{
134+
if(obj.GetType().GetProperty(s) != null)
135+
{
136+
ArtId o = (ArtId)GetPropValue(obj, s);
137+
list_art_id.Add(o.path);
138+
}
139+
}
140+
141+
*/
111142

143+
/*
112144
w.WriteLine(new Export<GameObject>(obj).GetText());
113145
114146
@@ -119,7 +151,7 @@ private static void DumpFile(string filename, StreamWriter w)
119151
writer.Close ();
120152
writer.Dispose ();
121153
}
122-
123-
}
124-
}
154+
*/
155+
}
156+
}
125157
}

DumpSectors/Program.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Program
1616
private static int sectorsRead = 0;
1717

1818
static void Main(string[] args)
19-
{
19+
{ /*
2020
if (args.Length != 1)
2121
{
2222
Console.WriteLine("Usage: DumpSector <sec-filename|directory>");
@@ -25,6 +25,8 @@ static void Main(string[] args)
2525
// var filename = args[0];
2626
var filename = "0.sec";
2727
28+
29+
2830
using (var w = new StreamWriter("sector.log", false, Encoding.UTF8, 8192))
2931
{
3032
@@ -37,7 +39,10 @@ static void Main(string[] args)
3739
DumpFile(filename, w);
3840
}
3941
}
42+
*/
4043

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

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

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

TempleFileFormats/ArcanumFileFormats.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@
125125
<Compile Include="ObjectsNew\ObjectClass\Written.cs" />
126126
<Compile Include="ObjectsNew\GameObjectHeader.cs" />
127127
<Compile Include="Utils\OrderFields.cs" />
128+
<Compile Include="Utils\temp.cs" />
128129
</ItemGroup>
129130
<ItemGroup />
130131
<ItemGroup>

TempleFileFormats/Maps/Sector.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public static uint GetSectorLoc(int x, int y)
3939

4040
public struct SectorTile
4141
{
42-
public byte[] Data { get; set; }
42+
public UInt32 Data { get; set; }
4343
}
4444

4545
public class SectorLight

TempleFileFormats/Maps/SectorIo.cs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,14 @@ public Sector ReadSector(BinaryReader reader)
7171
reader.ReadInt32(); // Aptitude Adjustment
7272
reader.ReadInt32(); // Light Scheme
7373
reader.ReadBytes(12);// Sound List
74-
reader.ReadBytes(512);
7574
}
75+
if (placeholder >= 0xAA0004)
76+
{
77+
reader.ReadBytes(512);
78+
}
79+
ReadObjects(reader, sector);
7680

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

7983
return sector;
8084
}
@@ -99,7 +103,7 @@ private SectorLight ReadLight(BinaryReader reader)
99103

100104
// Read the basic light information first
101105
result.Handle = handle;
102-
result.Position = reader.ReadLocation();
106+
result.Position = reader.ReadLocation_(true);
103107
result.offset_X = reader.ReadInt32();
104108
result.offset_Y = reader.ReadInt32();
105109
result.FLAGS_0 = reader.ReadInt32();
@@ -143,7 +147,8 @@ private void ReadTiles(BinaryReader reader, SectorTile[] tiles)
143147
{
144148
for (int i = 0; i < tiles.Length; ++i)
145149
{
146-
tiles[i].Data = reader.ReadBytes(4);
150+
tiles[i].Data = reader.ReadUInt32();
151+
TempleFileFormats.Utils.temp.list_art_id.Add(tiles[i].Data.ToString("X2"));
147152
}
148153
}
149154

@@ -162,8 +167,8 @@ private void SkipRoofList(BinaryReader reader)
162167
private void ReadTileScripts(BinaryReader reader, Sector sector)
163168
{
164169
var count = reader.ReadInt32();
165-
166-
for (int i = 0; i < count; ++i)
170+
//TODO: count > 0
171+
for (int i = 0; i < count; ++i)
167172
{
168173
var script = new TileScript()
169174
{
@@ -212,12 +217,6 @@ private void ReadObjects(BinaryReader reader, Sector sector)
212217

213218
for (var i = 0; i < count; ++i)
214219
{
215-
Console.Write(i.ToString() + " ->");
216-
Console.WriteLine(reader.BaseStream.Position.ToString("X4"));
217-
if(i == count -2)
218-
{
219-
Console.Read();
220-
}
221220
sector.Objects.Add(reader.GameObjectReader());
222221
}
223222
}

TempleFileFormats/NewMes/ArcText.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ public bool DelEntry(int index)
140140
protected int index = 0;
141141
protected bool loaded = false;
142142
protected int itemCount = 0;
143-
private string temp;
144143
}
145144

146145
}

TempleFileFormats/ObjectsNew/GameObjectReader.cs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,33 +44,30 @@ orderby p.PropertyOrder()
4444
if (readMethod.IsGenericMethod)
4545
{
4646
string generic_type_name = prop[i].PropertyType.FullName.Replace ("System.Tuple`2[[", "").Split (new char[]{ ',' })[0].Replace("[]","");
47-
readMethod = readMethod.MakeGenericMethod (Type.GetType(generic_type_name));
47+
readMethod = readMethod.MakeGenericMethod (Type.GetType(generic_type_name));
4848
}
4949

50-
5150
List<Object> parameters = new List<Object>() { reader };
52-
/*
53-
if (readMethod.GetParameters ().Length > 1) {
54-
parameters.Add (false);
55-
}
56-
*/
5751

5852
if (g.Header.bitmap.Get (bit, g.Header.IsPrototype ()))
5953
{
6054
prop[i].SetValue(g.Obj, readMethod.Invoke (binary_reader, parameters.ToArray()));
6155
}
6256
else
6357
{
64-
if (prototype != null)
58+
if (prototype != null && prototype.Header.GameObjectType.ToString() == gameobject_obj_type.ToString())
6559
{
6660
Type temp_type = prototype.Obj.GetType ();
6761
PropertyInfo temp_property = temp_type.GetProperty (prop [i].Name);
6862
Object temp_obj = temp_property.GetValue (prototype.Obj);
6963
prop [i].SetValue (g.Obj, temp_obj);
70-
//Console.Read ();
7164
}
7265
}
7366
}
67+
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))
68+
{
69+
TempleFileFormats.Utils.temp.list_art_id.Add(p);
70+
}
7471
return g;
7572
}
7673

0 commit comments

Comments
 (0)