Skip to content

Commit eacfc7e

Browse files
committed
Merge branch 'staging'
2 parents 806b313 + 92024ee commit eacfc7e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+10505
-4042
lines changed

AlienBML

CathodeLib/CathodeLib.csproj

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
<PackageId>CathodeLib</PackageId>
1010
<Authors>Matt Filer</Authors>
1111
<Description>Provides support for parsing and writing common Alien: Isolation formats from the Cathode engine.</Description>
12-
<Copyright>Matt Filer 2022</Copyright>
13-
<Version>0.2.0</Version>
12+
<Copyright>Matt Filer 2023</Copyright>
13+
<Version>0.3.0</Version>
1414
<OutputType>Library</OutputType>
15-
<AssemblyVersion>0.2.0.0</AssemblyVersion>
16-
<FileVersion>0.2.0.0</FileVersion>
15+
<AssemblyVersion>0.3.0.0</AssemblyVersion>
16+
<FileVersion>0.3.0.0</FileVersion>
1717
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
1818
</PropertyGroup>
1919

@@ -39,9 +39,7 @@
3939
</ItemGroup>
4040

4141
<ItemGroup>
42-
<Compile Include="..\AlienBML\AlienBML\AlienBML.cs" Link="Scripts\File Handlers\BML\AlienBML.cs" />
43-
<Compile Include="..\AlienBML\AlienBML\BML.cs" Link="Scripts\File Handlers\BML\BML.cs" />
44-
<Compile Include="..\AlienBML\AlienBML\BMLString.cs" Link="Scripts\File Handlers\BML\BMLString.cs" />
42+
<Compile Include="..\AlienBML\BML.cs" Link="Scripts\CATHODE\BML.cs" />
4543
</ItemGroup>
4644

4745
<ItemGroup>
@@ -73,8 +71,4 @@
7371
</EmbeddedResource>
7472
</ItemGroup>
7573

76-
<ItemGroup>
77-
<Folder Include="Scripts\File Handlers\BML\" />
78-
</ItemGroup>
79-
8074
</Project>
47 Bytes
Binary file not shown.

CathodeLib/Scripts/AlienLevel.cs

Lines changed: 0 additions & 108 deletions
This file was deleted.

CathodeLib/Scripts/AssetPAKs/AssetPAK.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ namespace CATHODE.Assets
66
{
77
public class AssetPAK
88
{
9-
protected string FilePathPAK = "";
10-
protected string FilePathBIN = "";
9+
protected string _filePathPAK = "";
10+
protected string _filePathBIN = "";
1111

1212
virtual public PAKReturnType Load() { return PAKReturnType.FAIL_FEATURE_IS_COMING_SOON; }
1313
virtual public List<string> GetFileNames() { return null; }
@@ -42,4 +42,17 @@ public enum PAKReturnType
4242
SUCCESS,
4343
SUCCESS_WITH_WARNINGS
4444
};
45+
46+
public enum FileIdentifiers
47+
{
48+
ASSET_FILE = 14,
49+
50+
SHADER_DATA = 3,
51+
MODEL_DATA = 19,
52+
TEXTURE_DATA = 45,
53+
54+
//From ABOUT.TXT (unsure where used)
55+
STRING_FILE_VERSION = 6,
56+
ENTITY_FILE_VERSION = 171,
57+
}
4558
}

