summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authormekolat <mekolat@users.noreply.github.com>2015-08-18 16:13:52 -0400
committermekolat <mekolat@users.noreply.github.com>2015-09-26 21:22:03 +0000
commit66626c7f79f1d1a07847b5d9de5591412d047603 (patch)
tree1bc1c5a161df4bf82b9a46839ea08c757ce4ec88 /src/map
parent6ec62e5c355408bdb8c828868d6f3ae0eabafd52 (diff)
downloadtmwa-66626c7f79f1d1a07847b5d9de5591412d047603.tar.gz
tmwa-66626c7f79f1d1a07847b5d9de5591412d047603.tar.bz2
tmwa-66626c7f79f1d1a07847b5d9de5591412d047603.tar.xz
tmwa-66626c7f79f1d1a07847b5d9de5591412d047603.zip
add builtins sqrt, cbrt, pow
Diffstat (limited to 'src/map')
-rw-r--r--src/map/script-fun.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/map/script-fun.cpp b/src/map/script-fun.cpp
index 496cc91..f85a181 100644
--- a/src/map/script-fun.cpp
+++ b/src/map/script-fun.cpp
@@ -310,6 +310,24 @@ void builtin_rand(ScriptState *st)
}
}
+static
+void builtin_sqrt(ScriptState *st)
+{
+ push_int<ScriptDataInt>(st->stack, static_cast<int>(sqrt(conv_num(st, &AARG(0)))));
+}
+
+static
+void builtin_cbrt(ScriptState *st)
+{
+ push_int<ScriptDataInt>(st->stack, static_cast<int>(cbrt(conv_num(st, &AARG(0)))));
+}
+
+static
+void builtin_pow(ScriptState *st)
+{
+ push_int<ScriptDataInt>(st->stack, static_cast<int>(pow(conv_num(st, &AARG(0)), conv_num(st, &AARG(1)))));
+}
+
/*==========================================
* Check whether the PC is at the specified location
*------------------------------------------
@@ -3369,6 +3387,9 @@ BuiltinFunction builtin_functions[] =
BUILTIN(mapexit, ""_s, '\0'),
BUILTIN(freeloop, "i"_s, '\0'),
BUILTIN(if_then_else, "iii"_s, '.'),
+ BUILTIN(sqrt, "i"_s, 'i'),
+ BUILTIN(cbrt, "i"_s, 'i'),
+ BUILTIN(pow, "ii"_s, 'i'),
{nullptr, ""_s, ""_s, '\0'},
};
} // namespace map