xforce/anno1800-mod-loader

ModOp type="merge" is behaving different than expected

Opened this issue · 1 comments

Input:

<Test>
    <Node>
        <Building>
            <BuildingCategoryName>11152</BuildingCategoryName>
            <BuildModeRandomRotation>180</BuildModeRandomRotation>
            <AllowChangeDirection>1</AllowChangeDirection>
        </Building>
    </Node>
</Test>

Patch:

<ModOps>
    <ModOp Type="merge" Path="/Test/Node/Building">
        <BuildModeRandomRotation>90</BuildModeRandomRotation>
        <AllowChangeDirection>1</AllowChangeDirection>
        <AllowChangeVariation>1</AllowChangeVariation>
    </ModOp>
</ModOps>

Expectation:

<Test>
    <Node>
        <Building>
            <BuildingCategoryName>11152</BuildingCategoryName>
            <BuildModeRandomRotation>90</BuildModeRandomRotation>
            <AllowChangeDirection>1</AllowChangeDirection>
            <AllowChangeVariation>1</AllowChangeVariation>
        </Building>
    </Node>
</Test>

Merge only updates existing nodes but doesn't add missing ones.
The only way to achieve the use case is by using add and ignoring the fact that nodes with the same name may be added multiple times.

I see two options either merge was meant different than my understanding, then I propose to add another operator.
Or merge needs some fixing - without changing existing behavior for compatibility reasons 😀

I just found #65 and understand the reasoning for list nodes, but I think for non-list nodes the story is quite different.