CathodeLib/Scripts/AssetPAKs/Handlers/MaterialMapping.cs

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -17,65 +17,65 @@ namespace CATHODE.Assets
1717
*/
1818
public class MaterialMapping : AssetPAK
1919
{
20-
List<EntryMaterialMappingsPAK> MaterialMappingEntries = new List<EntryMaterialMappingsPAK>();
21-
byte[] FileHeaderJunk = new byte[8];
20+
List<EntryMaterialMappingsPAK> _entries = new List<EntryMaterialMappingsPAK>();
21+
byte[] _headerJunk = new byte[8];
2222

2323
/* Initialise the MaterialMapPAK class with the intended location (existing or not) */
2424
public MaterialMapping(string PathToPAK)
2525
{
26-
FilePathPAK = PathToPAK;
26+
_filePathPAK = PathToPAK;
2727
}
2828

2929
/* Load the contents of an existing MaterialMapPAK */
3030
public override PAKReturnType Load()
3131
{
32-
if (!File.Exists(FilePathPAK))
32+
if (!File.Exists(_filePathPAK))
3333
{
3434
return PAKReturnType.FAIL_TRIED_TO_LOAD_VIRTUAL_ARCHIVE;
3535
}
3636

3737
try
3838
{
3939
//Open PAK
40-
BinaryReader ArchiveFile = new BinaryReader(File.OpenRead(FilePathPAK));
40+
BinaryReader pak = new BinaryReader(File.OpenRead(_filePathPAK));
4141

4242
//Parse header
43-
FileHeaderJunk = ArchiveFile.ReadBytes(8); //TODO: Work out what this contains
44-
int NumberOfFiles = ArchiveFile.ReadInt32();
43+
_headerJunk = pak.ReadBytes(8); //TODO: Work out what this contains
44+
int entryCount = pak.ReadInt32();
4545

4646
//Parse entries (XML is broken in the build files - doesn't get shipped)
47-
for (int x = 0; x < NumberOfFiles; x++)
47+
for (int x = 0; x < entryCount; x++)
4848
{
4949
//This entry
50-
EntryMaterialMappingsPAK NewMatEntry = new EntryMaterialMappingsPAK();
51-
NewMatEntry.MapHeader = ArchiveFile.ReadBytes(4); //TODO: Work out the significance of this value, to be able to construct new PAKs from scratch.
52-
NewMatEntry.MapEntryCoupleCount = ArchiveFile.ReadInt32();
53-
NewMatEntry.MapJunk = ArchiveFile.ReadBytes(4); //TODO: Work out if this is always null.
54-
for (int p = 0; p < (NewMatEntry.MapEntryCoupleCount * 2) + 1; p++)
50+
EntryMaterialMappingsPAK entry = new EntryMaterialMappingsPAK();
51+
entry.MapHeader = pak.ReadBytes(4); //TODO: Work out the significance of this value, to be able to construct new PAKs from scratch.
52+
entry.MapEntryCoupleCount = pak.ReadInt32();
53+
entry.MapJunk = pak.ReadBytes(4); //TODO: Work out if this is always null.
54+
for (int p = 0; p < (entry.MapEntryCoupleCount * 2) + 1; p++)
5555
{
5656
//String
57-
int NewMatStringLength = ArchiveFile.ReadInt32();
58-
string NewMatString = "";
59-
for (int i = 0; i < NewMatStringLength; i++)
57+
int length = pak.ReadInt32();
58+
string materialString = "";
59+
for (int i = 0; i < length; i++)
6060
{
61-
NewMatString += ArchiveFile.ReadChar();
61+
materialString += pak.ReadChar();
6262
}
6363

6464
//First string is filename, others are materials
6565
if (p == 0)
6666
{
67-
NewMatEntry.MapFilename = NewMatString;
67+
entry.MapFilename = materialString;
6868
}
6969
else
7070
{
71-
NewMatEntry.MapMatEntries.Add(NewMatString);
71+
entry.MapMatEntries.Add(materialString);
7272
}
7373
}
74-
MaterialMappingEntries.Add(NewMatEntry);
74+
_entries.Add(entry);
7575
}
7676

7777
//Done!
78-
ArchiveFile.Close();
78+
pak.Close();
7979
return PAKReturnType.SUCCESS;
8080
}
8181
catch (IOException) { return PAKReturnType.FAIL_COULD_NOT_ACCESS_FILE; }
@@ -86,7 +86,7 @@ public override PAKReturnType Load()
8686
public override List<string> GetFileNames()
8787
{
8888
List<string> FileNameList = new List<string>();
89-
foreach (EntryMaterialMappingsPAK MapEntry in MaterialMappingEntries)
89+
foreach (EntryMaterialMappingsPAK MapEntry in _entries)
9090
{
9191
FileNameList.Add(MapEntry.MapFilename);
9292
}
@@ -97,7 +97,7 @@ public override List<string> GetFileNames()
9797
public override int GetFilesize(string FileName)
9898
{
9999
int size = 0;
100-
foreach (string MatMap in MaterialMappingEntries[GetFileIndex(FileName)].MapMatEntries)
100+
foreach (string MatMap in _entries[GetFileIndex(FileName)].MapMatEntries)
101101
{
102102
size += MatMap.Length;
103103
}
@@ -107,9 +107,9 @@ public override int GetFilesize(string FileName)
107107
/* Find the entry object by name */
108108
public override int GetFileIndex(string FileName)
109109
{
110-
for (int i = 0; i < MaterialMappingEntries.Count; i++)
110+
for (int i = 0; i < _entries.Count; i++)
111111
{
112-
if (MaterialMappingEntries[i].MapFilename == FileName || MaterialMappingEntries[i].MapFilename == FileName.Replace('/', '\\'))
112+
if (_entries[i].MapFilename == FileName || _entries[i].MapFilename == FileName.Replace('/', '\\'))
113113
{
114114
return i;
115115
}
@@ -124,7 +124,7 @@ public override PAKReturnType ReplaceFile(string PathToNewFile, string FileName)
124124
{
125125
//Pull the new mapping info from the import XML
126126
XDocument InputFile = XDocument.Load(PathToNewFile);
127-
EntryMaterialMappingsPAK MaterialMapping = MaterialMappingEntries[GetFileIndex(FileName)];
127+
EntryMaterialMappingsPAK MaterialMapping = _entries[GetFileIndex(FileName)];
128128
List<string> NewOverrides = new List<string>();
129129
foreach (XElement ThisMap in InputFile.Element("material_mappings").Elements())
130130
{
@@ -155,7 +155,7 @@ public override PAKReturnType ExportFile(string PathToExport, string FileName)
155155
XElement MaterialPair = XElement.Parse("<map><original arrow='false'></original><override arrow='false'></override></map>");
156156

157157
int ThisEntryNum = 0;
158-
EntryMaterialMappingsPAK ThisEntry = MaterialMappingEntries[GetFileIndex(FileName)];
158+
EntryMaterialMappingsPAK ThisEntry = _entries[GetFileIndex(FileName)];
159159
for (int i = 0; i < ThisEntry.MapEntryCoupleCount; i++)
160160
{
161161
for (int x = 0; x < 2; x++)
@@ -191,24 +191,24 @@ public override PAKReturnType Save()
191191
try
192192
{
193193
//Re-write out to the PAK
194-
BinaryWriter ArchiveWriter = new BinaryWriter(File.OpenWrite(FilePathPAK));
195-
ArchiveWriter.BaseStream.SetLength(0);
196-
ArchiveWriter.Write(FileHeaderJunk);
197-
ArchiveWriter.Write(MaterialMappingEntries.Count);
198-
foreach (EntryMaterialMappingsPAK ThisMatRemap in MaterialMappingEntries)
194+
BinaryWriter pak = new BinaryWriter(File.OpenWrite(_filePathPAK));
195+
pak.BaseStream.SetLength(0);
196+
pak.Write(_headerJunk);
197+
pak.Write(_entries.Count);
198+
foreach (EntryMaterialMappingsPAK entry in _entries)
199199
{
200-
ArchiveWriter.Write(ThisMatRemap.MapHeader);
201-
ArchiveWriter.Write(ThisMatRemap.MapEntryCoupleCount);
202-
ArchiveWriter.Write(ThisMatRemap.MapJunk);
203-
ArchiveWriter.Write(ThisMatRemap.MapFilename.Length);
204-
ExtraBinaryUtils.WriteString(ThisMatRemap.MapFilename, ArchiveWriter);
205-
foreach (string MaterialName in ThisMatRemap.MapMatEntries)
200+
pak.Write(entry.MapHeader);
201+
pak.Write(entry.MapEntryCoupleCount);
202+
pak.Write(entry.MapJunk);
203+
pak.Write(entry.MapFilename.Length);
204+
ExtraBinaryUtils.WriteString(entry.MapFilename, pak);
205+
foreach (string name in entry.MapMatEntries)
206206
{
207-
ArchiveWriter.Write(MaterialName.Length);
208-
ExtraBinaryUtils.WriteString(MaterialName, ArchiveWriter);
207+
pak.Write(name.Length);
208+
ExtraBinaryUtils.WriteString(name, pak);
209209
}
210210
}
211-
ArchiveWriter.Close();
211+
pak.Close();
212212

213213
return PAKReturnType.SUCCESS;
214214
}

0 commit comments

Comments
 (0)