summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWushin <pasekei@gmail.com>2015-02-28 19:12:15 -0600
committerWushin <pasekei@gmail.com>2015-02-28 19:12:15 -0600
commit6bc82125235099bd21476fcc3056598f7ec028b8 (patch)
tree3c053e8e7baa44465fbd90e5e02682e4fd500493 /src
parent6ec97dc4556e36b7a3cdf17b8684fa074529ad8b (diff)
parent697ab2d5ee8c840dba925425ddbf6eba9eb6ee44 (diff)
downloadtmwa-6bc82125235099bd21476fcc3056598f7ec028b8.tar.gz
tmwa-6bc82125235099bd21476fcc3056598f7ec028b8.tar.bz2
tmwa-6bc82125235099bd21476fcc3056598f7ec028b8.tar.xz
tmwa-6bc82125235099bd21476fcc3056598f7ec028b8.zip
Merge pull request #33 from mekolat/freeloop
add freeloop builtin
Diffstat (limited to 'src')
-rw-r--r--src/map/script-call-internal.hpp2
-rw-r--r--src/map/script-call.cpp4
-rw-r--r--src/map/script-fun.cpp20
3 files changed, 23 insertions, 3 deletions
diff --git a/src/map/script-call-internal.hpp b/src/map/script-call-internal.hpp
index 983b361..b9b3a9f 100644
--- a/src/map/script-call-internal.hpp
+++ b/src/map/script-call-internal.hpp
@@ -53,7 +53,7 @@ public:
ScriptEndState state;
BlockId rid, oid;
ScriptPointer scriptp, new_scriptp;
- int defsp, new_defsp;
+ int defsp, new_defsp, freeloop;
};
void run_func(ScriptState *st);
diff --git a/src/map/script-call.cpp b/src/map/script-call.cpp
index b66af74..f412328 100644
--- a/src/map/script-call.cpp
+++ b/src/map/script-call.cpp
@@ -757,7 +757,7 @@ void run_script_main(ScriptState *st, Borrowed<const ScriptBuffer> rootscript)
{
rerun_pos = st->scriptp.pos;
st->state = ScriptEndState::ZERO;
- if (gotocount > 0 && (--gotocount) <= 0)
+ if (!st->freeloop && gotocount > 0 && (--gotocount) <= 0)
{
PRINTF("run_script: infinity loop !\n"_fmt);
st->state = ScriptEndState::END;
@@ -806,7 +806,7 @@ void run_script_main(ScriptState *st, Borrowed<const ScriptBuffer> rootscript)
st->state = ScriptEndState::END;
break;
}
- if (cmdcount > 0 && (--cmdcount) <= 0)
+ if (!st->freeloop && cmdcount > 0 && (--cmdcount) <= 0)
{
PRINTF("run_script: infinity loop !\n"_fmt);
st->state = ScriptEndState::END;
diff --git a/src/map/script-fun.cpp b/src/map/script-fun.cpp
index b9b581f..8c25266 100644
--- a/src/map/script-fun.cpp
+++ b/src/map/script-fun.cpp
@@ -1123,6 +1123,25 @@ void builtin_getequipid(ScriptState *st)
}
/*==========================================
+ * freeloop
+ *------------------------------------------
+ */
+static
+void builtin_freeloop(ScriptState *st)
+{
+ int num;
+ num = conv_num(st, &AARG(0));
+ if(num == 1)
+ {
+ st->freeloop = 1;
+ }
+ else
+ {
+ st->freeloop = 0;
+ }
+}
+
+/*==========================================
* 装備名文字列(精錬メニュー用)
*------------------------------------------
*/
@@ -3095,6 +3114,7 @@ BuiltinFunction builtin_functions[] =
BUILTIN(gety, ""_s, 'i'),
BUILTIN(getmap, ""_s, 's'),
BUILTIN(mapexit, ""_s, '\0'),
+ BUILTIN(freeloop, "i"_s, '\0'),
{nullptr, ""_s, ""_s, '\0'},
};
} // namespace map