summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormekolat <mekolat@users.noreply.github.com>2015-10-29 13:22:10 -0400
committermekolat <mekolat@users.noreply.github.com>2016-04-15 11:47:07 -0400
commitbd9a15547dab82334bbeafc00c1208cbbcdf6f69 (patch)
treefcfcebb2b765cbc9231186bed49984940d14db0f
parentd40c8dfa03ed4735299963c2dc51b189cef91e4d (diff)
downloadtmwa-bd9a15547dab82334bbeafc00c1208cbbcdf6f69.tar.gz
tmwa-bd9a15547dab82334bbeafc00c1208cbbcdf6f69.tar.bz2
tmwa-bd9a15547dab82334bbeafc00c1208cbbcdf6f69.tar.xz
tmwa-bd9a15547dab82334bbeafc00c1208cbbcdf6f69.zip
default getarg value
-rw-r--r--src/map/script-fun.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/map/script-fun.cpp b/src/map/script-fun.cpp
index fb9d1e3..9050189 100644
--- a/src/map/script-fun.cpp
+++ b/src/map/script-fun.cpp
@@ -224,8 +224,15 @@ void builtin_getarg(ScriptState *st)
}
int i = conv_num(st, &st->stack->stack_datav[st->defsp - 4]); // Number of arguments.
- if (arg > i || arg < 0)
+ if (arg > i || arg < 0 || i == 0)
+ {
+ const char a = 3; // ETX
+ if (HARG(1))
+ push_copy(st->stack, st->start + 3);
+ else
+ push_str<ScriptDataStr>(st->stack, VString<1>(a));
return;
+ }
push_copy(st->stack, (st->defsp - 4 - i) + arg);
}
@@ -4322,7 +4329,7 @@ BuiltinFunction builtin_functions[] =
BUILTIN(callfunc, "F"_s, '\0'),
BUILTIN(call, "F?*"_s, '.'),
BUILTIN(callsub, "L"_s, '\0'),
- BUILTIN(getarg, "i"_s, '.'),
+ BUILTIN(getarg, "i?"_s, '.'),
BUILTIN(return, "?"_s, '\0'),
BUILTIN(void, "?*"_s, '\0'),
BUILTIN(next, ""_s, '\0'),