1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-19 15:20:27 +00:00

IF_KEY_EXISTS used in util.cpp

This commit is contained in:
Zeno Rogue 2021-07-18 12:18:11 +02:00
parent cd60b0ffb3
commit e567fa2033

View File

@ -207,11 +207,10 @@ cld exp_parser::parse(int prio) {
cld c = rparse(0);
force_eat(")");
if(extra_params.count("angleunit")) {
a *= extra_params["angleunit"];
b *= extra_params["angleunit"];
c *= extra_params["angleunit"];
IF_KEY_EXISTS(it, extra_params, "angleunit") {
a *= it->second;
b *= it->second;
c *= it->second;
}
return edge_of_triangle_with_angles(real(a), real(b), real(c));
@ -238,14 +237,14 @@ cld exp_parser::parse(int prio) {
test.compute_sum();
test.compute_geometry();
res = test.edgelength;
if(extra_params.count("distunit"))
res /= extra_params["distunit"];
IF_KEY_EXISTS(it, extra_params, "distunit")
res /= it->second;
}
#endif
else if(eat("regangle(")) {
cld edgelen = parse(0);
if(extra_params.count("distunit")) {
edgelen = edgelen * extra_params["distunit"];
IF_KEY_EXISTS(it, extra_params, "distunit") {
edgelen = edgelen * it->second;
}
force_eat(",");
@ -261,14 +260,14 @@ cld exp_parser::parse(int prio) {
if(arb::legacy) {
res = M_PI - result;
if(extra_params.count("angleofs"))
res -= extra_params["angleofs"];
IF_KEY_EXISTS(it, extra_params, "angleofs")
res -= it->second;
}
else
res = result;
if(extra_params.count("angleunit"))
res /= extra_params["angleunit"];
IF_KEY_EXISTS(it, extra_params, "angleunit")
res /= it->second;
}
else if(eat("test(")) {
res = parsepar();
@ -319,8 +318,8 @@ cld exp_parser::parse(int prio) {
else if(next() == '(') at++, res = parsepar();
else {
string number = next_token();
if(extra_params.count(number)) res = extra_params[number];
else if(params.count(number)) res = params[number]->get_cld();
IF_KEY_EXISTS(it, extra_params, number) res = it->second;
else IF_KEY_EXISTS(it, params, number) res = it->second->get_cld();
else if(number == "e") res = exp(1);
else if(number == "i") res = cld(0, 1);
else if(number == "p" || number == "pi") res = M_PI;