Comments (4)
Or it could be done by adding unrecognised options as std::string options with a flag that marks them as unrecognised (so Get(), Add() etc. can still behave like they don't really exist) which would simplify writing them all back to XML in alphabetical order.
from freeorion.
As suggested, Options set by SetFromXMLRecursive (and perhaps SetFromCommandLine) that don't find an existing already-Added option in the DB could add a string-valued Option to the map.
When Adding an option in code, it checks for an existing option by the same name already, and throws an exception if a duplicate is found.
Instead, it could set the value of the new Option to whatever is already set in the existing Option by taking the result of the existing Option's GetValueString() function, and attempting to lexical_cast that to whatever the newly-Added Option's type is.
No need for an extra flag, I think.
If the lexical_cast fails, then use the default value of the newly-Added Option.
from freeorion.
That approach wouldn't allow functions such as Get(), Validate() or OptionExists() to tell the difference between options that have been registered with Add() (and therefore have the proper type info, validators, descriptions, defaults etc.) and ones that were merely found in the config or command line with no context. I just threw up a PR with the "save as a string Option with a flag" approach over here if you'd like to inspect it. Haven't done anything with SetFromCommandLine there but it would make sense for that to behave similarly to SetFromXMLRecursive.
from freeorion.
Seems reasonable
from freeorion.
Related Issues (20)
- Gcc 14 fails to build recent FreeOrion HOT 6
- FreeOrion fails to start with Debug build
- Switch positions of nest eradication and domesticated monsters HOT 1
- Review/Balance Policies HOT 2
- With 30-01 build GUI shows zeroes as values for ships and fleets HOT 1
- Neutral forces can see your stealthy ships on first bout already HOT 4
- Augmentation description/effect mismatch HOT 8
- (Specials Parser)Allow Tag Field HOT 2
- Error: Could not symlink bin/openssl HOT 3
- Inconsistant species modifiers to policies depending on focus HOT 3
- Can not launch test build on macOS. HOT 6
- Situation Report lists wrong system HOT 4
- Nearuniversal Translator Bonus Calculation ignores planets HOT 2
- Release 0.5.0.1 preparation
- (AI) misevaluation of some weapons HOT 4
- Can't Drag-Drop a Policy Over Another HOT 3
- Border Checkpoints Policy HOT 5
- Building FreeOrion 0.5 against Boost 1.85 fails HOT 14
- Incorect Annex Sitrep HOT 2
- Turn 1 Influence Malus HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from freeorion.