Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion EVEData/EVEData.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<ItemGroup>
<PackageReference Include="DecimalMath.DecimalEx" Version="1.0.2" />
<PackageReference Include="HtmlAgilityPack" Version="1.12.4" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
</ItemGroup>


Expand All @@ -34,6 +34,9 @@
<None Update="data\ShipTypes.dat">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="data\ShipTypesCN.dat">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="data\Systems.dat">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
2 changes: 1 addition & 1 deletion EVEData/EveAppConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class EveAppConfig
/// <summary>
/// Client ID from the EVE Developer setup
/// </summary>
public const string ClientID = "ID Goes here.. ";
public const string ClientID = "";

/// <summary>
/// SMT Version Tagline
Expand Down
99 changes: 99 additions & 0 deletions EVEData/EveManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,11 @@
/// </summary>
public SerializableDictionary<string, string> ShipTypes { get; set; }

/// <summary>
/// Gets or sets the Chinese Ship Type ID to Name dictionary (populated from ESI)
/// </summary>
public SerializableDictionary<string, string> ShipTypesCN { get; set; } = new SerializableDictionary<string, string>();

/// <summary>
/// Gets or sets the System ID to Name dictionary
/// </summary>
Expand Down Expand Up @@ -2398,6 +2403,100 @@
catch { }
}

/// <summary>
/// Load Chinese ship type names from built-in data, then merge user cache
/// </summary>
public void LoadShipTypesCNFromCache()
{
ShipTypesCN = new SerializableDictionary<string, string>();

// Load built-in Chinese ship names shipped with the application
string builtinFile = Path.Combine(DataRootFolder, "ShipTypesCN.dat");
if (File.Exists(builtinFile))
{
try
{
var builtin = Serialization.DeserializeFromDisk<SerializableDictionary<string, string>>(builtinFile);
if (builtin != null)
{
foreach (var kvp in builtin)
ShipTypesCN[kvp.Key] = kvp.Value;
}
}
catch { }
}

// Merge user cache (may contain updates or overrides)
string userCnFile = Path.Combine(SaveDataRootFolder, "ShipTypesCN.dat");
if (File.Exists(userCnFile))
{
try
{
var userCache = Serialization.DeserializeFromDisk<SerializableDictionary<string, string>>(userCnFile);
if (userCache != null)
{
foreach (var kvp in userCache)
ShipTypesCN[kvp.Key] = kvp.Value;
}
}
catch { }
}
}

/// <summary>
/// Fetch missing Chinese ship type names from ESI
/// </summary>
public async Task FetchShipTypeChineseNamesAsync(CancellationToken cancellationToken = default)
{
if (ShipTypes == null || ShipTypesCN == null) return;

List<int> missingIDs = new List<int>();
foreach (var kvp in ShipTypes)
{
if (!ShipTypesCN.ContainsKey(kvp.Key) && int.TryParse(kvp.Key, out int typeId) && typeId > 0)
{
missingIDs.Add(typeId);
}
}

if (missingIDs.Count == 0) return;

try
{
using (var semaphore = new SemaphoreSlim(5))
{
var tasks = missingIDs.Select(async typeId =>
{
await semaphore.WaitAsync(cancellationToken);
try
{
var response = await EveApiClient.Universe.GetTypeInfoAsync(typeId, null, "zh");
if (response != null && response.Model != null && !string.IsNullOrEmpty(response.Model.Name))
{
lock (ShipTypesCN)
{
ShipTypesCN[typeId.ToString()] = response.Model.Name;
}
}
}
catch { }
finally { semaphore.Release(); }
});

await Task.WhenAll(tasks);
}
}
catch { }

// Save cache
try
{
string cnFile = Path.Combine(SaveDataRootFolder, "ShipTypesCN.dat");
Serialization.SerializeToDisk(ShipTypesCN, cnFile);
}
catch { }
}

/// <summary>
/// Save the Data to disk
/// </summary>
Expand Down Expand Up @@ -3819,7 +3918,7 @@
}
}
}
catch(Exception e)

