From 9def9ec095864dbcc71792adafe6d5b4cdfb31e1 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 14 Oct 2016 22:54:22 +0200 Subject: [PATCH] - added more casting kludges so that I can run some tests with Heretic's definitions. --- src/dobjtype.h | 11 ----- .../codegeneration/thingdef_expression.cpp | 40 ++++++++++++++++--- 2 files changed, 35 insertions(+), 16 deletions(-) diff --git a/src/dobjtype.h b/src/dobjtype.h index 19aeca71b..b41ffe0e6 100644 --- a/src/dobjtype.h +++ b/src/dobjtype.h @@ -824,17 +824,6 @@ inline PClass::MetaClass *PClass::GetClass() const return static_cast(DObject::GetClass()); } -// A class that hasn't had its parent class defined yet --------------------- - -class PClassWaitingForParent : public PClass -{ - DECLARE_CLASS(PClassWaitingForParent, PClass); -public: - PClassWaitingForParent(FName myname, FName parentname); - - FName ParentName; -}; - // Type tables -------------------------------------------------------------- struct FTypeTable diff --git a/src/scripting/codegeneration/thingdef_expression.cpp b/src/scripting/codegeneration/thingdef_expression.cpp index a352c7b87..323ca083e 100644 --- a/src/scripting/codegeneration/thingdef_expression.cpp +++ b/src/scripting/codegeneration/thingdef_expression.cpp @@ -3942,13 +3942,43 @@ FxExpression *FxVMFunctionCall::Resolve(FCompileContext& ctx) { for (unsigned i = 0; i < ArgList->Size(); i++) { - // temporary hack to let strings get compiled as state. This will have to be done more intelligently. - if (i+implicit < argtypes.Size() && argtypes[i+implicit] == TypeState && (*ArgList)[i]->isConstant() && static_cast((*ArgList)[i])->ValueType == TypeString) + if ((*ArgList)[i]->isConstant()) { - auto statenode = new FxMultiNameState(static_cast((*ArgList)[i])->GetValue().GetString(), ScriptPosition); - delete (*ArgList)[i]; - (*ArgList)[i] = statenode; + if (i + implicit < argtypes.Size()) + { + auto type = static_cast((*ArgList)[i])->ValueType; + // temporary hack to add the casts which get used by the internal definitions + if (argtypes[i + implicit] == TypeState && type == TypeString) + { + ScriptPosition.Message(MSG_WARNING, "Converting %s to state", static_cast((*ArgList)[i])->GetValue().GetString()); + auto statenode = new FxMultiNameState(static_cast((*ArgList)[i])->GetValue().GetString(), ScriptPosition); + delete (*ArgList)[i]; + (*ArgList)[i] = statenode; + } + if (argtypes[i + implicit] == TypeSound && type == TypeString) + { + ScriptPosition.Message(MSG_WARNING, "Converting %s to sound", static_cast((*ArgList)[i])->GetValue().GetString()); + auto statenode = new FxConstant(FSoundID(static_cast((*ArgList)[i])->GetValue().GetString()), ScriptPosition); + delete (*ArgList)[i]; + (*ArgList)[i] = statenode; + } + if (argtypes[i + implicit] == TypeSInt32 && type == TypeFloat64) + { + ScriptPosition.Message(MSG_WARNING, "Converting %f to int", static_cast((*ArgList)[i])->GetValue().GetFloat()); + auto statenode = new FxConstant(static_cast((*ArgList)[i])->GetValue().GetInt(), ScriptPosition); + delete (*ArgList)[i]; + (*ArgList)[i] = statenode; + } + if (argtypes[i + implicit] == TypeFloat64 && type == TypeSInt32) + { + ScriptPosition.Message(MSG_WARNING, "Converting %d to float", static_cast((*ArgList)[i])->GetValue().GetInt()); + auto statenode = new FxConstant(static_cast((*ArgList)[i])->GetValue().GetFloat(), ScriptPosition); + delete (*ArgList)[i]; + (*ArgList)[i] = statenode; + } + } } + (*ArgList)[i] = (*ArgList)[i]->Resolve(ctx); if ((*ArgList)[i] == NULL) failed = true; }