Skip to content

Commit

Permalink
Bug Fixes, New Features, DLLExport Updated Again and Unity Wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
marcussacana committed May 14, 2018
1 parent 8229d49 commit befce09
Show file tree
Hide file tree
Showing 56 changed files with 274 additions and 933 deletions.
40 changes: 40 additions & 0 deletions SRL.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,64 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SRLTracer", "SRLTracer\SRLT
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Overlay", "Overlay\Overlay.csproj", "{CD45A40D-D1FC-4236-AAFA-5708F312C68A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SRLUnity", "SRLUnity\SRLUnity.csproj", "{67389C64-0F78-4B09-B551-9E099345022E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{DAE58CAE-D595-450F-815B-36AFFCBFCE41}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DAE58CAE-D595-450F-815B-36AFFCBFCE41}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DAE58CAE-D595-450F-815B-36AFFCBFCE41}.Debug|x64.ActiveCfg = Debug|Any CPU
{DAE58CAE-D595-450F-815B-36AFFCBFCE41}.Debug|x64.Build.0 = Debug|Any CPU
{DAE58CAE-D595-450F-815B-36AFFCBFCE41}.Debug|x86.ActiveCfg = Debug|Any CPU
{DAE58CAE-D595-450F-815B-36AFFCBFCE41}.Debug|x86.Build.0 = Debug|Any CPU
{DAE58CAE-D595-450F-815B-36AFFCBFCE41}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DAE58CAE-D595-450F-815B-36AFFCBFCE41}.Release|Any CPU.Build.0 = Release|Any CPU
{DAE58CAE-D595-450F-815B-36AFFCBFCE41}.Release|x64.ActiveCfg = Release|Any CPU
{DAE58CAE-D595-450F-815B-36AFFCBFCE41}.Release|x64.Build.0 = Release|Any CPU
{DAE58CAE-D595-450F-815B-36AFFCBFCE41}.Release|x86.ActiveCfg = Release|Any CPU
{DAE58CAE-D595-450F-815B-36AFFCBFCE41}.Release|x86.Build.0 = Release|Any CPU
{CBDDEDF3-D5C9-4CAA-8FEC-D67A999891CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CBDDEDF3-D5C9-4CAA-8FEC-D67A999891CF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CBDDEDF3-D5C9-4CAA-8FEC-D67A999891CF}.Debug|x64.ActiveCfg = Debug|Any CPU
{CBDDEDF3-D5C9-4CAA-8FEC-D67A999891CF}.Debug|x64.Build.0 = Debug|Any CPU
{CBDDEDF3-D5C9-4CAA-8FEC-D67A999891CF}.Debug|x86.ActiveCfg = Debug|Any CPU
{CBDDEDF3-D5C9-4CAA-8FEC-D67A999891CF}.Debug|x86.Build.0 = Debug|Any CPU
{CBDDEDF3-D5C9-4CAA-8FEC-D67A999891CF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CBDDEDF3-D5C9-4CAA-8FEC-D67A999891CF}.Release|Any CPU.Build.0 = Release|Any CPU
{CBDDEDF3-D5C9-4CAA-8FEC-D67A999891CF}.Release|x64.ActiveCfg = Release|Any CPU
{CBDDEDF3-D5C9-4CAA-8FEC-D67A999891CF}.Release|x64.Build.0 = Release|Any CPU
{CBDDEDF3-D5C9-4CAA-8FEC-D67A999891CF}.Release|x86.ActiveCfg = Release|Any CPU
{CBDDEDF3-D5C9-4CAA-8FEC-D67A999891CF}.Release|x86.Build.0 = Release|Any CPU
{CD45A40D-D1FC-4236-AAFA-5708F312C68A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CD45A40D-D1FC-4236-AAFA-5708F312C68A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CD45A40D-D1FC-4236-AAFA-5708F312C68A}.Debug|x64.ActiveCfg = Debug|Any CPU
{CD45A40D-D1FC-4236-AAFA-5708F312C68A}.Debug|x64.Build.0 = Debug|Any CPU
{CD45A40D-D1FC-4236-AAFA-5708F312C68A}.Debug|x86.ActiveCfg = Debug|Any CPU
{CD45A40D-D1FC-4236-AAFA-5708F312C68A}.Debug|x86.Build.0 = Debug|Any CPU
{CD45A40D-D1FC-4236-AAFA-5708F312C68A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CD45A40D-D1FC-4236-AAFA-5708F312C68A}.Release|Any CPU.Build.0 = Release|Any CPU
{CD45A40D-D1FC-4236-AAFA-5708F312C68A}.Release|x64.ActiveCfg = Release|Any CPU
{CD45A40D-D1FC-4236-AAFA-5708F312C68A}.Release|x64.Build.0 = Release|Any CPU
{CD45A40D-D1FC-4236-AAFA-5708F312C68A}.Release|x86.ActiveCfg = Release|Any CPU
{CD45A40D-D1FC-4236-AAFA-5708F312C68A}.Release|x86.Build.0 = Release|Any CPU
{67389C64-0F78-4B09-B551-9E099345022E}.Debug|Any CPU.ActiveCfg = Debug|x86
{67389C64-0F78-4B09-B551-9E099345022E}.Debug|x64.ActiveCfg = Debug|x64
{67389C64-0F78-4B09-B551-9E099345022E}.Debug|x64.Build.0 = Debug|x64
{67389C64-0F78-4B09-B551-9E099345022E}.Debug|x86.ActiveCfg = Debug|x86
{67389C64-0F78-4B09-B551-9E099345022E}.Debug|x86.Build.0 = Debug|x86
{67389C64-0F78-4B09-B551-9E099345022E}.Release|Any CPU.ActiveCfg = Release|x86
{67389C64-0F78-4B09-B551-9E099345022E}.Release|x64.ActiveCfg = Release|x64
{67389C64-0F78-4B09-B551-9E099345022E}.Release|x64.Build.0 = Release|x64
{67389C64-0F78-4B09-B551-9E099345022E}.Release|x86.ActiveCfg = Release|x86
{67389C64-0F78-4B09-B551-9E099345022E}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
32 changes: 28 additions & 4 deletions SRL/Compiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,13 @@ internal static void CompileStrMap() {
Log("{0} Found, Importing, Database ID: {1}...", false, Path.GetFileName(TLMapSrc), DBAr.Count - 1);
}