Check warning on line 3921 in EVEData/EveManager.cs

View workflow job for this annotation

GitHub Actions / build

The variable 'e' is declared but never used

Check warning on line 3921 in EVEData/EveManager.cs

View workflow job for this annotation

GitHub Actions / build

The variable 'e' is declared but never used
{
}
}
Expand Down Expand Up @@ -4241,7 +4340,7 @@
}
}
}
catch (Exception ex)

Check warning on line 4343 in EVEData/EveManager.cs

View workflow job for this annotation

GitHub Actions / build

The variable 'ex' is declared but never used

Check warning on line 4343 in EVEData/EveManager.cs

View workflow job for this annotation

GitHub Actions / build

The variable 'ex' is declared but never used
{
// Log error if needed
}
Expand Down Expand Up @@ -4273,7 +4372,7 @@

File.WriteAllLines(filePath, lines);
}
catch (Exception ex)

Check warning on line 4375 in EVEData/EveManager.cs

View workflow job for this annotation

GitHub Actions / build

The variable 'ex' is declared but never used

Check warning on line 4375 in EVEData/EveManager.cs

View workflow job for this annotation

GitHub Actions / build

The variable 'ex' is declared but never used
{
// Log error if needed
}
Expand Down
49 changes: 46 additions & 3 deletions EVEData/ZKillRedisQ.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@
zs.SystemName = EveManager.Instance.GetEveSystemNameFromID((int)r2z2Data.Esi.SolarSystemId);
zs.KillTime = r2z2Data.Esi.KillmailTime.ToLocalTime();

string shipID = r2z2Data.Esi.Victim.ShipTypeId.ToString();
zs.ShipTypeID = r2z2Data.Esi.Victim.ShipTypeId;
string shipID = zs.ShipTypeID.ToString();
if(EveManager.Instance.ShipTypes.ContainsKey(shipID))
{
zs.ShipType = EveManager.Instance.ShipTypes[shipID];
Expand Down Expand Up @@ -198,7 +199,7 @@
}
if(AllianceIDs.Count > 0)
{
EveManager.Instance.ResolveAllianceIDs(AllianceIDs);

Check warning on line 202 in EVEData/ZKillRedisQ.cs

View workflow job for this annotation

GitHub Actions / build

Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.

Check warning on line 202 in EVEData/ZKillRedisQ.cs

View workflow job for this annotation

GitHub Actions / build

Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.
}

if(updatedKillList)
Expand Down Expand Up @@ -231,9 +232,51 @@
public DateTimeOffset KillTime { get; set; }

/// <summary>
/// Gets or sets the Ship Lost in this kill
/// Gets or sets the Ship Type ID from the kill mail
/// </summary>
public string ShipType { get; set; }
public int ShipTypeID { get; set; }

private string m_shipType;

/// <summary>
/// Gets or sets the Ship Lost in this kill (English name)
/// </summary>
public string ShipType
{
get => m_shipType;
set
{
m_shipType = value;
OnPropertyChanged("ShipType");
OnPropertyChanged("ShipTypeDisplay");
}
}

/// <summary>
/// Gets the ship type name in the current display language
/// </summary>
public string ShipTypeDisplay
{
get
{
if (EveManager.CurrentLanguage == "zh-CN" &&
EveManager.Instance != null &&
EveManager.Instance.ShipTypesCN != null &&
EveManager.Instance.ShipTypesCN.ContainsKey(ShipTypeID.ToString()))
{
return EveManager.Instance.ShipTypesCN[ShipTypeID.ToString()];
}
return ShipType;
}
}

/// <summary>
/// Notify that ShipTypeDisplay may have changed (e.g. after language change or CN names loaded)
/// </summary>
public void RefreshShipTypeDisplay()
{
OnPropertyChanged("ShipTypeDisplay");
}

/// <summary>
/// Gets or sets the System ID the kill was in
Expand Down
Loading
Loading