Drake53 / War3Api

Warcraft III's Common and Blizzard API's in C#.
MIT License
23 stars 4 forks source link

War3Api.Generator.Object produces error when generating from latest API #20

Closed YakaryBovine closed 1 year ago

YakaryBovine commented 1 year ago

Hi, I'm trying to use War3Api.Generator.Object to generate code for the 1.36.0.20257 version of Warcraft. I did the following:

  1. Used CascViewer to extract my entire war3.w3mod folder into War3Api.Generator.Object\API\1.36.0.20257.
  2. In Program.cs, changed Version to 1.36.0.20257.
  3. Ran War3Api.Generator.Object from my IDE.

This process has worked for me in the past. This time it produced the following error:

C:\Users\zakar\AppData\Local\JetBrains\Toolbox\apps\Rider\ch-0\232.8660.212\plugins\dpa\DotFiles\JetBrains.DPA.Runner.exe --handle=4816 --backend-pid=35128 --etw-collect-flags=7 --detach-event-name=dpa.detach.4816 C:/Users/zakar/RiderProjects/War3Api/src/War3Api.Generator.Object/bin/Debug/net5.0/War3Api.Generator.Object.exe
Unhandled exception. System.AggregateException: One or more errors occurred. (An item with the same key has already been added. Key: 846416193)
 ---> System.ArgumentException: An item with the same key has already been added. Key: 846416193
   at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
   at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
   at War3Api.Generator.Object.Models.TableModel..ctor(String path, String keyColumn, String nameColumn, String tableName) in C:\Users\zakar\RiderProjects\War3Api\src\War3Api.Generator.Object\Models\TableModel.cs:line 31
   at War3Api.Generator.Object.AbilityApiGenerator.InitializeGenerator(String inputFolder) in C:\Users\zakar\RiderProjects\War3Api\src\War3Api.Generator.Object\AbilityApiGenerator.cs:line 46
   at War3Api.Generator.Object.Program.<>c__DisplayClass5_0.<Main>b__6() in C:\Users\zakar\RiderProjects\War3Api\src\War3Api.Generator.Object\Program.cs:line 39
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task.<>c.<.cctor>b__277_0(Object obj)
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.WaitAllCore(Task[] tasks, Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at System.Threading.Tasks.Task.WaitAll(Task[] tasks)
   at System.Threading.Tasks.Parallel.Invoke(ParallelOptions parallelOptions, Action[] actions)
--- End of stack trace from previous location ---
   at System.Threading.Tasks.Parallel.ThrowSingleCancellationExceptionOrOtherException(ICollection exceptions, CancellationToken cancelToken, Exception otherException)
   at System.Threading.Tasks.Parallel.Invoke(ParallelOptions parallelOptions, Action[] actions)
   at System.Threading.Tasks.Parallel.Invoke(Action[] actions)
   at War3Api.Generator.Object.Program.Main(String[] args) in C:\Users\zakar\RiderProjects\War3Api\src\War3Api.Generator.Object\Program.cs:line 30

Process finished with exit code -532,462,766.
YakaryBovine commented 1 year ago

This is the complete list of files it generated before crashing: image

YakaryBovine commented 1 year ago

Not sure if it's helpful, but this image shows the key, key column, and row: image

Drake53 commented 1 year ago

Sounds like an issue with wc3 data, wouldn't be the first time (I've had issues with triggerdata.txt before). Can you upload the .slk file so I can check it? As a workaround you could probably replace Add() with TryAdd().

YakaryBovine commented 1 year ago

Absolutely; I've attached the file in question. I renamed it from .slk to .txt to get it to upload; I assume you can just change it back. abilitydata.txt I'll try the workaround tomorrow, thankyou.

YakaryBovine commented 1 year ago

The workaround was effective and I was able to generate the code.

Drake53 commented 1 year ago

Thanks for uploading the file, I found that the duplicate key is AIs2 which is used for both StrengthBonus (+2) and Attack Speed Increase(greater). Can you test which ability is applied if you use this ability code? That will determine what to do when TryAdd returns false, either it should do nothing (take first entry) or overwrite the value (take last entry).

YakaryBovine commented 1 year ago

Yup - adding AIs2 to a unit gives the unit an Attack Speed bonus, so I guess it's the second one.