Don't break backwards compatibility with unmanaged forwards
Instead of adding new functions to `IForward`, we just allow NULL to be passed to `PushArray` and `PushString`.
This commit is contained in:
@@ -528,10 +528,17 @@ void CForward::_Int_PushArray(cell_t *inarray, unsigned int cells, int flags)
|
||||
|
||||
int CForward::PushArray(cell_t *inarray, unsigned int cells, int flags)
|
||||
{
|
||||
/* We don't allow this here */
|
||||
/* Push a reference to the NULL_VECTOR pubvar if NULL was passed. */
|
||||
if (!inarray)
|
||||
{
|
||||
return SetError(SP_ERROR_PARAM);
|
||||
/* Make sure this was intentional. */
|
||||
if (cells == 3)
|
||||
{
|
||||
return PushNullVector();
|
||||
} else {
|
||||
/* We don't allow this here */
|
||||
return SetError(SP_ERROR_PARAM);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_curparam < m_numparams)
|
||||
@@ -568,6 +575,12 @@ void CForward::_Int_PushString(cell_t *inarray, unsigned int cells, int sz_flags
|
||||
|
||||
int CForward::PushString(const char *string)
|
||||
{
|
||||
/* Push a reference to the NULL_STRING pubvar if NULL was passed. */
|
||||
if (!string)
|
||||
{
|
||||
return PushNullString();
|
||||
}
|
||||
|
||||
if (m_curparam < m_numparams)
|
||||
{
|
||||
if (m_types[m_curparam] == Param_Any)
|
||||
|
||||
@@ -55,8 +55,6 @@ public: //IForward
|
||||
virtual unsigned int GetFunctionCount();
|
||||
virtual ExecType GetExecType();
|
||||
virtual int Execute(cell_t *result, IForwardFilter *filter);
|
||||
virtual int PushNullString();
|
||||
virtual int PushNullVector();
|
||||
public: //IChangeableForward
|
||||
virtual bool RemoveFunction(IPluginFunction *func);
|
||||
virtual unsigned int RemoveFunctionsOfPlugin(IPlugin *plugin);
|
||||
@@ -74,6 +72,8 @@ private:
|
||||
CForward(ExecType et, const char *name,
|
||||
const ParamType *types, unsigned num_params);
|
||||
|
||||
int PushNullString();
|
||||
int PushNullVector();
|
||||
int _ExecutePushRef(IPluginFunction *func, ParamType type, FwdParamInfo *param);
|
||||
void _Int_PushArray(cell_t *inarray, unsigned int cells, int flags);
|
||||
void _Int_PushString(cell_t *inarray, unsigned int cells, int sz_flags, int cp_flags);
|
||||
|
||||
@@ -580,7 +580,7 @@ static cell_t sm_CallPushNullVector(IPluginContext *pContext, const cell_t *para
|
||||
}
|
||||
else if (s_pForward)
|
||||
{
|
||||
err = s_pForward->PushNullVector();
|
||||
err = s_pForward->PushArray(NULL, 3);
|
||||
}
|
||||
|
||||
if (err)
|
||||
@@ -621,7 +621,7 @@ static cell_t sm_CallPushNullString(IPluginContext *pContext, const cell_t *para
|
||||
}
|
||||
else if (s_pForward)
|
||||
{
|
||||
err = s_pForward->PushNullString();
|
||||
err = s_pForward->PushString(NULL);
|
||||
}
|
||||
|
||||
if (err)
|
||||
|
||||
Reference in New Issue
Block a user