KSP-RO / ContractConfigurator

A config file based solution for creating new contracts for Kerbal Space Program.
https://forum.kerbalspaceprogram.com/index.php?/topic/91625-1
Other
8 stars 10 forks source link

Made usage of expressions in Contract Requirement possible #36

Closed IO5 closed 9 months ago

IO5 commented 9 months ago

I tried to generate a sequence of contracts with DATA_EXPAND and .cfg like so:

CONTRACT_TYPE
{
    name = ExampleContract
    DATA_EXPAND
    {
        type = int
        stage = [1, 2, 3]
    }
    DATA
    {
        type = int
        prev = @/stage - 1
    }
    REQUIREMENT
    {
        name = CompleteContract
        type = CompleteContract

        contractType = "ExampleContract."+@/prev
    }
    ...

I got a NullReferenceException. The code for parsing "contractType" doesn't account for it not being immediately evaluated. By simply using SetValues as ParseValue's validation seems to do the trick. Using validation to set values feels kinda hacky, but is not without a precedent within the codebase, see: WaypointGenerator.cs:433 and 463

I also added MutuallyExclusive since be the logic in the code "tag" and "contractType" are mutually exclusive, but util is not used for some reason and there's no feedback for the contract creator.