-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
228 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,14 @@ | ||
# smupc | ||
Space Marine Locale Converter | ||
# Space Marine UPC converter | ||
Tool to decompress and compress UPC (\*.pc) files that contain locale texts. | ||
Resulting file (\*.locale) can be opened in text editor and edited. | ||
Be careful with spaces and tabs in the file, game accepts only original formatting. | ||
|
||
## Usage | ||
Tool requires .Net Framework 4.6.1 and DotNetZip. | ||
|
||
Available modes: | ||
- -p: default, packs all \*.locale files in current directory and its subdirs back into UPC | ||
- -pb: same as previous, but in big endian | ||
- -p src dest: packs \*.locale file from src back into UPC | ||
- -pb src dest: same as previous, but in big endian | ||
- -u src dest: unpacks UPC file from src to dest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.1.32228.430 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "smupc", "smupc\smupc.csproj", "{3BD9A44C-AC6C-41ED-B1D8-A2E6E9DD710F}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{3BD9A44C-AC6C-41ED-B1D8-A2E6E9DD710F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{3BD9A44C-AC6C-41ED-B1D8-A2E6E9DD710F}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{3BD9A44C-AC6C-41ED-B1D8-A2E6E9DD710F}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{3BD9A44C-AC6C-41ED-B1D8-A2E6E9DD710F}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {867418B4-EB44-4F93-8C4E-532797298B7F} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.Linq; | ||
using Ionic.Zlib; | ||
|
||
namespace smupc | ||
{ | ||
internal class Program | ||
{ | ||
public static void Unpack(string source, string dest) | ||
{ | ||
FileStream input = File.Open(source, FileMode.Open, FileAccess.Read); | ||
BinaryReader binaryReader = new BinaryReader(input); | ||
byte[] value = binaryReader.ReadBytes(4); | ||
byte[] compressed = binaryReader.ReadBytes((int)(binaryReader.BaseStream.Length - binaryReader.BaseStream.Position)); | ||
byte[] array = ZlibStream.UncompressBuffer(compressed); | ||
Debug.Assert(BitConverter.ToInt32(value, 0) == array.Length); | ||
File.WriteAllBytes(dest, array); | ||
} | ||
|
||
public static void Pack(string source, string dest, bool bigEndian) | ||
{ | ||
byte[] array = File.ReadAllBytes(source); | ||
byte[] collection = ZlibStream.CompressBuffer(array); | ||
byte[] source2 = BitConverter.GetBytes(array.Length); | ||
if (bigEndian) | ||
{ | ||
source2 = source2.Reverse().ToArray(); | ||
} | ||
List<byte> list = source2.ToList(); | ||
list.AddRange(collection); | ||
File.WriteAllBytes(dest, list.ToArray()); | ||
} | ||
|
||
public static void Pack(bool bigEndian) | ||
{ | ||
string searchPattern = "*.locale"; | ||
string[] files = Directory.GetFiles(Path.Combine(Directory.GetCurrentDirectory(), "data"), searchPattern, SearchOption.AllDirectories); | ||
string[] array = files; | ||
string[] array2 = array; | ||
foreach (string text in array2) | ||
{ | ||
string extension = Path.GetExtension(text); | ||
string str = Path.Combine(Path.GetDirectoryName(text), Path.GetFileNameWithoutExtension(text)); | ||
if (extension == ".locale") | ||
{ | ||
Pack(text, str + ".pc", bigEndian); | ||
} | ||
} | ||
} | ||
|
||
private static void Main(string[] args) | ||
{ | ||
string text = "-p"; | ||
if (args.Length >= 1) | ||
{ | ||
text = args[0]; | ||
} | ||
string text2 = null; | ||
string text3 = null; | ||
if (args.Length == 3) | ||
{ | ||
text2 = args[1]; | ||
text3 = args[2]; | ||
} | ||
int num; | ||
switch (text) | ||
{ | ||
case "-pb": | ||
if (text2 != null && text3 != null) | ||
{ | ||
Pack(text2, text3, bigEndian: true); | ||
} | ||
else | ||
{ | ||
Pack(bigEndian: true); | ||
} | ||
return; | ||
case "-p": | ||
if (text2 != null && text3 != null) | ||
{ | ||
Pack(text2, text3, bigEndian: false); | ||
} | ||
else | ||
{ | ||
Pack(bigEndian: false); | ||
} | ||
return; | ||
case "-u": | ||
num = ((args.Length == 3) ? 1 : 0); | ||
break; | ||
default: | ||
num = 0; | ||
break; | ||
} | ||
if (num != 0) | ||
{ | ||
Unpack(text2, text3); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System.Diagnostics; | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
using System.Runtime.Versioning; | ||
|
||
[assembly: CompilationRelaxations(8)] | ||
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] | ||
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] | ||
[assembly: AssemblyTitle("smupc")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("smupc")] | ||
[assembly: AssemblyCopyright("Copyright © 2019")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: ComVisible(false)] | ||
[assembly: Guid("3fa4bd77-2b19-4fff-b286-1367bc15f220")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] | ||
[assembly: AssemblyVersion("1.0.0.0")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<AssemblyName>smupc</AssemblyName> | ||
<GenerateAssemblyInfo>False</GenerateAssemblyInfo> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net461</TargetFramework> | ||
<Prefer32Bit>True</Prefer32Bit> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<LangVersion>Preview</LangVersion> | ||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="DotNetZip" Version="1.16.0" /> | ||
</ItemGroup> | ||
</Project> |