SearchViolations(DBAr.ToArray(), CFak.ToArray());

var DBS = DBAr.ToArray();
var Ilegals = CFak.ToArray();
SearchViolations(DBS, Ilegals);

if (RemoveIlegals)
RemoveViolations(ref DBS, Ilegals);

Log("{0} Databases Generated.", true, DBAr.Count);

Expand All @@ -95,9 +101,9 @@ internal static void CompileStrMap() {
Log("Building String Reloads...");
SRLData3 Data = new SRLData3() {
Signature = "SRL3",
Databases = DBAr.ToArray(),
Databases = DBS,
OriLetters = COri.ToArray(),
MemoryLetters = CFak.ToArray(),
MemoryLetters = Ilegals,
UnkChars = UErr.ToArray(),
UnkReps = UOri.ToArray(),
RepOri = ROri.ToArray(),
Expand Down Expand Up @@ -132,7 +138,25 @@ private static void SearchViolations(SRLDatabase2[] DBS, char[] Ilegals) {
}
}
}

private static void RemoveViolations(ref SRLDatabase2[] DBS, char[] Ilegals) {
Log("Removing Chars Violations...", true);
List<string> Violations = new List<string>();
uint Removed = 0;
for (uint x = 0; x < DBS.LongLength; x++) {
SRLDatabase2 Database = DBS[x];
for (uint y = 0; y < Database.Replace.LongLength; y++) {
foreach (char Ilegal in Ilegals) {
int Len = Database.Replace[y].Length;
Database.Replace[y] = Database.Replace[y].Replace(Ilegal.ToString(), "");
Removed += (uint)(Len - Database.Replace[y].Length);
}
}
DBS[x] = Database;
}
Log("{0} Violations Removed", true, Removed);
}


