nickbabcock / Pdoxcl2Sharp

A Paradox Interactive general file parser
MIT License
39 stars 13 forks source link

Consecutive Elements with ID #32

Closed TommasoBelluzzo closed 8 years ago

TommasoBelluzzo commented 8 years ago

Dear nickbabcock, I recently started tinkering a little bit your parser to fix some issues on my Stellaris savegames. It works like a charm, but I think it cannot handle this kind of parsing:

pop=
{
    0={
        species_index=120
        growth_state=1
        ethos={
            ethic="ethic_individualist"
            ethic="ethic_fanatic_materialist"
        }
        tile=844437815033858        pop_faction=0
        required_growth={
            type=food_surplus
            value=25.000
        }
    }
    1={
        species_index=120
        growth_state=1
        ethos={
            ethic="ethic_individualist"
            ethic="ethic_fanatic_materialist"
        }
        tile=1125912791744514       pop_faction=0
        required_growth={
            type=food_surplus
            value=25.000
        }
    }
    2={
        species_index=120
        growth_state=1
        ethos={
            ethic="ethic_individualist"
            ethic="ethic_fanatic_materialist"
        }
        tile=844433520066562        pop_faction=0
        required_growth={
            type=food_surplus
            value=25.000
        }
    }
}

Where the number before the brakets is a unique identifier. Do you have any plan on improving this for the new synthax being used? Best regards.

nickbabcock commented 8 years ago

In EU4 savegames, provinces are stored like so

-1={
  name="Stockholm"
  # etc
}
-2={
  name="Another one"
  # etc
}

This was solved in ProvinceCollection.cs

public void TokenCallback(ParadoxParser parser, string token)
{
    provinces.Add(parser.Parse(new Province(-int.Parse(token))));
}

Let me know if this helps.

TommasoBelluzzo commented 8 years ago

Aaaaah that works like a charm! Many thanks man!

nickbabcock commented 8 years ago

No problem, I haven't tested this parser with Stellaris or for HOI4, so if you come across bugs or if you have improvements you've coded, feel free to file more issues/PRs :smile: