1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-10-21 00:47:40 +00:00

parser:: error handling now uses exceptions

This commit is contained in:
Zeno Rogue
2019-12-23 21:44:51 +01:00
parent a83220c34e
commit 15000034fd
6 changed files with 63 additions and 29 deletions

View File

@@ -743,17 +743,20 @@ EX namespace dialog {
}
EX void apply_edit() {
exp_parser ep;
ep.s = ne.s;
ld x = real(ep.parse());
if(!ep.ok()) return;
if(ne.sc.positive && x <= 0) return;
*ne.editwhat = x;
if(ne.intval) *ne.intval = ldtoint(*ne.editwhat);
#if CAP_ANIMATIONS
if(ne.animatable) anims::animate_parameter(*ne.editwhat, ne.s, reaction ? reaction : reaction_final);
#endif
if(reaction) reaction();
try {
exp_parser ep;
ep.s = ne.s;
ld x = ep.rparse();
if(ne.sc.positive && x <= 0) return;
*ne.editwhat = x;
if(ne.intval) *ne.intval = ldtoint(*ne.editwhat);
#if CAP_ANIMATIONS
if(ne.animatable) anims::animate_parameter(*ne.editwhat, ne.s, reaction ? reaction : reaction_final);
#endif
if(reaction) reaction();
}
catch(hr_parse_exception&) {
}
}
EX void bound_low(ld val) {