Skip to content
Draft
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.Runtime.Remoting.Channels;

namespace ATT.DB.Types
{
Expand Down
56 changes: 34 additions & 22 deletions .contrib/Source Code/Parser/DB/WagoData.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using ATT.DB.Types;
using Csv;
using CsvHelper;
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
Expand Down Expand Up @@ -140,12 +142,14 @@ public static Dictionary<string, object> GetExportableData<T>(T o) where T : IDB
/// <param name="path">The path of the CSV file.</param>
public static void LoadFromCSV(string path)
{
Framework.LogDebug($"Wago.LoadFromCSV: {path}");
Trace.WriteLine($"Wago.LoadFromCSV: {path}");

// Parse the filename for the database type and locale, if specified.
var filename = path.Substring(path.LastIndexOf('\\') + 1);
var filename = path.Substring(path.LastIndexOf(Path.DirectorySeparatorChar) + 1);
var segments = filename.Split('.', '-', '_'); // Example: Item_enUS.1.15.7.60277

Trace.WriteLine($"filename: {filename}");

// The Type is always listed first, followed by the locale (Default: enUS)
string type = segments[0];
string locale = segments[1];
Expand Down Expand Up @@ -1070,13 +1074,6 @@ public static void StoreLocalizedData<T>(IDictionary<long, T> db, string locale
}
#endregion
#region Cache Helper
/// <summary>
/// The default CSV Options to use for Wago Data Modules.
/// </summary>
private static readonly CsvOptions DEFAULT_CSV_OPTIONS = new CsvOptions
{
AllowNewLineInEnclosedFieldValues = true
};

/// <summary>
/// The Cache class retains useful Type-specific data to ensure that the fastest parsing and data storage methods are utilized.
Expand Down Expand Up @@ -1180,24 +1177,36 @@ public static Dictionary<string, object> GetExportableData(T o)
/// <exception cref="InvalidProgramException"></exception>
public static void LoadFromCSV(string content, string locale)
{
foreach (var line in CsvReader.ReadFromText(content, DEFAULT_CSV_OPTIONS))
using var reader = new StringReader(content);
using var csv = new CsvReader(reader, CultureInfo.InvariantCulture);

var records = csv.GetRecords<dynamic>();

foreach (var record in records)
{
T obj = (T)Activator.CreateInstance(ParseType);
foreach (var header in line.Headers)

// Convert dynamic record to dictionary for easier header/property access
var recordDict = (IDictionary<string, object>)record;

foreach (var kvp in recordDict)
{
var header = kvp.Key;
var valueObj = kvp.Value?.ToString() ?? "";

if (AllPropertiesByName.TryGetValue(header, out var property))
{
if (line.HasColumn(header))
try
{
var value = line[header];
try
{
property.SetValue(obj, Convert.ChangeType(value, property.PropertyType, System.Globalization.CultureInfo.InvariantCulture));
}
catch (Exception ex)
{
throw new InvalidProgramException($"Failed converting property {ParseType.Name}.{property.Name} [{property.PropertyType.Name}] from: '{value}' [{value.GetType().Name}]", ex);
}
// Convert to property type
var convertedValue = Convert.ChangeType(valueObj, property.PropertyType, CultureInfo.InvariantCulture);
property.SetValue(obj, convertedValue);
}
catch (Exception ex)
{
throw new InvalidProgramException(
$"Failed converting property {ParseType.Name}.{property.Name} [{property.PropertyType.Name}] from: '{valueObj}' [{valueObj.GetType().Name}]",
ex);
}
}
/*
Expand All @@ -1207,6 +1216,8 @@ public static void LoadFromCSV(string content, string locale)
}
*/
}

// Add to cache
if (CachedData.TryAdd(obj.ID, obj))
{
//Framework.LogWarn($"WagoData.Load.{ParseType.Name}.Add: {obj.ID}", line.Values);
Expand All @@ -1215,6 +1226,7 @@ public static void LoadFromCSV(string content, string locale)
{
//Framework.LogWarn($"WagoData.Load.{ParseType.Name}.Skip: {obj.ID}", line.Values);
}

StoreLocalizedData(obj, locale);
}

Expand Down
10 changes: 8 additions & 2 deletions .contrib/Source Code/Parser/Framework/Framework.cs
Original file line number Diff line number Diff line change
Expand Up @@ -776,13 +776,19 @@ public static void InitConfigSettings(string filepath, bool replaceConfig = fals
{
Log($"Using config: {filepath}");
Config = new CustomConfiguration(filepath);
Console.Title = $"ATT Parser: {filepath}";
if (OperatingSystem.IsWindows())
{
Console.Title = $"ATT Parser: {filepath}";
}
}
else
{
Log($"Added config: {filepath}");
Config.ApplyFile(filepath);
Console.Title += $" + {filepath}";
if (OperatingSystem.IsWindows())
{
Console.Title += $" + {filepath}";
}
}
}

Expand Down
210 changes: 22 additions & 188 deletions .contrib/Source Code/Parser/Parser.csproj
Original file line number Diff line number Diff line change
@@ -1,188 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{47D83200-8E21-487B-8F44-B08C7A1CBC82}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>ATT</RootNamespace>
<AssemblyName>Parser</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFrameworkProfile />
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>lib\att_logo_128_new_jrX_icon.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>..\..\Parser\</OutputPath>
<DefineConstants>TRACE;RETAIL;TWW</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
<Optimize>true</Optimize>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>..\..\Parser\</OutputPath>
<DefineConstants>TRACE;DEBUG;RETAIL;TWW</DefineConstants>
<Optimize>false</Optimize>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<StartupObject>ATT.Program</StartupObject>
</PropertyGroup>
<ItemGroup>
<Reference Include="Csv, Version=2.0.93.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\Csv.2.0.93\lib\net40\Csv.dll</HintPath>
</Reference>
<Reference Include="KeraLua, Version=1.3.2.0, Culture=neutral, PublicKeyToken=04d04586786c6f34, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>lib\KeraLua.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="NLua, Version=1.3.2.0, Culture=neutral, PublicKeyToken=8df2ab518030ea95, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>lib\NLua.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<Compile Include="CollectedStatus.cs" />
<Compile Include="CustomConfiguration.cs" />
<Compile Include="DataValidator.cs" />
<Compile Include="DB\Attributes\ExportableDataAttribute.cs" />
<Compile Include="DB\Attributes\DataModuleAttribute.cs" />
<Compile Include="DB\Interfaces\IWagoHolidayNameID.cs" />
<Compile Include="DB\Interfaces\IWagoQuestID.cs" />
<Compile Include="DB\Interfaces\IWagoUiMapID.cs" />
<Compile Include="DB\Interfaces\IWagoAreaID.cs" />
<Compile Include="DB\Interfaces\IWagoItemModifiedAppearanceID.cs" />
<Compile Include="DB\Interfaces\IWagoTransmogSetID.cs" />
<Compile Include="DB\Interfaces\IWagoSpellID.cs" />
<Compile Include="DB\Interfaces\IWagoItemID.cs" />
<Compile Include="DB\Interfaces\IWagoChild.cs" />
<Compile Include="DB\Attributes\LocalizeAttribute.cs" />
<Compile Include="DB\Types\HolidayNames.cs" />
<Compile Include="DB\Types\Holiday.cs" />
<Compile Include="DB\Types\HouseDecor.cs" />
<Compile Include="DB\Types\SkillLineAbility.cs" />
<Compile Include="DB\Types\UiMapAssignment.cs" />
<Compile Include="DB\Types\UiMap.cs" />
<Compile Include="DB\Types\ContentTuning.cs" />
<Compile Include="DB\Types\AreaTable.cs" />
<Compile Include="DB\Types\AchievementCategory.cs" />
<Compile Include="DB\Types\BattlePetSpecies.cs" />
<Compile Include="DB\Types\ArtifactAppearance.cs" />
<Compile Include="DB\Types\ItemBonus.cs" />
<Compile Include="DB\Types\WorldMapOverlay.cs" />
<Compile Include="DB\Types\RaceTypeBitIndexes.cs" />
<Compile Include="DB\Types\ItemSearchName.cs" />
<Compile Include="DB\Types\TaxiNodes.cs" />
<Compile Include="DB\Types\ItemEffect.cs" />
<Compile Include="DB\Types\GlyphProperties.cs" />
<Compile Include="DB\Types\ItemXItemEffect.cs" />
<Compile Include="DB\Types\Item.cs" />
<Compile Include="DB\Types\SpellEffect.cs" />
<Compile Include="DB\Types\ItemModifiedAppearance.cs" />
<Compile Include="DB\Types\TransmogSet.cs" />
<Compile Include="DB\Types\TransmogSetItem.cs" />
<Compile Include="DB\Types\ClassTypeFlags.cs" />
<Compile Include="DB\Types\TransmogSourceTypeFlags.cs" />
<Compile Include="DB\Types\TypeFlags.cs" />
<Compile Include="DB\Types\ModifierTree.cs" />
<Compile Include="DB\WagoData.cs" />
<Compile Include="Export\Export %28Compressed Lua%29.cs" />
<Compile Include="Export\Export %28Pure Lua%29.cs" />
<Compile Include="Export\Export %28Raw Lua%29.cs" />
<Compile Include="Export\Export %28Shortcuts%29.cs" />
<Compile Include="Export\Export %28Structures%29.cs" />
<Compile Include="Export\Export.cs" />
<Compile Include="Export\Exporter.cs" />
<Compile Include="Export\Object Data\HeaderData.cs" />
<Compile Include="Export\Object Data\QuestData.cs" />
<Compile Include="Export\Object Data\MapData.cs" />
<Compile Include="Export\Object Data\CriteriaData.cs" />
<Compile Include="Export\Object Data\HeirloomData.cs" />
<Compile Include="Export\Object Data\ItemData.cs" />
<Compile Include="Export\Object Data\ItemSourceData.cs" />
<Compile Include="Export\Object Data\AchievementData.cs" />
<Compile Include="Export\Object Data\RecipeData.cs" />
<Compile Include="Export\Object Data\MountData.cs" />
<Compile Include="Export\Object Data\ObjectData.cs" />
<Compile Include="Extensions.cs" />
<Compile Include="FieldTypes\Providers.cs" />
<Compile Include="FieldTypes\Coords.cs" />
<Compile Include="FieldTypes\Cost.cs" />
<Compile Include="FieldTypes\IExportableField.cs" />
<Compile Include="FieldTypes\IProcessedField.cs" />
<Compile Include="FieldTypes\LockCriteria.cs" />
<Compile Include="FieldTypes\Timeline.cs" />
<Compile Include="FieldTypes\TimelineEntry.cs" />
<Compile Include="Framework\ConcurrentHashSet.cs" />
<Compile Include="Framework\ConcurrentDataList.cs" />
<Compile Include="Framework\Framework.Objects.cs" />
<Compile Include="Framework\Framework.Items.cs" />
<Compile Include="Framework\Framework.cs" />
<Compile Include="Framework\Framework.Processing.cs" />
<Compile Include="Framework\Handler.cs" />
<Compile Include="Framework\HierarchicalFieldAdjustments.cs" />
<Compile Include="Framework\ReplacementTree.cs" />
<Compile Include="Framework\Structs.cs" />
<Compile Include="Harvesters\ObjectHarvester.cs" />
<Compile Include="Framework\ParseStage.cs" />
<Compile Include="MiniJSON.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Tracer.cs" />
<Compile Include="DB\Interfaces\IDBType.cs" />
<Compile Include="DB\Types\Achievement.cs" />
<Compile Include="DB\Types\Criteria.cs" />
<Compile Include="DB\Types\CriteriaTree.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<Compile Include="Framework\Framework.Logging.cs" />
<Compile Include="Framework\Framework.Merge.cs" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Content Include="lib\att_logo_128_new_jrX_icon.ico" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CsvHelper" Version="33.1.0" />
<PackageReference Include="KeraLua" Version="1.4.9" />
<PackageReference Include="NLua" Version="1.7.8" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Content Include="lib\att_logo_128_new_jrX_icon.ico" />
</ItemGroup>
</Project>
12 changes: 7 additions & 5 deletions .contrib/Source Code/Parser/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ static void ImportAchievementCategoryData(AchievementCategory achievementCategor

static int Main(string[] args)
{
string exePath = Assembly.GetExecutingAssembly().Location;
Console.WriteLine(exePath);
// Setup tracing to the console.
Tracer.OnWrite += Console.Write;
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledExceptionHandler);
Expand Down Expand Up @@ -425,10 +427,10 @@ static int Main(string[] args)
string content = "";
try
{
var mainFileName = $"{databaseRootFolder}\\..\\_main.lua";
var mainFileName = $"{databaseRootFolder}{Path.DirectorySeparatorChar}..{Path.DirectorySeparatorChar}_main.lua";
if (!File.Exists(mainFileName))
{
Trace.WriteLine("Could not find the '_main.lua' header file.");
Trace.WriteLine($"Could not find the {mainFileName} header file.");
Trace.WriteLine("Operation cannot continue without it.");
Framework.WaitForUser("Press any key to close...");
return ErrorCode;
Expand Down Expand Up @@ -832,9 +834,9 @@ static void ProcessInitialCommandBlock(StringBuilder builder, string content, re
{
// Attempt to parse a command that initiates a command block.
int newLineIndex = content.IndexOf('\n', index += 4);
var command = content.Substring(index, (newLineIndex > 0 ? newLineIndex : length) - index).Trim().ToUpper().Split(' ');
var command = content.Substring(index, (newLineIndex > 0 ? newLineIndex : length) - index).Trim().Split(' ');
index = newLineIndex;
switch (command[0])
switch (command[0].ToUpper())
{
case "IF":
PreProcessorNestLevel = 0;
Expand Down Expand Up @@ -944,7 +946,7 @@ static void ProcessImportCommand(string[] command, StringBuilder builder, string
builder.Append("-- ").Append(shortname).AppendLine();

// Are we already using the Retail DB?
string filename = ".\\DATAS\\" + shortname;
string filename = $".{Path.DirectorySeparatorChar}DATAS{Path.DirectorySeparatorChar}" + shortname.Replace('\\', Path.DirectorySeparatorChar);
if (Directory.Exists(filename))
{
int fileCount = 0;
Expand Down