Input: Integer button codes are still allowed in RGSS3

This commit is contained in:
Jonas Kulla 2014-12-09 04:21:48 +01:00
parent 6c92101e05
commit 685f8b63b3
2 changed files with 23 additions and 12 deletions

View file

@ -40,20 +40,26 @@ MRB_FUNCTION(inputUpdate)
static mrb_int getButtonArg(mrb_state *mrb)
{
mrb_int num;
mrb_value arg;
if (rgssVer >= 3)
mrb_get_args(mrb, "o", &arg);
if (mrb_fixnum_p(arg))
{
num = mrb_fixnum(arg);
}
else if (mrb_symbol_p(arg) && rgssVer >= 3)
{
mrb_sym sym;
mrb_get_args(mrb, "n", &sym);
mrb_value symHash = getMrbData(mrb)->buttoncodeHash;
mrb_value numVal = mrb_hash_fetch(mrb, symHash, mrb_symbol_value(sym),
mrb_value numVal = mrb_hash_fetch(mrb, symHash, arg,
mrb_fixnum_value(Input::None));
num = mrb_fixnum(numVal);
}
else
{
mrb_get_args(mrb, "i", &num);
// FIXME: RMXP allows only few more types that
// don't make sense (symbols in pre 3, floats)
num = 0;
}
return num;