Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
aff1620286
8536
Assets/mappings.jsonc
Normal file
8536
Assets/mappings.jsonc
Normal file
File diff suppressed because it is too large
Load Diff
201
Assets/tempData.json
Normal file
201
Assets/tempData.json
Normal file
File diff suppressed because one or more lines are too long
@ -1,4 +1,3 @@
|
||||
|
||||
[
|
||||
{"Role":"assault","Limit":2,"Difficulty":"easy"},
|
||||
{"Role":"assault","Limit":2,"Difficulty":"normal"},
|
||||
@ -35,5 +34,6 @@
|
||||
{"Role":"bossKojaniy","Limit":2,"Difficulty":"normal"},
|
||||
{"Role":"followerKojaniy","Limit":2,"Difficulty":"normal"},
|
||||
{"Role":"skier","Limit":2,"Difficulty":"normal"},
|
||||
{"Role":"peacemaker","Limit":2,"Difficulty":"normal"}
|
||||
]
|
||||
{"Role":"peacemaker","Limit":2,"Difficulty":"normal"},
|
||||
{"Role":"bossPartisan","Limit":2,"Difficulty":"normal"}
|
||||
]
|
12
DumpLib/DUMPDATA/endRaid.json
Normal file
12
DumpLib/DUMPDATA/endRaid.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"profile": null,
|
||||
"result": "Left",
|
||||
"killerId": null,
|
||||
"killerAid": null,
|
||||
"exitName": null,
|
||||
"inSession": true,
|
||||
"favorite": false,
|
||||
"playTime": 33,
|
||||
"InsuredItems": [],
|
||||
"ProfileId": ""
|
||||
}
|
30
DumpLib/DUMPDATA/raidConfig.json
Normal file
30
DumpLib/DUMPDATA/raidConfig.json
Normal file
@ -0,0 +1,30 @@
|
||||
{
|
||||
"keyId": null,
|
||||
"location": "Interchange",
|
||||
"timeVariant": "CURR",
|
||||
"metabolismDisabled": false,
|
||||
"timeAndWeatherSettings": {
|
||||
"isRandomTime": false,
|
||||
"isRandomWeather": false,
|
||||
"cloudinessType": "Clear",
|
||||
"rainType": "NoRain",
|
||||
"windType": "Light",
|
||||
"fogType": "NoFog",
|
||||
"timeFlowType": "x1",
|
||||
"hourOfDay": -1
|
||||
},
|
||||
"botSettings": {
|
||||
"isScavWars": false,
|
||||
"botAmount": "AsOnline"
|
||||
},
|
||||
"wavesSettings": {
|
||||
"botAmount": "AsOnline",
|
||||
"botDifficulty": "AsOnline",
|
||||
"isBosses": true,
|
||||
"isTaggedAndCursed": false
|
||||
},
|
||||
"side": "Pmc",
|
||||
"raidMode": "Local",
|
||||
"playersSpawnPlace": "SamePlace",
|
||||
"CanShowGroupPreview": true
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"serverId": null,
|
||||
"location": "Lighthouse",
|
||||
"location": "Interchange",
|
||||
"timeVariant": "CURR",
|
||||
"mode": "PVE_OFFLINE",
|
||||
"mode": "TRAINING",
|
||||
"playerSide": "Pmc"
|
||||
}
|
@ -23,5 +23,11 @@
|
||||
<None Update="DUMPDATA\raidSettings.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="DUMPDATA\endRaid.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="DUMPDATA\raidConfig.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
@ -7,295 +7,185 @@ namespace DumpLib
|
||||
{
|
||||
public static class DumpyTool
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public static string DumpDataPath = (Directory.GetCurrentDirectory() + "\\DUMPDATA\\").Replace("\\\\", "\\");
|
||||
|
||||
public static SptConfigClass ConfigSettings = (SptConfigClass)GetSptConfig();
|
||||
|
||||
/// <summary>
|
||||
/// always start from 1 as their iterations are 1 to 6
|
||||
/// </summary>
|
||||
public static int Iteration = 1;
|
||||
|
||||
/// <summary>
|
||||
/// <para>Method to create a "combined" Type that takes a GenericType</para>
|
||||
/// <para>Example: ClientApplication + GInterface145 = ClientApplication(GInterface145)</para>
|
||||
/// </summary>
|
||||
/// <param name="firstType">Object (Type)</param>
|
||||
/// <param name="secondType">Object (Type)</param>
|
||||
/// <returns>Type</returns>
|
||||
public static Type CreateGenericType(object firstType, object secondType)
|
||||
{
|
||||
try
|
||||
{
|
||||
return (firstType as Type).MakeGenericType(new Type[] { secondType as Type });
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UtilsHelper.LogError("CreateCombinedType");
|
||||
UtilsHelper.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
public static MethodInfo CreateDeserializerMethod(object type)
|
||||
{
|
||||
try
|
||||
{
|
||||
return ReflectionHelper.GetDeserializerMethodInfo().MakeGenericMethod(new Type[] { type as Type });
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UtilsHelper.LogError("CreateCombinedMethod");
|
||||
UtilsHelper.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static object CreateBackendSessionAndTarkovApp(out object tarkovApp)
|
||||
{
|
||||
try
|
||||
{
|
||||
// To get to this point and keeping this generic
|
||||
// Get types required
|
||||
var singletonType = ReflectionHelper.GetSingletonType();
|
||||
var clientApplicationType = ReflectionHelper.GetClientApplicationType();
|
||||
var interfaceType = ReflectionHelper.GetInterfaceType();
|
||||
|
||||
// Create singleton
|
||||
var clientApplicationInterfaceType = CreateGenericType(clientApplicationType, interfaceType);
|
||||
var singletonClientApplicationInterfaceType = CreateGenericType(singletonType, clientApplicationInterfaceType);
|
||||
|
||||
// Get singleton instance
|
||||
var singletonClientApplicationInterfaceInstance = ReflectionHelper.GetSingletonInstance(singletonClientApplicationInterfaceType);
|
||||
|
||||
tarkovApp = singletonClientApplicationInterfaceInstance;
|
||||
return ReflectionHelper.GetBackendSession(singletonClientApplicationInterfaceInstance);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UtilsHelper.LogError("CreateBackendSession");
|
||||
UtilsHelper.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static object GetWaveSettings()
|
||||
{
|
||||
try
|
||||
{
|
||||
// combine List<> and WaveSettingsType
|
||||
var listWaveType = CreateGenericType(ReflectionHelper.GetListType(), ReflectionHelper.GetWaveSettingsType());
|
||||
|
||||
// combine with JsonConvert.DeserializeObject<>() and invoke with getCurrentDir + "\\DUMPDATA\\.replace("\\\\","\\") + "botReqData.json";
|
||||
return CreateDeserializerMethod(listWaveType).Invoke(null, new[] { File.ReadAllText(Path.Combine(DumpDataPath, "botReqData.json")) });
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UtilsHelper.LogError("GetWaveSettings");
|
||||
UtilsHelper.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static object GetSptConfig()
|
||||
{
|
||||
try
|
||||
{
|
||||
return CreateDeserializerMethod(typeof(SptConfigClass)).Invoke(null,
|
||||
new[] { File.ReadAllText(Path.Combine(DumpDataPath, "config.json")) });
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static object GetRaidSettings()
|
||||
{
|
||||
try
|
||||
{
|
||||
return CreateDeserializerMethod(ReflectionHelper.GetLocalRaidSettingsType()).Invoke(null,
|
||||
new[] { File.ReadAllText(Path.Combine(DumpDataPath, "raidSettings.json")) });
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool GotBackend = false;
|
||||
public static object WaveSettings = null;
|
||||
public static object RaidSettings = null;
|
||||
public static object AppRaidSettings = null;
|
||||
public static FieldInfo MainMenuController = null;
|
||||
public static object Session = null;
|
||||
public static object TarkovApp = null;
|
||||
public static int ErrorCounter = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Method to run main menu Task, this will request data from BSG, map loot and bot data
|
||||
/// </summary>
|
||||
public static async Task StartDumpyTask()
|
||||
{
|
||||
if (!ConfigSettings.QuickDumpEnabled)
|
||||
if (!DataHelper.ConfigSettings.QuickDumpEnabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Utils.LogInfo("[Dumpy] Starting Dumpy");
|
||||
|
||||
await Task.Factory.StartNew(async delegate
|
||||
{
|
||||
UtilsHelper.LogInfo("[Dumpy] Starting Dumpy Loop");
|
||||
while (true)
|
||||
bool run = true;
|
||||
while (run)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!GotBackend)
|
||||
{
|
||||
// get client backend session
|
||||
Session = CreateBackendSessionAndTarkovApp(out TarkovApp);
|
||||
// get field for MainMenuController
|
||||
MainMenuController = ReflectionHelper.GetMainMenuControllerField();
|
||||
// get wave information from json
|
||||
WaveSettings = GetWaveSettings();
|
||||
// get Raid Settings from json
|
||||
RaidSettings = GetRaidSettings();
|
||||
// get Raid settings from tarkovApp
|
||||
AppRaidSettings = ReflectionHelper.GetRaidSettingsFromApp(TarkovApp);
|
||||
|
||||
CheckVariableConditions();
|
||||
GotBackend = true;
|
||||
}
|
||||
SetupBackend();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UtilsHelper.LogError("[Dumpy] Exception occured in StartDumpyTask::GotBackend");
|
||||
UtilsHelper.LogError(e);
|
||||
Utils.LogError("[Dumpy] Exception occured in SetupBackend");
|
||||
Utils.LogError(e);
|
||||
|
||||
if (ErrorCounter > 3)
|
||||
if (DataHelper.ErrorCounter >= 3)
|
||||
{
|
||||
UtilsHelper.LogError("[Dumpy] ErrorsCounter was above 3, exiting app!");
|
||||
// use EFT method to close app
|
||||
ReflectionHelper.GetApplicationQuitMethod().Invoke(null, null);
|
||||
Utils.LogError("[Dumpy] ErrorsCounter was 3, exiting app!");
|
||||
MethodHelper.GetApplicationQuitMethod().Invoke(null, null);
|
||||
}
|
||||
|
||||
ErrorCounter += 1;
|
||||
DataHelper.ErrorCounter += 1;
|
||||
|
||||
UtilsHelper.LogError("[Dumpy] Resetting backend and trying again");
|
||||
ClearVariables();
|
||||
Utils.LogError("[Dumpy] Resetting backend and trying again");
|
||||
DataHelper.ClearVariables();
|
||||
DataHelper.GotBackend = false;
|
||||
}
|
||||
|
||||
try
|
||||
if (DataHelper.GotBackend)
|
||||
{
|
||||
if (Iteration > 6)
|
||||
try
|
||||
{
|
||||
// reset to 1
|
||||
Iteration = 1;
|
||||
|
||||
UtilsHelper.LogInfo($"[Dumpy] Restarting Loop in {ConfigSettings.SptTimings.AllIterationDelayMs}ms");
|
||||
var controller = MainMenuController.GetValue(TarkovApp);
|
||||
|
||||
if (controller != null)
|
||||
// Although there are now no map iterations, use the iterations to "reset" the afk montior
|
||||
if (DataHelper.Iteration > 6)
|
||||
{
|
||||
controller.GetType().GetMethod("StopAfkMonitor").Invoke(controller, null);
|
||||
DataHelper.Iteration = 1;
|
||||
|
||||
var controller = DataHelper.MainMenuController.GetValue(DataHelper.TarkovApp);
|
||||
if (controller != null)
|
||||
{
|
||||
controller.GetType().GetMethod("StopAfkMonitor").Invoke(controller, null);
|
||||
}
|
||||
|
||||
Utils.LogInfo($"[Dumpy] Restarting Loop in {DataHelper.ConfigSettings.SptTimings.AllIterationDelayMs}ms");
|
||||
await Task.Delay(DataHelper.ConfigSettings.SptTimings.AllIterationDelayMs);
|
||||
}
|
||||
else
|
||||
{
|
||||
Utils.LogInfo($"Dumpy iteration number: {DataHelper.Iteration}");
|
||||
foreach (var map in DataHelper.ConfigSettings.MapNames)
|
||||
{
|
||||
// Set location in the RaidSettings object
|
||||
Utils.LogInfo($"[Dumpy] Setting LocalRaidSettings location to: {map}");
|
||||
DataHelper.LocalRaidSettings.GetType().GetField("location")
|
||||
.SetValue(DataHelper.LocalRaidSettings, map);
|
||||
|
||||
// Set location in the RaidConfig object
|
||||
Utils.LogInfo($"[Dumpy] Setting RaidSettings location to: {map}");
|
||||
DataHelper.RaidSettings.GetType().GetProperty("SelectedLocation")
|
||||
.SetValue(DataHelper.RaidSettings, ReflectionHelper.CheckLocationID(map));
|
||||
|
||||
// "/client/raid/configuration"
|
||||
// Call server with new map name in RaidSettings
|
||||
Utils.LogInfo($"[Dumpy] Sending RaidConfig");
|
||||
await (Task)DataHelper.Session.GetType().GetMethod("SendRaidSettings")
|
||||
.Invoke(DataHelper.Session, new[] { DataHelper.RaidSettings });
|
||||
|
||||
// Artificial wait to hopefully keep BSG off our toes
|
||||
Utils.LogInfo("Waiting 10s");
|
||||
await Task.Delay(10000);
|
||||
|
||||
// "/client/match/local/start"
|
||||
// Call server with new map name in LocalRaidSettings
|
||||
Utils.LogInfo($"[Dumpy] Getting loot for {map}");
|
||||
var localRaidSettings = DataHelper.Session.GetType().GetMethod("LocalRaidStarted")
|
||||
.Invoke(DataHelper.Session, new[] { DataHelper.LocalRaidSettings });
|
||||
// Await the task
|
||||
await (Task)localRaidSettings;
|
||||
// Get the result
|
||||
var result = localRaidSettings.GetType().GetProperty("Result").GetValue(localRaidSettings);
|
||||
// get the string from the result
|
||||
var result2 = (string)result.GetType().GetField("serverId").GetValue(result);
|
||||
// set that to our LocalRaidSettings object
|
||||
DataHelper.LocalRaidSettings.GetType().GetField("serverId").SetValue(DataHelper.LocalRaidSettings, result2);
|
||||
|
||||
// Artificial wait to hopefully keep BSG off our toes
|
||||
Utils.LogInfo("Waiting 10s");
|
||||
await Task.Delay(10000);
|
||||
|
||||
// "/client/game/bot/generate"
|
||||
// Call server with bot wave data
|
||||
Utils.LogInfo($"[Dumpy] Getting Bot Data");
|
||||
await (Task)DataHelper.Session.GetType().GetMethod("LoadBots")
|
||||
.Invoke(DataHelper.Session, new[] { DataHelper.WaveSettings });
|
||||
|
||||
// Artificial wait to hopefully keep BSG off our toes
|
||||
Utils.LogInfo("Waiting 10s");
|
||||
await Task.Delay(10000);
|
||||
|
||||
var emptyArray = ReflectionHelper.CreateGenericMethod(typeof(Array).GetMethod("Empty"), TypeHelper.GetJsonTokenCreateType())
|
||||
.Invoke(null, null);
|
||||
Utils.LogInfo($"[Dumpy] Sending local raid ended");
|
||||
await (Task)DataHelper.Session.GetType().GetMethod("LocalRaidEnded")
|
||||
.Invoke(DataHelper.Session, new object[]
|
||||
{
|
||||
DataHelper.LocalRaidSettings,
|
||||
DataHelper.EndRaidClass,
|
||||
emptyArray,
|
||||
Activator.CreateInstance(ReflectionHelper.CreateGenericType(TypeHelper.GetDictionaryType(), typeof(string),
|
||||
emptyArray.GetType()))
|
||||
});
|
||||
|
||||
// after, reset LocalRaidSettings.serverId to null;
|
||||
DataHelper.LocalRaidSettings.GetType().GetField("serverId").SetValue(DataHelper.LocalRaidSettings, null);
|
||||
|
||||
await Task.Delay(DataHelper.ConfigSettings.SptTimings.SingleIterationDelayMs);
|
||||
}
|
||||
|
||||
DataHelper.Iteration++;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Utils.LogError("[Dumpy] Exception occured in StartDumpyTask::Iteration");
|
||||
Utils.LogError(e);
|
||||
|
||||
if (DataHelper.ErrorCounter >= 3)
|
||||
{
|
||||
Utils.LogError("[Dumpy] ErrorsCounter was 3, exiting app");
|
||||
MethodHelper.GetApplicationQuitMethod().Invoke(null, null);
|
||||
}
|
||||
|
||||
await Task.Delay(ConfigSettings.SptTimings.AllIterationDelayMs);
|
||||
DataHelper.ErrorCounter += 1;
|
||||
|
||||
Utils.LogError("[Dumpy] Resetting backend and trying again");
|
||||
DataHelper.ClearVariables();
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilsHelper.LogInfo($"Map iteration number: {Iteration}");
|
||||
foreach (var map in ConfigSettings.MapNames)
|
||||
{
|
||||
// theory is send a request SendRaidSettings before starting
|
||||
|
||||
// Set location in the RaidSettings object
|
||||
UtilsHelper.LogInfo($"[Dumpy] Setting RaidSettings location to: {map}");
|
||||
RaidSettings.GetType().GetField("location").SetValue(RaidSettings, map);
|
||||
|
||||
// Call server with new map name
|
||||
UtilsHelper.LogInfo($"[Dumpy] Getting loot for {map}");
|
||||
await (Task)Session.GetType().GetMethod("LocalRaidStarted")
|
||||
.Invoke(Session, new[] { RaidSettings });
|
||||
|
||||
// Call server with bot wave data
|
||||
UtilsHelper.LogInfo($"[Dumpy] Getting Bot Data");
|
||||
await (Task)Session.GetType().GetMethod("LoadBots")
|
||||
.Invoke(Session, new[] { WaveSettings });
|
||||
|
||||
await Task.Delay(ConfigSettings.SptTimings.SingleIterationDelayMs);
|
||||
}
|
||||
|
||||
Iteration++;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UtilsHelper.LogError("[Dumpy] Exception occured in StartDumpyTask::Iteration");
|
||||
UtilsHelper.LogError(e);
|
||||
|
||||
if (ErrorCounter > 3)
|
||||
{
|
||||
UtilsHelper.LogError("[Dumpy] ErrorsCounter was above 3, exiting app");
|
||||
// use EFT method to close app
|
||||
ReflectionHelper.GetApplicationQuitMethod().Invoke(null, null);
|
||||
}
|
||||
|
||||
ErrorCounter += 1;
|
||||
|
||||
UtilsHelper.LogError("[Dumpy] Resetting backend and trying again");
|
||||
ClearVariables();
|
||||
}
|
||||
}
|
||||
}, TaskCreationOptions.LongRunning);
|
||||
}
|
||||
|
||||
private static void CheckVariableConditions()
|
||||
private static void SetupBackend()
|
||||
{
|
||||
UtilsHelper.LogInfo($"[Dumpy] CheckVariableConditions");
|
||||
UtilsHelper.LogInfo($"[Dumpy] GotBackend- type: {GotBackend.GetType()} null?: {GotBackend == null}");
|
||||
UtilsHelper.LogInfo($"[Dumpy] WaveSettings- type: {WaveSettings.GetType()} null?: {WaveSettings == null}");
|
||||
UtilsHelper.LogInfo($"[Dumpy] MainMenuController- type: {MainMenuController.GetType()} null?: {MainMenuController == null}");
|
||||
UtilsHelper.LogInfo($"[Dumpy] Session- type: {Session.GetType()} null?: {Session == null}");
|
||||
UtilsHelper.LogInfo($"[Dumpy] TarkovApp- type: {TarkovApp.GetType()} null?: {TarkovApp == null}");
|
||||
UtilsHelper.LogInfo($"[Dumpy] RaidSettings- type: {RaidSettings.GetType()} null?: {RaidSettings == null}");
|
||||
UtilsHelper.LogInfo($"[Dumpy] CheckVariableConditions");
|
||||
UtilsHelper.LogInfo($"[Dumpy] AppRaidSettings- type: {AppRaidSettings.GetType()} null?: {AppRaidSettings == null}");
|
||||
UtilsHelper.LogInfo($"[Dumpy] CheckVariableConditions");
|
||||
UtilsHelper.LogInfo($"[Dumpy] -----------------------------------------------------------------------------");
|
||||
if (!DataHelper.GotBackend)
|
||||
{
|
||||
// get client backend session
|
||||
DataHelper.Session = ReflectionHelper.CreateBackendSessionAndTarkovApp(out DataHelper.TarkovApp);
|
||||
// get field for MainMenuController
|
||||
DataHelper.MainMenuController = ReflectionHelper.GetMainMenuControllerField();
|
||||
// get wave information from json
|
||||
DataHelper.WaveSettings = ReflectionHelper.GetWaveSettings();
|
||||
// get Raid Settings from json
|
||||
DataHelper.LocalRaidSettings = DataHelper.GetLocalRaidSettings();
|
||||
// get Raid Config from json
|
||||
DataHelper.RaidSettings = DataHelper.GetRaidConfigSettings();
|
||||
// get locationDetails
|
||||
DataHelper.LocationValues = ReflectionHelper.GetLocationValuesFromSession();
|
||||
// get End raid class from json
|
||||
DataHelper.EndRaidClass = DataHelper.GetEndRaidClass();
|
||||
// get player profile
|
||||
DataHelper.PlayerProfile = ReflectionHelper.GetPlayerProfile();
|
||||
// Set up end raid class
|
||||
DataHelper.EndRaidClass.GetType().GetField("profile").SetValue(DataHelper.EndRaidClass, DataHelper.PlayerProfile);
|
||||
|
||||
DataHelper.GotBackend = true;
|
||||
}
|
||||
}
|
||||
|
||||
private static void ClearVariables()
|
||||
{
|
||||
GotBackend = false;
|
||||
WaveSettings = null;
|
||||
MainMenuController = null;
|
||||
Session = null;
|
||||
TarkovApp = null;
|
||||
RaidSettings = null;
|
||||
AppRaidSettings = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method to log Requests and Responses
|
||||
@ -309,7 +199,7 @@ namespace DumpLib
|
||||
var uri = new Uri((string)requestType.GetType().GetMethod("get_MainURLFull").Invoke(requestType, null));
|
||||
var path = (Directory.GetCurrentDirectory() + "\\HTTP_DATA\\").Replace("\\\\", "\\");
|
||||
var file = uri.LocalPath.Replace("/", ".").Remove(0, 1);
|
||||
var time = DateTime.Now.ToString(ConfigSettings.DateTimeFormat);
|
||||
var time = DateTime.Now.ToString(DataHelper.ConfigSettings.DateTimeFormat);
|
||||
|
||||
if (Directory.CreateDirectory(path).Exists)
|
||||
{
|
||||
@ -317,17 +207,21 @@ namespace DumpLib
|
||||
if (Directory.CreateDirectory($@"{path}req.{file}").Exists)
|
||||
{
|
||||
if (reqParams != null)
|
||||
File.WriteAllText($@"{path}req.{file}\\req.{file}_{time}_{ConfigSettings.Name}.json", JsonConvert.SerializeObject(reqParams));
|
||||
{
|
||||
File.WriteAllText($@"{path}req.{file}\\req.{file}_{time}_{DataHelper.ConfigSettings.Name}.json", JsonConvert.SerializeObject(reqParams));
|
||||
}
|
||||
}
|
||||
|
||||
if (Directory.CreateDirectory($@"{path}resp.{file}").Exists)
|
||||
File.WriteAllText($@"{path}resp.{file}\\resp.{file}_{time}_{ConfigSettings.Name}.json", (string)responseText);
|
||||
{
|
||||
File.WriteAllText($@"{path}resp.{file}\\resp.{file}_{time}_{DataHelper.ConfigSettings.Name}.json", (string)responseText);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UtilsHelper.LogError("[Dumpy] Exception occured at LogRequestResponse");
|
||||
UtilsHelper.LogError(e);
|
||||
Utils.LogError("[Dumpy] Exception occured at LogRequestResponse");
|
||||
Utils.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
116
DumpLib/Helpers/DataHelper.cs
Normal file
116
DumpLib/Helpers/DataHelper.cs
Normal file
@ -0,0 +1,116 @@
|
||||
using System.Reflection;
|
||||
using DumpLib.Models;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace DumpLib.Helpers;
|
||||
|
||||
public static class DataHelper
|
||||
{
|
||||
public static Assembly _newtonAssembly =
|
||||
Assembly.LoadFrom((Directory.GetCurrentDirectory() + "\\EscapeFromTarkov_Data\\Managed\\Newtonsoft.Json.dll").Replace("\\\\", "\\"));
|
||||
|
||||
public static Assembly _msAssembly =
|
||||
Assembly.LoadFrom((Directory.GetCurrentDirectory() + "\\EscapeFromTarkov_Data\\Managed\\mscorlib.dll").Replace("\\\\", "\\"));
|
||||
|
||||
public static Assembly _eftAssembly =
|
||||
Assembly.LoadFrom((Directory.GetCurrentDirectory() + "\\EscapeFromTarkov_Data\\Managed\\Assembly-CSharp.dll").Replace("\\\\", "\\"));
|
||||
|
||||
public static Assembly _comfortAssembly =
|
||||
Assembly.LoadFrom((Directory.GetCurrentDirectory() + "\\EscapeFromTarkov_Data\\Managed\\Comfort.dll").Replace("\\\\", "\\"));
|
||||
|
||||
public static string DumpDataPath = (Directory.GetCurrentDirectory() + "\\DUMPDATA\\").Replace("\\\\", "\\");
|
||||
|
||||
public static SptConfigClass ConfigSettings = GetSptConfig();
|
||||
|
||||
public static int Iteration = 1;
|
||||
public static bool GotBackend = false;
|
||||
public static object WaveSettings = null;
|
||||
public static object LocalRaidSettings = null;
|
||||
public static object RaidSettings = null;
|
||||
public static FieldInfo MainMenuController = null;
|
||||
public static object Session = null;
|
||||
public static object TarkovApp = null;
|
||||
public static object LocationValues = null;
|
||||
public static object EndRaidClass = null;
|
||||
public static object PlayerProfile = null;
|
||||
public static int ErrorCounter = 0;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static SptConfigClass GetSptConfig()
|
||||
{
|
||||
try
|
||||
{
|
||||
return JsonConvert.DeserializeObject<SptConfigClass>(
|
||||
File.ReadAllText(Path.Combine(DumpDataPath, "config.json"))
|
||||
);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Utils.LogError("GetSptConfig");
|
||||
Utils.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static object GetRaidConfigSettings()
|
||||
{
|
||||
try
|
||||
{
|
||||
return ReflectionHelper.CreateDeserializerMethod(TypeHelper.GetRaidConfigType()).Invoke(null,
|
||||
new[] { File.ReadAllText(Path.Combine(DataHelper.DumpDataPath, "raidConfig.json")) });
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Utils.LogError("GetRaidConfigSettings");
|
||||
Utils.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static object GetEndRaidClass()
|
||||
{
|
||||
try
|
||||
{
|
||||
return ReflectionHelper.CreateDeserializerMethod(TypeHelper.GetEndRaidType()).Invoke(null,
|
||||
new[] { File.ReadAllText(Path.Combine(DataHelper.DumpDataPath, "endRaid.json")) });
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Utils.LogError("GetEndRaidClass");
|
||||
Utils.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static object GetLocalRaidSettings()
|
||||
{
|
||||
try
|
||||
{
|
||||
return ReflectionHelper.CreateDeserializerMethod(TypeHelper.GetLocalRaidSettingsType()).Invoke(null,
|
||||
new[] { File.ReadAllText(Path.Combine(DataHelper.DumpDataPath, "raidSettings.json")) });
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Utils.LogError("GetLocalRaidSettings");
|
||||
Utils.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static void ClearVariables()
|
||||
{
|
||||
GotBackend = false;
|
||||
WaveSettings = null;
|
||||
MainMenuController = null;
|
||||
Session = null;
|
||||
TarkovApp = null;
|
||||
LocalRaidSettings = null;
|
||||
RaidSettings = null;
|
||||
LocationValues = null;
|
||||
EndRaidClass = null;
|
||||
PlayerProfile = null;
|
||||
}
|
||||
}
|
71
DumpLib/Helpers/MethodHelper.cs
Normal file
71
DumpLib/Helpers/MethodHelper.cs
Normal file
@ -0,0 +1,71 @@
|
||||
using System.Reflection;
|
||||
|
||||
namespace DumpLib.Helpers;
|
||||
|
||||
public class MethodHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Method to get DeserializeObject from Newtonsoft assembly
|
||||
/// </summary>
|
||||
/// <returns>MethodInfo</returns>
|
||||
public static MethodInfo GetDeserializerMethodInfo()
|
||||
{
|
||||
try
|
||||
{
|
||||
return DataHelper._newtonAssembly.GetTypes().First(x =>
|
||||
x.Name == "JsonConvert"
|
||||
).GetMethods().First(m =>
|
||||
m.Name == "DeserializeObject" &&
|
||||
m.IsGenericMethodDefinition &&
|
||||
m.GetParameters().Length == 1 &&
|
||||
m.GetParameters().Any(p =>
|
||||
p.ParameterType == typeof(string)
|
||||
)
|
||||
);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Utils.LogError("GetDeserializerMethodInfo");
|
||||
Utils.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method to get Quit method from EFT (as of 20/05/2024 - GClass1955)
|
||||
/// </summary>
|
||||
/// <returns>MethodInfo</returns>
|
||||
public static MethodInfo GetApplicationQuitMethod()
|
||||
{
|
||||
try
|
||||
{
|
||||
return DataHelper._eftAssembly.GetTypes().First(x =>
|
||||
x.GetMethods().Any(y =>
|
||||
y.Name == "Quit")
|
||||
).GetMethod("Quit");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Utils.LogError("GetApplicationQuitMethod");
|
||||
Utils.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static MethodInfo GetToUnparsedDataMethod()
|
||||
{
|
||||
try
|
||||
{
|
||||
return DataHelper._eftAssembly.GetTypes().First(x =>
|
||||
x.GetMethods().Any(m =>
|
||||
m.Name == "ToUnparsedData"
|
||||
)).GetMethod("ToUnparsedData");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Utils.LogError("GetToUnparsedDataMethod");
|
||||
Utils.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
@ -2,132 +2,12 @@
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace DumpLib.Helpers
|
||||
{
|
||||
public static class ReflectionHelper
|
||||
{
|
||||
private static Assembly _newtonAssembly = Assembly.LoadFrom((Directory.GetCurrentDirectory() + "\\EscapeFromTarkov_Data\\Managed\\Newtonsoft.Json.dll").Replace("\\\\", "\\"));
|
||||
|
||||
private static Assembly _msAssembly = Assembly.LoadFrom((Directory.GetCurrentDirectory() + "\\EscapeFromTarkov_Data\\Managed\\mscorlib.dll").Replace("\\\\", "\\"));
|
||||
|
||||
private static Assembly _eftAssembly = Assembly.LoadFrom((Directory.GetCurrentDirectory() + "\\EscapeFromTarkov_Data\\Managed\\Assembly-CSharp.dll").Replace("\\\\", "\\"));
|
||||
|
||||
private static Assembly _comfortAssembly = Assembly.LoadFrom((Directory.GetCurrentDirectory() + "\\EscapeFromTarkov_Data\\Managed\\Comfort.dll").Replace("\\\\", "\\"));
|
||||
|
||||
/// <summary>
|
||||
/// Method to get Singleton<> type from Comfort.dll
|
||||
/// </summary>
|
||||
/// <returns>Type</returns>
|
||||
public static Type GetSingletonType()
|
||||
{
|
||||
try
|
||||
{
|
||||
return _comfortAssembly.GetTypes().First(x => x.Name.StartsWith("Singleton"));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UtilsHelper.LogError("GetSingletonType");
|
||||
UtilsHelper.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method to get ClientApplication<> type from EFT's assembly
|
||||
/// </summary>
|
||||
/// <returns>Type</returns>
|
||||
public static Type GetClientApplicationType()
|
||||
{
|
||||
try
|
||||
{
|
||||
return _eftAssembly.GetTypes().First(x => x.Name.StartsWith("ClientApplication"));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UtilsHelper.LogError("GetClientApplicationType");
|
||||
UtilsHelper.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method to get (as of 25/01/2024 - GInterface145) type from EFT's assembly
|
||||
/// </summary>
|
||||
/// <returns>Type</returns>
|
||||
public static Type GetInterfaceType()
|
||||
{
|
||||
try
|
||||
{
|
||||
return _eftAssembly.GetTypes()
|
||||
.First(x => x.IsInterface && x.GetMethods().Any(m => m.Name == "GetPhpSessionId"));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UtilsHelper.LogError("GetInterfaceType");
|
||||
UtilsHelper.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method to get TarkovApplication type from EFT's assembly
|
||||
/// </summary>
|
||||
/// <returns>Type</returns>
|
||||
public static Type GetTarkovApplicationType()
|
||||
{
|
||||
try
|
||||
{
|
||||
return _eftAssembly.GetTypes().First(x => x.Name == "TarkovApplication");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UtilsHelper.LogError("GetTarkovApplicationType");
|
||||
UtilsHelper.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method to get (as of 25/01/2024 - GClass1464) type from EFT's assembly
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static object GetWaveSettingsType()
|
||||
{
|
||||
try
|
||||
{
|
||||
return _eftAssembly.GetTypes().First(x =>
|
||||
{
|
||||
// if type contains Role, Limit and Difficulty, return true
|
||||
var fields = x.GetFields();
|
||||
if (fields.Any(f => f.Name == "Role") && fields.Any(f => f.Name == "Limit") && fields.Any(f => f.Name == "Difficulty") && fields.Length == 3)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UtilsHelper.LogError("GetWaveSettingsType");
|
||||
UtilsHelper.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static Type GetListType()
|
||||
{
|
||||
try
|
||||
{
|
||||
return _msAssembly.GetTypes().First(x => x.Name.StartsWith("List") && x.Namespace == "System.Collections.Generic");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UtilsHelper.LogError("GetListType");
|
||||
UtilsHelper.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method to get FieldInfo of a field on the TarkovApplication Type for later use
|
||||
/// </summary>
|
||||
@ -136,13 +16,13 @@ namespace DumpLib.Helpers
|
||||
{
|
||||
try
|
||||
{
|
||||
return GetTarkovApplicationType().GetFields(BindingFlags.Instance | BindingFlags.NonPublic)
|
||||
return TypeHelper.GetTarkovApplicationType().GetFields(BindingFlags.Instance | BindingFlags.NonPublic)
|
||||
.First(x => x.FieldType.GetMethods().Any(m => m.Name == "StopAfkMonitor"));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UtilsHelper.LogError("GetMainMenuControllerField");
|
||||
UtilsHelper.LogError(e);
|
||||
Utils.LogError("GetMainMenuControllerField");
|
||||
Utils.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
@ -162,8 +42,8 @@ namespace DumpLib.Helpers
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UtilsHelper.LogError("GetSingletonInstance");
|
||||
UtilsHelper.LogError(e);
|
||||
Utils.LogError("GetSingletonInstance");
|
||||
Utils.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
@ -177,82 +57,181 @@ namespace DumpLib.Helpers
|
||||
{
|
||||
try
|
||||
{
|
||||
return GetTarkovApplicationType().GetMethod("GetClientBackEndSession").Invoke(instance, null);
|
||||
return TypeHelper.GetTarkovApplicationType().GetMethod("GetClientBackEndSession").Invoke(instance, null);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UtilsHelper.LogError("GetBackendSession");
|
||||
UtilsHelper.LogError(e);
|
||||
Utils.LogError("GetBackendSession");
|
||||
Utils.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method to get DeserializeObject from Newtonsoft assembly
|
||||
/// <para>Method to create a "combined" Type that takes a GenericType</para>
|
||||
/// <para>Example: ClientApplication + GInterface145 = ClientApplication(GInterface145)</para>
|
||||
/// </summary>
|
||||
/// <returns>MethodInfo</returns>
|
||||
public static MethodInfo GetDeserializerMethodInfo()
|
||||
/// <param name="firstType">Object (Type)</param>
|
||||
/// <param name="secondType">Object (Type)</param>
|
||||
/// <returns>Type</returns>
|
||||
public static Type CreateGenericType(object firstType, object secondType)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _newtonAssembly.GetTypes().First(x => x.Name == "JsonConvert").GetMethods().First(m =>
|
||||
m.Name == "DeserializeObject" && m.IsGenericMethodDefinition && m.GetParameters().Length == 1 &&
|
||||
m.GetParameters().Any(p => p.ParameterType == typeof(string)));
|
||||
return (firstType as Type).MakeGenericType(new Type[] { secondType as Type });
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UtilsHelper.LogError("GetDeserializerMethodInfo");
|
||||
UtilsHelper.LogError(e);
|
||||
Utils.LogError("CreateGenericType1");
|
||||
Utils.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static Type CreateGenericType(object firstType, object secondType, object thirdType)
|
||||
{
|
||||
try
|
||||
{
|
||||
return (firstType as Type).MakeGenericType(new Type[] { secondType as Type, thirdType as Type });
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Utils.LogError("CreateGenericType2");
|
||||
Utils.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method to get Quit method from EFT (as of 20/05/2024 - GClass1955)
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns>MethodInfo</returns>
|
||||
public static MethodInfo GetApplicationQuitMethod()
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
public static MethodInfo CreateDeserializerMethod(object type)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _eftAssembly.GetTypes().First(x => x.GetMethods().Any(y => y.Name == "Quit")).GetMethod("Quit");
|
||||
return MethodHelper.GetDeserializerMethodInfo().MakeGenericMethod(new Type[] { type as Type });
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UtilsHelper.LogError("GetApplicationQuitMethod");
|
||||
UtilsHelper.LogError(e);
|
||||
Utils.LogError("CreateDeserializerMethod");
|
||||
Utils.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static MethodInfo CreateGenericMethod(MethodInfo method, object type)
|
||||
{
|
||||
try
|
||||
{
|
||||
return method.MakeGenericMethod(new Type[] { type as Type });
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Utils.LogError("CreateGenericMethod");
|
||||
Utils.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method to get LocalRaidSettings Type from EFT
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns>object</returns>
|
||||
public static object GetLocalRaidSettingsType()
|
||||
/// <returns></returns>
|
||||
public static object CreateBackendSessionAndTarkovApp(out object tarkovApp)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _eftAssembly.GetTypes().First(x => x.Name == "LocalRaidSettings");
|
||||
// To get to this point and keeping this generic
|
||||
// Get types required
|
||||
var singletonType = TypeHelper.GetSingletonType();
|
||||
var clientApplicationType = TypeHelper.GetClientApplicationType();
|
||||
var interfaceType = TypeHelper.GetInterfaceType();
|
||||
|
||||
// Create singleton
|
||||
var clientApplicationInterfaceType = CreateGenericType(clientApplicationType, interfaceType);
|
||||
var singletonClientApplicationInterfaceType = CreateGenericType(singletonType, clientApplicationInterfaceType);
|
||||
|
||||
// Get singleton instance
|
||||
var singletonClientApplicationInterfaceInstance = ReflectionHelper.GetSingletonInstance(singletonClientApplicationInterfaceType);
|
||||
|
||||
tarkovApp = singletonClientApplicationInterfaceInstance;
|
||||
return ReflectionHelper.GetBackendSession(singletonClientApplicationInterfaceInstance);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UtilsHelper.LogError("GetLocalRaidSettingsType");
|
||||
UtilsHelper.LogError(e);
|
||||
Utils.LogError("CreateBackendSessionAndTarkovApp");
|
||||
Utils.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static object GetRaidSettingsFromApp(object tarkovApp)
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static object GetWaveSettings()
|
||||
{
|
||||
try
|
||||
{
|
||||
return tarkovApp.GetType().GetField("_raidSettings").GetValue(tarkovApp);
|
||||
// combine List<> and WaveSettingsType
|
||||
var listWaveType = CreateGenericType(TypeHelper.GetListType(), TypeHelper.GetWaveSettingsType());
|
||||
|
||||
// combine with JsonConvert.DeserializeObject<>() and invoke with getCurrentDir + "\\DUMPDATA\\.replace("\\\\","\\") + "botReqData.json";
|
||||
return CreateDeserializerMethod(listWaveType)
|
||||
.Invoke(null, new[] { File.ReadAllText(Path.Combine(DataHelper.DumpDataPath, "botReqData.json")) });
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UtilsHelper.LogError("GetRaidSettingsFromApp");
|
||||
UtilsHelper.LogError(e);
|
||||
Utils.LogError("GetWaveSettings");
|
||||
Utils.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static object GetLocationValuesFromSession()
|
||||
{
|
||||
try
|
||||
{
|
||||
var locationsProp = DataHelper.Session.GetType().GetProperty("LocationSettings").GetValue(DataHelper.Session);
|
||||
return locationsProp.GetType().GetField("locations").GetValue(locationsProp);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Utils.LogError("GetLocationValuesFromSession");
|
||||
Utils.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static object CheckLocationID(string map)
|
||||
{
|
||||
try
|
||||
{
|
||||
var values = (IEnumerable<object>)DataHelper.LocationValues.GetType().GetProperty("Values").GetValue(DataHelper.LocationValues);
|
||||
return values.FirstOrDefault(x => x.GetType().GetField("Id").GetValue(x).ToString().ToLower().Contains(map.ToLower()));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Utils.LogError("CheckLocationID");
|
||||
Utils.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static object GetPlayerProfile()
|
||||
{
|
||||
try
|
||||
{
|
||||
var profile = DataHelper.Session.GetType().GetProperty("Profile").GetValue(DataHelper.Session);
|
||||
var converterMethod = CreateGenericMethod(MethodHelper.GetToUnparsedDataMethod(), TypeHelper.GetProfileType());
|
||||
return converterMethod.Invoke(null, new[] { profile, Array.Empty<JsonConverter>() });
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Utils.LogError("GetPlayerProfile");
|
||||
Utils.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
256
DumpLib/Helpers/TypeHelper.cs
Normal file
256
DumpLib/Helpers/TypeHelper.cs
Normal file
@ -0,0 +1,256 @@
|
||||
namespace DumpLib.Helpers;
|
||||
|
||||
public static class TypeHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Method to get Singleton<> type from Comfort.dll
|
||||
/// </summary>
|
||||
/// <returns>Type</returns>
|
||||
public static Type GetSingletonType()
|
||||
{
|
||||
try
|
||||
{
|
||||
return DataHelper._comfortAssembly.GetTypes().First(x => x.Name.StartsWith("Singleton"));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Utils.LogError("GetSingletonType");
|
||||
Utils.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method to get ClientApplication<> type from EFT's assembly
|
||||
/// </summary>
|
||||
/// <returns>Type</returns>
|
||||
public static Type GetClientApplicationType()
|
||||
{
|
||||
try
|
||||
{
|
||||
return DataHelper._eftAssembly.GetTypes().First(x => x.Name.StartsWith("ClientApplication"));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Utils.LogError("GetClientApplicationType");
|
||||
Utils.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method to get (as of 25/01/2024 - GInterface145) type from EFT's assembly
|
||||
/// </summary>
|
||||
/// <returns>Type</returns>
|
||||
public static Type GetInterfaceType()
|
||||
{
|
||||
try
|
||||
{
|
||||
return DataHelper._eftAssembly.GetTypes().First(x =>
|
||||
x.IsInterface &&
|
||||
x.GetMethods().Any(m =>
|
||||
m.Name == "GetPhpSessionId"
|
||||
)
|
||||
);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Utils.LogError("GetInterfaceType");
|
||||
Utils.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method to get TarkovApplication type from EFT's assembly
|
||||
/// </summary>
|
||||
/// <returns>Type</returns>
|
||||
public static Type GetTarkovApplicationType()
|
||||
{
|
||||
try
|
||||
{
|
||||
return DataHelper._eftAssembly.GetTypes().First(x =>
|
||||
x.Name == "TarkovApplication"
|
||||
);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Utils.LogError("GetTarkovApplicationType");
|
||||
Utils.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method to get (as of 25/01/2024 - GClass1464) type from EFT's assembly
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static Type GetWaveSettingsType()
|
||||
{
|
||||
try
|
||||
{
|
||||
return DataHelper._eftAssembly.GetTypes().First(x =>
|
||||
{
|
||||
var fields = x.GetFields();
|
||||
if (fields.Any(f => f.Name == "Role") &&
|
||||
fields.Any(f => f.Name == "Limit") &&
|
||||
fields.Any(f => f.Name == "Difficulty")
|
||||
&& fields.Length == 3)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Utils.LogError("GetWaveSettingsType");
|
||||
Utils.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static Type GetListType()
|
||||
{
|
||||
try
|
||||
{
|
||||
return DataHelper._msAssembly.GetTypes().First(x =>
|
||||
x.Name.StartsWith("List") &&
|
||||
x.Namespace == "System.Collections.Generic"
|
||||
);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Utils.LogError("GetListType");
|
||||
Utils.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method to get LocalRaidSettings Type from EFT
|
||||
/// </summary>
|
||||
/// <returns>object</returns>
|
||||
public static Type GetLocalRaidSettingsType()
|
||||
{
|
||||
try
|
||||
{
|
||||
return DataHelper._eftAssembly.GetTypes().First(x =>
|
||||
x.Name == "LocalRaidSettings");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Utils.LogError("GetLocalRaidSettingsType");
|
||||
Utils.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static Type GetRaidConfigType()
|
||||
{
|
||||
try
|
||||
{
|
||||
return DataHelper._eftAssembly.GetTypes().First(x =>
|
||||
x.Name == "RaidSettings");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Utils.LogError("GetRaidConfigType");
|
||||
Utils.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static Type GetEndRaidType()
|
||||
{
|
||||
try
|
||||
{
|
||||
return DataHelper._eftAssembly.GetTypes().First(x =>
|
||||
x.GetFields().Any(f =>
|
||||
f.Name == "killerAid"
|
||||
)
|
||||
);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Utils.LogError("GetEndRaidType");
|
||||
Utils.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static Type GetJsonConverterType()
|
||||
{
|
||||
try
|
||||
{
|
||||
return DataHelper._eftAssembly.GetTypes().First(x =>
|
||||
x.GetMethods().Any(m =>
|
||||
m.Name == "ToUnparsedData"
|
||||
)
|
||||
);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Utils.LogError("GetJsonConverterType");
|
||||
Utils.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static Type GetProfileType()
|
||||
{
|
||||
try
|
||||
{
|
||||
return DataHelper._eftAssembly.GetTypes().First(x =>
|
||||
x.Name == "Profile");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Utils.LogError("GetProfileType");
|
||||
Utils.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: CLEAN UP REFLECTION
|
||||
public static Type GetJsonTokenCreateType()
|
||||
{
|
||||
try
|
||||
{
|
||||
return DataHelper._eftAssembly.GetTypes().First(x =>
|
||||
{
|
||||
var fields = x.GetFields();
|
||||
var methods = x.GetMethods();
|
||||
|
||||
return fields.Length == 6 &&
|
||||
fields.Any(f => f.Name == "location") &&
|
||||
fields.Any(f => f.Name == "_id") &&
|
||||
methods.Any(m => m.Name == "Clone") &&
|
||||
methods.Any(m => m.Name == "ToString");
|
||||
});
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Utils.LogError("GetJsonTokenCreateType");
|
||||
Utils.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static Type GetDictionaryType()
|
||||
{
|
||||
try
|
||||
{
|
||||
return DataHelper._msAssembly.GetTypes().First(x =>
|
||||
x.Name.StartsWith("Dictionary") &&
|
||||
x.Namespace == "System.Collections.Generic");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Utils.LogError("GetDictionaryType");
|
||||
Utils.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
@ -3,7 +3,7 @@ using System.IO;
|
||||
|
||||
namespace DumpLib.Helpers
|
||||
{
|
||||
public static class UtilsHelper
|
||||
public static class Utils
|
||||
{
|
||||
private static string _loggerPath = (Directory.GetCurrentDirectory() + "\\DUMPDATA\\Log.txt").Replace("\\\\", "\\");
|
||||
|
Loading…
x
Reference in New Issue
Block a user