core/systems/ForwardSys.cpp
changeset 2181 7c85684253ed
parent 2142 d9d876e97a66
child 2183 4dde8a7f95a8
     1.1 --- a/core/systems/ForwardSys.cpp	Mon Jul 07 23:12:21 2008 +0000
     1.2 +++ b/core/systems/ForwardSys.cpp	Tue Jul 08 09:20:47 2008 +0000
     1.3 @@ -186,11 +186,6 @@
     1.4  
     1.5  void CForwardManager::ForwardFree(CForward *fwd)
     1.6  {
     1.7 -	if (fwd == NULL)
     1.8 -	{
     1.9 -		return;
    1.10 -	}
    1.11 -
    1.12  	m_FreeForwards.push(fwd);
    1.13  	m_managed.remove(fwd);
    1.14  }
    1.15 @@ -288,15 +283,11 @@
    1.16  		return err;
    1.17  	}
    1.18  
    1.19 -	if (filter)
    1.20 -	{
    1.21 -		filter->OnExecuteBegin();
    1.22 -	}
    1.23 -
    1.24  	FuncIter iter = m_functions.begin();
    1.25  	IPluginFunction *func;
    1.26  	cell_t cur_result = 0;
    1.27  	cell_t high_result = 0;
    1.28 +	cell_t low_result = 0;
    1.29  	int err;
    1.30  	unsigned int failed=0, success=0;
    1.31  	unsigned int num_params = m_curparam;
    1.32 @@ -316,12 +307,16 @@
    1.33  		{
    1.34  			int err = SP_ERROR_PARAM;
    1.35  			param = &temp_info[i];
    1.36 +
    1.37  			if (i >= m_numparams || m_types[i] == Param_Any)
    1.38  			{
    1.39  				type = param->pushedas;
    1.40 -			} else {
    1.41 +			}
    1.42 +			else
    1.43 +			{
    1.44  				type = m_types[i];
    1.45  			}
    1.46 +
    1.47  			if ((i >= m_numparams) || (type & SP_PARAMFLAG_BYREF))
    1.48  			{
    1.49  				/* If we're byref or we're vararg, we always push everything by ref.
    1.50 @@ -330,26 +325,30 @@
    1.51  				if (type == Param_String)
    1.52  				{
    1.53  					err = func->PushStringEx((char *)param->byref.orig_addr, param->byref.cells, param->byref.sz_flags, param->byref.flags);
    1.54 -				} else if (type == Param_Float || type == Param_Cell) {
    1.55 +				}
    1.56 +				else if (type == Param_Float || type == Param_Cell)
    1.57 +				{
    1.58  					err = func->PushCellByRef(&param->val); 
    1.59 -				} else {
    1.60 +				}
    1.61 +				else
    1.62 +				{
    1.63  					err = func->PushArray(param->byref.orig_addr, param->byref.cells, param->byref.flags);
    1.64  					assert(type == Param_Array || type == Param_FloatByRef || type == Param_CellByRef);
    1.65  				}
    1.66 -			} else {
    1.67 +			}
    1.68 +			else
    1.69 +			{
    1.70  				/* If we're not byref or not vararg, our job is a bit easier. */
    1.71  				assert(type == Param_Cell || type == Param_Float);
    1.72  				err = func->PushCell(param->val);
    1.73  			}
    1.74 +
    1.75  			if (err != SP_ERROR_NONE)
    1.76  			{
    1.77 -				if (!filter || !filter->OnErrorReport(this, func, err))
    1.78 -				{
    1.79 -					g_DbgReporter.GenerateError(func->GetParentContext(), 
    1.80 -						func->GetFunctionID(), 
    1.81 -						err, 
    1.82 -						"Failed to push parameter while executing forward");
    1.83 -				}
    1.84 +				g_DbgReporter.GenerateError(func->GetParentContext(), 
    1.85 +					func->GetFunctionID(), 
    1.86 +					err, 
    1.87 +					"Failed to push parameter while executing forward");
    1.88  				continue;
    1.89  			}
    1.90  		}
    1.91 @@ -357,12 +356,10 @@
    1.92  		/* Call the function and deal with the return value. */
    1.93  		if ((err=func->Execute(&cur_result)) != SP_ERROR_NONE)
    1.94  		{
    1.95 -			if (filter)
    1.96 -			{
    1.97 -				filter->OnErrorReport(this, func, err);
    1.98 -			}
    1.99  			failed++;
   1.100 -		} else {
   1.101 +		}
   1.102 +		else
   1.103 +		{
   1.104  			success++;
   1.105  			switch (m_ExecType)
   1.106  			{
   1.107 @@ -386,14 +383,11 @@
   1.108  					}
   1.109  					break;
   1.110  				}
   1.111 -			case ET_Custom:
   1.112 +			case ET_LowEvent:
   1.113  				{
   1.114 -					if (filter)
   1.115 +					if (cur_result < low_result)
   1.116  					{
   1.117 -						if (filter->OnFunctionReturn(this, func, &cur_result) == Pl_Stop)
   1.118 -						{
   1.119 -							goto done;
   1.120 -						}
   1.121 +						low_result = cur_result;
   1.122  					}
   1.123  					break;
   1.124  				}
   1.125 @@ -406,25 +400,39 @@
   1.126  	}
   1.127  
   1.128  done:
   1.129 +
   1.130  	if (success)
   1.131  	{
   1.132 -		if (m_ExecType == ET_Event || m_ExecType == ET_Hook)
   1.133 +		switch (m_ExecType)
   1.134  		{
   1.135 -			cur_result = high_result;
   1.136 -		} else if (m_ExecType == ET_Ignore) {
   1.137 -			cur_result = 0;
   1.138 +		case ET_Ignore:
   1.139 +			{
   1.140 +				cur_result = 0;
   1.141 +				break;
   1.142 +			}
   1.143 +		case ET_Event:
   1.144 +		case ET_Hook:
   1.145 +			{
   1.146 +				cur_result = high_result;
   1.147 +				break;
   1.148 +			}
   1.149 +		case ET_LowEvent:
   1.150 +			{
   1.151 +				cur_result = low_result;
   1.152 +				break;
   1.153 +			}
   1.154 +		default:
   1.155 +			{
   1.156 +				break;
   1.157 +			}
   1.158  		}
   1.159 +
   1.160  		if (result)
   1.161  		{
   1.162  			*result = cur_result;
   1.163  		}
   1.164  	}
   1.165  
   1.166 -	if (filter)
   1.167 -	{
   1.168 -		filter->OnExecuteEnd(&cur_result, success, failed);
   1.169 -	}
   1.170 -
   1.171  	return SP_ERROR_NONE;
   1.172  }
   1.173