Open CrazyOrange opened 1 year ago
Eric successfully tested this version.
Would love to see an example calculations.txt file
Would love to see an example calculations.txt file
A default file could look like this (used the currently used formulas):
CalcSpeed=power <= 0 ? 0 : (power - 6000) * (1000 - 270) / (50000 - 6000) + 270
CalcReichweite=verbrauch <= 0 ? 0 : tank / verbrauch * speed
EnoughPower=power * 4 >= weight
Would love to see an example calculations.txt file
Hi, this is my calculations.txt in use with my custom builds.csv and relations.csv, works like a charm, with pretty realistic outcome for Hitec-planes
CalcSpeed=power <= 0 ? 0 : ((power / 60000 - 0.5) * (950 - 600)) + 750
CalcReichweite=verbrauch <= 0 ? 0 : tank / verbrauch * speed
EnoughPower=weight <= 120000 ? speed >= 650 : (weight <= 225000 ? speed >= 740 : speed >= 830)
How does the FormularParser/exprtk handle syntax errors? Does it crash or fallback to default with an error message?
Otherwise lgtm
lgtm
I didn't test this on purpose, but when I accidentally had 0,5 instead of 0.5 in my formula, the game just ended up not showing anything in the line where the plane's speed should be indicated at Hitec. No crash, but no fallback to default either.
Added FormulaParser which reads pareses formulas from Data/calculations.txt using exprtk Math parser. Backwards compatible by using the default formulas if no file is provided. Compiling with /bigobj is only added in debug mode as it seems to be small enough in release mode.
Available formulas: CalcSpeed, CalcReichweite, EnoughPower Available varibales: power, weight, speed, verbrauch, tank. (speed is always zero when used in CalcSpeed formula) Added dependency to jansson lib