From a88ffd2d9b2adec5de19a1bb88e6b8656985a044 Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Wed, 27 Aug 2014 13:40:22 -0700 Subject: Yes, I do --- src/map/script.cpp | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'src/map/script.cpp') diff --git a/src/map/script.cpp b/src/map/script.cpp index d5eb379..4aeb7d9 100644 --- a/src/map/script.cpp +++ b/src/map/script.cpp @@ -1195,15 +1195,29 @@ RString conv_str(ScriptState *st, struct script_data *data) static __attribute__((warn_unused_result)) int conv_num(ScriptState *st, struct script_data *data) { + int rv = 0; get_val(st, data); assert (!data->is()); - if (auto *u = data->get_if()) + MATCH (*data) { - RString p = u->str; - *data = ScriptDataInt{atoi(p.c_str())}; + default: + abort(); + CASE (const ScriptDataStr&, u) + { + RString p = u.str; + rv = atoi(p.c_str()); + } + CASE (const ScriptDataInt&, u) + { + return u.numi; + } + CASE (const ScriptDataPos&, u) + { + return u.numi; + } } - // TODO see if I also need to return for other types? - return data->get_if()->numi; + *data = ScriptDataInt{rv}; + return rv; } static __attribute__((warn_unused_result)) -- cgit v1.2.3-70-g09d2