Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
cadon committed May 18, 2024
2 parents b5034a4 + 9cfc409 commit ca99f6e
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 22 deletions.
2 changes: 1 addition & 1 deletion ARKBreedingStats/Form1.collection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ private Creature ImportExportGunFiles(string[] filePaths, bool addCreatures, out

foreach (var filePath in filePaths)
{
var c = ImportExportGun.LoadCreature(filePath, out lastError, out serverMultipliersHash);
var c = ImportExportGun.LoadCreature(filePath, out lastError, out serverMultipliersHash, out _);
if (c != null)
{
newCreatures.Add(c);
Expand Down
2 changes: 1 addition & 1 deletion ARKBreedingStats/Form1.exportGun.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ private void AsbServerDataSent(ProgressReportAsbServer data)
if (string.IsNullOrEmpty(data.ServerHash))
{
// import creature
var creature = ImportExportGun.LoadCreatureFromJson(data.JsonText, null, out resultText, out _);
var creature = ImportExportGun.LoadCreatureFromJson(data.JsonText, null, out resultText, out _, out _);
if (creature == null)
{
SetMessageLabelText(resultText, MessageBoxIcon.Error);
Expand Down
9 changes: 7 additions & 2 deletions ARKBreedingStats/Form1.importSave.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ private async Task<string> RunSavegameImport(string fileLocation, string conveni
switch (uri.Scheme)
{
case "ftp":
case "ftps":
string errorMessage;
(workingCopyFilePath, errorMessage) = await CopyFtpFileAsync(uri, uriFileRegex, convenientName ?? serverName ?? fileLocation,
workingCopyFolderPath);
Expand Down Expand Up @@ -202,8 +203,12 @@ private async Task<string> RunSavegameImport(string fileLocation, string conveni
}
}
var client = new AsyncFtpClient(ftpUri.Host, credentials.Username, credentials.Password, ftpUri.Port);
client.Config.EncryptionMode = FtpEncryptionMode.Auto;
client.Config.ValidateAnyCertificate = true;
if (ftpUri.Scheme == "ftps")
{
client.Config.EncryptionMode = FtpEncryptionMode.Auto;
client.Config.ValidateAnyCertificate = true;
}

string ftpPath = null;

try
Expand Down
2 changes: 1 addition & 1 deletion ARKBreedingStats/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
// Revision
//
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("0.61.2.0")]
[assembly: AssemblyFileVersion("0.61.3.0")]
[assembly: NeutralResourcesLanguage("en")]

2 changes: 1 addition & 1 deletion ARKBreedingStats/_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"ARK Smart Breeding": {
"Id": "ARK Smart Breeding",
"Category": "main",
"version": "0.61.2.0"
"version": "0.61.3.0"
},
"SpeciesColorImages": {
"Id": "SpeciesColorImages",
Expand Down
19 changes: 13 additions & 6 deletions ARKBreedingStats/importExportGun/ImportExportGun.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ internal static class ImportExportGun
/// <summary>
/// Load creature from file created with the export gun (mod).
/// Supports .sav files (ASE) and .json files (ASA).
/// The out parameter statValues contains the stat values of the export file.
/// </summary>
public static Creature LoadCreature(string filePath, out string resultText, out string serverMultipliersHash, bool allowUnknownSpecies = false)
public static Creature LoadCreature(string filePath, out string resultText, out string serverMultipliersHash, out double[] statValues, bool allowUnknownSpecies = false)
{
resultText = null;
statValues = null;
serverMultipliersHash = null;
if (string.IsNullOrEmpty(filePath) || !File.Exists(filePath))
return null;
Expand All @@ -42,7 +44,7 @@ public static Creature LoadCreature(string filePath, out string resultText, out
break;
}

var creature = LoadCreatureFromJson(jsonText, resultText, out resultText, out serverMultipliersHash, filePath, allowUnknownSpecies);
var creature = LoadCreatureFromJson(jsonText, resultText, out resultText, out serverMultipliersHash, out statValues, filePath, allowUnknownSpecies);
if (creature == null) return null;
creature.domesticatedAt = File.GetLastWriteTime(filePath);
return creature;
Expand All @@ -62,9 +64,10 @@ public static Creature LoadCreature(string filePath, out string resultText, out
return null;
}

public static Creature LoadCreatureFromJson(string jsonText, string resultSoFar, out string resultText, out string serverMultipliersHash, string filePath = null, bool allowUnknownSpecies = false)
public static Creature LoadCreatureFromJson(string jsonText, string resultSoFar, out string resultText, out string serverMultipliersHash, out double[] statValues, string filePath = null, bool allowUnknownSpecies = false)
{
resultText = resultSoFar;
statValues = null;
serverMultipliersHash = null;
if (string.IsNullOrEmpty(jsonText))
{
Expand All @@ -86,31 +89,34 @@ public static Creature LoadCreatureFromJson(string jsonText, string resultSoFar,

serverMultipliersHash = exportedCreature.ServerMultipliersHash;

return ConvertExportGunToCreature(exportedCreature, out resultText, allowUnknownSpecies);
return ConvertExportGunToCreature(exportedCreature, out resultText, out statValues, allowUnknownSpecies);
}

private static Creature ConvertExportGunToCreature(ExportGunCreatureFile ec, out string error, bool allowUnknownSpecies = false)
private static Creature ConvertExportGunToCreature(ExportGunCreatureFile ec, out string error, out double[] statValues, bool allowUnknownSpecies = false)
{
error = null;
statValues = null;
if (ec == null) return null;

var species = Values.V.SpeciesByBlueprint(ec.BlueprintPath, true);
if (species == null)
{
error = $"blueprintpath {ec.BlueprintPath} couldn't be found, maybe you need to load a mod values file.";
error = $"Unknown species. The blueprintpath {ec.BlueprintPath} couldn't be found, maybe you need to load a mod values file.";
if (!allowUnknownSpecies)
return null;
}

var wildLevels = new int[Stats.StatsCount];
var domLevels = new int[Stats.StatsCount];
var mutLevels = new int[Stats.StatsCount];
statValues = new double[Stats.StatsCount];
var si = 0;
foreach (var s in ec.Stats)
{
wildLevels[si] = s.Wild;
domLevels[si] = s.Tamed;
mutLevels[si] = s.Mutated;
statValues[si] = s.Value;
si++;
}

Expand All @@ -122,6 +128,7 @@ private static Creature ConvertExportGunToCreature(ExportGunCreatureFile ec, out
&& string.IsNullOrEmpty(ec.OwningPlayerName)
&& string.IsNullOrEmpty(ec.ImprinterName)
&& ec.OwningPlayerID == 0
&& ec.TameEffectiveness == 0
;

var isBred = !string.IsNullOrEmpty(ec.ImprinterName)
Expand Down
13 changes: 7 additions & 6 deletions ARKBreedingStats/multiplierTesting/StatsMultiplierTesting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -606,13 +606,14 @@ private void ProcessDroppedFiles(string[] files)
string lastError = null;
string serverMultipliersHash = null;
Creature creature = null;
double[] statValues = null;
if (!creatureImported)
creature = ImportExportGun.LoadCreature(filePath, out lastError, out serverMultipliersHash, true);
creature = ImportExportGun.LoadCreature(filePath, out lastError, out serverMultipliersHash, out statValues, true);
if (creature != null)
{
creatureImported = true;
SetCreatureValuesAndLevels(creature);
SetCreatureValuesAndLevels(creature, statValues);
results.Add($"imported creature values and levels from {filePath}{(string.IsNullOrEmpty(lastError) ? string.Empty : $". {lastError}")}");
creatureImported = true;
}
else if (lastError != null)
{
Expand Down Expand Up @@ -648,15 +649,15 @@ private void SetCreatureValueValues(CreatureValues cv)
SetCreatureValues(cv.statValues, null, null, cv.level, (cv.tamingEffMax - cv.tamingEffMin) / 2, cv.imprintingBonus, cv.isTamed, cv.isBred, cv.Species);
}

private void SetCreatureValuesAndLevels(Creature cr)
private void SetCreatureValuesAndLevels(Creature cr, double[] statValues = null)
{
var levelsWildAndMutated = cr.levelsWild;
var levelsWildAndMutated = cr.levelsWild.ToArray();
if (cr.levelsMutated != null)
{
for (int si = 0; si < Stats.StatsCount; si++)
levelsWildAndMutated[si] = cr.levelsWild[si] + cr.levelsMutated[si];
}
SetCreatureValues(cr.valuesDom, levelsWildAndMutated, cr.levelsDom, cr.Level, cr.tamingEff, cr.imprintingBonus, cr.isDomesticated, cr.isBred, cr.Species);
SetCreatureValues(statValues ?? cr.valuesDom, levelsWildAndMutated, cr.levelsDom, cr.Level, cr.tamingEff, cr.imprintingBonus, cr.isDomesticated, cr.isBred, cr.Species);
}

private void SetServerMultipliers(ExportGunServerFile esm)
Expand Down
8 changes: 4 additions & 4 deletions ARKBreedingStats/values/Values.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,11 @@ private void InitializeSpeciesAndColors(bool undefinedColorAsa = false)
{
foreach (Species sp in _V.species)
{
if (specialFoodData.ContainsKey(sp.name))
if (sp.taming != null && specialFoodData.TryGetValue(sp.name, out var customFoodData))
{
sp.taming.eats = specialFoodData[sp.name].eats;
sp.taming.eatsAlsoPostTame = specialFoodData[sp.name].eatsAlsoPostTame;
sp.taming.specialFoodValues = specialFoodData[sp.name].specialFoodValues;
sp.taming.eats = customFoodData.eats;
sp.taming.eatsAlsoPostTame = customFoodData.eatsAlsoPostTame;
sp.taming.specialFoodValues = customFoodData.specialFoodValues;
}
//if (sp.IsDomesticable && !specialFoodData.ContainsKey(sp.name)) speciesWoFoodData.Add(sp.name);
}
Expand Down

0 comments on commit ca99f6e

Please sign in to comment.