Need help restructuring ShipPartsParser

Programmers discuss here anything related to FreeOrion programming. Primarily for the developers to discuss.

Moderator: Committer

Post Reply
Message
Author
Ophiuchus
Programmer
Posts: 3433
Joined: Tue Sep 30, 2014 10:01 am
Location: Wall IV

Need help restructuring ShipPartsParser

#1 Post by Ophiuchus »

I wanted to restructure the parsing of capacity/damage/shots because it helps me with the targetting feature and makes also sense.
The difference is between weapons (damage -> capacity, shots -> capacity2) and the hangar/other parts (capacity -> capacity, damage -> capacity2).

So it would make sense that the subparser creates a pair<optional<double>,optional<double>> which gets used from the outer parser. But actually i do not know how to do so.

here is what i managed until now: commit

Any hints how to proceed?
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Look, ma... four combat bouts!

User avatar
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: Need help restructuring ShipPartsParser

#2 Post by Dilvish »

Your general idea of making this particular pair sub-parser sounds fine to me.

It's been a long while since I've done any serious work with the parsers, and I won't be able to do anything with this for at least a few more days, but if you don't get it sorted out in the meantime I'll try taking a look at it when I can.

For all these cases where you are running into trouble with the parser, keeping in mind the idea I think Geoff suggested that you might be running into complications from the overall complexity of the parsing rule you are trying, for things like your double values you could think of starting with just the simple double parser rather than the full blown flexible double parser, for example (if I am remembering the namings and their order of complexity correctly).
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

Post Reply