/// <summary>
/// Load the String.srl Data
/// </summary>
Expand Down
26 changes: 16 additions & 10 deletions SRL/FileWorker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,20 @@ partial class StringReloader {
/// <param name="Path">Path to the LST file</param>
/// <param name="In">Original Lines</param>
/// <param name="Out">Target Lines</param>
static void ReadDump(string Path, ref List<string> In, ref List<string> Out, bool IgnoreOutput = true, bool IgnoreMask = false) {
static void ReadDump(string Path, ref List<string> In, ref List<string> Out, bool IgnoreOutput = false, bool IgnoreMask = false) {
using (TextReader Reader = File.OpenText(Path)) {
while (Reader.Peek() != -1) {
try {
string L1 = Reader.ReadLine().Replace(BreakLineFlag, "\n").Replace(ReturnLineFlag, "\r");
string L2 = Reader.ReadLine().Replace(BreakLineFlag, "\n").Replace(ReturnLineFlag, "\r");

if (IgnoreOutput) {
In.Add(L1);
continue;
}
if (L2 != L1 || (IgnoreMask && IsMask(L1))) {
if (IgnoreOutput || (!string.IsNullOrWhiteSpace(L2) && !In.Contains(L1))) {
if (!string.IsNullOrWhiteSpace(L2) && !In.Contains(L1)) {
In.Add(L1);
if (IgnoreOutput)
Out.Add(L2);
Out.Add(L2);
}
}
} catch (Exception ex){
Expand Down Expand Up @@ -114,6 +116,7 @@ private static void LoadConfig() {
NoTrim = false;
ReloadMaskParameters = false;
LiteMode = false;
RemoveIlegals = false;

SRLSettings Settings;
OverlaySettings OverlaySettings;
Expand Down Expand Up @@ -232,6 +235,11 @@ private static void LoadConfig() {
Warning("String Injection Disabled by User...");
}

if (Settings.RemoveViolations) {
RemoveIlegals = true;
Warning("Violation remover enabled, please, consider manual repair...");
}

if (OverlaySettings.Enable) {
OverlayEnabled = true;
ShowNonReloads = OverlaySettings.ShowNonReloaded;
Expand Down Expand Up @@ -439,7 +447,7 @@ static void DumpData(bool TLMode = false) {
if (File.Exists(CharMapSrc)) {
File.Delete(CharMapSrc);
}
SRLData2 Data = new SRLData2();
SRLData3 Data = new SRLData3();
StructReader Reader = new StructReader(TLMap);
Reader.ReadStruct(ref Data);
Reader.Close();
Expand All @@ -453,16 +461,14 @@ static void DumpData(bool TLMode = false) {
AppendLst(Str, TLMode ? Str : Data.Databases[0].Replace[i], TLMapSrc);
}
} else {
int ID = 1;
foreach (SRLDatabase DataBase in Data.Databases) {
foreach (SRLDatabase2 DataBase in Data.Databases) {
for (uint i = 0; i < DataBase.Original.LongLength; i++) {
string Str = DataBase.Original[i];
if (string.IsNullOrWhiteSpace(Str))
continue;

AppendLst(Str, TLMode ? Str : DataBase.Replace[i], string.Format(TLMapSrcMsk, ID));
AppendLst(Str, TLMode ? Str : DataBase.Replace[i], string.Format(TLMapSrcMsk, DataBase.Name));
}
ID++;
}
}

Expand Down
7 changes: 4 additions & 3 deletions SRL/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,18 @@ public static IntPtr Service(IntPtr hWnd, IntPtr hInst, IntPtr hCmdLine, int nCm
return IntPtr.Zero;
}

public static string ProcessManagerd(string Text) {
public static string ProcessManaged(string Text) {
Managed = true;
IntPtr Ptr = Marshal.StringToHGlobalAuto(Text);
IntPtr New = Process(Ptr);
Text = Marshal.PtrToStringAuto(New);
Marshal.FreeHGlobal(Ptr);
return Text;
}
public static char ProcessManagerd(char Char) {
public static char ProcessManaged(char Char) {
Managed = true;
return (char)(Process(new IntPtr(Char)).ToInt32() & 0xFFFF);
IntPtr Result = Process(new IntPtr(Char));
return (char)(Result.ToInt32() & 0xFFFF);
}
}
}
6 changes: 6 additions & 0 deletions SRL/Output.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ internal static void CheckArguments() {
CmdLineChecked = true;
string[] Commands = Environment.GetCommandLineArgs();

if (Ini.GetConfigStatus(CfgName, "WorkingDir;WorkDir;DataDir", IniPath) == Ini.ConfigStatus.Ok) {
CustomDir = Ini.GetConfig(CfgName, "WorkingDir;WorkDir;DataDir", IniPath, true);
if (!CustomDir.EndsWith("\\"))
CustomDir += '\\';
}

if (Ini.GetConfig(CfgName, "Debug", IniPath, false).ToLower() == "true")
AppendArray(ref Commands, "-debug");
if (Ini.GetConfig(CfgName, "Delay", IniPath, false).ToLower() == "true")
Expand Down
1 change: 1 addition & 0 deletions SRL/Reloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ static IntPtr ProcessChar(IntPtr CharInt) {
}

internal static dynamic ParsePtr(IntPtr IntPtr) {

if (Environment.Is64BitProcess)
return unchecked((ulong)IntPtr.ToInt64());
else
Expand Down
35 changes: 25 additions & 10 deletions SRL/SRL.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@
</TargetFrameworkProfile>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<DllExportNamespace>SRL</DllExportNamespace>
<DllExportDDNSCecil>false</DllExportDDNSCecil>
<DllExportSkipOnAnyCpu>false</DllExportSkipOnAnyCpu>
<DllExportOrdinalsBase>1</DllExportOrdinalsBase>
<DllExportGenExpLib>false</DllExportGenExpLib>
<DllExportOurILAsm>false</DllExportOurILAsm>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -51,9 +45,10 @@
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
</PropertyGroup>
<ItemGroup>
<Reference Include="DllExport, Version=1.5.2.30304, Culture=neutral, PublicKeyToken=8337224c9ad9e356, processorArchitecture=MSIL">
<HintPath>..\packages\DllExport.1.5.2\lib\net20\DllExport.dll</HintPath>
<Reference Include="DllExport, PublicKeyToken=8337224c9ad9e356">
<HintPath>$(SolutionDir)packages\DllExport.1.6.0\gcache\metalib\$(DllExportNamespace)\$(DllExportMetaLibName)</HintPath>
<Private>False</Private>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down Expand Up @@ -82,7 +77,6 @@
<Compile Include="Variables.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="SRL.ini">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand All @@ -97,5 +91,26 @@
<PreBuildEvent>
</PreBuildEvent>
</PropertyGroup>
<Import Project="../packages/DllExport.1.5.2/tools/net.r_eg.DllExport.targets" Condition="Exists('../packages/DllExport.1.5.2/tools/net.r_eg.DllExport.targets')" />
<PropertyGroup>
<DllExportIdent>7F7DF673-A44D-4629-B740-74D2223DF2E6</DllExportIdent>
<DllExportMetaLibName>DllExport.dll</DllExportMetaLibName>
<DllExportNamespace>SRL</DllExportNamespace>
<DllExportDDNSCecil>true</DllExportDDNSCecil>
<DllExportSkipOnAnyCpu>false</DllExportSkipOnAnyCpu>
<PlatformTarget>AnyCPU</PlatformTarget>
<DllExportOrdinalsBase>1</DllExportOrdinalsBase>
<DllExportGenExpLib>false</DllExportGenExpLib>
<DllExportOurILAsm>true</DllExportOurILAsm>
<DllExportLeaveIntermediateFiles>false</DllExportLeaveIntermediateFiles>
<DllExportTimeout>300000</DllExportTimeout>
<DllExportPeCheck>2</DllExportPeCheck>
</PropertyGroup>
<Import Project="$(SolutionDir)packages\DllExport.1.6.0\tools\net.r_eg.DllExport.targets" Condition="Exists('$(SolutionDir)packages\DllExport.1.6.0\tools\net.r_eg.DllExport.targets')" Label="8337224c9ad9e356" />
<Target Name="DllExportRestorePkg" BeforeTargets="PrepareForBuild">
<Warning Condition="!Exists('$(SolutionDir)DllExport.bat')" Text="We can't find 'DllExport.bat' in '$(SolutionDir)' - https://github.com/3F/DllExport" />
<Exec Condition="('$(DllExportModImported)' != 'true' Or !Exists('$(SolutionDir)packages\DllExport.1.6.0\tools\net.r_eg.DllExport.targets')) And Exists('$(SolutionDir)DllExport.bat')" Command="cd &quot;$(SolutionDir)&quot; &amp; DllExport.bat -action Restore" />
</Target>
<Target Name="DllExportRPkgDynamicImport" BeforeTargets="PostBuildEvent" DependsOnTargets="GetFrameworkPaths" Condition="'$(DllExportModImported)' != 'true' And '$(DllExportRPkgDyn)' != 'false'">
<MSBuild BuildInParallel="true" UseResultsCache="true" Projects="$(MSBuildProjectFullPath)" Properties="DllExportRPkgDyn=true" Targets="Build" />
</Target>
</Project>
1 change: 1 addition & 0 deletions SRL/SRL.ini
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ WorkingDir=StringReloader
ReloadMaskArgs=true
CustomCredits=
LiteMode=false
RemoveViolations=true

[WordWrap]
Enable=false
Expand Down
14 changes: 7 additions & 7 deletions SRL/StringWorker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,19 @@ internal static string MaskReplace(string Mask, string String, string Target) {
}

if (i == 0 && !String.StartsWith(M)) {
Error("Invalid Mask Replace Request\nM: {0}\nS: {1}", Mask, String);
Warning("Invalid Mask Replace Request\nM: {0}\nS: {1}", Mask, String);
return String;
}

int Skiped = x;
while (!String.Substring(x, String.Length - x).StartsWith(M)) {
if (++x >= String.Length) {
Error("Invalid Mask Replace Request\nM: {0}\nS: {1}", Mask, String);
Warning("Invalid Mask Replace Request\nM: {0}\nS: {1}", Mask, String);
return String;
}
}
if (i + 1 >= Source.LongLength && String.Substring(x, String.Length - x) != M) {
Error("Invalid Mask Replace Request\nM: {0}\nS: {1}", Mask, String);
Warning("Invalid Mask Replace Request\nM: {0}\nS: {1}", Mask, String);
return String;
}
if (x > Skiped) {
Expand Down Expand Up @@ -116,7 +116,7 @@ internal static string MaskReplace(string Mask, string String, string Target) {
object[] F = Format.ToArray();
if (Sort.Length != F.Length) {
//Not log as error because sometimes is just a bad input from the game.
Log("Invalid Mask Replace Request\nM: {0}\nS: {1}", true, Mask, String);
Warning("Invalid Mask Replace Request\nM: {0}\nS: {1}", true, Mask, String);
return String;
}
Array.Sort(Sort, F);
Expand Down Expand Up @@ -163,7 +163,7 @@ internal static string[] SplitMask(string String) {
while (i < String.Length && String[i] != '}')
i++;
if (i >= String.Length || String[i] != '}') {
Error("Bad String Format: \"{0}\"\nAt: {0}", String, o);
Warning("Bad String Format: \"{0}\"\nAt: {0}", String, o);
}

Strings.Add(Content);
Expand Down Expand Up @@ -194,15 +194,15 @@ internal static int[] MaskSort(string String) {
while (i < String.Length && String[i] != '}')
i++;
if (i >= String.Length || String[i] != '}') {
Error("Bad String Format: \"{0}\"\nAt: {0}", String, o);
Warning("Bad String Format: \"{0}\"\nAt: {0}", String, o);
}
o++;
string Str = String.Substring(o, i - o).Split(':')[0];
int ID = 0;
if (int.TryParse(Str, out ID))
IDS.Add(ID);
else
Error("Bad Mask Format, Invalid ID: {0}", Str);
Warning("Bad Mask Format, Invalid ID: {0}", Str);
continue;
}
}
Expand Down
3 changes: 3 additions & 0 deletions SRL/Types.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@ struct SRLSettings {

[FieldParmaters(DefaultValue = false, Name = "LiteMode;FastMode;CompatibiltyMode")]
public bool LiteMode;

[FieldParmaters(DefaultValue = false, Name = "RemoveIlegals;RemoveViolation;RemoveViolations;RemoveOutputViolation")]
public bool RemoveViolations;
}

[FieldParmaters(Name = "WordWrap")]
Expand Down
4 changes: 3 additions & 1 deletion SRL/Variables.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ struct Range {
static bool NoTrim = false;
static bool ReloadMaskParameters = false;
static bool LiteMode = false;

static bool RemoveIlegals = false;


static bool OverlayEnabled = false;
static bool OverlayInitialized = false;
static bool ShowNonReloads = false;
Expand Down
4 changes: 0 additions & 4 deletions SRL/packages.config

This file was deleted.

Loading

0 comments on commit befce09

Please sign in to comment.