HearthSim / python-hsreplay

Python library for creating and parsing HSReplay XML files
https://hearthsim.info/hsreplay/
MIT License
50 stars 14 forks source link

Missing "state.UpdateCurrentNode(typeof(Game), typeof(Action));" when handling ACTION_END tag #20

Closed sebastientromp closed 8 years ago

sebastientromp commented 8 years ago

When converting the following output_log to XML using the C# implementation, you get an incorrect XML: the last action is nested, while it should really be at the root.

forgottentorch.txt actual_forgottentorch.xml.txt

It looks like DataHandler.cs isn't updating the currentnode before setting the new node value:

if(data == "ACTION_END")
{
    state.Node = state.Node.Parent ?? state.Node;
    return;
}

adding the following line seems to fix the issue (at least on my Java implementation which is a direct port of the c# one):

if(data == "ACTION_END")
{
    state.UpdateCurrentNode(typeof(Game), typeof(Action));
    state.Node = state.Node.Parent ?? state.Node;
    return;
}

as it results in the following XML: forgottentorch.xml.txt

As I have no way to run / test C#, I'll leave it to you to see if the fix is needed :)

jleclanche commented 8 years ago

Closing bugs from deprecated c# interface.