diff --git a/src/thingdef/thingdef.cpp b/src/thingdef/thingdef.cpp index b8ae5fc8f..918768215 100644 --- a/src/thingdef/thingdef.cpp +++ b/src/thingdef/thingdef.cpp @@ -303,7 +303,7 @@ static void FinishThingdef() VMScriptFunction *func = buildit.MakeFunction(); #if 1 const char *marks = "======================================================="; - char label[40]; + char label[64]; int labellen = mysnprintf(label, countof(label), "Function %s.States[%d] (*%d)", tcall->ActorInfo->Class->TypeName.GetChars(), tcall->FirstState, tcall->NumStates); diff --git a/src/thingdef/thingdef_expression.cpp b/src/thingdef/thingdef_expression.cpp index c40ba766f..f8941c822 100644 --- a/src/thingdef/thingdef_expression.cpp +++ b/src/thingdef/thingdef_expression.cpp @@ -365,7 +365,7 @@ FxExpression *FxParameter::Resolve(FCompileContext& ctx) static void EmitConstantInt(VMFunctionBuilder *build, int val) { // If it fits in 24 bits, use PARAMI instead of PARAM. - if ((val << 8) >> 8) + if (((val << 8) >> 8) == val) { build->Emit(OP_PARAMI, val); } diff --git a/src/thingdef/thingdef_parse.cpp b/src/thingdef/thingdef_parse.cpp index eb68a6d27..02fb125d6 100644 --- a/src/thingdef/thingdef_parse.cpp +++ b/src/thingdef/thingdef_parse.cpp @@ -151,6 +151,21 @@ FxExpression *ParseParameter(FScanner &sc, PClass *cls, char type, bool constant { sc.ScriptError("Default parameter must be constant."); } + // Do automatic coercion between ints and floats. + if (type == 'x' || type == 'X') + { + if (x->ValueType != VAL_Int) + { + x = new FxIntCast(x); + } + } + else + { + if (x->ValueType != VAL_Float) + { + x = new FxFloatCast(x); + } + } break; default: diff --git a/src/zscript/vmdisasm.cpp b/src/zscript/vmdisasm.cpp index 108f4b726..0864e881b 100644 --- a/src/zscript/vmdisasm.cpp +++ b/src/zscript/vmdisasm.cpp @@ -217,7 +217,7 @@ void VMDisasm(FILE *out, const VM_UBYTE *code, int codesize, const VMScriptFunct break; case OP_PARAMI: - col = printf_wrapper(out, "%d", i + 4 + ABCs(&code[i])); + col = printf_wrapper(out, "%d", ABCs(&code[i])); break; case OP_RET: